Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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.

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

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

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.

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

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.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |