RS-232

From ScienceZero
Jump to: navigation, search

Binary numbers are written with the most significant bits to the left but RS-232 transmits the least significant first so the oscilloscope waveform will be mirrored compared to the binary value transferred.

Microcontrollers and UARTs (Universal asynchronous receiver/transmitter) often have the outputs inverted for use with inverting level translators like the MAX232 for generating the full RS-232 voltage levels.

The UARTs in modern PCs are often remarkably forgiving and in some cases will work with 0 V instead of negative voltages so it can in some cases be possible to get a connection to work without level translators.

A microcontroller that is floating in relation to the PC ground can in some cases work by the addition of one inverter and connecting the uninverted signal to Signal Ground and the inverted signal to Receive Data. This will give fully compatible RS-232 voltage levels for CMOS running at 5 V, and marginal voltage levels for CMOS running at 3-3.3 V.


Format

  • One start bit
  • 5-8 data bits
  • Odd, even or no parity
  • 1, 1.5 or 2 stop bits

The parity bit ensures that the number of 1's are either even or odd. The parity bit for 1111000'b with even parity would be 0 since 1 would give an odd number of 1's.


Error detection

The receiver will check that the parity bit if any is correct and that the number of start and stop bits are correct. Depending on the data transmitted it is possible that the receiver will not detect error on a continuous stream of data, even if every single byte is wrong. Reliable transmission requires a protocol with more robust error detection to be added.


Drivers

  • Receiver input resistance 3 to 7 kΩ
  • Driver load impedance 3 to 7 kΩ


RS-232 voltage levels
Level Transmitter capable Receiver capable
Space state (0) +5 V to +15 V +3 V to +25 V
Mark state (1) -5 V to -15 V -3 V to -25 V
Undefined N/A -3 V to +3 V


Pinouts

Pinout of plugs
DB-25 Pin DB-9 Pin Short Name
1 N/A - Protective ground
2 3 TD Transmit Data
3 2 RD Receive Data
4 7 RTS Request To Send
5 8 CTS Clear To Send
6 6 DSR Data Set Ready
7 5 SG Signal Ground
8 1 CD Carrier Detect
20 4 DTR Data Terminal Ready
22 9 RI Ring Indicator


Cables

  • Maximum cable capacitance for 15 m at 20 00 baud is 2500 pF
RS-232 cable length (experimental)
Baud rate Maximum length Maximum length
19 200 50 ft 15 m
9600 500 ft 150 m
4800 1000 ft 300 m
2400 3000 ft 900 m


Waveform

Transmission of the character "T" ( 124'd, 01010100'b ) at 38400 baud

RS232-T.png

Bit label start bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 stop idle
Logic value 0 0 0 1 0 1 0 1 0 1 1
Type space space space mark space mark space mark space mark mark
Voltage +5 V +5 V +5 V -5 V +5 V -5 V +5 V -5 V +5 V -5 V -5 V
  • Eight data bits, no parity, one stop bit (8N1)