Every technology can be understood
and recreated by anyone once they are clear with its fundamental operation. One
such technology I am going to deal with is the Autonomous vehicle/Robot. Most
of the beginners think (as I did when I was a beginner) that only master minded
Engineers and Scientists can develop a Robot or Vehicle that can move
autonomously( like this). Well, that is true if one is expecting 99% accuracy in operation
of that vehicle. But with lesser accuracy and with better knowledge in vehicle
control mechanism, one can build their own Autonomous vehicle. So,
here, I will be explaining how to make your own simple Autonomous vehicle.
Let us first consider an ordinary vehicle.
The vehicle control mechanism involves increasing/decreasing the vehicle`s
speed, braking and steering. The steering and motion of the vehicle is normally controlled by the user
who makes decision based on the vehicle`s environment, whereas in case of an
Autonomous vehicle there will be no user interaction, except for the marking of
the destination point that the vehicle must reach. Therefore, suitable
sensors must replace the human user.
The following pictures depict the functioning
of an ordinary vehicle with a human user on it and an Autonomous vehicle with
sensors and processor.
Now lets start to built an
Autonomous vehicle. From the above two pictures, it is understood that the
designer of an autonomous vehicle must decide how to sense the obstacles around
the vehicle, How to move the vehicle from source to destination point while
deciding the appropriate path to be taken.
The following flowchart shows the simple open loop architecture of an autonomous vehicle,
To keep it simple, I am considering
an autonomous vehicle with following specifications,
·
Obstacle detection using proximity sensor
·
Navigation using GPS
·
Battery powered vehicle(control using PWM and Relay
drives)
·
Differential drive(skid steer)
Of course, if you are familiar with
image/signal processing you can use camera, LIDAR/RADAR for obstacle sensing.
Since this explanation is for beginners, I am not considering the on road rules
detection and path determination as it makes things more complicated.
For clear understanding, the
vehicle construction is explained in 4 steps as follows,
1.Vehicle control
mechanism:
Before designing the vehicle control mechanism
one must be aware of the maximum payload of that vehicle based on which the
components can be picked up.
There are two ways by which the
vehicle can be controlled
1. Fixed speed
control
2. Variable
speed control
In fixed speed control, the
vehicle can be either moved(with a constant speed) or stopped. A simple relay
logic controller is enough to perform this type of control. You can either
build your own relay based controller for your vehicle or else you can buy a
relay shield to control the vehicle motors from the micro controller. Below
shown is the relay based motor shield and Arduino MCU.
Check for the motor driver`s data
sheet whether the current rating of the motors used falls within the range of
the driver being used or else you will end up frying the driver on
continuous usage. The following picture shows the sample connection between the
relay driver and the microcontroller,
Logic sequence can be sent via the
microcontroller to the input of the relay driver to switch the motors ON/OFF as
well as to control their rotating direction.
For eg: consider 10,11,12,13 pins of Arduino as input to the motor driver,
10 - LOW
11 - HIGH
12 - HIGH
13 - LOW
By using the above sequence you can switch corresponding relays associated with input pins from Arduino. Likewise, you can try different input sequences for forward and reverse motions.
For eg: consider 10,11,12,13 pins of Arduino as input to the motor driver,
10 - LOW
11 - HIGH
12 - HIGH
13 - LOW
By using the above sequence you can switch corresponding relays associated with input pins from Arduino. Likewise, you can try different input sequences for forward and reverse motions.
In variable speed control of the vehicle, MOSFETs can be used to
control the motors by passing PWM signals from the microcontroller. The two
types of MOSFETs available are the TTL driven and CMOS driven MOSFETs. The
former type can be directly interfaced with a processor/microcontroller since
most of the MCU provides TTL output. Below shown is the motor control circuit
using PWM signal from Arduino with TTL driven MOSFET,
Connect the Gate of the MOSFET to PWM pin of Arduino. By varying the duty cycle of that pin, you can control the MOSFET`s gate which in turn controls the motor`s speed.
However, this configuration works
fine only for few trials and causes permanent damage to the transistor on
prolonged usage. The reason is that, the transistor stays in linear region for
a long time before it reaches the saturation region. Thus the performance of
the MOSFET never reaches its optimum point which leads to over heating of the
MOSFET and you will end up frying the MOSFET(as I did) on further usage.
For better understanding, the
linear and saturation region of a transistor can be compared to a human
sprinting and jogging respectively. One cannot sprint for a long time since he
deprives of energy while he can jog for a long time. And that’s why the MOSFET
gets damaged with direct TTL output. In order to avoid this problem, a buffer
can be added between the TTL output and the gate to improve the MOSFET`s
switching performance by decreasing the rise and fall timings(which provided
faster current sourcing and sinking). TTL output with buffer is shown below,
If you are using a CMOS driven
MOSFET, the TTL output(0-5V) from a MCU cannot be used directly to switch the
gate ON/OFF, since voltage higher than 5V is required to turn the transistor
gate ON. In that case, the circuit shown below can be used,
Here, the optocoupler and the diode
is used for protection purpose. R3 resistor(resistor connected to ground) is to
assist transistor turn OFF. R4 resistor( resistor connected to 3rd
terminal of optocoupler) must be low in order to avoid positive feedback(which
creates oscillations) and to obtain better transistor switching speed. Its
value can be calculated using the formula,
R= rise or
fall time/ 2.2Ciss
Ciss is the sum of
capacitors from gate to drain and gate to source(this value can be obtained
from the MOSFET data sheet). Also keep in mind that, in CMOS configuration, the
Vgate must be plus 5V higher than the Vcc to prevent
damage against the MOSFET used.
Multiple motors can be controlled with the
same circuit as shown below,
So now the first part in Autonomous
vehicle construction is completed. Now we can manually control the vehicle`s
acceleration, deceleration and braking with the MCU.
2.Obstacle
detection:
As I mentioned already, there are
several ways of detecting obstacles in robotics. To keep it as simple as possible for
beginners, I consider the ultrasonic proximity sensor(for eg: HC SR04). You can
google for Arduino interface code for the sensor module and the connection is
shown below,
The obstacle sensing range can be
set as you wish and the sensor can be mounted over a servo motor to get 180
degree field of view. Don’t forget to use a pull up resistor to avoid garbage
values in the sensor readings. Also provide enough delay time in the servo
sweep so that the echo pulse can reach the receiver completely.
Now, we have a developed an
obstacle sensing mechanism and we already know how to control the vehicle
manually. Now all we have to do is to combine both the methods.
3. Manipulating the
vehicle based on obstacle detected:
Lets consider the maximum range of
the sensor is 4 meters and anything within 2meters is considered as obstacle.
The following algorithm can be used to control the vehicle based on the sensor
reading,
Function name()
{
Read
sensor value;
If
(value>2meter)
Move forward
Else
Activate
servo and scan for obstacles in left and right side of vehicle
If
(more space in left than in right)
Move
left
Else
Move
right
} // continue loop
This algorithm detects the obstacle
and manipulates the vehicle based on the sensor values. And the resultant
vehicle will be an obstacle avoiding vehicle(with no motive, i.e, it moves
randomly avoiding obstacles)
Go to this link to see the control of DC motors based on the obstacles sensed by an IR proximity sensor and also check this link in which the sensor is mounted on a servo motor and the above algorithm is implemented in it.
4. GPS based
navigation:
The components required for this
purpose are the GPS receiver/shield and a compass. Using the Haversine formula,
the distance from the source to destination point can be calculated. Since the
distance is calculated in straight lines, way points must be declared in case of
destination points other than straight lines.
Below shown is the schematic of the
Arduino GPS shield, tiny GPS function can be uploaded to the Arduino MCU to
obtain the NMEA strings and make sure the jumpers are placed in the right
position.
click here to learn more about Arduino and GPS
Below shown is the compass
interface with Arduino MCU,
Using the compass, determine the
vehicles direction with respect to the destination point and turn the vehicle
until both the values are equal(use atan2() to get the vehicle`s current direction with respect to destination using the GPS coordinates). Then, move the vehicle to the calculated
distance(measure the distance moved using an encoder) and “you will reach your
destination point”(with lot of errors obviously). While moving from the source
to destination point, the obstacle detection and manipulation function will act
as an interrupt function.
I hope right now you got an idea
about how to build an Autonomous vehicle. However, to increase the accuracy,
you have to add lot of feedback loops and control algorithms to the system(this
is a basic model after all).
For further clarifications, feel
free to contact me at sriram.emarose@gmail.com and http://www.linkedin.com/in/sriramemarose
No comments:
Post a Comment