|
|
|
Sending binary through rs232
|
Original Message
|
Name: Robcowell
Date: November 5, 2004 at 08:12:16 Pacific
Subject: Sending binary through rs232OS: XP SP2CPU/Ram: 1.81Ghz/512mb |
Comment: Im having difficulty sending binary down a serial cable, i want to send the binary code 1101 but do not know how to do it. I m playing around with the mscomm controls and other code i can find but i am a complete noob to this, what is the code so that when i click a button it sends 1101 down the line??? I am using VB6
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: wizard-fred
Date: November 5, 2004 at 11:58:57 Pacific
|
Reply: (edit)In general serial ports send whole characters of 10 bits (8 data + start and stop bits). So you are not going to get only 1101. Remember that serial data also has a time reference.
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Robcowell
Date: November 5, 2004 at 14:21:31 Pacific
|
Reply: (edit)hi wizard-fred Thanks for the thoery and i will bare this is mind..my main problem is that how many times i try to get it too work i don't seem to sending the correct output, i think all i am sending is text. so how do you turn say.. chr(9) to binary, i have been told that i need to pass a byte as a variant, but i don't know how to actually do it.. any ideas, whats the syntax to getting around this problem??? rob
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: StuartS
Date: November 5, 2004 at 23:29:39 Pacific
|
Reply: (edit)As Wizard-Fred says, you need to send at least a byte. The MSComm control will take care of the start/stop and parity bits providing is is configured correctly. For 1101 you need to send number 13. The binary equivalent of 9 is 1001. The MS calculator that comes with all version so Windows has a binary/decimal/hexadecimal converter. To work out the syntax, highlight the MSCom control on a form and press F1. Providing you have the Help installed correctly you will get all the instructions s you need on using the MSComm control. Stuart
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: wizard-fred
Date: November 5, 2004 at 23:33:44 Pacific
|
Reply: (edit)The problem is where are you reading the output. The output on the RS-232 cable will always be in the 10 bit pattern (unless the chip is reprogrammed) because that what the chip is programmed to do (convert ascii input to RS-232 data format), the receiving chip will convert the RS-232 back to ascii. If you read the cable you won't get your 1101. Now if you monitor the output of the receiving UART you will get 00001101 if you send chr$(13) into the sending UART. If you send chr$(9); the TAB character the receiving chip will decode to 00001001. Actually you are essentially limited to 256 characters 0 to 255, 00000000 to 11111111. The problem is I don't know how you are reading the data or where you are reading the data (or how do you want to use the data or do you only want 4 bits of the data). Or as a serial data stream or parallel output. You may be better of controlling on of the handshake ports or using the parallel port.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Robcowell
Date: November 8, 2004 at 13:19:56 Pacific
|
Reply: (edit)Hi guys, thanks for the help, I have been able to successfully do what i was looking at doing (if you follow my point...;) I will bare in mind what both of you have said. Im sending my output to a PIC microcontroller that will read the binary data to activate some motors...i will take on board this USART and have a read around. Thanks for the help.. Rob
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: bamakhrama
Date: November 17, 2004 at 02:39:47 Pacific
|
Reply: (edit)For more info regarding using parallel & serial ports under Win & Linux machines see http://www.epanorama.net/circuits/ I hope that will do the job.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|