Light Following Robot - Seminar Paper

Light Following Robot
Introduction:
The light following robot is a mobile machine which is capable of detecting and following the light source on the traveling path. It is developed without the help of a micro-controller for providing easier connections and understanding of the circuit. It requires fewer numbers of electronic components and very cost-effective as well.
The concept of this light following robot is very simple. It includes two photodiodes, one on the right and other on the left. When the light falls on the right photodiode, the robot will move on the right side. Similarly, the robot will move on the left side when the light falls on the left photodiode.

Components used:
  • Battery: One 9V battery will be sufficient for powering the robot. For more usages, two pairs of 9V battery may be required.
  • Battery holder: It is used to connect the battery with the circuit.
  • Breadboard: One breadboard is used for designing the circuit. The electronic components are connected by inserting it in the holes of the breadboard. 
  • Capacitor: Two 10uf capacitors are implemented to store the current, equalize the power output, filter, and so on.
  • Castor Wheel: One castor wheel is mounted in front of the hard board for providing easy and comfortable moving of the robot.
  • Gear Motor: Two 300rpm gear motors are connected with the wheel for moving the robot.
  • IC 7805: One IC 7805 voltage regulator is incorporated for allowing 5V of power supply to the circuit instead of 9V.
  • IC L293D: One L293D IC motor driver is used for driving two motors in both clockwise and anticlockwise directions.
  • IC LM358: One LM358 IC voltage comparator is attached to the circuit for comparing voltages across the + and – terminals.
  • LED: A 1.5V 200mA LED is attached to notify the falling of light source on the photodiode.
  • Resistor: One 1K & three 10K resistors are required for this process to reduce the voltage. The ranges of the resistors can be calculated with the help of a multimeter.
  • Wheels: Two wheels (10cm dia.) are coupled with the gear motor. When the motor is powered, the wheels will start to rotate and move the robot.
  • Wires: Two meters of both two core and four core wires will be required. For breadboard connections, two core wires should be used and for motor connections, four core wires should be used.


Construction and Working Principle:
Connect a 9V battery to the breadboard with the help of a battery holder. The positive power supply is passed to the IN of IC 7805 (1), and sent out through the OUT (3). The negative power supply is sent to the GND (2) connection of IC 7805. In between, two capacitors (C1 & C2) are connected to the IN and OUT of IC 7805 respectively. As a result of this process, 5V of current is obtained.
Now, connect an IC LM358 in the breadboard. As it is a voltage comparator, it will predict the output from the photodiodes based on the input voltage. For instance, let us consider that the voltage at 3rd pin is more than or equal to the voltage at 2nd pin. At this time, the 1st pin of IC LM358 will be high or else it will stay low. A 10K resistor is coupled with each photodiodes. Then, place an IC L293D in the breadboard, and join the 2nd and 15th pin of it with 1st pin of IC LM358. In between this connection, include a LED with the 10K resistor.
The four – core wire of left motor is connected to the 3rd & 6th pin of IC L293D, while the right motor is attached with 11th & 14th pin. The two 10cm wheels are mounted with the motors. A castor wheel is included at the front of the robot for balanced and comfortable movements. A power supply of 5V is applied to the 1st, 7th, 8th, 9th, & 16th pins. The remaining 4th, 5th, 10th, 12th, & 13th pins are connected to the ground.
After finishing all the circuit connections, place the robot in the dark room. Connect the 9V battery and power the robot. Now, show the light in front of the robot, and it will follow the light wherever it goes.
As like line following robot, this robot can also be developed within a price of $40 US dollars.
Building a simple and easy microcontroller based robot is always a fascinating topic to be discussed, especially for the robotics newbie enthusiast. On this tutorial I will show you how to build your own microcontroller based robot which known as a photovore or you could call it as the light chaser robot using the simplest possible circuit for the microcontroller based robot brain, locomotion motor and the sensor.
One of the most frustrating parts when building your first microcontroller based robot is to program it and to download it into the microcontroller flash ram. On this tutorial this kind of “trouble maker” is being reduced as we will use the PICAXE programming editor from the Revolution Education Ltd (http://www.rev-ed.co.uk/picaxe) as our Integrated Development Environment (IDE) to program our robot brain using the BASIC (Beginners All Purpose Symbolic Instruction Code) language and to download the program into the PICAXE 28X1 microcontroller.
The PICAXE 28X1 microcontrollers actually is based on the popular Microchip 8-bit 28 pins PIC16F886 microcontroller that have a preload PICAXE BASIC interpreter firmware inside, in fact when you buy it its looks the same as the usual Microchip PIC16F886 microcontroller. Together with the free PICAXE Programming Editor and simple serial cable connector for the program downloader makes this PICAXE framework suitable for beginners and even for the professional.

You could read more information about the PICAXE microcontroller on my previous posted blog “Introduction to the Embedded system with PICAXE Microcontroller“.
On this tutorial I will refer this photovore robot as the BRAM-AXE as this is a simplify version of the more advanced version of its big brother BRAM (Beginners Robot Autonomous Mobile) which you could read more information about it on my previous posted blog “Building BRAM your first Autonomous Mobile Robot using Microchip PIC Microcontroller – Part 1” and “Behavior Based Artificial Intelligent Mobile Robot with Sharp GP2D120 Distance Measuring Sensor – BRAM Part 2“.
The BRAM-AXE robot simply use its light sensitive sensor to navigate to the light source, when it being placed in the dark environment it will automatically switch to the light search mode and try to find the light source, when it encounter the light source it will navigate to the light source and when the light source intensity is bright enough it will stop and enjoying the light. You could see all this behavior on the video at the end of this tutorial. Ok now let’s list down all the electronics parts, robot chassis materials and software needed to build this interesting robot.


  • BRAM-AXE board: based on the PICAXE 28X1 microcontrollers together with the PICAXE serial downloader cable which you could easily build from my previous posted blog “Make your own Microcontroller Printed Circuit Board (PCB) using the Toner Transfer Method“.
  • Two LDR and Two 1K Ohm 0.25 watt resistor
  • Two Continues Servo (on this tutorial I use the Parallax Continues Servo)
  • Two toys tire to be attached to the servo’s arms
  • Enough cables and Tubing (1mm and 3mm)
  • 3 x AA battery holder with 3 x AA alkaline battery
  • 1 CD or DVD
  • A good double tape or epoxy glue for the permanent robot
  • One paper clips and neck less beads for the robot caster (the robot’s third wheel)
  • Enough bolts and nuts for the caster
  • PICAXE Programming Editor from Revolution Education Ltd which you could download from their website.

The BRAM-AXE Chassis Assembly
The BRAM-AXE main chassis is made from the CD/DVD which you could find easily at home or just use the blank one as I did if you don’t have any discarding CD/DVD at home. For the wheel you could use any toy’s wheel or you could use anything that has a circle form as long as the diameter is greater or equal to the servo’s arms.
The assembly of BRAM-AXE chassis is straight forward; you just need to drill two holes for placing the caster. Attached the two continues servo on the button of the CD/DVD with the double tapes and attached the wheel to the servo’s arms with the double tape or you could use the epoxy for permanent one. You could see the whole process on these following pictures:

Now attached the 3 x AA battery holder and BRAM-AXE board on top of the CD; again using our flexible friend the double tape as shown on these following pictures.

Connect the power socket to the BRAM-AXE polarized power pin and the servo’s socket to the BRAM-AXE board output 0 and output 1 three pins socket respectively as shown on this following servo’s circuit diagram.

The BRAM-AXE board output pins is design to be attached directly with the servo, every output pins provide both power and ground needed to power the servo. Connect the left servo connector to the BRAM-AXE output 0 and the right servo connector to the BRAM-AXE output 1. After finishing all this steps now it’s the time to test the robot steering mechanism.
The BRAM-AXE Steering Method
The BRAM-AXE steering use the simple method called the “differential drive“; when the two servos rotate on the same direction the robot will move forward or backward, and when they rotate on different direction (counter rotation to each other) the robot will rotate to left or right.
Servo basically is a high quality geared DC motor with electronic circuit for controlling the DC motor rotation direction and position; its being used widely in model hobbyist such as car R/C model for steering and acceleration control or airplane R/C model for moving the rudder, ailerons, elevators and acceleration control. Typically there are two type of servo available on the market the first one is “standard” servo which could rotate between 120 to 180 degree and the second one is “continues” servo which could rotate 360 degree.

By using the continues servo, the locomotion circuit become very simple as we only connect the servo directly to the BRAM-AXE board and supply the correct PWM (Pulse Width Modulation) signal in order to make it rotate. The PICAXE BASIC language has a build in servo commands that we could use to make the servo rotate.
servo output_pin, n
servopos output_pin, n
The servo command will initial the PICAXE 28X1 (Microchip PIC16F886) internal TIMER which is used to generate the PWM signal to the servo and after initialization you have to use the servopos command in order to control the servo. The n is the number between 75 and 255, where this number will determine the servo rotation direction (clock wise or counter clock wise). The output_pin is the PICAXE 28X1 output pin which range from 0 to 7.

Usually the servo is designed to have a wide tolerance on the incoming PWM signal, but if your servo doesn’t work with the above value (125 and 200) try to experiment with other value as long as the value range is between 75 and 255. For more information about controlling the servo you could read my previous posted blog “Basic Servo Motor Controlling with Microchip PIC Microcontroller“.

The BRAM-AXE Sensors
In order to make the complete photovore robot, we need to use the light sensitive sensor; the simple and cheapest one is to use a special made resistor (made from Cadmium Sulfide) called Light Dependent Resistor or LDR for short. The LDR will vary its resistance according to the light intensity fall on its surface; the bright light intensity will make its resistance decrease significantly (about 1K Ohm to 5 K Ohm) while on the completely dark its resistance will increase as high as 100 K Ohm.
By connecting the LDR in series with 1 K Ohm resistor, we could get the simplest possible light sensor circuit that will give us the variable voltage output according to the light intensity as shown on this following picture.
This simple circuit is known as the voltage divider circuit, you could read more information about the voltage divider circuit on my previous posted blog “Basic Resistor Circuit“.
Connect the sensor circuit output directly to the PICAXE 28X1 microcontroller analog to digital conversion (ADC) input port (ADC 0 and ADC 1) and use the power taken from the BRAM-AXE board output pin as shown on these following pictures:
With the PICAXE ADC feature, now we could easily read the numeric representation of the light intensity on each sensor (left LDR and right LDR) using this following PICAXE BASIC commands:
readadc adc_channel, variable
The readadc command will read the ADC input port (0 to 3 on PICAXE 28X1 microcontroller) and assigned the 8-bit data value to the variable. By examining the ADC value we could command our robot to follow the light as shown on this following BRAM-AXE_photovore.bas program:
'***************************************************************************
'  File Name    : bram-axe_photovore.bas
'  Version      : 1.0
'  Description  : BRAM-AXE Photovore
'  Author       : RWB
'  Target       : BRAM-AXE Learning Board - PICAXE 28x1
'  Intepreter   : PICAXE Firmware version A.6
'  IDE          : PICAXE Programming Editor Version 5.2.6
'  Programmer   : PICAXE Programming Editor Version 5.2.6
'  Last Updated : 03 January 2010
'
  BRAM-AXE Bang-Bang steer control
    if ldr_left > ldr_right then
    diffvalue=ldr_left - ldr_right
    if diff_value >= 20 then
      gosub BRAM_RotateRight
    else
     gosub BRAM_MoveForward
    endif
  endif

  if ldr_right > ldr_left then
    diffvalue=ldr_right - ldr_left
    if diff_value >= 20 then
      gosub BRAM_RotateLeft
    else
      gosub BRAM_MoveForward
    endif
  endif

  pause 10       ' Pause 10 seconds  

  goto main      ' Back to main loop
  end
BRAM Steering Subroutines
BRAM_MoveForward:
  if stop_stat = 1 then
    servo 0,125        ' Init Left Servo Forward
    servo 1,200        ' Init Right Servo Backward
    stop_stat=0
  else
    servopos 0,125     ' Left Servo Forward
    servopos 1,200     ' Right Servo Backward
  endif
return
BRAM_MoveBackward:
  if stop_stat = 1 then
    servo 0,200        ' Init Left Servo Backward
    servo 1,125        ' Init Right Servo Forward
    stop_stat=0
  else
    servopos 0,200     ' Left Servo Backward
    servopos 1,125     ' Right Servo Forward
  endif
return
BRAM_RotateRight:
  if stop_stat = 1 then
    servo 0,125        ' Init Left Servo Forward
    servo 1,125        ' Init Right Servo Forward
    stop_stat=0
  else
    servopos 0,125     ' Left Servo Forward
    servopos 1,125     ' Right Servo Forward
  endif
return
BRAM_RotateLeft:
  if stop_stat = 1 then
    servo 0,200        ' Init Left Servo Backward
    servo 1,200        ' Init Right Servo Backward
    stop_stat=0
  else
    servopos 0,200     ' Left Servo Backward
    servopos 1,200     ' Right Servo Backward
  endif
return
BRAM_Stop:
  stop_stat=1
  settimer off
return
' EOF: bram-axe_photovore.bas
The key for this photovore program to work properly is to place the two LDR sensors about 45 degree from the center of the robot chassis as shown on these following pictures:

When the two LDR sensors get an equal light intensity than we command the BRAM-AXE to move forward, when the light intensity is bright enough than we make it stop as shown on this PICAXE BASIC code:
' STOP both LDR greater or equal to 90
if ldr_left >= 90 and ldr_right >= 90 then
  gosub BRAM_Stop
  pause 10
  goto main
endif
When one of the LDR sensors is brighter then the other than we command the BRAM-AXE to rotate right or rotate left:
' BRAM-AXE Bang-Bang steer control
if ldr_left > ldr_right then
    diffvalue=ldr_left - ldr_right
    if diff_value >= 20 then
      gosub BRAM_RotateRight
    else
      gosub BRAM_MoveForward
    endif
endif

if ldr_right > ldr_left then
    diffvalue=ldr_right - ldr_left
    if diff_value >= 20 then
      gosub BRAM_RotateLeft
    else
      gosub BRAM_MoveForward
    endif
endif
When both LDR sensors is quite dark than we command the BRAM-AXE to enter the light search mode, this light search program algorithm will keep the BRAM-AXE to move forward, backward, rotate left and right until it locate the light source.
The BRAM-AXE photovore program algorithm use the simplest steering method control called the bang-bang control or on/off control which is the simplest closed loops control method usually used in the embedded system. For more information about the bang-bang control method you could read my previous posted blog “Basic Servo Motor Controlling with Microchip PIC Microcontroller“.
You could adjust all the bang-bang control numeric values to suite your need, in order to do that you have to know the ADC value before making your adjustment. This could be done by opening the commented PICAXE BASIC serial data transmit and pause command on these following lines:
' For Debugging the ADC Value
sertxd("LDR Left: ",#ldr_left,13,10)
sertxd("LDR Right: ",#ldr_right,13,10)
pause 100
You could display these value directly to the PICAXE Programming Editor build in serial terminal, which you could access from menu PICAXE -> Terminal or you could press the F8 key, re-down load the code again to run this monitor. Do not disconnect the serial programmer cable from the BRAM-AXE board as the PICAXE BASIC sertxd command use this serial connection to transmit the data and make sure you set the baud rate to 4800.

Conclusion
As you’ve learned to build this simple and easy to build photovore robot hopefully this will trigger your passion to learn more about robotics and the embedded system. Learning by experiences is the key to success in learning the embedded system, keep experimenting as this will build your understanding and confidence in developing your own embedded system project.

No comments:

Post a Comment

leave your opinion