View
212
Download
0
Category
Preview:
Citation preview
Workshop on Line Follower Robo-car
Organized By: Telecom Club
Presented By
Mohammed Abdul Kader
Assistant Professor, Dept. of EEE, IIUC
Email:kader05cuet@gmail.com Website: kader05cuet.wordpress.com
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2
Line Follower Robo-Car
Line follower robo-car is a simple example of automated system with feedback.
Line follower robot is a robo car that can follow a path. The path can be visible like a black
line on the white surface (or vice-verse). It is an integrated design from the
knowledge of Mechanical, Electrical and Computer engineering.
Required Components
DC Motor
IR Sensor
Chassis Microcontroller
Motor Driver
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 3
Timer/ Counter
I/O Port
What is Microcontroller?
Micro-computer in a single chip.
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 4
Name of Some Microcontroller Manufacturer
ATMEL (AVR microcontroller)
Microchip (PIC microcontroller)
Texas Instruments (TI)
Freescale
Philips
Motorola ARDUINO
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 5
Crystal Oscillator Program Loader Microcontroller Linear Voltage Regulator
Advantages of Arduino: Reduces hardware complexity
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 6
Advantages of Arduino: Programming Easy
• Programming in C
• Lot of functions in the library.
• No need to learn internal
architecture of microcontroller.
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 7
Arduino UNO Digital I/O Pins
Vcc and GND Pins
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 8
Digital I/O Pins
Most of the important pins of microcontroller are digital input-output pins.
These pins are used to connect INPUT Device (i.e. Push Button, keypad, digital sensors
etc) and OUTPUT Device (i.e. LED, Display, Relay, Motor etc.) with microcontroller.
These pins can act as INPUT or
OUTPUT.
Digital Output pin means microcontroller
can make this pin HIGH or LOW state
(Write Operation).
Digital Input pin means microcontroller
can read HIGH or LOW state from other
devices (Read Operation).
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 9
Configuring Digital I/O Pins
digitalWrite(pin number, HIGH/LOW)
digitalWrite(13,HIGH)
digitalWrite(13,LOW)
pinMode(pin Number, OUTPUT)
An LED is connected with pin 13.
The pin should be an OUTPUT pin.
We can configure a pin as OUTPUT by
“pinMode” function.
pinMode(13, OUTPUT)
Configuring as OUTPUT
Making a Pin HIGH or LOW
Microcontroller can make a digital pin HIGH or LOW by
digitalWrite function.
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 10
Program Structure in ARDUINO
Verify Program
Load Program
Processor run the instructions
written here only once after
loading program or reset .
Serial monitor
Processor run the instructions written here
repeatedly after loading program or reset .
i.e. void loop() function creates an infinite
loop.
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 11
void setup()
{
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(300);
}
LED Blinking
Note: To insert a time delay in the program use following function-
delay(time_in_ms);
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 12
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 13
When IR falls in IR
photo diode
When IR doesn’t fall in
IR photo diode
How IR sensor works
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 14
Sensing Line (Distinguishing Between Black and White Colors)
OUTPUT is LOW
when sensor gets
white surface
OUTPUT is HIGH
when sensor gets
Black surface
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 15
Sensor Module
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 16
Reading IR Sensor
Boolean a;
void setup()
{
pinMode(7,INPUT);
}
void loop()
{
a=digitalRead(7);
}
Moving a Robocar
Workshop on "Line Follower Robocar", By-Mohammaed Abdul
Kader,Assistant Prof, EEE, IIUC
17
Direction control of DC Motor
+
-
+
-
HIGH
LOW
2.7 to 5V
0 to 0.5V
40 mA
P=VI = 5 X 40 mA = 200 mW= 0.2 W
Not enough power to drive a DC motor.
The DC motor used in our project
needs voltage of 6 to 12 V and 300-
1000 mA current. Minimum of
(6X300) =1800 mW or, 1.8 W power
So, OUTPUT pins of microcontroller can not
drive the DC motor required in our project.
How can we control the direction of DC motor
by microcontroller? Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC
18
H-Bridge Motor driver
HIGH
LOW
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE,
IIUC 19
HIGH
LOW
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof,
EEE, IIUC 20
H-Bridge Motor driver
LOW
HIGH
ON
ON
OFF
OFF
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 21
H-Bridge Motor driver
HIGH
LOW
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 22
H-Bridge Motor driver
Motor Driver IC (L298N)
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 23
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 24
Speed Control of DC Motor
In ARDUINO,
duty cycle of PWM is set by the function
analogWrite(pin_no, duty_cycle)
Where, duty_cycle = 0 to 255 (0 to 100%)
L298 Motor Driver Module
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 25
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 26
Tracking Algorithm (Principle of line tracking):
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 27
Start
Left_Sensor==HIGH and
right_sensor==HIGH
Read left_sensor
and right_sensor
Rotate both
motor in
forward
YES
A
Left_Sensor==LOW and
right_sensor==HIGH
Stop left motor
and rotate right
motor in forward
A
YES
NO
Left_Sensor==HIGH and
right_sensor==LOW
Stop right motor
and rotate left
motor in forward
A
YES
NO
Stop both motors
NO
A
END
Flow-Chart
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 28
Circuit Diagram
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 29
Program
int rightsensor=6;
int leftsensor=7;
int rightmotorP=12;
int rightmotorN=11;
int leftmotorP=10;
int leftmotorN=9;
void setup() {
pinMode(rightsensor,INPUT);
pinMode(leftsensor,INPUT);
pinMode(rightmotorP,OUTPUT);
pinMode(rightmotorN,OUTPUT);
pinMode(leftmotorP,OUTPUT);
pinMode(leftmotorN,OUTPUT);
analogWrite(5, 100);
analogWrite(3,100);
}
void loop() {
boolean rs=digitalRead(rightsensor);
boolean ls=digitalRead(leftsensor);
if(rs==HIGH && ls==HIGH)
{
digitalWrite(rightmotorP,HIGH);
digitalWrite(rightmotorN,LOW);
digitalWrite(leftmotorP, HIGH);
digitalWrite(leftmotorN, LOW);
}
else if(rs==HIGH && ls==LOW)
{
digitalWrite(rightmotorP,LOW);
digitalWrite(rightmotorN,LOW);
digitalWrite(leftmotorP, HIGH);
digitalWrite(leftmotorN, LOW);
}
else if(rs==LOW && ls==HIGH)
{
digitalWrite(rightmotorP,HIGH);
digitalWrite(rightmotorN,LOW);
digitalWrite(leftmotorP, LOW);
digitalWrite(leftmotorN, LOW);
}
Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 30
else
{
digitalWrite(rightmotorP,LOW);
digitalWrite(rightmotorN,LOW);
digitalWrite(leftmotorP, LOW);
digitalWrite(leftmotorN, LOW);
delay(50);
digitalWrite(rightmotorP,LOW);
digitalWrite(rightmotorN,HIGH);
digitalWrite(leftmotorN, HIGH);
digitalWrite(leftmotorP, LOW);
delay(50);
}
}
Recommended