PID Line Follower Atmega328P

Written by: admin@makezilla

INTRODUCTION

Hi guys am a 3rd Year University Student of Lovely Professional University, India currently pursuing Electronics and Communication Engineering .

Youtube Channel ::::https://www.youtube.com/channel/UC6ck0xanIUl14OorqW06VZA

Facebook Profile :::: https://www.facebook.com/arnab.das.bwn

GitHub :::: https://github.com/arnabdasbwn

Wordpress :::: https://arnabdasbwn.wordpress.com/

This instructable is about making a efficient and reliable Line Follower withPID (proportional-integral-derivative) Control (Mathematical) running inside its brain (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.

  1. Sensor (Eye to see the line)
  2. Microcontroller (Brain to do some calculations)
  3. Motors (Muscle Power)
  4. Motor Driver
  5. Chassis
  6. Battery (Energy Source)
  7. Wheel
  8. Misc

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

Picture of Sensor ( Eye ) QTR 8RC0J617.1200.jpgheader_pololu_no_padding-2b1f4358369783f94324952f54c855cb.png0J629.650.png

Thanks to Pololu for 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 hasseveral 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

Specifications

  • 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:

  1. Turn on IR LEDs (optional).
  2. Set the I/O line to an output and drive it high.
  3. Allow at least 10 μs for the sensor output to rise.
  4. Make the I/O line an input (high impedance).
  5. Measure the time for the voltage to decay by waiting for the I/O line to go low.
  6. 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.

http://www.instructables.com/files/orig/FAZ/L8ZK/ICE1THOL/FAZL8ZKICE1THOL.pdf

http://www.instructables.com/files/orig/F81/P4U8/ICE1THQX/F81P4U8ICE1THQX.pdf

http://www.instructables.com/files/orig/F5A/UNEX/ICE1THSU/F5AUNEXICE1THSU.pdf

http://www.instructables.com/files/orig/FY9/P0V9/ICE1THV4/FY9P0V9ICE1THV4.pdf

 

Step 2: Microcontroller (Brain) Atmega328P

Picture of Microcontroller (Brain) Atmega328Prender2.jpg

Thanks to Atmel Corporation For Manufacturing this Awesome Microcontroller AKA Atmega328 .

Key parameters for ATmega328P

Parameter Value

  • 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

  1. Cheap
  2. Has enough RAM For computation
  3. Sufficient I/O Pins for This Project
  4. 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...

http://www.instructables.com/files/orig/FCB/MLWD/ICG28SNK/FCBMLWDICG28SNK.exe

http://www.instructables.com/files/orig/FHU/YH4W/ICG2AL3Y/FHUYH4WICG2AL3Y.brd

http://www.instructables.com/files/orig/F6X/08ZM/ICG2AL7S/F6X08ZMICG2AL7S.sch

Step 3: Motor And Motor Driver

Picture of Motor And Motor Driverm4.jpgeagleUp_motor driver_board_top.jpg

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.

http://www.instructables.com/files/orig/F8O/ICCN/ICG2AJKW/F8OICCNICG2AJKW.brd

http://www.instructables.com/files/orig/FUC/BMOJ/ICG2AJLN/FUCBMOJICG2AJLN.sch

Step 4: Chassis and Misc

Picture of Chassis and MiscDSC04955.jpgDSC04957.jpg

The Bot is made UP of Ply Wood Of 6mm Thickness.

Leave a Reply