PDA

View Full Version : DC through Serial Port

shyam4uall
12-25-2008, 08:52 PM
How can i control two bi-directional motor through PC serial port ?

allbits
12-26-2008, 10:50 AM
1) send serial data, using C, or VB, or matlab or whatever. Read the serial data using a microcontrller.

or

2) use the RTS and DTR lines.

you might have to convert the voltage levels.

shyam4uall
12-26-2008, 08:49 PM
what is the bit pattern and how to send them i.e how could i know which data i have send through the serial port ?

How (or what) to program the microcontroller according to the bit received (seems to be a funny question) but if anyone can explain it a bit it would be helpful.

shyam4uall
12-31-2008, 08:11 AM
Suppose I send "1" through serial port (PC) to the micrcontroller's UART (i.e RX) and then send the binary code of "1" to the 4 data bus (4-pin) of any port.Is it possible to do so ?

Can i directly send the serial data (1 or 2 or 3) to 4 pins of any port (A or B) ?

shyam4uall
01-18-2009, 07:57 PM
I want this logic to run a motor

PC0 PC1 PC2 PC3
1 0 1 0 FORWARD (Keyboard W)
0 1 0 1 BACKWARD (Keyboard S)
1 0 0 1 LEFT (Keyboard A)
0 1 1 0 RIGHT (Keyboard D)

#define FORWARD (1<<0)|(1<<2) //FORWARD = 1010
#define BACKWARD (1<<1)|(1<<3) //BACKWARD = 0101
#define LEFT (1<<0)|(1<<3) //LEFT = 1001
#define RIGHT (1<<1)|(1<<2) //RIGHT = 0110
void main()
{
char data;

DDRC |=(1<<0)|(1<<1)|(1<<2)|(1<<3);

while(1)
{

if(data=="W")
{
PORTC |= FORWARD;
}

if(data=="D")
{
PORTC |= RIGHT;
}

if(data=="S")
{
PORTC |= BACKWARD;
}

if(data=="A")
{
PORTC |= LEFT
}

I have this code (WinAVR) for Atmega8.Is the program correct ??

There are other functions as well but i m concerned with the main part.