31.4 SERIAL COMMUNICATIONS
Serial communication channels send data one bit at a time.
These techniques are often slower, but are essential when transmitting using radio waves, telephone lines, or similar media.
Serial lines have become one of the most common methods for transmitting data to instruments, and most personal computers now have two serial ports.
Serial data can be transmitted two ways,
asynchronous - the data bits arrive unannounced, without any coordination between sender and receiver. (this is the most common)
RS-485 - allows multiple talkers and listeners on one serial line (this can be the basis for a network)
A typical data byte looks like the one below. The voltage/current on the line is turned on/off. The width of the bits determines the possible bits per second (bps). The value shown before is used to transmit a single byte.
data - this byte could be 7 or 8 bits, but is almost always 8 now. The value shown here is 01001000 binary.
parity - this lets us check to see if the byte was sent properly. The most common choices here are no parity bit (just drop it out), or even parity, or odd parity. In this case there are two bits set. If we are using even parity the bit would be set. If we are using odd parity the bit would be off
Typical electrical connections look like,
31.4.1 RS-232
This standard is based on a high being +3 to +15V, and an off being -3 to -15V (+/-12V is commonly used).
The typical connection scheme is shown below. notice that the lines are crossed between connectors. Also note that in some cases the dsr/dtr lines are not used. (Note: these are the lines used when connecting to a modem)
DSR/DTR - (data set ready, data terminal ready) these handshaking lines indicate when the remote machine is ready to receive data.
A cable that emulates a modem connection between two devices is shown below and is called a null modem cable.
There are typically two connectors used for these devices. (Note: the connectors have very fine numbers on them)
The main pin assignments for the DB-25 are,
The pin assignments for the DB-9 are,
There are other settings such as half/full duplex.
When communicating between two devices the setting must agree baud rate, stop bits, parity, data bits, full/half duplex, etc.
The figure below shows a PLC connected to a data terminal with a serial line. This is followed by ladder logic to use the serial connection.
31.4.1.1 - ASCII Functions
ASCII functions can be used to interpret and manipulate strings in PLCs.
An example of this function is given below,
31.4.2 ASCII (American Standard Code for Information Interchange)
While numbers are well suited binary, characters don't naturally correspond to numbers. To overcome this a standard set of characters and controls were assigned to numbers. As a result, the letter `A' is readily recognized by most computers world-wide when they see the number 65.