Not true for either the PC or PIC side - you can send any value from 0 (0000000) to 255 (11111111) inclusive. I'm not sure what the 'problem' you heard was referring to.Vandal S said:but i heard(that's why i'm asking) that there is a problem with the rs-232, you can only send ASCII codes, or something like that, anyway, not 10101010 for example.
Vandal S said:i tested with an osciloscope with hyperterminal and terminal1.9b.
when i press 1, there are indeed 8 bits, 4 of them (the first from left) i recognized; they respond the numbers, 8 is 1000 in inverse order and negated. some bits from right responded to some letters.
If you enter '10011011' as eight individual characters on hyperterminal then of course you will get eight bytes. If you want it as a single byte then you have to enter that value as a single character. This is problematic for non-displayable characters. However, Windows provides a way for you to do this:Vandal S said:but is there a program in which i enter 10011011 for example and i see on the osciloscope that thing? if i do that, there would be 8 bytes; i want to see them in a single byte.
i think this was what that person tried to explain to me.
For example to enter '10011011' as a single character:- Make sure NumLock is enabled on your keyboard.
- Press and hold the ALT key.
- While holding down the ALT key, enter the 3-digit decimal code for the extended ASCII character you want to generate using the numeric keypad.
- Release the ALT key.
NOTE that you need to enter the DECIMAL value of the charater
If you need to send lots of non-displayable characters you may want to create a file containing the data you want to send, and then use the Send File feature to send the data. I don't use Hyperterminal so I don't if you can send a file using it, but there are other serial communiations programs that allow you to do that.- Convert '10011011' binary to decimal - it equal 155 decimal
- Press and hold the ALT key
- On the numeric keypad press 1, then 5, then 5
- Release the alt key
#define SYNC_BYTE 'U'
#define CMD_FORWARD 'W'
#define CMD_REVERSE 'S'
void main(void)
{
char data_byte; // To hold the byte we receive from the UART
SioInit(4800); // Initialize the UART hardware to 4800 baud
MotorInit(); // Setup the Motor Driver Hardware
while(1) // Stay in this loop forever
{
while (!SioCharRdy()); // Loop until we get a byte from UART
data_byte = SioGetChar(); // Get the character from the UART
if (data_byte == SYNC_BYTE) // If we received a SYNC character...
{
while (!SioCharRdy()); // Loop until we get command from UART
data_byte = SioGetChar(); // Get the command byte from the UART
switch(data_byte) // Set motors based on reeived command
{
case CMD_FORWARD: // If Forward command...
MotorForward(); // make the motors go forward
break;
case CMD_REVERSE: // If Reverse command...
MotorReverse(); // make the motors go backward
break;
case statements for other commands here
default: // For invalid commands...
MotorStop(); // Stop the car
break;
}
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?