Friday 8 February 2013

Basic PC controlled robot

             A PC controlled robot is robotic platform that operates based on the data transmitted from the PC 
 serial COM port.

COM port is a 9 pin port that transmit data serially using UART(Universal asynchronous reception and transmission)  protocol. This is a full duplex which means one can transmit and receive data simultaneously.
Just like a USB port a PC will have a COM port at its back. It looks like this...
     
        
                             

Though this port is having 9 pins we deal with only two pins. The are...
         PIN 2:Serial Receiver(Rx)
              PIN 3:Serial Transmitter(Tx) 
PIN 5:Signal Ground 
if your PC is not having a serial port you can use a USB to Serial cable..

The connections of of PC and microcontroller will be as follows

We connected the circuit....but ..
Can a microcontroller understand the data sent by a PC ?
Have you seen the word "TTL" in the above picture..........? 
it stands for (Transistor Transistor Logic). In which a logic '0' is represented by 0V
                                                                                logic '1' is represented by 5V
but the data transferred from the PC will follow RS-232(Recommended standard) logic
The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels for the data transmission and the control signal lines. Valid signals are either in the range of +3 to +15 volts or the range -3 to -15 volts; the range between -3 to +3 volts is not a valid RS-232 level. For data transmission lines (TxD, RxD and their secondary channel equivalents) logic one is defined as a negative voltage, the signal condition is called marking. Logic zero is positive and the signal condition is termed spacing.  

So to convert the voltage levels we need a level converter. MAX232 chip is used to do this job.

MAX232 connections with PC 

Basically PC will have a male port. so take a female port and make this circuit and connect to the PC and microcontroller.



   now your microcontroller will receive the proper data from PC
Here comes the Question what microcontroller to choose?

Here i'm considering 8051 microcontroller...for beginners



now after the connection..... the programming for 8051 using keil microvision 3

Connecting motors to the microcontroller using an L293D motor driver
i connected the RA(1234) pins to Port1 lower pins
P1.0=>PA0
P1.1=>PA1
P1.2=>PA2
P1.3=>PA3

 before going through the code reader must know about 8051 microcontroller.
if you press reset it says "HEY" on hyper terminal

Code:
#include<reg51.h>

void serial_init()     // Initialize Timer 1 for serial communication
{
TMOD=0x20;  //Timer1, mode 2, baud rate 9600 bps
TH1=0XFD; 
SCON=0x50;
TR1=1;
}

unsigned char  recieve()  //Function to receive serial data
{
   unsigned char value;
   while(RI==0);
   value=SBUF;
   RI=0;
    return value;
}

void transmit(unsigned char data)  // Funtion to transmit serial data
{

SBUF=data;
while(TI==0);
TI=0;
}

void main()
{serial_init();
transmit('H');transmit('E');transmit('Y');// display "HEY" on serial hyperterminal
unsigned char x; while(1) { x= recieve();
if(x==w)
P1=0x0a;// forword
else if(x==a)
P1=0x06;// left turn
else if(x==w)
P1=0x09;// right turn
else if(x==w)
P1=0x05;// back
else
P1=0x00//stop
}
}
to execute this project you will need to open hyper terminal which is not possible in Windows7  instead you can use the following softwear
DOWNLOAD:  udp://tracker.ccc.de:80/announce
   select your COM port and settings as shown in the picture...
and type the data....in the field....
it starts.....working enjoy...............................................................

2 comments:

Kr. Abhishek said...

Hello sir, I just finished a android controlled robo using HC05, is there any app or program that transmits serial data from computer usins pc's Bluetooth?

Unknown said...

Really this information is more informative & valuable. Thanks for sharing the great knowledge among us. Chip Level Training in Hyderabad

Post a Comment