Beruflich Dokumente
Kultur Dokumente
External Viva
Name of the Examiners
1.
2.
ACKNOWLEDGEMENT
An endeavor over long period can be successful only with advice and guidance
of many well wishers. My sincere thanks to the management and -----------,
DEAN, BRM IIT, for providing me the opportunity to conduct my project
works. I am highly indebted to Mr. R.K.BHOI, CS DEPARTMENT, BRM IIT
for his assistance and constant source of encouragement.
I wish to express my profound and deep sense of gratitude to Mr. SASMIT
HOTA, IT DEPARTMENT, BRM IIT for sparing his valuable time to extend
help in every step of my project work.
Last but not the least we would like to thank our friends and family for their
help in every way for the success of this project report.
CONTENTS
PAGE
1. SYNOPSIS.
2. PREAMBLE...
2.1 INTRODUCTION....
2.2 PROBLEM DEFINITION.....
2.3 OBJECTIVES OF THE STUDY.
2.4 SCOPE OF STUDY.
2.5 REVIEW OF LITERATURE..
2.6 APPLICATIONS.........
2.7 LIMITATIONS....
2.8 METHODOLOGY...
3. THEORY....
3.1 THE DIFFRENTIAL STEERING SYSTEM..
3.2 D.C. MOTORS
3.3 H-BRIDGE MOTOR CONTROL...
3.4 INTELLIGENCE.
3.5 THE AVR-ATMEGA16 MICROCONTROLLER..
3.6 PWM SPEED CONTROL...
3.7 THE PICMICRO CCP MODULES.
4. DESIGN AND IMPLEMENTATION.
4.1
SCHEMATIC....
4.2
PROCESS EXPLANATION.....
4.3
FLOW CHART.....
4.4
CODE....
4.5
CODE EXPLANATION...
7. APPENDIX
1. SYNOPSIS
The line following robot, operates as the name specifies. It is programmed to
follow a dark line on a white background and detect turns or deviations and
modify the motors appropriately. The optical sensor is an array of commercially
available IR reflective type sensors.
The core of the robot is the ATMEGA 16 microcontroller. The speed control of
the motors is achieved by the two PWM modules in the C. The direction
control is provided by 2 I/O pins. The H-Bridge motor driving/control chip
takes these signals and translates it into current direction entering the motor
armature. The motors require separate supply for operation.
The differential steering system is used to turn the robot. In this system, each
back wheel has a dedicated motor while the front wheels are free to rotate. To
move in a straight line, both the motors are given the same voltage (same
polarity). To manage a turn of different sharpness, the motor on the side of the
turn required is given lesser voltage. To take a sharp turn, its polarity is
reversed.
The robot uses IR sensors to sense the line. An array of 8 IR LEDs (Tx) and
sensors (Rx), facing the ground has been used in this setup. The output of the
sensors is an analog signal which depends on the amount of light reflected back,
this analog signal is given to the comparator to produce 0s and 1s which are
then fed to the microcontroller.
The control has 6 modes of operation, turn left/right, move left/right, and drift
left/right. The actual action is caused by controlling the direction/speed of the
two motors (the two back wheels), thus causing a turn. The actual
implementation is a behavior based (neural) control with the sensors providing
the inputs. The robot can also be programmed to find the line by pseudo-random
2. PREAMBLE
2.1. INTRODUCTION
The robots of the movies, such as C-3PO and the Terminator are portrayed as
fantastic, intelligent, even dangerous forms of artificial life. However, robots of
today are not exactly the walking, talking intelligent machines of movies,
stories and our dreams.
In the 1970s scientists proposed that in the year 2000 we would have created
artificial life forms, almost perfect in terms of intelligence and capabilities. The
dream of free and efficient labor made the researchers of the time go on day and
night to bring the dream to existence. But the task was futile due to the lack of
compact processors to carry out the calculations which were oh so necessary.
Now in the year 2000, the micro-processor technology is thousands of times
more advanced than what existed back then. But still the robots of today are no
way close to what our movies portray them to be. This is not only due to
drawbacks in processor technology, but also in various other fields such as
vision, motor control so and so forth.
Robots may never make it to our kitchens or living rooms as personal slaves,
but they certainly have made their way to the manufacturing industry, aerospace industry, and yes to the work benches of robotic hobbyists. Robots are
now working in dangerous places, such as nuclear disposal, space explorers, fire
fighting and many more.
The word "robot" originates from the Czech word for forced labor or serf.
Robots are electronic devices intended to perform a desired function. Many
refer to them as "machines", however, a drill press is a machine, yet it requires
an operator to perform its function, where robots can be programmed to do it
themselves. Robots have the potential to change our economy, our health, our
standard of living, our knowledge and the world in which we live. As the
technology progresses, we are finding new ways to use robots. Each new use
brings new hope and possibilities, but also potential dangers and risks. Robotics
is not only a science, but it is also an art. The bots we build reflect the ideas and
personalities we portray. There are many different versions of robots that can be
made. From turtle bots to vehicles like the Mars rovers to rovers like R2-D2.
From walkers that have anywhere from 1 to 10 legs to robotic arms to androids.
Whatever you can dream, you can create. The level of expertise you want your
robot to have and how much learning and research you want to do is up to you.
For those who have relative experience in computer programming and
electronics, this may come easier to you than anyone new to the hobby. Those
who build models, RC vehicles, and other artwork will find it challenging to
modify some of their previous projects.
We have seen how ants always travel in a line, following an invisible route in
search of food, or back home. How on roads we follow lanes to avoid accidents
and traffic jams. Ever thought about a robot which follows line? A perfect or
near perfect mimic of mother-nature? After all the purpose of robotics is to
recreate in terms of machines what we see around to solve a problem or fulfill a
requirement.
Programming intelligence into a robot (or computer) is a difficult task and one
that has not been very successful to date even when supercomputers are used.
This is not to say that robots cannot be programmed to perform very useful,
detailed, and difficult tasks; they are. Some tasks are impossible for humans to
perform quickly and productively. For instance, imagine trying to solder 28
filament wires to a 1/4in square sliver of silicon in 2 s to make an integrated
circuit chip. Its not very likely that a human would be able to accomplish this
task without a machine. But machine task performance, as impressive as it is,
isnt intelligence.
The robot must also be capable of following a line even if it has breaks.
on a white background or a white line on a dark background. The robot can also
be programmed to decide what kind of line it is, instead of a user interface. The
motor control could be modified to steer a convectional vehicle, and not require
a differential steering system. The robot could be modified to be a four wheel
drive. Extra sensors could be attached to allow the robot to detect obstacles, and
if possible bypass it and get back to the line. In other words, it must be capable
predicting the line beyond the obstacle. Speed control could also be
incorporated. Position and distance sensing devices could also be built in which
can transmit information to a mother station, which would be useful in tracking
a lost carrier.
every hardware feature and the instruction set. The most helpful is the design
tips section which answered most of the questions which were bogging my head
down.
Robotics by C. K. Kuo was another book I referred for this project. Even though
2.6. APPLICATION
Industrial automated equipment carriers
Entertainment and small household applications.
Automated cars.
Tour guides in museums and other similar applications.
Second wave robotic reconnaissance operations.
2.7. LIMITATIONS
Choice of line is made in the hardware abstraction and cannot be
changed by software.
The project was entirely (other than PCB) designed, created, soldered, tested
and coded by me. For which Im thankful for, as I have learnt much more in the
processes and not to mention the fun had.
3. THEORY
3.1. THE DIFFERENTIAL STEERING SYSTEM
The differential steering system is familiar from ordinary life because it is the
arrangement used in a wheelchair. Two wheels mounted on a single axis are
independently powered and controlled, thus providing both drive and steering.
Additional passive wheels (usually casters) are provided for support. Most of us
have an intuitive grasp of the basic behavior of a differential steering system. If
both drive wheels turn in tandem, the robot moves in a straight line. If one
wheel turns faster than the other, the robot follows a curved path. If the wheels
turn at equal speed, but in opposite directions, the robot pivots.
Where give the displacement (distance traveled) for the left and right wheels
respectively, is the turn radius for the inner (left) wheel, is the distance
between wheels (from center-to-center along the length of the axle), and is the
angle of the turn in radian. In this discussion, we will treat the axle's center
are required to achieve accurate control over the axial rotation of these motors.
Although recent developments in stepper motor technologies have come a long
way, the benefits offered by smooth control and high levels of acceleration with
DC motors far outweigh any disadvantages.
Several characteristics are important when selecting DC motors and these can
be split into two specific categories. The first category is associated with the
input ratings of the motor and specifies its electrical requirements, like
operating voltage and current. The second category is related to the motor's
output characteristics and specifies the physical limitations of the motor in
terms of speed, torque and power.
Example specifications of the motors used are given below:
As noticed, the torque provided can hardly move 30gm of weight around with
wheel diameter of about 2cm. This is a fairly a huge drawback as the robot
could easily weigh about a kg. This is accomplished by gears which reduce the
speed (2400 rpm is highly impractical) and effectively increase the torque. If the
speed is reduced by using a gear system by a factor of
increased by the same factor. For example, if the speed is reduced from 2400
rpm, to 30 rpm, then the torque is increased by a factor of (2400/30 = 80) in
other words the torque becomes 30 80 2400 gm-cm or 2.4 kg-cm which is more
than sufficient.
The Explanation is simple, If A & D are turned on, then the current flows in the
direction shown in the figure below.
If you turn on the two upper circuits, the motor resists turning, so you
effectively have a breaking mechanism. The same is true if you turn on both of
the lower circuits. This is because the motor is a generator and when it turns it
generates a voltage. If the terminals of the motor are connected (shorted), then
the voltage generated counteracts the motors freedom to turn. It is as if you are
applying a similar but opposite voltage to the one generated by the motor being
turned. In other words, it acts like a brake. Any other state like A & C = ON or
B & D = ON will cause a direct path to ground causing a very high current to
pass through the relays thus causing a burnt fuse (if it exists).
The following figure shows an H-Bridge using only transistors. The same
theory applies.
Usually, the above circuitry can be used only for direction control. The Existing
H-Bridge is further modified to include another transistor, now making speed
control possible too. This is shown in the figure below.
The same direction rules apply, but now the motor will behave as per the
direction control only when a 1 is given to the EN input. Speed control is
usually done by giving a PWM signal, and the duty cycle is varied to vary the
speed of the motor. Usually protection diodes are also incorporated across the
transistors to catch the back voltage that is generated by the motor's coil when
the power is switched on and off. This fly-back voltage can be many times
higher than the supply voltage! If diodes are not used, the transistors have a
good chance to get burnt.
3.4. THE IR SENSORS
It has been shown that practically all electronic devices need DC supply. A
direct voltage of constant magnitude requires to be supplied, for the smooth and
efficient functioning of these devices. A properly designed voltage regulator
ensures that, irrespective of change in supply voltage, load impedance or
temperature, the DC supply is maintained at a constant level. This is achieved
by incorporating some type of feedback in the regulator circuit.
An IC voltage regulator unit contains all the circuitry required in a single IC.
Thus there are no discrete components and the circuitry needed for the reference
source, the comparator and control elements are fabricated on a single chip.
Even the over load and short-circuit protection mechanism is integrated into the
IC. IC voltage regulators are designed to provide either a fixed positive or
negative voltage, or an adjustable voltage which can be set for any value
ranging between two voltage levels.
3.7. BATTERY
Motors on a robot consume most of the power. For most of them, each DC
motor typically consumes 1.5W on the average. For differential steering, two
DC motors consume up to 3W. By comparison, the logic components typically
draw a total of about 80mA. Even at a supply voltage of 12V, the logic
component only consumes 1W.
3.8. INTELLIGENCE
There are two schools of thought concerning the creation of intelligence in
artificial systems. The first approach programs an expert system (top down); the
second is a neural or behavior based system (bottom up). The expert system
uses rules to guide the robot in task performance. Behavior based programs
create an artificial behavior in the robot that causes it to reflectively
(automatically) perform the task required. Behaviors may be
programmed
is simulated in software.
The research done on the line sensors showed that there are two main
methods used:
A Light dependant resistor picking up light reflected off the floor from an
LED.
A Phototransistor picking up light reflected from an infra red LED.
The Infra Red option has 2 major benefits over the visual spectrum solution.
Firstly that the Infra Red Spectrum is a lot cleaner than the visual spectrum,
there is a lot less potential for interference. The other advantage is that
phototransistors will react much quicker than Light dependant resistors.
However, what appears white and black to the naked eye, may not be
distinguishable in the Infra red spectrum.
The resistance of the sensor decreases when IR light falls on it. A good sensor
will have near zero resistance in presence of light and a very large resistance in
absence of light. We have used this property of the sensor to form a
potential divider. The potential at point 2 is
Rsensor / (Rsensor + R1).
Again, a good sensor circuit should give maximum change in potential at point
2 for no-light and bright-light conditions. This is especially important if you
plan to use an ADC in place of the comparator.
To get a good voltage swing, the value of R1 must be carefully chosen. If
Rsensor = a when no Light falls on it and Rsensor = b when light falls on it.
The difference in the two potentials is: Vcc * { a/(a+R1) - b/(b+R1) }
cc
cc
Fig 4.1
4.1.4. BATTERY
If we assume the whole robot consume 5W, it requires 4500J of energy to last
15minutes. If we use a 6V battery, it must have a capacity of
4500J/6V=750Asec or 104mAH. This may imply that getting a battery of
150mAH is sufficient. Unfortunately, the discharge curve of a 150mAH will not
sustain the required voltage for 15 minutes.
Thus a Zinc Chloride battery was used of rating of 1.2mA for the robot to last
longer than 15min and also to take practical situations into considerations.
4.1.5. VOLTAGE REGULATOR
The circuit requires two voltage sources; one for the digital ICs (+5V) and a
+12V to the motors. The motor is supplied 12V unregulated supply directly
from the battery as regulation would be difficult and unnecessary; whereas the
digital ICs and the microcontroller require a perfect ripple free +5V to function
properly. The L7805C is a 5V voltage regulator IC. The capacitors added to the
input of the voltage regulator are to isolate the spikes generated by the motor
from the input and to reduce noise. The 10 F capacitor at the output is to
maintain stability and improve regulation. These are standard values. The 0.1
F capacitor is used at the input because of the fact that high value capacitors
have poor high frequency response.
4.1.6. D.C. MOTORS
Geared D.C. motors were used which can operate in the range from 0V to 12V
.The D.C. motors have a speed of 2400rpm and a torque of 15gm-cm. The gears
decrease the speed to 30rpm at 6V and thus considerably increasing the torque
so that the robot can carry the load of its frame and the lead-acid battery. Two
such motors are used in the rear of the robot, and a dummy castor is fixed to the
front to stabilize the robot.
The entire motor control circuitry is shown in the above figure along with the
internal circuitry of the L293D motor control IC. The table below clearly
indicated the operation of the IC.
& IN4. Now we have 1 directional control per motor. The ENABLE of each
motor section is given PWM inputs to further improve on the control. Now,
each motor has a direction control and a speed control. The clamping diodes are
built into the chip which prevent the back EMF generated by the motors to harm
the H-bridge. The inversion was achieved using the 74HCT04 HEX inverter IC
having a slew rate of about 6ns which is negligible compared to the reaction
time of the H-bridge itself.
4.1.8 COMPARATOR
The reference voltage is generated by the 20k POT and given to all the
comparators to the non-inverting input. When the respective sensor is on the
line, the emitted light is absorbed by the line and the transistor is the cut-off
mode, thus a potential of 4.6V is given to the inverting input which is greater
than Vref (which is chosen to be 2.5V), thus the output of the comparator goes
low. When the sensor is not on the line (reflective white surface) the potential
across the detector is usually 0.6V. Thus the output of the comparator goes high
(the non-inverting input has a greater potential). Thus the output of the
comparator goes low only when the sensor is over the line. The comparator is
open collector, and hence a pull-up resistor of 10 k is required at the output.
time the commands executed by the microcontroller is also shown. From the
above figure, it should be clear about the software requirements.
The surface is sampled every 2.1ms using the timer 0 interrupt routine. This
implies that the line is sampled 476 times in a second. From observations, the
robot travels at a maximum speed of around 10cm/sec. In other words, 47.6
samples are taken per cm, or 4.76 samples per mm. This is more than ever
required! Due to the fact that the robot can remember and follow the previous
task when its sensors do not see a line, enables the robot to trace a sharp turn,
even if in case the robot runs off the line while making the turn.
4.4 ALGORITHM
: 256
*****************************************************/
//#define debug 1
#include <mega16.h>
#include <delay.h>
#ifdef debug
#include <stdio.h>
#endif
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
FWD 0xAA
REV 0x55
R 0x22
L 0x88
CW 0x99
CCW 0x66
STOP 0x00
B 0xFF
RSPEED OCR1AL
LSPEED OCR1BL
SPEED0 255
SPEED1 0
SPEED2 0
SPEED3 0
MAX 3
HMAX 1
// Func7=In Func6=In
Func1=In Func0=In
Func5=In
Func4=In
Func3=In
Func2=In
PORTB=0x00;
DDRB=0x00;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In
Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T
State0=T
PORTC=0x00;
DDRC=0xFF;
// Port D initialization
// Func7=In Func6=In Func5=Out Func4=Out Func3=In Func2=In
Func1=In Func0=In
// State7=T State6=T State5=0 State4=0 State3=T State2=T
State1=T State0=T
PORTD=0x00;
DDRD=0x30;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 921.600 kHz
// Mode: Fast PWM top=00FFh
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
TCCR1A=0xA1;
TCCR1B=0x0A;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0xFF;
OCR1BH=0x00;
OCR1BL=0xFF;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
#ifdef debug
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 57600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x07;
#endif
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
while (1){
#ifdef debug
if(rep<255)
rep++;
if(prev!=PINA) {
prev=PINA;
printf("%u\r",rep);
for(i=0;i<8;i++)
printf("%u\t",(prev>>i)&0x01);
rep=0;
}
#endif
if(PINA!=255){
rotpow=255;
ldev=rdev=0;
if(PINA.3==0)
rdev=1;
if(PINA.2==0)
rdev=2;
if(PINA.1==0)
rdev=3;
if(PINA.0==0)
rdev=4;
if(PINA.4==0)
ldev=1;
if(PINA.5==0)
ldev=2;
if(PINA.6==0)
ldev=3;
if(PINA.7==0)
ldev=4;
if(rdev>ldev)
move(R,0,195+12*rdev);
if(rdev<ldev)
move(L,0,195+12*ldev);
if(rdev==ldev)
move(FWD,0,200);
}
else
{
for(i=0,dirl=0;i<MAX;i++) {
if(history[i]==L)
{dirl++;}
}
if(rotpow<160) {rotpow=160;}
if(rotpow<255) {rotpow++;}
if(dirl>HMAX)
{move(CW,0,rotpow);}
else
{move(CCW,0,rotpow);}
}
};
}