SerialPort Config
SerialPort Config
Communications K
In This Appendix...
Introduction to Serial Communications..................................................................... K-2
Appendix K: Introduction to Serial Communications
Wiring Standards
There are three different wiring standards that can be used with most of the DirectLOGIC
PLCs: RS-232C, RS-422 and RS-485. DL05 PLCs only support RS-232C, although RS-422/
RS-485 can be accomplished by using converters, such as the FA-ISOCON.
RS-232C is a point-to-point wiring standard with a practical wiring distance of 15 meters, or 50
feet, maximum. This means that only two devices can communicate on an RS-232C network,
a single master device and a single slave device, and the total cable length cannot exceed 50
feet. AutomationDirect L19772 cable (Belden® 8102), or equivalent, is recommended for
RS-232C networks.
Ports 1 and 2 on the DL05 use RJ12 phone type connectors (see pages 4-4 and 4-5 for the
cable connections).
Communications Protocols
A communications protocol is the ‘language’ the devices on a network use to communicate
with each other. All the devices on the network must use the same communications protocol in
order to be able to communicate with each other. The protocols available in the DirectLOGIC
DL05 PLCs are listed in the following table.
DL05 Communications Protocols
Protocol Master Slave Port 1* Port 2 RS-232C RS-422 RS-485
K-Sequence No Yes Yes Yes Yes No No
DirectNET Yes Yes Yes Yes Yes Yes** No
Modbus RTU Yes Yes Yes Yes Yes Yes** No
ASCII (Non-Sequence) Out No No Yes Yes Yes** No
* Port 1 supports slave only and is only RS-232C with fixed communications parameters of 9600 baud, 8 data bits, 1 start
bit, 1 stop bit, odd parity and station address 1. It is an asynchronous, half-duplex DTE port and auto-selects between
K-Sequence, DirectNET and Modbus RTU protocols.
** RS-422 is available on Port 2 using an RS-422 converter such as the FA-ISOCON.
K-Sequence protocol is not available for use by a master DL05 PLC. Therefore, it cannot
be used for networking between PLCs. Its primary use in the DL05 PLC is as a slave to
DirectSOFT programming software and to an operator interface.
DirectNET protocol is available for use by a master or by a slave DL05 PLC. This, and the fact
that it is ‘native’ protocol, makes it ideal for PLC-to-PLC communication over a point-to-point
or multipoint network using the RX and WX instructions.
Modbus RTU protocol is a very common industry standard protocol, and can be used by a
master or slave DL05 to communicate with a wide variety of industrial devices which support
this protocol.
ASCII (Non-Sequence) is another very common industry standard protocol, and is commonly
used where alpha-numeric character data is to be transferred. Many input devices, such as
barcode readers and electronic scales, use ASCII protocol. Many output devices accept ASCII
commands as well.
No matter which wiring standard or protocol is used, there are several communications
parameters to select for each device before it will be able to communicate. These parameters
include:
• Baud Rate • Flow Control
• Data Bits • Echo Suppression
• Parity • Timeouts
• Stop Bits • Delay Times
• Station Address • Format
All of these parameters may not be necessary, or available, for your application. The parameters
used will depend on the protocol being used and whether the device is a master or a slave.
NOTE: An important point to remember is that when the same parameter is available in the master and in
the slave (i.e. Baud Rate, Parity, Stop Bits, etc), the settings must match.
1 1
Top View
Note that the default configuration for port 2 is:
• Auto-detect among K-Sequence,DirectNET, and Modbus RTU protocols
• Timeout = Base Timeout x 1 (800 ms)
• RTS on delay time = 0 ms
• RTS off delay time = 0ms
• Station Number = 1
• Baud rate = 19200
• Stop bits = 1
• Parity = odd
• Format = Hex
In order to set up Port 2 in relay ladder logic the appropriate values must be written to V7655
(Word 1), V7656 (Word 2) and V7650 (Word 3, for ASCII only) to specify the settings for
the port. Then write the ‘setup complete’ flag (K0500) to V7657 (Word 4) to request the CPU
to accept the port settings. Once the CPU sees the ‘setup complete’ flag in V7657 it will test
the port settings for validity, and then change the value in V7657 to 0A00 (‘A’ for Accepted)
or if there was an error in the port settings, the CPU will change the value in V7657 to 0E00
(‘E’ for Error).
NOTE: This is a Helpful Hint. Rather than build the setup words manually from the tables, use DirectSOFT to
set up the port as desired then use a Dataview to view the setup words as BCD/HEX. Then simply use these
numbers in the setup code.
The data that is written to the port setup words has two formats. The format that is used
depends on whether K-Sequence, DirectNET, Modbus RTU (method 1) or ASCII (method
2) is selected.
_FirstScan
Use the ladder logic shown at right to set up port 2 for SP0
LD
Modbus protocol for the following: RTS On-delay of 10ms, K3022
Base timeout x1, RTS Off-delay of 5ms, Odd parity, 1 Stop
bit, 19,200 baud or Station Number 23. OUT
V7655
LD
K8617
OUT
V7656
LD
K500
OUT
V7657
V7656 (Word 2) Parity Data Bits Stop Bits Baud Rate Protocol Mode
ppsd 0bbb aaaa aaaa pp d s bbb aaaa aaaa
10 = Odd 1 = 7 bits 1 = 2 bits 001 = 600 0111 0001 = Xon/Xoff flow control
11 = Even 010 = 1200 0111 0010 = RTS flow control
0111 0011 = Xon/Xoff and
DL05/06 V7656 011 = 2400
RTS flow control
100 = 4800
101 = 9600
110 = 19200
111 = 38400
Hex value of the V-memory location to temporarily store the ASCII data coming into
DL05/06 the PLC.
Set this parameter to the start of a contiguous block of 64 unused words.
_FirstScan
Use the ladder logic shown at right to set up port 2 SP0
LD
for Non-sequence (ASCII) communications with the K3012
following: RTS On-delay of 10ms, Base timeout x1,
RTS Off-delay of 5ms, Odd parity, 1 Stop bit, 19,200 OUT
V7655
baud, 8 data bits, V-memory buffer starting at V2000
and no flow control. LD
K8670
OUT
V7656
LDA
O2000
OUT
V7650
LD
K500
OUT
V7657
K-Sequence Communications
The K-Sequence protocol can be used for communication with DirectSOFT, an operator
interface or any other device that can be a K-Sequence master. The DL05 PLC can be a
K-Sequence slave on either port 1 or port 2. The DL05 PLC cannot be a K-Sequence master.
In order to use port 2 for K-Sequence communications you first need to set up the port using
either DirectSOFT or ladder logic as previously described.
DirectNET Communications
The DirectNET protocol can be used to communicate to another PLC or to other devices that
can use the DirectNET protocol. The DL05 can be used as either a master using port 2 or a
slave using either port 1 or port 2.
In order to use port 2 for DirectNET communications you must first setup the port using
either DirectSOFT or ladder logic as previously described.
For network slave operation, nothing more needs to be done. Port 2 will function as a slave
unless network communications instructions are executed by the ladder logic program.
For a network master operation you will simply need to add some ladder rungs using the
network communication instructions RX and/or WX. Only one network communication
instruction should be executed at any given time. If you have just a few network communications
instructions in your program, you can use discrete bits to interlock them. If you are using many
network communications instructions, a counter or a shift register will be a more convenient
way to interlock the instructions.
The following step-by-step procedure will provide the information necessary to set up your
ladder program to receive data from a network slave.
The number of bytes specified also depends on the type of data you want to obtain. For
example, the DL05 Input points can be accessed by V-memory locations or as X input
locations. However, if you only want X0–X27, you’ll have to use the X input data type because
the V-memory locations can only be accessed in 2-byte increments. The following table shows
the byte ranges for the various types of DirectLOGIC products.
LDA
O40400
WX
VY0
C100
RST
http://support.automationdirect.com/technotes.html#plccomm
If more than one network communication instruction is used, the rungs need to be interlocked
to ensure that only one communication instruction is executed at any given time. If only a few
network communications instructions are used in your program, discrete bits can be used to
interlock them. If many network communications instructions are used, either a counter or a
shift register will be a more convenient way to interlock the instructions.