Serial Data Standards
Serial Data Standards
1
• Electronic communications is all about interlinking circuits (processors or other
integrated circuits)
• For individual circuits to exchange information, they must share a common
standard communication protocol
• The most common serial communication protocols are RS232, RS422 and RS485,
created by the Electronics Industries Association and named Recommended
Standard no. X (RSX)
2
RS232 Standard
• The RS232 standard is used in PCs
• In RS232, a 1 bit is represented by -3 to -25V and a logic 0 bit by +3 to +25V (higher
voltages are used to overcome voltage drops along the line) and -3 to +3V is
undefined:
Logic 0: A voltage between +3 and +25V
Logic 1: A voltage between -3 and -25V
Undefined: A voltage between -3 and +3V
• PC power supplies use +12V and -12V and these voltages are mostly used for RS232
(logic 0 = +12V and logic 1 = -12V)
• DB-9 (9 pin, no handshaking) and DB-25 (25 pin, handshaking) connectors are
associated with the RS232 standard
• Between two PC’s communicating using RS-232 communications and hardware
handshaking (flow control), one side of the connection sends a “flow control” signal
to tell the other side to stop or start transmitting
3
• Flow control signals are sent when the sender needs to take a break, such as
when a data buffer is full
• Flow control uses RS-232’s RTS and CTS signals to indicate when data
transmission should be paused or re-started
• For example, as indicated below, when PC1 is ready to receive, it raises the RTS
signal to request data from PC2
4
• Many applications do not use hardware handshaking but Tx, Rx and GND lines
with some form of software handshaking and flow control is then part of the
application program
• Since the communication data is based on the voltage on the wires relative to
ground (GND), a GND connection must be made between devices that
communicate using RS-232
• An RS232 wiring diagram is shown below:
• In RS232, data is sent serially (one bit after another) because there is only one
data line in each direction
5
• This mode of data transmission also requires that the receiver knows when the
actual data bits are arriving so that it can synchronize itself to the incoming data
• To achieve this, a logic 0 is sent as a synchronization start bit
• A typical data frame for RS232 applications is shown below:
• The first bit is the start bit, followed by data bits (may be 5, 6, 7 or 8 bits and the
least significant bit is sent out first), parity bit (even, odd or none) followed by a
stop bit
• Following the stop bit is 1, 1.5 or two stop bits to indicate that a frame is
complete, before the next frame can be sent
6
• There is a relationship between speed of data transmission and length of cable
connecting two devices using RS232 standard
• The table below shows the relationship between transmission speed (baud-rate
in bits per second) and cable length in metres for the RS232 standard:
7
• In the past, PCs used to have two COM ports (COM1 and COM2), which were
RS232-type connectors
• In recent years, COM ports have been replaced with USB ports
• A Serial(COM)-to-USB converter is used to connect a microcontroller serial port to
the USB port of a PC
• The Arduino Uno board has on-board Serial-to-USB converter and connects
directly to USB ports
• A microcontroller uses TTL voltage levels (e.g., logic 1 = +5V and logic 0 = 0V)
• Since the RS232 is not TTL compatible, to connect any RS232 to a microcontroller,
a voltage converter such as a MAX232 is used
• A MAX232 converts TTL logic levels to RS232 voltage levels and vice versa
• A MAX232 chip is referred to as a line driver
8
MAX232
• The ATmega328P pins, TXD and RXD, PD0 and PD1, are TTL compatible, and,
therefore require a line driver (voltage converter) to make them RS232
compatible
• The MAX232 converts RS232 voltage levels to TTL voltage levels and vice versa
• The MAX232 uses a +5V voltage power supply, which can also power the AVR
• A MAX232 IC and details are shown in the next slide:
9
10
• A circuit which could be used to connect an AVR to a DB9 (RS232) connector via a
MAX232 level converter is shown below:
11
• The pins used in the circuit are explained as follows:
DB9 (RS232):
o Pin 2 (Rx) - receives an RS232 voltage level from MAX232 Pin 14
o Pin 3 (Tx) - sends out an RS232 voltage level to MAX232 Pin 13
o Pin 5 (Gnd)
MAX232
o Pin 14 (T1out) - sends out an RS232 voltage level (Pin 11 TTL voltage level converted) to Rx (DB9)
o Pin 13 (R1in) - receives an RS232 voltage level from Tx (DB9)
o Pin 12 (R1out) - sends out a TTL voltage level (Pin 13 RS232 voltage level converted) to RXD (AVR)
o Pin 11 (T1in) - receives a TTL voltage level from TXD (AVR)
12
RS422 Standard
• The RS422 standard is designed to be tolerant of noise over long cable runs
• It achieves this by using differential signaling, which has high immunity to noise
• The RS422 standard allows reliable serial data communication for:
o Distances of up to 1200 metres
o Data rates of up to 10 Mb/s
• Each signal uses two wires to pass the data as shown below:
• The line voltages are -2V to -6V for logic 1 and +2V to +6V for logic 0
• The line driver for the RS422 interface produces a 5V differential voltage on two wires
(two wires are needed to transmit each signal – logic 0 or logic 1)
13
• For logic 0, the voltage on A is greater than on B (A > B) and vice versa for logic 1
(A < B): if A > B the value is logic 0 and if A < B the value is logic1
• RS422 networks can be used in full-duplex or half-duplex modes, but are often
used in half-duplex mode
• One line driver can drive up to 10 receivers (multi-drop) as shown below:
14
• The host is the master and the devices are the slaves
• The master can transmit to slaves and a slave can transmit to the master
• The master is responsible for initiating communication
15
• In order to prevent signal reflection, termination resistors are used to match the
impedance of the receive and transmit nodes, as shown below:
16
RS485 Standard
• The RS485 is similar to RS422 in that it uses differential transmission (same line
voltages of -2V to -6V for logic 1, +2V to +6V for logic 0 and a 5V differential voltage on
two wires)
• However, it allows reliable serial data communication for:
o Distances of up to 1200m (same as RS422)
o Data rated of up to 10 Mbps (same as RS422)
o Up to 32 line drivers per on the same line
o Up to 32 receivers permitted on the same line
• RS485 is generally a 2-wire half duplex system (three wires are required and turns are
taken in transmitting data)
17
• The half-duplex system is shown below:
18
• A 120 Ohm resistor must be used to terminate the main line as shown below:
19
• The detailed RS485 two-wire system is shown below:
21
• The detailed RS485 four-wire system is shown below: