Showing posts with label 8051 programming. Show all posts
Showing posts with label 8051 programming. Show all posts

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;
    }
}

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





keil uvision 3 tutorial




The Keil uvision3 8051 Development Tools are designed to solve the complex problems facing embedded software developers.



  • When starting a new project, simply select the microcontroller you use from the Device Database and the µVision IDE sets all compiler, assembler, linker, and memory options for you.

  • Numerous example programs are included to help you get started with the most popular embedded 8051 devices.

  • The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN, UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051 device.

  • Simulation helps you understand hardware configurations and avoids time wasted on setup problems. Additionally, with simulation, you can write and test applications before target hardware is available.

  • When you are ready to begin testing your software application with target hardware, use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to download and test program code on your target system, flsh magic is also a very well known for hex loader.




Now here is a step by step process to make an assembly program in the keil development tool for 8051 microcontroller .














KEIL basic's : 1. Open keil from start menu.






                   2. The figure show the basic names of the windows reffred in this tutorial.

















keil uvision 3 window










starting new assembly project: 1. select the new uvision project from the poject menu.















2. Name the project like 'toggle'.




3. click the save button.


































































































4. The device window will be displayed






5. select the microcontroller which will you using for me its ..NXP.






6. Double click on NXP.


























7. Scroll down and select the p89v51rd2.






8. click ok.

































Creating source file: 1. click file menu and select new.

























2. A new window will open up in the keil IDE.























3. Write your assembly code into his window as shown.














































































































































4. Click the file menu and select save as..









5.name the file with '.asm' extension like (toggle.asm).






6. click the save button.






























Adding File to the project: 1. Expand targeet1 in the tree menu.























2. now right click on source group1 and select add files to the source group1.






























3. find your .asm file and select that and click on add button.






























Testing Program in Debugger: 1. go to the project menu and click on the rebuild all targets.













2.in the buid in menu it should report '0 error', or, '0 warning'.






























3. now click on the debug menu and select the start and stop debug session. 





































Running the keil debugger: 1. The keil debugger should be running.






























2. go to peripheral menu and select the input output port 1.























3. A new window should pop up and this shows the port and their pin.




























4. Step through the code by pressing f11.






















5. now to exit out go into the debug menu and click start and stop debug button.









now its time o check how it works their is a video tutorial from 2embeddedrobotics to work on keil first time

















***************************best of luck****************************



 
Copyright Electronics Projects And Details All Rights Reserved
ProSense theme created by Dosh Dosh and The Wrong Advices.
Blogerized by Alat Recording Studio Rekaman.