Sunday, 30 October 2011

mobile operated robot program


Writing a c program for mobile operated robot is not a very difficult task we just have to take the basic block diagram in our mind that a microcontroller get the input and give the decision based on our program.
Now form the DTMF decoder we will get the 4 bit data on the port2 of microcontroller 8051.We also know that the data given by decoder is equal to a number pressed by input mobile.

HARDWARE CONFIGURATION: Before writing the program we should know the hardware configuration of the circuit where the input's and output's are connected and for what task we have to make the program.
INPUT'S: The microcontroller 8051 is connected with DTMF decoder as follow -the port 1 is the input port where the DTMF data bits  D0 to D3 are connected with P1.0 to P1.3 as given in the below fig.
DTMF &  MICROCONTROLLER  CONNECTION 
**Note:-for making the port1 as an input port pass 0xff at the port1.

OUTPUT'S: The microcontroller 8051 is connected with motor driver as follow: the port 2 is the output port and the pin connection is shown in fig. for moving the motor's in forward direction we have to give 10 to the motor or (M1A =0  & M1B =1) this condition makes the motor M1 in forward direction.

MOTOR DRIVER & MICROCONTROLLER CONNECTION
**Note:-for making the port2 as an output port pass 0x00 at the port2.
CREATING LOGIC:  Now the main part of the programming  is to create a decision on the basis of some condition like when the key 2 is press then send some data to the output prot of the  microntroller now I create  a data according to my project you can create your own.I am using the key 2,4,6,8 & 5 for controlling the robot.
DECISION BASED ON CONDITION
FLOW CHART: Programming is an art which includes some step's the flow chart is also a step of programming we can make the program without a flow chart but for making an efficient and error free program then we should use this step a flow chart of the program is shown below.

C PROGRAM FOR MOBILE OPERATED ROBOT:

****---------------------------------------------------------------------------------------------------------------------****

#include<reg51.h> //header file for 8051 microcontroller
void Main()
{
P1=0xff; //initialize as an input port
P2=0x00; //initialize as an output port
while(1) //infinte loop
   {
     if(P1==0xf2) //check for key 2-decision is forward
        {
          P2=0x0a; //m1 and m2 forward as 1010 these are four lsb bits of port 2
        }
      else if(P1==0xf4) //check for key 4-decision is left
         {
           P2=0x08;
        }
       else if(P1==0xf6) //check for key 6-decision is right
        {
            P2=0x02;
      }
      else if(P1==0xf8) //check for key 8-decision is backward
       {
           P2=0x05;
       }
      else if(P1==0xf5) //check for key 5-decision is stop
      {
           P2=0x00;
     }
    else
           P2=0x00;
    }
}

****--------------------------------------------------------------------------------------------------------------------****




About the Author

vikas

Author & Editor

Hobbyst Researcher and working in electronics domain, M.Tech in VLSI Design and Embedded Systems.

3 comments:

  1. i am using a serial gsm ttl modem instant of mobile phone so i want to know how to make connection to dtmf decoder ic plz help me sir

    ReplyDelete
  2. sir i am facing problem with the keil code kindly tell it or mail me at krishanjiwangupta@gmail.com

    ReplyDelete

 
2embeddedrobotics © 2015 - Designed by Templateism.com