Saturday 14 February 2015

Robotic Car using 8051

Hi guys. Now I am going to show "How to make robot car using 8051" using "Embedded C" programming. I can show in software simulation mode using Proteus software and, for compiling Embedded C-programme in Keil software. Now see the program of this project..

Software programming:-   

This program is very simple and easy by making robot car using 8051. And this programme is used for controlling four DC_MOTORS used for running the robot car in efficiently. Lets see the program..

#include<reg51.h>
sbit m1p = P2^0;                           //  Motor 1 positive terminal is assigned to port 2(P2^0)
sbit m1n = P2^1;                           // Motor 1 negative terminal is assigned to port 2(P2^1)
sbit m2p = P2^2;                           // Motor 2 positive terminal is assigned to port 2(P2^2)
sbit m2n = P2^3;                           // Motor 2 negative terminal is assigned to port 2(P2^3)
sbit m3p = P2^4;                           // Motor 3 positive terminal is assigned to port 2(P2^4)
sbit m3n = P2^5;                           // Motor 3 negative terminal is assigned to port 2(P2^5)
sbit m4p = P2^6;                           // Motor 4 positive terminal is assigned to port 2(P2^6)
sbit m4n = P2^7;                           // Motor 4 negative terminal is assigned to port 2(P2^7)
sbit F = P1^0;                                // Forward switch is connected to port 1(P1^0)
sbit Ba = P1^1;                              // Backward switch is connected to port 1(P1^1)
sbit R = P1^2;                                // Right switch is connected to port 1(P1^2)
sbit L = P1^3;                                // Left switch is connected to port 1(P1^3)  */
                                                     
void forward()                                //  Robot forwarding function
{
m1p = 1;
m2p = 1;
m3p = 1;
m4p = 1;
m1n = 0;
m2n = 0;
m3n = 0;
m4n = 0;
}
void backward()                             // Robot backward function
{
m1p = 0;
m2p = 0;
m3p = 0;
m4p = 0;
m1n = 1;
m2n = 1;
m3n = 1;
m4n = 1;
}
void left()                                        // Robot left turning function
{
m1p = 1;
m1n = 0;
m2p = 1;
m2n = 0;
m3p = 0;
m3n = 1;
m4p = 0;
m4n = 1;
}
void right()                                   // Robot right turning function
{
m1p = 0;
m1n = 1;
m2p = 0;
m2n = 1;
m3p = 1;
m3n = 0;
m4p = 1;
m4n = 0;
}
void stop()                                     // Robot stop function
{
m1p = 0;
m1n = 0;
m2p = 0;
m2n = 0;
m3p = 0;
m3n = 0;
m4p = 0;
m4n = 0;
}
void main()                                   // Main function 
{
F = 0;                                           // Initialise all switches are equal to zero 
  Ba = 0;
L = 0;
R = 0;
while(1)
{
if(F==1)
forward();                                  
else if(Ba==1)
backward();
else if(L==1)
left();
else if(R==1)
right();
else
stop();
}
}

This is very simple program for understanding.

Hardware implementation :- 

Now see the robot hardware simulation in Proteus software. And assume the first two motors are in one side of the robo and next two motors are in another side of the robo car. For easy understanding see the below figure


 while pressing Forward(F) button all motors are running forward direction and pressing Backward(BA) button all motors are running in reverse direction. Similarly while pressing Left(L) button, first two motors are rotate in forward and next two motors are rotate in backward direction then robot is turning left direction and pressing Right(R) button, first two motors are rotate in backward and next two motors are rotate in forward direction then robot is turning right direction.
This process is enough for making simple robot car. Then implement this on hardware it looks like this

And see the below video for easily understanding..

  

3 comments:

Unknown said...

Hi, can i have this code in .asm format. And if use only two tyres and motors, can the left and right function work?

Unknown said...

is this for your final project? syafiq nadzri..

Unknown said...

Yes, it is for my final project. I searched all in the internet but all i found is in c format. Can u help me?