.post large { float:left; color: $headerBgColor; font-size:100px; line-height:80px; padding-top:1px; padding-right:5px; }

News and Materials Headline Animator

Sunday, June 6, 2010

line follower using PIC18f4550










Line follower is an autonomous robot which follows a particular line of particular width. Its direction is determined by the direction of the line. Based on the line follower GRID and RACE CIRCUIT SOLVER have been solved

The autonomous bot can be designed either using analogue components or using a microcontroller and sensors.
DEVELOPMENT BOARD
We have designed the line follower using microchips microcontroller PIC18F4550 development board designed by TRI-INDIA. The board can be designed easily, but since this is our first project and we had little knowledge about the circuit board, we decided to buy it. PIC18F4550 is a 40 pin microcontroller having 5 ports named as A, B, C, D, E with a clock speed of 4mhz.It has inbuilt 256k EEPROM and 2k SRAM. It can be programmed through MPlab development suite. The compiler used is C18 compiler. It includes all the c language techniques and the additional techniques to manipulate the pic18f4550.the c18 compiler is a student’s edition developed by the microchip.
The code is written in C format and is then converted into a hex file in the MPlab. The hex file is then dumped into the controller through JDM programmer (in circuit system programming).
The sensors used are normal infra red sensors. It has a transmitter and a receiver. The transmitter keeps transmitting the signal. When a dark surface appears the signal is absorbed and when a light surface appears the signal is reflected and he receiver picks up the signal

POWER SUPPLY
The supply we used is two rechargeable lead acid batteries of 6 v and 1.2 amp connected in series. So the total input given to the board is 12v 1.2 amps. The lead acid batteries are powerful and bulky and proper care must be taken so that they don’t get short circuited.
MECHANICAL CONSTRUCTION
The mechanical construction needs to be planned carefully. There has to be a balance between speed and torque. We used 100 rpm geared dc motors because they have high torque and its speed is considerable (for starters like us).In case higher rpm motors are selected the weight of the chassis has to be reduced. The relation between the torque and the speed is inverse. We have used wood of 3.4-4 mm thickness to prepare the chassis. The cassis consisted of two platforms as shown in the above figures. The bottom one is 16x12cm and the upper one is 9x8cm.The bottom part is cut into v shape so that it resembles the formula 1 car and for no other reason. The two parts are held apart at a height of 5cm using nut and bolt of considerable strength. The dc motors are clamped to the bottom piece using bulb clamps and screwed them tightly. The batteries make up most of the weight so they are kept a point where even the weights of the motors
are also countered. The motors are driven through L293D drivers included in the development board.
The sensors are mounted on the front side as shown in the figure.
Two sensors are mounted. In case the left sensor comes out of the black surface the bot goes right until not true and vice versa.
ALGORITHM
1. Check the sensors, power supply and if the screws are tight and the connections.
2. Switch on the supply
3. If the left sensor does not detect the black surface turn right until not true
4. if the right sensor does not detect the black surface turn left until not true
5. If both the sensor detects black then go straight
6. if both detect white then stop.
Source Code
Motor Connections PORTS
M1- RC1 RD0
M3 - RD2 RD3
Sensor Connections PORTS
S1 – RA0
S2 – RA1
# define m0 PORTCbits.RC1 //motor 1 terminal
# define m1 PORTDbits.RD0 //motor 1 other terminal
# define m2 PORTDbits.RD2 //motor 2 terminal
# define m3 PORTDbits.RD3 //motor 2 other terminal
# define s1 PORTAbits.RA0 //left sensor
# define s2 PORTAbits.RA1 //right sensor
# include
# include
# include
void main()
{
ADCON1 = 0b00001111; //makes all the ports digital ports
TRISCbits.TRISC1=0; //initialize Port c1 as output
TRISDbits.TRISD0=0; //initialize port d0 as output
TRISDbits.TRISD2=0; //initialize port d2 as output
TRISDbits.TRISD3=0; //initialize port d3 as output
TRISA = 1; //initialize port A as input as sensors are connected to these ports
while(1) //infinite loop
{
while(s1==1 && s2==1)
{
m0=1;
m1=0;
m2=1;
m3=0;
}
while(s1==1 && s2==0) //in case the bot shifts towards right(of the line)
{
m0=0;
m1=0;
m2=1;
m3=0;
}
while(s1==0 && s2==1) //in case the bot shifts towards left(of the line)
{
m0=1;
m1=0;
m2=0;
m3=0;
}
while(s1==0 && s2==0) //in case the bot wanders into the arena...this problem can be overcomed by using three sensors.
{
m0=0;
m1=0;
m2=0;
m3=0;
}
}
}
HOW TO CREATE HEX FILE
1)install MPlab and c18 compiler
2)go to project and open project wizard and select your pic 18 device
3)in the tool suite contents add the c18 compiler
4)then create a file name for it and finish the process
5)write the above code in the editor and save it in *.c format
6)then go to view and open project
7)right click on source files and add the c file you just saved
8)right click on the linker files and add the corresponding PIC model linker file from the c18 folder (if you are using 18f4550 add 18f4550.lkr)
9)then go to project-build options and click on project
10)for output directory direct it to where you want it to be saved
11)for include directory the path should direct to c18 folder ‘h’
12)for library director ‘lib’ and linker ‘lkr’
13)apply the changes and then click on build all in the projects menu
14)The hex file is created in case there are no errors in the code

No comments:

Post a Comment

Popular Posts

News and Materials

Subscribe Now: Feed Icon

Infolinks In Text Ads

Related Posts with Thumbnails

Latest News

Time