IR Based Line Following Robot From Scratch [No Microcontroller]

by Neutrino-1 in Circuits > Electronics

4136 Views, 31 Favorites, 0 Comments

IR Based Line Following Robot From Scratch [No Microcontroller]

Line following bot without Programming [No Microcontroller] | Weekend Project
line following bot gif.gif
vlcsnap-2021-05-31-06h59m42s370.png
vlcsnap-2021-05-31-06h59m58s220.png

In this instructable we'll use the concept, reflection of infrared radiation to built a circuit which can detect the difference between black and white coloured surface. That might not sound interesting but later we can use that circuit to build a robot which will follow a black line, and the best part is, the whole build is purely based on electronics and no programming or coding is required! If you are getting started with electronics or getting a concept of science into a project this would be a great place to start. So, grab the components mentioned below and get started with the instructable.

Supplies

These are the list of products which can help you do this project with ease

(Affiliate Link)

Infrared Radiation

vlcsnap-2021-05-31-07h48m45s075.png
vlcsnap-2021-05-31-07h28m05s983.png
vlcsnap-2021-05-31-07h28m12s778.png
vlcsnap-2021-05-31-07h47m20s816.png

Light is a complicated topic in physics because of it's dual nature where it act as both particle and wave at the same time. To understand how this project works will just stick on to our pal Maxwell and consider light as electromagnetic waves! These waves consists of several wavelength starting from from the shortest wavelength Gamma waves to the longest wavelength Radio Waves . The most common electromagnetic waves that everybody experience in day to day life is from 380nm to 740nm A.K.A “the visible region” or "the visible light".

Similarly, Infrared Radiation is part of the electromagnetic spectrum with the wavelength of 700nm to 1mm. infrared radiation has slightly longer wavelength than the visible light therefore this radiation is invisible to human eye but can be caught on most of the camera.

[Note : Infrared radiation also obeys all the laws of reflection and the laws of refraction just like the visible light]

Source of IR Radiation

4923566097_8fb8bcc415_b.jpg
vlcsnap-2021-05-31-08h09m56s295.png
vlcsnap-2021-05-31-08h10m27s573.jpg

Sun is major source of electromagnetic radiation but most physical body emit some sort of radiation based on there property like nuclear radiation by nuclear substances (Gamma waves), heat produced by human body (infrared radiation), etc. Infrared radiation is produced by all the physical object which have temperature more than absolute zero or -273k(approx.). But the magnitude of infrared radiation produced is very small so, the IR detector which we use in this project cannot capture them. Therefore we will have to use an IR emitting LED which emit infrared radiation with greater intensity. There are two types IR LED narrow band and a wide band. In this instructable we'll use a narrow band IR emitting LED and in later steps we'll see the reason, why we chose this.

Formation of Colour

vlcsnap-2021-05-31-08h09m12s930.png

Between 380nm to 740nm we have visible light, this visible light is further divided into different colours based on the wavelength [eg : Green - 590nm to 635nm]. When all these colours is removed form the spectrum it becomes dark/black because our eyes don't receive any input and combining all the colours in the spectrum we perceive the colour white. By now the concept of colour makes sense in electromagnetic waves but the interesting question to ask is... what makes the physical object like plant Green? and apple Red?

Every object absorb and transmit light in some or the other way. When the light strikes the surface of the object, different wavelength of light get absorbed depending on the molecular composition of the physical object. So whatever colour we see is just the reflected wavelength of the light which is not absorbed by the object. In the same context we see the colour white because of reflection of the all the wavelength of light that wasn't absorbed by the body and finally black is due to absorption of all the wavelength of the light (Even though we don't see Infrared radiation the concept of absorption and reflection remains exactly the same).

[Note : Whatever we talked so far will only be 100% true in a perfect world! In reality some wavelength is always absorbed and reflected]

Designing the Circuit

11 (2).png
[DIY] proximity sensor Arduino compatible | Op-Amp Project

We need a circuit which can give a high signal when it's on black line and low signal when it's on white surface. For this we need to read the intensity of IR reflection on the surface caused by IR LED. To read the intensity of light we need to use a IR receiver.

Since we are going to use the reflection of IR light, the IR captured by the receiver will be very small and wouldn’t be useful to use in our circuit because of it's analog nature so, we'll build a amplifier and voltage comparator using IC 358 (OPAMP) and finally to show the output we'll use a RED LED.

Working With IR Receiver

vlcsnap-2021-05-31-10h20m24s069 (2).png
vlcsnap-2021-05-31-10h20m38s207 (2).png
vlcsnap-2021-06-01-11h47m41s226 (2).png
vlcsnap-2021-06-01-11h47m23s472.png

The IR receiver looks similar to a LED which is tinted black. This has to be connected in opposite direction to the polarity or in technical term the receiver diode has to be reverse biased. In reverse biased condition receiver act as a water valve, depending on the intensity of IR light falls on the receiver the current flow through the receiver proportionally, just like the valve let the water flow as you open the valve (If no IR light is captured by the IR receiver there will be no current flowing).

We'll build a voltage divider using the receiver diode and a 10k resistor. This will help us get the voltage value and this voltage value is affected by the amount of infrared light that falls on it so, we can give this as an input to the comparator to decided the output. (If the IR reflection is more then the voltage across the receiver diode reduce (white surface) and when the IR reflection is less then the voltage across the receiver diode increases (black surface))

OP-AMP As Comparator

vlcsnap-2021-06-01-11h44m11s781 (2).png
vlcsnap-2021-06-01-12h09m02s917.png
vlcsnap-2021-06-01-12h03m06s169 (2).png
vlcsnap-2021-06-01-12h03m17s113.png
vlcsnap-2021-06-01-12h03m26s460.png

Op-amp comparator is a comparator circuit which takes 2 voltage level as input and outputs HIGH(VCC) or LOW(GND). If the input to inverting terminal of the op-amp is greater than non-inverting terminal, then the output is LOW and when the non-inverting terminal input is greater than the inverting terminal then the output is HIGH.

We can built the comparator by placing 2 potentiometer at the inverting, non inverting terminal input and a LED at the output of the op-amp. Now when you power the circuit and adjust the potentiometer the input the op-amp will be varied when input to inverting terminal of the op-amp is greater than non-inverting terminal, then the output is LOW and the LED doesn't glow. When the non-inverting terminal input is greater than the inverting terminal then the output is HIGH and the LED glows.

[Link for more detailed/technical guide on op-amp as comparator]

Building the Sensor

Schematic_LineFollowing bot_2021-06-02 (2).png
vlcsnap-2021-06-01-12h03m48s358.png
vlcsnap-2021-06-01-12h21m15s453 (2).png
vlcsnap-2021-06-01-12h21m28s035 (2).png
vlcsnap-2021-06-01-12h22m04s879.png
vlcsnap-2021-06-01-12h21m57s130.png

we’ll just replace one potentiometer with the receiver diode positive terminal to inverting terminal of the op-amp and connect a led with 220 ohm’s resistor to see output. So, the working is very simple, there will be decrease in voltage across receiver when IR light strike the receiver and this decrease will be compared by op-amp with the voltage set by the potentiometer and triggers the output.

As we know the circuit works! it’s time to build the circuit in a perf board. I just placed the components in the board as exactly as the circuit diagram and soldered them together.

[Hint : Make sure that the IR transmitter and receiver are placed as closely as possible for better sensing]

Voila! we have successfully completed the IR proximity sensor. if you don't want to build this, you can also buy exactly the same circuit from an online store.

Working of the Bot

vlcsnap-2021-06-01-14h20m45s141 (2).png
10.png
11 (2).png
12.png

Before moving with the bot replicate the sensor on both side of the PCB.

You might ask why the stroke with of the line is so large where it's technically just a rectangle and not a line anymore, that because the line should be able to completely absorb the IR light emitted by the IR transmitter LED so we can detect we are on the black surface.

When the line is between 2 sensors the bot runs both the motor and makes the bot move forward, but when any one of the sensor detects the black surface, the motor adjacent to the sensor is stopped and the other one continues to move forward. This motion gives turn to the bot and by doing this back and forth on both the motors the bot aligns itself on the line.

How Does L293D Works?

l293d pinout.PNG
vlcsnap-2021-06-01-14h31m03s557.png
CC.png
ACC.png
STOP.png

We can't just connect the motors directly to sensors, just like we did with the output LED because the motors requires large current compared to an LED. So if we connect the motor to the sensor, it will destroy the circuit.

Therefore we need a motor driver, In this case I'm using a IC called L293D[datasheet].

With this IC we can control 2 motors (clockwise and anticlockwise direction) using just 4 pins.

  • Pin 2 and Pin 7 to control one motor which is connected to pin 3 and pin 6.
  • Pin 15 and Pin 10 to control the other motor which is connected to pin 11 and pin 14

When the input is '1'(HIGH) to pin 2 and '0'(LOW) to pin 7 the motor turns clockwise and when the input is '0'(LOW) to pin 2 and '1'(HIGH) to pin7 the motor turns in anticlockwise direction. But if the input to both the pins are same either 1(HIGH) 1(HIGH) or 0(LOW) 0(LOW) the motor stops spinning. This same logic is applicable for the other motor connected on the pin 14 and pin 11.

Building the Line Following Robot Circuit

Schematic_LineFollowing bot_2021-06-02.png
vlcsnap-2021-06-01-14h38m13s148.png
vlcsnap-2021-06-01-14h38m35s542.png
vlcsnap-2021-06-01-14h38m20s186.png
vlcsnap-2021-06-01-14h39m17s776.png
vlcsnap-2021-06-01-14h39m01s256.png

We can get the final circuit by just combining both circuit from step 7 and step 9. Where one sensor output is attached to one pin of the L293D input (for 1st motor input) and the other sensor output is also connected to L293D input (for 2nd motor input).

To finalize the circuit I used a perfboard to solder all the components of the motor driver and I used the header pins to create a connection between the sensor board and the motor driver board. Also I have drilled few holes on the PCB where I can use them for assembly.

Need to Develop This Project Into a PCB?

PCB-Cupid-logo-Design_Black_070123.png

Getting a electronics project into production would be nightmare. To ease you into the production world we have developed a platform (PCB CUPID) for PCB enthusiasts and hobbyists to ask and answer questions related to PCB design, fabrication, and assembly.

In addition to the Q&A feature, this website also has a wealth of blog posts and useful resources to help you learn about developing and manufacturing printed circuit boards. Whether you're a beginner looking for a crash course on PCB basics, or an experienced designer looking for tips and tricks, you'll find something of value on the site

So head on over and check it out, and don't forget to participate in the Q&A community to get help and share your own knowledge. Thanks!

Final Assembly

vlcsnap-2021-06-01-14h39m30s175.png
vlcsnap-2021-06-01-14h40m07s027.png
vlcsnap-2021-06-01-14h40m18s651.png
vlcsnap-2021-06-01-14h40m37s971.png
vlcsnap-2021-06-01-14h41m02s371.png

You can build a custom chassis to hold the motors and the circuit by 3d printing or by laser cutter, but to keep things simple I have used the PCB as part of the chassis for the bot and to have a better support I sandwich the motor between the PCB that we build and a copper clad of same dimension. To keep them attached I used some fasteners(bolts and nuts) and some hot glue. Once the body was done, I used a caster wheel as the support wheel for the bot. That's it, this concludes the assembly for the bot.

Power Supply

vlcsnap-2021-06-01-14h41m02s371.png
vlcsnap-2021-06-01-14h41m17s472.png
vlcsnap-2021-06-01-14h44m34s595 (2).png
vlcsnap-2021-06-01-14h45m33s677.png

You can just use a 9v battery for the power source as both IC 358 and IC L293D tolerant to that voltage.

But the issue with this method is the 9v battery exhaust very soon. So, I used a single 18650 Lithium Ion battery along with a boost convertor (convert 3.7v to 5v) to run this bot. Along with this you can use tp4056 to charge the battery or instead you can use the Lipo charger mentioned in the supplies to charge the battery externally.

Sponsor : Seeed Studio Fusion PCB

Seeed Studio Fusion PCB - Service takes care of the entire fabrication process from PCB manufacturing, parts sourcing, assembly and testing services, so you can be sure that they are getting a quality product. After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.


Final Thoughts!

vlcsnap-2021-06-01-14h45m33s677.png
line following bot gif.gif
[DIY] proximity sensor Arduino compatible | Op-Amp Project
Line following bot without Programming [No Microcontroller] | Weekend Project

This project does comes with few limitation of there own

  • They don't work well with 90 degree turns
  • The bot just stops if it find a 'T' junction because it triggers both sensor which stops both the motor
  • The bot hard stop the motors to align itself on the line, which create a jerk motion rather a smooth transition

Advantages of this bot

  • No programming is required
  • Cost of the overall build is relatively less
  • Very basic knowledge of electronics is required

Let me know what you think about this Instructable, if you would like to read more check out my profile or you can checkout my YouTube channel.