Professional Documents
Culture Documents
AUTONOMOUS ROBOT
INTRODUCTION
The purpose of the project is to design a path tracing system for
a robot which is not under human control. The robot is designed
to move around at its own will. The movements of the robot
might depend on various factors which include information from
the sensors, some task specified by the user by programming the
microcontroller which specifies the movements based on the
task to be accomplished.
The path tracing system will track the movements of the robot
and makes a map from the starting point to the stopping point of
the robot. The path tracing system will help in supervising the
movements of the robot and, if required, in controlling the robot
to reach the destination. However, to trace the path to scale and
with accuracy, a lot of measuring devices need to be interfaced
with the microcontroller. Some of these devices are speedometer
(which will help in determining the speed of the robot), a device
to measure the r.p.m. of the motors and a device to measure the
angle of steering. Interfacing these devices with the
microcontroller will enhance the accuracy of the path tracing
system as more information is available regarding the
movements.
APPLICATONS
Any process requiring a great deal of accuracy requires human
supervision. Hence, even if we design an autonomous system,
which is reliable as well as accurate, the essence of human
supervision cannot be ignored. The path tracing system helps us
to keep a track of the movements of the robot to make sure that
the robot is moving in the right direction to enable the robot to
reach the desired destination. The programs can be modified as
per need, if one wishes to control the robot to ensure that the
robot reaches the destination if it strays from the desired path.
Many other devices can be interfaced with the microcontroller,
in case, one wants to make the robot multi-tasking. These
devices can also be controlled by using the required programs.
However, in this project, we limit the application to tracing the
path followed by robot which is free to move randomly without
any human control.
HARDWARE COMPONENTS
1. Robot (using D.C. motors)
2. Two ATMega32 Microcontrollers
3. Wireless Transmitter Section
4. Wireless Receiver Section
5. DB9 Connector
6. RS-232 Cable
HARDWARE DETAILS
1. Robot: The robot used for the project has two D.C. motors driven
using L293D (motor driver IC). The data to the motor driver is
provided by the microcontroller.
Figure 1: ROBOT
USB PORT
BUZZER
RESET
ISP
MCU
POWER LED
PWM LED
1 Microcontroller
The Mini Board is designed for AVR Atmega32.
LDR
DC JACK
2 Power Supply
The supply voltage to the AVR microcontroller is provided either
through DC Jack or USB. It is connected to the AVR's VCC pin.
2.1 DC Jack
Connect external power supply to this jack.
2.2 USB
Connect USB connector to this Port.
3 Reset Button
Press this button to reset the Mini Board.
Reset Button is connected on Pin no. 9 (RESET)
4 LDR
LDR (Light Dependent Resistor) is
connected to microcontroller for
applications that are dependent on
intensity of external light source.
LDR is connected on Pin no. PA1
5 ISP
In-System Programming uses the AVR internal SPI (Serial Peripheral
Interface) to download code into the flash and EEPROM memory of
the AVR. ISP programming requires only VCC, GND, RESET and 3
signal lines for programming.
The AVR can be programmed at the normal operating
voltage, normally 2.7V-6.0V. No high voltage signals
are required. The ISP programmer can program both
the internal flash and EEPROM. It also programs fuse
bits for selecting clock options, startup time and
internal Brown Out Detector (BOD) for the device.
During ISP programming the 6-wire cable must always be connected to
the header marked ISP (6PIN).
ISP port also acts power source. ISP is connected on Pin nos.
MOSI
PB5
MISO
PB6
SCK
PB7
RESET
RESET (9)
VCC
VCC
6 PWM LED
PWM LED is connected to microcontroller for
applications that require PWM application. LED is
used to check proper functioning of PWM
application. PWM LED is connected on Pin no
PD5
GND
GND
7 PORT A, B, C & D
These Ports are connected to microcontroller for interfacing I/O Pins of
Microcontroller.
PORT A
PORT B
Pin B0 (PB0) - Pin B3 (PB3)
Pin B0 (PB3) - Pin B3 (PB7)
PORT C
PORT D
DB9 Connector : The DB9 (originally DE-9) connector is an analog 9pin plug of the D-Subminiature connector family (D-Sub or Sub-D). The
DB9 connector is mainly used for serial connections, allowing for the
asynchronous transmission of data as provided for by standard RS-232
(RS-232C).
Pins
Pin number Name
1
CD - Carrier Detect
RI - Ring Indicator
Shield
SOFTWARES USED
1. AVR Studio 4: For programming the microcontrollers to control
the robot and to communicate with the computer through USART.
2. MATLAB: For creating the map of path traced by using the data
provided b the microcontroller.
Hence, sufficient knowledge is required for programming the
microcontroller for USART communication and for using the serial data
on MATLAB to generate the map.
If you connect two DTEs or two DCEs using a straight serial cable, the
TD pins on each device are connected to each other, and the RD pins on
each device are connected to each other. Therefore, to connect two like
devices, you must use a null modem cable. As shown in the following
diagram, null modem cables cross the transmitting and receiving lines in
the cable.
UNIX platforms use a 9-pin connection. In fact, only three pins are
required for serial port communications: one for receiving data, one for
transmitting data, and one for the signal ground.
The following diagram shows the pin assignment scheme for a 9-pin
male connector on a DTE.
The pins and signals associated with the 9-pin connector are described in
the following table. Refer to the RS-232 standard for a description of the
signals and pin assignments used for a 25-pin connector.
Serial Port Pin and Signal Assignments
Pin Label Signal Name
Signal Type
CD
Carrier Detect
Control
RD
Received Data
Data
TD
Transmitted Data
Data
Ground
Control
RTS
Request to Send
Control
CTS
Clear to Send
Control
RI
Ring Indicator
Control
pins are used for transmitting and receiving data. For these devices, the
TD, RD, and GND pins are used. However, some types of serial port
devices support only one-way or half-duplex communications. For these
devices, only the TD and GND pins are used. This guide assumes that a
full-duplex serial port is connected to your device.
The TD pin carries data transmitted by a DTE to a DCE. The RD pin
carries data that is received by a DTE from a DCE.
The Control Pins
The control pins of a 9-pin serial port are used to determine the presence
of connected devices and control the flow of data. The control pins
include
The RTS and CTS Pins. The RTS and CTS pins are used to signal
whether the devices are ready to send or receive data. This type of data
flow controlcalled hardware handshakingis used to prevent data
loss during transmission. When enabled for both the DTE and DCE,
hardware handshaking using RTS and CTS follows these steps:
1. The DTE asserts the RTS pin to instruct the DCE that it is ready to
receive data.
2. The DCE asserts the CTS pin indicating that it is clear to send data
over the TD pin. If data can no longer be sent, the CTS pin is
unasserted.
3. The data is transmitted to the DTE over the TD pin. If data can no
longer be accepted, the RTS pin is unasserted by the DTE and the
data transmission is stopped.
The DTR and DSR Pins. Many devices use the DSR and DTR pins to
signal if they are connected and powered. Signaling the presence of
connected devices using DTR and DSR follows these steps:
1. The DTE asserts the DTR pin to request that the DCE connect to
the communication line.
2. The DCE asserts the DSR pin to indicate it is connected.
3. DCE unasserts the DSR pin when it is disconnected from the
communication line.
The DTR and DSR pins were originally designed to provide an
alternative method of hardware handshaking. However, the RTS and
CTS pins are usually used in this way, and not the DSR and DTR pins.
Refer to your device documentation to determine its specific pin
behavior.
The CD and RI Pins. The CD and RI pins are typically used to
indicate the presence of certain signals during modem-modem
connections.
A modem uses a CD pin to signal that it has made a connection with
another modem, or has detected a carrier tone. CD is asserted when the
DCE is receiving a signal of a suitable frequency. CD is unasserted if the
DCE is not receiving a suitable signal.
The RI pin is used to indicate the presence of an audible ringing signal.
RI is asserted when the DCE is receiving a ringing signal. RI is
unasserted when the DCE is not receiving a ringing signal (e.g., it is
between rings).
The following notation expresses the format for serial port data:
number of data bits - parity type - number of stop bits
For example, 8-N-1 is interpreted as eight data bits, no parity bit, and
one stop bit, while 7-E-2 is interpreted as seven data bits, even parity,
and two stop bits.
The data bits are often referred to as a character because these bits
usually represent an ASCII character. The remaining bits are called
framing bits because they frame the data bits.
Use the get function to display one or more properties and their current
values to the command line. To display all properties and their current
values:
get(s)
ByteOrder = littleEndian
BytesAvailable = 0
BytesAvailableFcn =
BytesAvailableFcnCount = 48
BytesAvailableFcnMode = terminator
BytesToOutput = 0
ErrorFcn =
InputBufferSize = 512
Name = Serial-COM1
OutputBufferSize = 512
OutputEmptyFcn =
RecordDetail = compact
RecordMode = overwrite
RecordName = record.txt
RecordStatus = off
Status = closed
Tag =
Timeout = 10
TimerFcn =
TimerPeriod = 1
TransferStatus = idle
Type = serial
UserData = []
ValuesReceived = 0
ValuesSent = 0
SERIAL specific properties:
BaudRate = 9600
BreakInterruptFcn =
DataBits = 8
DataTerminalReady = on
FlowControl = none
Parity = none
PinStatus = [1x1 struct]
PinStatusFcn =
Port = COM1
ReadAsyncMode = continuous
RequestToSend = on
StopBits = 1
Terminator = LF
To display the current value for one property, supply the property name
to get.
get(s,'OutputBufferSize')
ans =
512
To display the current values for multiple properties, include the
property names as elements of a cell array.
get(s,{'Parity','TransferStatus'})
ans =
'none' 'idle'
Configuring Property Values
We can configure property values using the set function:
set(s,'BaudRate',4800);
or the dot notation:
s.BaudRate = 4800;
Reading data :
The Input Buffer and Data Flow describes the flow of data from
the device to MATLAB software.
Reading Text Data describes how to read from the device, and
format the data as text.
Reading Binary Data describes how to read binary (numerical)
data from the device.
The following table shows the functions associated with reading data.
Functions Associated with Reading Data
Function
Name
Description
fgetl
Read one line of text from the device and discard the
terminator
fgets
Read one line of text from the device and include the
terminator
fread
fscanf
Function
Name
Description
readasync
stopasync
The following table shows the properties associated with reading data.
Properties Associated with Reading Data
Property Name Description
BytesAvailable
TransferStatus
PROGRAMS :
1. Sample program for the microcontroller connected to the
robot: This program is written in Embedded C. The
microcontroller generates 4-bit values to control the D.C. motors.
1001 -> Forward movement
0101 -> Left turn
1010 -> Right turn
0110 -> Reverse gear
The microcontroller also sends the data about the movement of the
robot through the wireless transmitter section.
#define F_CPU 4000000UL
#include<avr/io.h>
#include<util/delay.h>
int main(void)
{
unsigned int count=1;
DDRC=0xFF;
DDRD=0xFF;
PORTC=0x09;
PORTD=0x01;
while(1)
{
if(count%4==1)
{
PORTC=0x09;
PORTD=0x01;
}
else if(count%4==2)
{
PORTC=0x05;
PORTD=0x02;
_delay_ms(255);
PORTC=0x09;
}
else if(count%4==3)
{
PORTC=0x0A;
PORTD=0x03;
_delay_ms(255);
PORTC=0x09;
}
else if(count%4==0)
{
PORTC=0x06;
PORTD=0x04;
}
_delay_ms(255);
_delay_ms(255);
_delay_ms(255);
_delay_ms(255);
if(count==160)
count=1;
else
count++;
}
}
UCSRA=(1<<UDRE);
UCSRB=(1<<TXEN);
UCSRC=(1<<URSEL)|(1<<USBS)|(1<<UCSZ1)|(1<<UCSZ
0);
}
int main(void)
{
DDRA=0x00;
unsigned char data;
unsigned int baud=25,count1=0,count2=0,count3=0,count4=0;
USART_init(baud);
while(1)
{
PINA=PORTA;
if((PINA & 0x0F)==0x01)
{
count2=0;
count3=0;
count4=0;
if(count1==0)
{
data=0x09;
count1++;
}
else if (count1==1)
{
data=0x19;
}
USART_Transmit(data);
}
else if((PINA & 0x0F)==0x02)
{
count1=0;
count3=0;
count4=0;
if(count2==0)
{
data=0x05;
count2++;
}
else if (count2==1)
{
data=0x15;
}
USART_Transmit(data);
}
else if((PINA & 0x0F)==0x03)
{
count1=0;
count2=0;
count4=0;
if(count3==0)
{
data=0x0A;
count3++;
}
else if (count3==1)
{
data=0x1A;
}
USART_Transmit(data);
}
else if((PINA & 0x0F)==0x04)
{
count1=0;
count2=0;
count3=0;
if(count4==0)
{
data=0x06;
count4++;
}
else if (count4==1)
{
data=0x16;
}
USART_Transmit(data);
}
}
}
a map of all the moves. The program gets its input data from a
serial port device (COM8) connected to the computer. However,
before executing the program it should be made sure that the frame
format of the data sent by the microcontroller should match the
frame format which is expected by the receiver.
Program:
function h=testmapserial(a)
m=ones(8*a);
s=serial('COM8');
set(s,'FlowControl','hardware','StopBits',2);
i=4*a+1;
j=4*a+1;
prev=1;
fopen(s);
for p=1:1:a
out=fread(s,1,'uint8');
if(out==9)
x=1;
elseif(out==5)
x=2;
elseif(out==10)
x=3;
elseif(out==6)
x=4;
end
if (x==1)
if (prev==1)
for y=1:1:4
m(i-y,j)=0;
end
i=i-4;
elseif (prev==2)
for y=1:1:4
m(i,j+y)=0;
end
j=j+4;
elseif (prev==3)
for y=1:1:4
m(i,j-y)=0;
end
j=j-4;
elseif (prev==4)
for y=1:1:4
m(i+y,j)=0;
end
i=i+4;
end
elseif (x==2)
if (prev==3)
for y=1:1:4
m(i-y,j)=0;
end
i=i-4;
prev=1;
elseif (prev==1)
for y=1:1:4
m(i,j+y)=0;
end
j=j+4;
prev=2;
elseif (prev==4)
for y=1:1:4
m(i,j-y)=0;
end
j=j-4;
prev=3;
elseif (prev==2)
for y=1:1:4
m(i+y,j)=0;
end
i=i+4;
prev=4;
end
elseif (x==3)
if (prev==2)
for y=1:1:4
m(i-y,j)=0;
end
i=i-4;
prev=1;
elseif (prev==4)
for y=1:1:4
m(i,j+y)=0;
end
j=j+4;
prev=2;
elseif (prev==1)
for y=1:1:4
m(i,j-y)=0;
end
j=j-4;
prev=3;
elseif (prev==3)
for y=1:1:4
m(i+y,j)=0;
end
i=i+4;
prev=4;
end
elseif (x==4)
if (prev==4)
for y=1:1:4
m(i-y,j)=0;
end
i=i-4;
elseif (prev==3)
for y=1:1:4
m(i,j+y)=0;
end
j=j+4;
elseif (prev==2)
for y=1:1:4
m(i,j-y)=0;
end
j=j-4;
elseif (prev==1)
for y=1:1:4
m(i+y,j)=0;
end
i=i+4;
end
end
h=imshow(m)
end
i
j
fclose(s);
delete(s);
clear s;
end