Experiment On Mobile Robot Hardware Involving Sensors (Line Follower Using Firebird V At-Mega 328P)
Experiment On Mobile Robot Hardware Involving Sensors (Line Follower Using Firebird V At-Mega 328P)
AIM:
Conduct Experiment to follow the line using Firebird V Atmega328P Robot.
1. Firebird V Atmega328P
2. Arduino IDE
3. AVR Bootloader
PROCEDURE:
Open Arduino IDE.
Write the line follower program in embedded C language.
Once, the coding has been finished, in Tools > Select board > Arduino 328P.
Verify the code and find if any error is present.
If not the temp file is created in the temp folder.
To navigate to Temp folder, Hold Windows+R > type in %TEMP% > click enter.
You will be navigated to the temp folder.
Inside the temp folder a .hex file with the program name would be created, copy that
file, and paste it in desktop.
Open AVR bootloader.
Select the port the Firebird V is connected to the system.
Select the microcontroller to 328P and fix the baud rate to 115200.
After the initial setup, click on three dots present in AVR bootloader and navigate to
the place you have stored the file.
Select the file and click on program and wait till the code has been fully uploaded..
THEORY:
FIRE BIRD V will help us get acquainted with the world of robotics and embedded
systems. Thanks to its innovative architecture and adoption of the ‘Open-Source Philosophy’
in its software and hardware design, us will be able to create and contribute too, complex
applications that run on this platform, helping us acquire expertise as us spend more time with
them. Fire Bird V is designed by NEX Robotics and Embedded Real Time Systems lab, CSE
IIT Bombay. As a Robotic Research Platform, the Fire Bird V provides an excellent
environment for experimentation, algorithm development and testing. Its modular architecture
allows us to control it using multiple processors such as 8051, AVR and ARM7 etc. Modular
sensor pods can be mounted on the platform as dictated by intended applications. Precision
position encoders makes it possible to have accurate position control. Platform can be
upgraded to tank drive, Hexapod, or any other desired form very easily. It is powered by high
performance rechargeable NiMH batteries. A 2.4GHz ZigBee module provide secure and
multi-channel wireless communication up to a range of one kilometer line of sight.
Microcontroller:
Atmel ATMEGA2560 as Master microcontroller
Atmel ATMEGA8 as Slave microcontroller.
Sensors:
Three white line sensors (extendable to 7)
Five Sharp GP2D12 IR range sensor (80cm) (One in default configuration.
(Also supports GP2D120 (30cm) and GP2Y0A02 (150cm)Eight analog IR
proximity sensors (20cm)
Eight analog directional light intensity sensors
Two position encoders (extendable to four)
Battery voltage sensing
Current Sensing (Optional)
Servo mounted sensor pod (optional)
Wireless colour camera (optional)
Ultrasound scanner (optional)
Gyroscope and Accelerometer (optional)
Magnetometer (optional)
GPS receiver (optional)
Indicators:
2 x 16 Characters LCD
Indicator LEDs
Buzzer
Control
Autonomous Control
PC as “Master” and Robot as “Slave” in wired or wireless mode
Distributed (multi robot) communication.
Communication
Wireless ZigBee Communication (2.4GHZ) (Optional)
USB Communication
Wired RS232 (serial) communication
APPLICATIONS:
Learning Embedded systems and robotics
Mapping and autonomous navigation
Mobile sensor network
Real-Time systems Collaborative robotics
Swarm robotics and other behaviours
Control system
SCHEMATIC DIAGRAMS:
PROGRAM:
#include <avr/interrupt.h>
#include <util/delay.h>
#include <math.h>
#include "lcd.c"
void port_init();
void timer5_init();
void velocity(unsigned char, unsigned char);
void motors_delay();
unsigned char ADC_Conversion(unsigned char);
unsigned char ADC_Value;unsigned char flag= 0;
unsigned char Left_white_line= 0;
unsigned char Center_white_line= 0;
unsigned char Right_white_line= 0;
void lcd_port_config (void) {
DDRC= DDRC | 0xF7;
PORTC= PORTC& 0x80;
}
void adc_pin_config (void) {
DDRF= 0x00;
PORTF= 0x00;
DDRK= 0x00;
PORTK= 0x00;
}
void motion_pin_config (void) {
Academic Year: 2024 – 2025 (Even Semester) Roll No: 71812210012
20RA277Autonomous Mobile Robots Laboratory/Exp. No: Name: Gowriraj PK
5
DDRA= DDRA | 0x0F;
PORTA= PORTA& 0xF0;
}
void adc_init() {
ADCSRA= 0x00;
ADCSRB= 0x00;
ADMUX= 0x20;
ACSR= 0x80;
ADCSRA= 0x86;
}
unsigned char ADC_Conversion(unsigned char Ch) {
unsigned char a;
if(Ch>7) {
ADCSRB= 0x08;
}
Ch= Ch& 0x07;
ADMUX= 0x20| Ch;
ADCSRA= ADCSRA | 0x40;
while((ADCSRA&0x10)==0);
a=ADCH;
ADCSRA= ADCSRA|0x10;
ADCSRB= 0x00;
return a; }
void print_sensor(char row, char coloumn,unsigned charchannel) {
ADC_Value= ADC_Conversion(channel);
lcd_print(row, coloumn, ADC_Value, 3); }
void velocity (unsigned char left_motor, unsigned charright_motor) {
OCR5AL= (unsigned char)left_motor;
OCR5BL= (unsigned char)right_motor;
}
void motion_set (unsigned char Direction) {
Academic Year: 2024 – 2025 (Even Semester) Roll No: 71812210012
20RA277Autonomous Mobile Robots Laboratory/Exp. No: Name: Gowriraj PK
5
unsigned char PortARestore= 0;
Direction &= 0x0F;
PortARestore= PORTA;
PortARestore &= 0xF0;
PortARestore |= Direction;
PORTA= PortARestore;
}
void forward (void)
{motion_set (0x06);}
void stop (void) {
motion_set (0x00); }
void init_devices (void) {
cli();
port_init();
adc_init();
timer5_init();
sei();
}
int main()
{
init_devices();
lcd_set_4bit();
lcd_init();
while(1)
{
Left_white_line = ADC_Conversion(3);
Center_white_line = ADC_Conversion(2);
Right_white_line = ADC_Conversion(1);
flag=0;
print_sensor(1,1,3);
print_sensor(1,5,2);
print_sensor(1,9,1);
if(Center_white_line<0x28)
{
flag=1;
forward();
velocity(150,150);
}
if((Left_white_line>0x28) &&(flag==0))
{
flag=1;
forward();
velocity(130,50);
}
if((Right_white_line>0x28) && (flag==0))
{
flag=1;
forward();
velocity(50,130);
}
if(Center_white_line>0x28&& Left_white_line>0x28&&Right_white_line>0x28)
{
forward();
velocity(0,0); }}}
Academic Year: 2024 – 2025 (Even Semester) Roll No: 71812210012
20RA277Autonomous Mobile Robots Laboratory/Exp. No: Name: Gowriraj PK
5
Viva Questions:
Inferences/Observations:
Gained an understanding of how IR sensors detect the contrast between a line and its
background, enabling autonomous navigation.
Learned the importance of sensor calibration to ensure accurate detection, as improper
calibration can lead to tracking errors.
Understood the role of the motor driver (L293D) in controlling the movement of DC
motors based on microcontroller signals.
Observed that surface quality (e.g., brightness, reflectivity, and texture) significantly
affects sensor readings and robot performance.
Realized that speed control using PWM is crucial, as excessive speed may cause
overshooting, while slow speeds improve precision but reduce efficiency.
Noted the challenges in handling sharp turns and intersections, which can be improved
using advanced algorithms like PID control.
Gained insights into how battery voltage fluctuations impact motor speed and sensor
sensitivity, affecting the robot’s reliability.
RESULT:
Thus, the code has been successfully verified and the Line following using Firebird V mobile robot
is done.
Academic Year: 2024 – 2025 (Even Semester) Roll No: 71812210012
20RA277Autonomous Mobile Robots Laboratory/Exp. No: Name: Gowriraj PK
5