serial communication

MrChips

Joined Oct 2, 2009
30,821
The PC does not know the difference between text or binary information.

The programmer has to choose how the information is encoded in the transmitted data.

All data transmitted is binary.
 

MaxHeadRoom

Joined Jul 18, 2013
28,698
Usually ASCII is used to transmit alpha/numeric as only 7 bits can be used, with binary value's, it is normal to use the full 8 bits, for RS232/RS485 anyway.
The TX & RX end have to use the same protocol in order to receive valid data.
Max.
 

jpanhalt

Joined Jan 18, 2008
11,087
I cannot speak for a real PC, but I suspect the following answer applies to them as well.

Take Papabravo's example of 0X41. That is hex for the binary number 01000001. It is also hex for the ASCII value "A" or the decimal value of 65. The term radix describes whether you are using hex, decimal, ascii, octal, or binary. Now, if you send the binary equivalent (01000001) via serial to a typical LCD monitor, it will show an "A", because the radix for such monitors is set ASCII.

If you want that monitor to show the number "65", you have to send the binary numbers for the ascii equivalents of a "6" and of "5." Conveniently, the conversion from decimal number to ascii can be done by adding decimal 48. Thus, you need to send the value 54 in binary (6+48 = 54) and then 53 in binary.

Now, let's assume that instead of sending to a typical monitor, you are sending to a small microcontroller. The program of that microcontroller can be set to interpret a serial communication by whatever radix you chose. So, you can set that program to use an 8-bit binary byte for 54 (b'00110110') as the decimal value "54".

John

Edit: Corrected the binary for 0X41. Thank you Papabravo.
 
Last edited:
Top