A Basic LFR [Line following robot]

Posted: October 7, 2011 in diy, line follower, robot, robot basics, robotics, simple line follower, simple robot
Hai Fellas,

If you are reading this post, I assume that you are interested in robotics and eager to get started. If you think that this is a rubbish, then quit immediately.

You wanna build a line following robot (one of the basic robots to get started in robotics). A line follower follows a line with a contrasting background (like black line on white background). I assume that you posses the basic knowledge in electronics. Okay, let me put forward the parts needed to build your bot. In brief, you need a controller, IR sensors( to sense the line) ,an op-amp (nothing but a simple amplifier), a H-bridge motor driver (to provide high current to drive the motors) and of course, motors and wheels for locomotion.

There are three simple steps to build a line follower.

  1. Build the sensor circuits
  2. Amplify the sensor input and provide it to a pre-programmed controller
  3. Interface the controller with a H-bridge.

Block diagram of a line follower:

 

Here is the bot I built. Try it if you can (tested),

Parts needed:

  1. PIC16F84A (you can use any controller – provided you know how to program it) – 1no
  2. LM358N dual op-amp – 1no
  3. L293D H-bridge motor driver – 1no
  4. 7805 voltage regulator – 1no
  5. 4 or 10 or 20Mhz crystal oscillator for the controller – 1no
  6. 0.01uf ceramic condenser – 1no
  7. Resistors (4k7,1k,1k) – 1no(each)
  8. Preset 100k – 2
  9. LED – 2
  10. IR led (transparent) – 2
  11. IR receiver led (black) – 2
  12. 100 or 150 rpm geared dc motors – 2
  13. Wheels for the above motors – 2
  14. 1.5V AA battery – 8nos
  15. Solder less bread board (If you don’t like soldering)
  16. Any base (I took the package cover of my portable hard disk)

Here I used only two sensor. Being simple, a two sensor line follower cannot take acute turns and misses short turns.

Got the parts ready eh? Okay, let’s get started.

STEP1: Make the IR sensor modules (The eye of the robot). Cut a small piece of circuit board as shown in the figure below to mount the IR sensor module (IR transmitter and receiver pair – the transparent and black bulbs).

Follow the circuit below to make two of those.

STEP2: Now, make the Op-amp circuit (to amplify the signal from the IR sensor) according to the given circuit on the bread board

STEP3: Programming the microcontroller:

Now, this is the challenging part for the beginner. Here is the programmer for PIC16F84A by JDM. Solder the circuit on a blank circuit board and connect it to the serial port of your computer. It works pretty nice and is a really small circuit.. here take a look at it [which I made]

[Warning: Serial port is a must. USB to serial converters will not work.] If you want USB programmer, go and buy a MICROCHIP pickit 2 programmer which programs a wide range of PIC’s via USB.

Now, after building or buying the programmer, load the program into the controller. This is done using software like pony prog or IC prog. Here is the tutorial to how to program the PIC

Here is the ASM program for the basic line follower:

;****************************************
;
; Author    : Anish
; Controller: PIC16F84A
; Code for  : Line follower
;
;****************************************
;————————————————-+
;switch to register bank 1
;and set upper nibble of portB as input
;and lower nibble of portB as output
;————————————————+

bsf status,5
movlw B’11110000′
movwf TRISB
bcf status,5

;———————————————–+
;set RB0 and RB2 (motor forward)
;and continously check if RB5 or RB4
;is set.
;If RB5 is set, call the right flag
;If RB4 is set, call the left flag
;———————————————–+

start movlw B’00000101′
movwf PORTB
btfsc PORTB,5
call right
btfsc PORTB,4
call left
goto start
end

;———————————————–+
;If RB4 is set, set RB0 and RB3
;Break out of the loop if RB4 is reset
;else loop till RB4 is reset
;———————————————–+

left
movlw B’00001001′
movwf PORTB
btfsc PORTB,4
goto left
return

;———————————————–+
;If RB5 is set, set RB1 and RB2
;Break out of the loop if RB5 is reset
;else loop till RB5 is reset
;———————————————–+

right
movlw B’00000110′
movwf PORTB
btfsc PORTB,5
goto right
return

If you are not sure about compiling an ASM code, then here I provide the ready to go hex code. Just copy paste this below code on to a notepad and save it with a .hex extension and that will do. While programming, select this .hex file and program the IC.

:100000008316F0308600831205308600861A102091
:10001000061A0B20042809308600061A0B2808004F
:0A00200006308600861A102808003A
:02400E00F13F80
:00000001FF

STEP4: Finished programming… Now, it’s time to assemble… Wire the PIC as shown in the schematic below on the bread board. You can replace the 7805 with a 5 volt battery. The reason I used the 7805 is, to take 5V necessary for other circuits from the 12V supply of the motor which reduces the extra 5v battery and added weight.

STEP5: Now, also fix and wire the L293D as shown below on the bread board [Motor driver IC is used because, the PIC controller cannot directly deliver the current needed by the motor to run].

Assemble the parts motor with wheels, bread board, the sensors on a base and there you go… Your line follower is ready… Here are some of the pictures of the line follower I made on the solder less bread board

Like some videos?

Watch the sensor in action:

Rules of Thumb:

  1. Never use PP3 battery for powering up the motors.
  2. Use geared dc motors of low RPM – 100rpm motors will do [This is because, when you use a high rpm geared motors or ordinary dc motors, the robot as it attains great speed while traversing a straight line will miss the turn ahead – hope you get it]
  3. Assemble and test the whole thing on a solderless breadboard before soldering it on a general purpose pcb
  4. While soldering the circuit, use IC base for all the IC’s so that they can be – taken out used for other purpose/replaced easily when damaged/protected from overheating during soldering process

Resources:

  1. Some basic electronics
  2. Basics of PIC programming
  3. Digit website

Credits to:

  1. Digit Magazine for getting me started
  2. JDM for that nice and easy programmer
  3. My dad for financing me.

Comment for any queries.. and I’ll keep the robot updated for better versions.

Next update will be the same robot with 3 IR sensors. A better follower

Comments
  1. ijustine says:

    Thanks for that awesome posting. It saved MUCH time 🙂

  2. RITESH says:

    Nice work anish………………….!!u can use other motor for bot b'coz u does not require high torque which will consume power of motors!http://robokits.co.in/shop/index.php?main_page=product_info&cPath=2_3&products_id=247&zenid=ea3264b3432e30fb2fb8781c2d060a47

  3. CraigOctocus says:

    Nice information to my mind. Thank u a lot for sharing this information.

  4. Roy says:

    Im waiting for next update…anyway thanks!

Leave a reply to Roy Cancel reply