22
The mobile line follower robot is a type of mobile robot with only has one specific task which is to follow the line made with black tape over the white background or vise verse. The LFR perhaps is one of the most popular robot build by the roboticists. What makes this LFR is so popular, I think because of its simplicity and yet it could be used as the teaching tools of how we could implement the industrial standard control system such as the PID (Proportional Integral Deferential) control system on this robot. Another factor probably is the increase of the LFR annual tournament conducted in many countries. The basic principal of the line follower robot actually almost the same as the light follower robot, but instead of tracking the light the LFR sensor is used to track the line, therefore by differentiating the line color and it’s surrounding (black over white or vise verse) any light sensitive sensor could be used to navigate the mobile robot to follow this track.

Lfr My Final

Embed Size (px)

Citation preview

Page 1: Lfr My Final

The mobile line follower robot is a type of mobile robot with only has one specific task which is to follow

the line made with black tape over the white background or vise verse. The LFR perhaps is one of the

most popular robot build by the roboticists. What makes this LFR is so popular, I think because of its

simplicity and yet it could be used as the teaching tools of how we could implement the industrial

standard control system such as the PID (Proportional Integral Deferential) control system on this robot.

Another factor probably is the increase of the LFR annual tournament conducted in many countries.

The basic principal of the line follower robot actually almost the same as the light follower robot, but

instead of tracking the light the LFR sensor is used to track the line, therefore by differentiating the line

color and it’s surrounding (black over white or vise verse) any light sensitive sensor could be used to

navigate the mobile robot to follow this track.

Base on the above fact, I designed the simplest possible electronics circuit that use the navigation

principal shown above to track the black tape line.

Page 2: Lfr My Final

The 2N3904 NPN Bipolar Junction Transistor (BJT) is designed to operate as the current gainer amplifier;

this means we operate the 2N3904 transistor in its linear region. The advantages of using the transistor

in its linear region is; the transistor collector current passed through the DC motor will varying according

to the base current which controlled by the LDR (Light Dependent Transistor) and 10 K trimmer

potentiometer (trimpot). Therefore the current through the DC motor will vary according to the light

intensity received by the LDR.

Using this simple principal we could easily used this circuit to track the black tape by locating the LDR

and the white LED in such a way that the LDR will receive less light from the white LED when the LDR

position right on top of the black tape and this will make the DC motor to turn slowly (less collector

current). When the LDR position outside the black tape (on the top of the white background) the LDR will

receive more light from the white LED; this will make the motor to turn faster (more collector current).

Page 3: Lfr My Final

The trimpot is use to adjust the DC motor speed, while the 1N4148 diode is use to protect the transistor

again the EMF (Electromotive Force) generated by the DC motor inductor when its switch off. The key of

successfully building this circuit is heavily depend on the geared DC motor we choosed.

You have to choose the geared DC motors which rated 5 volt that have low power consumption (small

current) as the 2N3094 transistor only allowed max 100 mA current on its collector (you could replace it

with 2N2222A transistor, max 800mA) and try to use a low RPM (rotation per minute) geared DC motor

(remember must be the geared DC motor). The lower RPM is required here because the LDR has a slow

response comparing to other light sensitive component (e.g. photo transistor), so the Line Follower Robot

could keep follow the black track line. You could always experiment with your own geared DC motor

speed on different track’s route by adjusting the 10 K Ohm trimport.

Page 4: Lfr My Final

One of disadvantage using the transistor on its linear region to control the DC motor’s speed is the power

dissipation (power loss as heat) on the transistor especially if we use large power DC motor, the common

and efficient method to control the motor’s speed is to use the PWM (pulse width modulation) which

make the transistor on and off rapidly; but for the geared DC motor used in this Line Follower Robot

project we simply take advantage of the transistor in its linear region to change its speed (i.e. by

changing the transistor collector current). You could read more information about building the PWM

based Line Follower Robot on “The LM324 Quad Op-Amp Line Follower Robot with Pulse Width

Modulation” project on this blog

This line follower robot use what is called the “differential drive” steering method, which use two

independent motor mounted in fixed positions on the left and right side of robot’s chassis. This mean by

slowing the rotation speed of the left DC motor will make the robot to arc to the left and slowing the

rotation speed of the right DC motor will make the robot to arc to the right. If both motor rotate at the

same speed than the robot will simply go straight as shown on this following picture.

Therefore by arching to the left and to the right or go straight the robot could easily follow the black line

track. As you know how this two transistors line follower robot circuit works, now its time to build the

robot chassis.

The LFR Chassis Construction

The LFR construction in this tutorial is very simple as I just use a 1 mm cardboard for the main body

construction and use caster (the third wheel) made from bead and paperclip as shown on my previous

posted blog Building BRAM your first Autonomous Mobile Robot using Microchip PIC Microcontroller.

Page 5: Lfr My Final

By using this easy to handle construction material hoping you could easily build this Line Follower Robot,

these following pictures show how to assembly all these parts together.

Page 6: Lfr My Final

I use double tape to hold the 3 x AA (4.5 volt) battery holder and the micro geared DC motor (now you

understand how important this double tape to the robot’s builder); the DC motor also is reinforced with

the plastic cable’s ties. The electronics component is soldered on the 18 x 38 mm prototype PCB and I

just use the duct tape to hold the LDR and LED together as shown on the above circuit. To make it more

interesting I put one  three colors auto flashing LED for the indicator.

Page 7: Lfr My Final

Bellow is the complete list of material and electronics component used to build this line follower robot:

1. Thick paper (1 mm), double tape, duct tape, plastic cable’s ties

2. One paper clip and bead for the caster (the third wheel)

3. Adequate Bolts and Nuts

4. One 3 x AA Battery holder and 3 x AA (1.5 Volt Alkaline) Battery

5. Two micro geared DC motor rated 5 volt, unloaded RPM < 50, unloaded current: < 50mA

6. 18 x 38 mm prototype PCB

7. Two 220 Ohm 0.25 watt resistor

8. Two LDR (about 2 ~ 5K Ohm in the bright light and 100K Ohm in the dark).

9. Two 3mm white LED

10. One auto flashing RGB LED with one 220 ohm resistor 0.25 watt (optional)

11. Two 10 K Ohm Trimmer Potentiometer

12. Two 1N4148 Diodes

13. Two 2N3904 or 2N2222A Transistors.

Page 8: Lfr My Final

Now it’s time to show the capabilities of this simple and easy to build line follower robot.

The Final Thought

As you’ve seen from the demo video above this two transistors Line Follower Robot sometimes out

perform many of the microcontroller based line follower robot designed and for sure using more complex

circuit (e.g. the 8-bits microcontroller and the motor controller) and not to mention the microcontroller’s

programming; which eventually do the same job as demonstrated by this simple two transistors based

line follower robot.

For higher speed line follower robot with more complex track, we need to use the microcontroller,

although it’s possible to use just a discrete electronics components but its required more complex circuit

which than the microcontroller based solution become more simple and cheap to be used. On my second

part of the line follower robot (LFR), we will build the microcontroller’s based LFR which using more

advance sensors to track the line compared to this one.

Page 9: Lfr My Final
Page 10: Lfr My Final
Page 11: Lfr My Final

Designing a simple and yet functional Line Follower Robot (LFR) is always a fascinating and challenging

subject to be learned, the LFR actually could be implemented in many ways start from a simple two

transistors to a sophisticated PID (Proportional, Integrate and Differential) which take advantage of the

programmable feature of microcontroller to calculate the PID equation to successfully navigate the black

track line on a white background surface.

Designing a non microcontroller based LFR is quite challenging tasks as we need to limit the electronic

components numbers so the LFR will not too complicated to be built by most average robotics beginners

or electronic hobbyists, but at the same time we need to have a good speed control mechanism in order

for the LFR to navigate the black track line successfully. The microcontroller based design LFR in the

other hand is a popular choice because it reduces a number of electronic components significantly while

still providing a flexible programmable control to the LFR.

On this tutorial we are going to build yet another LFR using just the standard analog components easily

found on the market but use the same speed control method technique found in many good

microcontroller based Line Follower Robot design. As the result we could get a good precision analog line

follower robot that comparable to the microcontroller based Line Follower Robot design. On this tutorial

you will also learn many useful information of how to use the operational amplifier.

The Line Follower Robot

This Line Follower Robot basically use a Cadmium Sulphide (CdS) photocell sensor or known as Light

Dependent Resistor (LDR) and the high intensity blue Light Emitting Diode (LED) to illuminate the area

under the photocell sensor to sense the black track line and the DC motor speed control technique to

navigate the black line track as shown on this following picture:

Page 12: Lfr My Final

The easy method to navigate the black track line is to turn ON and OFF the left or the right DC motor

according to the sensor reading (black turn OFF and white turn ON), but using this method will make the

LFR to move in zigzag way. By proportionally control both left and right DC motor speed according to the

light intensity level received by the photocell sensor (reflected back by the black track line) we could

make the LFR easily navigate this track. The common technique to control the motor speed efficiently is

to use a pulse signal known as the pulse width modulation or PWM for short.

PWM basically is an ON and OFF pulse signal with a constant period or frequency. The proportion of pulse

ON time to the pulse period is called a “duty cycle” and it expressed in percentage. For example if the

proportion of pulse ON time is 50% to the total pulse period than we say that the PWM duty cycle is 50%.

Page 13: Lfr My Final

The PWM duty cycle percentage is corresponding to the average power produced by the pulse signal; the

lower percentage produces less power than the higher percentage.

Therefore by changing the PWM duty cycles we could change the average voltage across the DC motor

terminals, this mean we could vary the DC motor speed just by changing the PWM duty cycle. Therefore

to make the LFR smoothly navigate the black track line, we have to adjust the PWM duty cycle according

to the photocell sensor reading. The brighter light intensity level received by sensor (sensor is on the

white surface) will result in higher PWM duty cycle percentage and the darker light intensity level (sensor

is on the black line) received by photocell sensor will result in lower PWM duty cycle percentage.

By converting each of the photocell sensor light intensity level reading to the corresponding voltage level

we could achieve this objective by using what is known as the Voltage Control Pulse Width Modulation

principal.

Actually generating the PWM signal is easier with microcontroller instead of discrete components

because all you have to do is to program the microcontroller PWM peripheral to do the task. On this

tutorial we will learn of how to build this LFR with Voltage Control PWM using the same working principal

found in many today’s modern microcontroller but using just the analog electronic components.

Now let list down the necessary electronic and other supported components to build this awesome LFR:

1. Resistors: 220 (2), 1K (2), 15K (1), 33K (1), 47K (2), and 100K (1)

2. Trimpots: 100K (2)

3. Two Light Dependent Resistor (dark above 100KOhm and below 5KOhm  on bright light intensity)

4. Capacitors: 47uF/16v (1) and 0.1uF (5)

5. Diodes: 1N4148 (2)

6. High Intensity 3 mm blue Light Emitting Diode (2)

7. Optional 5 mm auto flash RGB LED with 330 Ohm resistor for the power indicator

8. Transistors: BC639 (2)

9. IC: National Semiconductor LM324 Quad Operational Amplifier (1)

10. DC Motor: Solarbotics GM2 Geared DC motor with Wheel (2)

11. Prototype Board: 52 x 38 mm for main board and 50 x 15 mm for sensors

12. 3xAA Battery holder

13. CD/DVD ROM (2)

14. Plastic Beads and Paper Clip for the castor (the third wheel)

15. Bolt, Nuts, Double Tape and Standard Electrical Tape for the black line

The complete Line Follower Robot electronics schematic is shown on this following picture:

Page 14: Lfr My Final

The Voltage Control PWM

The main brain of this Line Follower Robot is lay behind the LM324 quad operational amplifier from

National Semiconductor. The dual in line LM324 packages contains four identical op-amps and is

specially designed to operate as an analog device.

The voltage control PWM could be generated by first using the triangle signal generator which provide

the basic PWM pulse frequency and the necessary ramp voltage (rise and down) to produce the PWM

signal. Next by continuously comparing this ramp voltage according to the voltage level produced by the

photocell sensor using the comparator circuit we could produced the exact voltage control PWM as

shown on this following picture.

Page 15: Lfr My Final

When the triangle rise ramp signal reaches the voltage threshold point it will turn ON the comparator

because the comparator non inverting input (V+) voltage is greater than the comparator inverting input

(V-) voltage and when the down ramp signal reaches the voltage threshold point it will turn OFF the

comparator because now the comparator inverting input (V-) voltage is greater than the comparator non

inverting input (V+) voltage. You could read more about how the comparator works on Working with the

Comparator Circuit in this blog.

If we set the threshold point voltage higher, then the ON period will be shorten; and if we set the

threshold point voltage lower, then the ON period will be longer. Therefore by varying the threshold point

voltage we could also vary the ON and OFF period of the comparator which is the exact behavior that we

are looking for to produce the required PWM signal to drive the Line Follower Robot geared DC motor.

The ramp signal is provided by the two op-amps (U1A and U1B) that generate the triangle wave signal

while the comparator for producing the PWM to each DC motor is provided by the other two op-amps

(U1C and U1D) that receipt its input from the voltage divider circuit (VR and LDR) which provide the

voltage threshold point and together with the triangle wave to produce the required PWM pulse

Page 16: Lfr My Final

The PWM principal explained above is also used in many today’s modern microcontrollers PWM

peripheral; but instead of processing the analog signal it process the digital signal. The ramp signal is

replaced by the digital counter (TIMER peripheral) that will count up from 0 to 255 and start from 0

again, while the threshold point voltage is provided by threshold point register that hold the digital value

(e.g. 100).

Microcontroller uses the digital comparator to compare these two digital values, when the digital counter

counting up and reach the threshold point (i.e. 100) then the PWM peripheral will turn on to the output

port and when it reach the maximum value (i.e. 255) it will turn off to the output port. Therefore by

changing the threshold point register value we could change the PWM duty cycle output. You could read

Page 17: Lfr My Final

more about microcontroller based PWM on H-Bridge Microchip PIC Microcontroller PWM Motor

Controller andIntroduction to AVR Microcontroller Pulse Width Modulation (PWM) articles on this blog.

When designing the electronic circuit is a good habit to prototype it first, the prototype circuit enables us

to fine tune the electronics design and give us the picture (signal wave) of how the circuit really works.

The following picture is the Line Follower Robot circuit prototype on a breadboard complete with sensor

(LED and LDR pairs) and the GM2 geared DC motor from Solarbotics.

The Triangle Wave Generator Circuit

Now as you understand the principal of how the Line Follower Circuit works than let’s take a look at the

triangle wave generator circuit. In order to make it easy to understand I redraw the electronic schematic

circuit separately as shown on this following picture:

Page 18: Lfr My Final

To generate the triangle wave we need to use the Schmitt Trigger circuit (also called a comparator with

hysteresis) that act as ON and OFF switch to the Integrator circuit input. The integrator uses the R5 and

C2 to produce the necessary triangle linear ramp (up and down) on its output.

When the power up we assume the U1A output is HIGH (Vcc); the C2 capacitor will start to charge

through the R5 resistor. Because the R5 and C2 is connected to the U1B inverting input (V-), therefore

the U1B output will start to ramp down. The U1A non inverting input (V+) get the positive feedback from

R3 and R4, when the U1B output voltage reach the threshold voltage below Vref than it will turn the U1A

output to LOW (0). This bottom threshold voltage could be calculated as follow:

Vth = (R4 (Vout-u1a – Vout-u1b) / (R4 + R3)) + Vou-u1b; Vout-u1a = Vcc; Vcc = 4.5 Volt

Vth <= Vref, Vref = 0.4 Vcc

(R4 (Vcc – Vout-u1b) / (R4 + R3)) + Vout-u1b <= 0.4 Vcc

Now putting all the resistors value then we will get this following result:

(47 (Vcc – Vout-u1b)/ 147) + Vout-u1b <= 0.4 Vcc

1.4 – 0.3 Vout-u1b + Vout-u1b <= 1.8

Vout-u1b <= 0.6 Volt

Therefore the U1B output will ramp down to about 0.6 volt than the U1A output will turn OFF. Next the

C2 capacitor will discharge through R5 and the UA1B output will start to ramp up and it start to increase

the voltage across the R4 (Vth – threshold voltage) until the Vth voltage above the Vref voltage then the

U1A output will turn to HIGH and the whole cycle will repeat again. This upper threshold voltage could be

calculated as follow:

Vth = (R4 (Vout-u1a – Vout-u1b) / (R4 + R3)) + Vou-u1b; Vout-u1a = 0; Vcc = 4.5 Volt

Vth >= Vref; Vref = 0.4 Vcc

(R4 (- Vout-u1b) / (R4 + R3)) + Vout-u1b >= 0.4 Vcc

Now putting all the resistors value then we will get this following result:

(47 (- Vout-u1b)/ 147) + Vout-u1b >= 0.4 Vcc

- 0.3 Vout-u1b + Vout-u1b >= 1.8

Vout-u1b >= 2.6 Volt

Therefore the triangle voltage will ramp up from 0.6 volt to 2.6 volt then ramp down to 0.6 volt

repeatedly. The frequency of the triangle wave could be calculated as follow:

Frequency = (1 / (4 x R5 x C2)) x (R3/R4) Hertz

Now putting all the resistors and capacitor value then we will get this following result:

Frequency = (1 / (4 x 15,000 x 0.0000001)) x (100,000/47,000) = 354.61 Hz

As you might guess the actual frequency measured on this Line Follower Robot prototype circuit above is

about 292 Hz, this is due to the electronic components tolerance value (resistors and capacitors).

Page 19: Lfr My Final

Therefore if you want to have the exact frequency you could put a 100K trimport in series with R5

resistors. The voltage divider R1 and R2 provide the voltage reference (DC bias voltage) to both U1A and

U1B op-amps.

The Sensor Circuit

As mention above this Line Follower Robot take advantage of the photo-resistor (CdS) known as Light

Dependent Resistor (LDR). The LDR will decreases its resistance in the presence of light and increase its

resistance in the dark. The region under the LDR is illuminate with a high intensity blue LED, the white

surface will reflect most of the light to the LDR surface while the black track line will absorb most of the

light, therefore less light will reflect to the LDR surface.

As the robot move on the black track line the LDR will continuously capture the reflected light and

convert this light intensity into the corresponding voltage and feeding it to the inverting input (V-) of U1C

(left sensor) and U1D (right sensor).

The 100K trimpot and LDR basically is the voltage divider circuit when the LDR detect the black track line

it will receive less light intensity (LDR resistance increase) and the voltage (V-) will increase; this will

Page 20: Lfr My Final

decrease the PWM duty cycle output and as the result the geared DC motor will turn slowly or stop.

When the LDR on the white surface it will receive maximum light intensity (LDR resistance decrease) and

the voltage (V-) will decrease; this will increase the PWM duty cycle output and as the result the geared

DC motor will turn fast.

You could simply exchange the comparator V+ and V- input source to make the Line Follower Robot

detect the white line on the black surface instead of normal black line on the white surface. By using two

DPDT (Double Pole Double Throw) switches you could achieve this behavior as shown on this following

picture:

The geared DC motor driver uses the BC639 transistor and the base terminal is connected to the

comparator output through the 1K resistor. The transistor is operated as a switch which turns ON and

OFF the geared DC motor according to the PWM pulse current it received from the comparator. The 0.1uF

capacitor across the geared DC motor’s terminal is used to reduce noise generated by the DC motor. For

more information about using transistor as switch you could read Using Transistor as Switch article on

this blog.

The Line Follower Robot Construction

The Line Follower Robot construction could be constructed freely but the easiest one is to use the

discarded CD/DVD ROM as shown on this following pictures:

Page 21: Lfr My Final

I glue the two CDROM together in order to make more room and attached the two DC motors, 3xAA

battery holder, main board and sensor board using the double tape. The sensor sensitivities and the Line

Page 22: Lfr My Final

Follower Robot speed could be controlled by adjusting the 100K trimport. After putting all the parts

together now is time to watch how this nice Line Follower Robot in action:

The Final Thought

As you’ve seen from the demo video above this Line Follower Robot design is capable to handle and

smoothly navigate a quite complex black track line. This prove that a good analog Line Follower Robot

design sometimes could outperform many microcontrollers based Line Follower Robot.

Building the Line Follower Robot (LFR) is one of my favorite projects as I enjoy designing and making this

kind of robot, it also gives much joy and fun to my kids as well. I hope this project will give you as much

joy as I did; building, watching, and playing with this analog Line Follower Robot.