You are on page 1of 4

9.

6 Data Communications/RS232
RS232 communications between PCs, modems etc. form part of an engineers life. The problem seems to arise when self built products need to be interfaced to the outside world. The permutations of 9 or 25 pins on a D connector and the software controlling communications are endless. A minimum interface can be 3 wires Ground, Transmit, and Receive but what to do with the remaining pins? The voltage levels are between 3 and 15 volts allowing plenty of leeway for both drivers and receivers. When connecting equipment with RS232 interfaces, it is important to know which is classified as the Data Controlling Equipment (DCE) and which is Data Terminal Equipment (DTE). Cables/Connectors 9 ways D Pin Function 1 2 3 4 5 6 7 8 9 Carrier Detect Receive Data Transmit Data Data Terminal Ready Ground Data Set Ready Request To Send Clear To Send Ring Indicator Data direction | | O O <> | O | |

Common Problems Result Garbled characters Lost data Double space Overwriting No display of characters Double characters Data Format Data sent via an RS232 interface follows a standard format. Start bits Stop bits Data bits Parity bits always 1 bit 1 or 2 bits 7 or 8 bits none if no error detection is required odd or even if error detection is required Possible reasons parity, speed, character length, stop bits flow control translation of carriage returns or line feeds translation of carriage returns or line feeds duplex operation duplex operation

DATA FORMAT: 8 DATA BITS, 1 STOP BIT

Parity Parity checking requires the addition of an extra bit to the data byte. The parity system may be either odd or even and both systems give the same level of error detection. In an odd parity system, the overall count of 1s in the combined data byte, plus parity bit, is odd. Thus, with an 8 bits data byte of 10101100 the parity bit would be set to 1. In an even parity system, the overall count of 1s in the combined data byte, plus parity bit, is even. Thus, with an 8 bits data byte of 10101100 the parity bit would be set to 0. If corruption of either data bytes or of the parity bit itself takes place, when the receiver carries out the parity check, the corruption will be recognized. In the event of more than one bit being corrupted, it is possible that the receiver will not recognize the problem, provided that the parity appears correct. So, parity checking is not a cast iron method of checking for transmission errors, but in practice, it provides a reasonable level of security in most systems. The parity system does not correct errors in itself; it only indicates that an error has occurred and it is up to the system software to react to the error state; in most systems this would result in a request for re-transmission of the data. The PICmicroMCU does not have on-chip parity testing or generation, so the function needs to be generated in software. This adds an overhead to the code generated which could have a knock on effect on execution times. Bit Rate Time Calculation As BAUD is bits per second, each data bit has a time of 1/(baud rate) This works out as 1200 baud = 833uS, 2400 baud = 416uS, 9600 baud = 104uS

ASCII Conversion Table

RS232 Handshaking

Typical Null Modem Connections

You might also like