|Try our online PLC Simulator- FREE. Click here now to try it.|
Learn quickly with our PLC Training DVD Series: on sale
Click here now for details!
RS-232 Communications (hardware)
RS-232 communications is the most popular method of plc to external device communications. Let's tackle it piece by piece to see how simple it can be when we understand it.
RS-232 is an asynchronous (a marching band must be "in sync" with each other so that when one steps they all step. They are asynchronous in that they follow the band leader to keep their timing) communications method. We use a binary system (1's and 0's) to transmit our data in the ASCII format. (American Standard Code for Information Interchange- pronounced ASS-KEY) This code translates human readable code (letters/numbers) into "computer readable" code (1's and 0's). Our plcs serial port is used for transmission/reception of the data. It works by sending/receiving a voltage. A positive voltage is called a MARK and a negative voltage is called a SPACE. Typically, the plc works with +/- 15volts. The voltage between +/- 3 volts is generally not used and is considered noise.
There are 2 types of RS-232 devices. The first is called a DTE device. This means Data Terminal Equipment and a common example is a computer. The other type is called a DCE device. DCE means Data Communications Equipment and a common example is a modem. Your plc may be either a DTE or DCE device. Check your documentation.
The plc serial port works by turning some pins on while turning other off. These pins each are dedicated to a specific purpose. The serial port comes in 2 flavors-- a 25-pin type and a 9-pin type. The pins and their purposes are shown below. (This chart assumes your plc is a DTE device)
Each pins purpose in detail:
What happens when your plc and external device are both DTE (or both DCE) devices? They can't talk to each other, that's what happens. The picture below shows why 2 same type devices can't communicate with each other.
Notice that in the picture above, the receive data line (pin2) of the first device is connected to the receive data line of the second device. And the transmit data line (pin3) of the first device is connected to the transmit data of the second device. It's like talking through a phone with the wires reversed. (i.e. your mouth piece is connected directly to the other parties mouthpiece and your ear piece is connected directly to the other parties earpiece.) Obviously, this won't work well!
The solution is to use a null-modem connection as shown below. This is typically done by using a reverse (null-modem) cable to connect the devices.
To summarize everything, here's a typical communications session. Both devices are powered up. The plc is DTE and the external device is DCE.
The external device turns on DSR which tells the plc that's it's powered up and "there". The PLC turns on RTS which is like asking the external device "are you ready to receive some data?" The external device responds by turning on it's CTS which says it's ok to for the plc to send data. The plc sends the data on its TD terminal and the external device receives it on its RD terminal. Some data is sent and received. After a while, the external device can't process the data quick enough. So, it turns off its CTS terminal and the plc pauses sending data. The external device catches up and then turns its CTS terminal back on. The plc again starts sending data on its TD terminal and the external device receives it on its RD terminal. The plc runs out of data to send and turns off its RTS terminal. The external device sits and waits for more data.Learn quickly with our PLC Training DVD Series: on sale
Click here now for details!