PID Line Follower Atmega328P

DSC04945

DSC04957


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

Instructables::::  http://www.instructables.com/member/Arnab+Das

This instructable is about making a efficient and reliable Line Follower with PID(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


header_pololu_no_padding-2b1f4358369783f94324952f54c855cb.png
0J629.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 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

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.

 


Step 2: Microcontroller (Brain) Atmega328P


Picture of Microcontroller (Brain) Atmega328P
render2.jpg
                WP_20150228_03_15_15_Pro WP_20150228_03_15_24_Pro

 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…


Step 3: Motor And Motor Driver


Picture of Motor And Motor Driver
                                                                            m4.jpg
eagleUp_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.


Step 4: Chassis and Misc


Picture of Chassis and Misc
DSC04955.jpg
DSC04957.jpg

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

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s