Introduction: PID Line Follower Atmega328P
Line follower is an autonomous robot which follows either black line in white are or white line in black area. Robot must be able to detect particular line and keep following it.
So there will be few parts/steps to make a LINE FOLLOWER I will be discussing all of them step by step.
- Sensor (Eye to see the line)
- Microcontroller (Brain to do some calculations)
- Motors (Muscle Power)
- Motor Driver
- Battery (Energy Source)
Here is the VIDEO OF THE LINE FOLLOWER
IN THE NEXT STEPS I WILL BE DISCUSSING IN DETAILS ABOUT EVERY COMPONENTS
Step 1: Sensor ( Eye ) QTR 8RC
Thanks toPololufor manufacturing this awesome sensor.
The module is a convenient carrier for eight IR emitter and receiver (phototransistor) pairs evenly spaced at intervals of 0.375" (9.525 mm). To use a sensor, you must first charge the output node (Charging the capacitor) by applying a voltage to its OUT pin. You can then read the reflectance by withdrawing the externally supplied voltage and timing how long it takes the output voltage to decay due to the integrated phototransistor. Shorter decay time is an indication of greater reflection. This measurement approach has several advantages, especially when coupled with the ability of the QTR-8RC module to turn off LED power:
- No analog-to-digital converter (ADC) is required.
- Improved sensitivity over voltage-divider analog output.
- Parallel reading of multiple sensors is possible with most microcontrollers.
- Parallel reading allows optimized use of LED power enable option
- Dimensions: 2.95" x 0.5" x 0.125" (without header pins installed)
- Operating voltage: 3.3-5.0 V
- Supply current: 100 mA
- Output format: 8 digital I/O-compatible signals that can be read as a timed high pulse
- Optimal sensing distance: 0.125" (3 mm)Maximum recommended sensing distance: 0.375" (9.5 mm)
- Weight without header pins: 0.11 oz (3.09 g)
Interfacing the QTR-8RC Outputs to Digital I/O Lines
The QTR-8RC module has eight identical sensor outputs that, like the Parallax QTI, require a digital I/O line capable of driving the output line high and then measuring the time for the output voltage to decay. The typical sequence for reading a sensor is:
- Turn on IR LEDs (optional).
- Set the I/O line to an output and drive it high.
- Allow at least 10 μs for the sensor output to rise.
- Make the I/O line an input (high impedance).
- Measure the time for the voltage to decay by waiting for the I/O line to go low.
- Turn off IR LEDs (optional).
These steps can typically be executed in parallel on multiple I/O lines.
With a strong reflectance, the decay time can be as low as several dozen microseconds; with no reflectance, the decay time can be up to a few milliseconds. The exact time of the decay depends on your microcontroller’s I/O line characteristics. Meaningful results can be available within 1 ms in typical cases (i.e. when not trying to measure subtle differences in low-reflectance scenarios), allowing up to 1 kHz sampling of all 8 sensors. If lower-frequency sampling is sufficient, substantial power savings can be realized by turning off the LEDs. For example, if a 100 Hz sampling rate is acceptable, the LEDs can be off 90% of the time, lowering average current consumption from 100 mA to 10 mA.
Step 2: Microcontroller (Brain) Atmega328P
Key parameters for ATmega328P
- Flash (Kbytes): 32 Kbytes
- Pin Count: 32
- Max. Operating Freq. (MHz): 20 MHz
- CPU: 8-bit AVR
- Max I/O Pins: 23
- Ext Interrupts: 24
- SPI: 2
- TWI (I2C): 1
- UART: 1
- ADC channels: 8
- ADC Resolution (bits): 10
- SRAM (Kbytes): 2
- EEPROM (Bytes): 1024
- I/O Supply Class: 1.8 to 5.5
- Operating Voltage (Vcc):1.8 to 5.5
- Timers: 3
For Detailed Information go through the Datasheet of Atmega328P.
In this project I am using Atmega328P for Few Reason
- Has enough RAM For computation
- Sufficient I/O Pins for This Project
- Atmega328P is used In Arduino .... U may notice in the Picture and Video an Arduino Uno but nighter i am using Arduino IDE or Any Arduino .. I have Used Only the hardware as an interfacing board. I have erased the bootloader and used USB ASP for Programming the chip.
For Programming The Chip i have used Atmel Studio 6
All THE SOURCE CODE IS IN GitHub Download It and Check test.c file.
To Compile this package you have to download and install The POLOLU AVR LIBRARY SETUP Check The Attachments ...
I am also UPLOADING a Atmega328P Development Board Schematic and Board File ... You Can Manufacture It by Yourself...
Step 3: Motor and Motor Driver
I have Used 350RPM 12V BO Type Geared DC motor as actuator. To know more info... MOTOR LINK
As a motor driver i have used L293D H- bridge IC.
I am attaching the Schematic and Board File for the same.
Step 4: Chassis and Misc
The Bot is made UP of Ply Wood Of 6mm Thickness.