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..

  

Monday, 9 February 2015

Led chaser using 8051

Hi friends. Now I am going to show the basic “Embedded C” programming for “LED CHASER using 8051”. I am using ‘ KEIL ’ Software for compiling Embedded C program and, for Hardware simulation I am using ‘ PROTEUS ’ Software.


Software programming:-



This is the basic program for LED chaser using 8051, because as you see this program is very large that’s why it is very basic program for easily understanding the Embedded C programming. Before you seeing this program you may know about keil software. Lets see the program..


#include<reg51.h>           // This command is used for including all register file of 8051.
sbit led1=P2^0;                // This is used for initializing single bit of P2.0 to led1.
sbit led2=P2^1;
sbit led3=P2^2;
sbit led4=P2^3;
sbit led5=P2^4;
sbit led6=P2^5;
sbit led7=P2^6;
sbit led8=P2^7;

void delay (unsigned int ms)                   // This loop is used for time taken by each led is ON or OFF.
{
                unsigned int i, j;                                                        
                for (i=0; i<=ms; i++)
                 for (j=0; j<1275; j++);                                 // Here 1275 indicates 1 millisecond.
}
void main ()
{  
                                led1=0;
                                led2=0;                      // Firstly I initialize all leds into OFF state
                                led3=0;                      //          i.e. led (n) =0;
                                led4=0;                      //                   n: - No. of Leds */
                                led5=0;
                                led6=0;
                                led7=0;
                                led8=0;
                while (1)
                {
                               
                                delay (10);                  // delay (10) means led 1 is ON by delay 10 milliseconds.
                                led1=1;
                                delay (10);
                                led1=0;
                                led2=1;
                                delay (10);
                                led2=0;
                                led3=1;
                                delay (10);
                                led3=0;
                                led4=1;
                                delay (10);
                                led4=0;
                                led5=1;
                                delay (10);
                                led5=0;
                                led6=1;
                                delay (10);
                                led6=0;
                                led7=1;
                                delay (10);
                                led7=0;
                                led8=1;
                                delay (10);
                                led8=0;
                                led1=1;
                }
}               

You can use Arrays concept on this program then shorten the program. But I make this program for easily understanding to every one.
  
Hardware implementation:-

You can run this program on 8051 micro-controller by using ‘PROTEUS’ Software. Before you can go this you know about this software like Open New Project, dump ‘.hex ‘file on your controller so on. Lets see the circuit diagram of this project..
     

In the above circuit Power supply(Vcc=5v) and Ground terminals are not necessary in this software because these terminals are inbuilt in Proteus and there is no need using crystal oscillator for small applications but, you can do large applications on Proteus then you need crystal oscillator for accuracy output. If you need RESET switch then design it in this software. By click on this switch(sw1) then the circuit will go to initial stage directly, instead of ON and OFF the power supply. This 8051 micro-controller give the input voltage is in between 4.5v to 5.5v. For more information about 8051 micro-controller you can see the data-sheet. Now see the circuit design when using crystal oscillator and RESET button in Proteus..
  

I make a video tutorial for this project see this and enjoy it. Thanks for watching please subscribe it on youtube