0% found this document useful (0 votes)
49 views13 pages

SerialPort Config

Direct Logic serialPort Configuración tecnica

Uploaded by

rodrigo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views13 pages

SerialPort Config

Direct Logic serialPort Configuración tecnica

Uploaded by

rodrigo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Introduction to Serial Appendix

Communications K
In This Appendix...
Introduction to Serial Communications..................................................................... K-2
Appendix K: Introduction to Serial Communications

Introduction to Serial Communications


DirectLOGIC® PLCs have two built-in serial communication ports which can be used
to communicate to other PLCs or to other serial devices. In order to fully understand the
capabilities and limitations of the serial ports, a brief introduction to serial communications is
in order.
There are three major components to any serial communications setup:
• Wiring standard
• Communications protocol
• Communications parameters
Each of these will be discussed in more detail as they apply to DirectLOGIC PLCs.

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).

K-2 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

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.

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-3
Appendix K: Introduction to Serial Communications

DL05 Port Specifications Communications Port 2


Connects to HPP, DirectSOFT 5, operator interfaces,
Communications Port 1 etc.
Connects to HPP, DirectSOFT 5, operator 6-pin, RS232C
interfaces, etc.
Communication speed (baud): 300, 600, 1200, 2400,
6-pin, RS232C 4800, 9600, 19200, 38400
Communication speed (baud): 9600 (fixed) Parity: odd (default), even, none
Parity: odd (fixed)
Port 2 Station Address: 1 (default)
Port 1 Station Address: 1 (fixed) 8 data bits
8 data bits 1 start, 1 stop bit
1 start, 1 stop bit Asynchronous, half-duplex, DTE
Asynchronous, half-duplex, DTE Protocol (auto-select): K-sequence (slave only),
Protocol (auto-select): K-sequence (slave only), DirectNET (master/slave), Modbus RTU (master/slave),
DirectNET (slave only), Modbus RTU (slave only) Non-Sequence/Print

Port 1 Pin Descriptions Port 2 Pin Descriptions


1 0V Power (-) connection (GND) 1 0V Power (-) connection (GND)
2 5V Power (+) connection 2 5V Power (+) connection
DL05 Port Pinouts 3 RXD Receive data (RS-232C) 3 RXD Receive data (RS-232C)
4 TXD Transmit data (RS-232C) 4 TXD Transmit data (RS-232C)
5 5V Power (+) connection 5 RTS Request to send (RS-232C)
6 0V Power (-) connection (GND) 6 CTS Power (-) connection (GND)

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

K-4 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

Port Setup Using DirectSOFT or Ladder Logic Instructions


Port 2 on the DL05 can be configured for communications using the various protocols which
have been previously mentioned. Also, the communications parameters can be configured
to match the parameters in the other device(s) with which the PLC will be communicating.
The port may be configured using the DirectSOFT PLC programming software, or by using
ladder logic within the PLC program. It is important to note that the settings for Port 2 are
never saved to disk with DirectSOFT, so if you are using Port 2 in other than its default
configuration it is a good idea to include the port setup in the ladder program, typically on a
first scan bit, or in an initialization subroutine.
To set up Port 2 using DirectSOFT, the PLC must be turned on and connected to DirectSOFT.
With the PLC Setup toolbar displayed, select the Port 2 button or select PLC > Setup > Setup
Sec. Comm Port... from the menu bar located at the top of the programming window. A
dialog box like the one below will appear. Make the appropriate settings and write them to the
PLC.

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.

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-5
Appendix K: Introduction to Serial Communications

Port 2 Setup for RLL Using K-Sequence, DirectNET or Modbus RTU


Timeout
V7655 (Word 1) RTS On-delay Protocol RTS Off-delay
(% of timeout)
0yyy 0ttt mmmm mxxx yyy ttt mmmmm xxx
000 = 0ms 000 = 100% 10000 = K-Sequence 000 = 0ms
001 = 2ms 001 = 120% 01000 = DirectNET 001 = 2ms
010 = 5ms 010 = 150% 00100 = Modbus RTU 010 = 5ms
011 = 10ms 011 = 200% 011 = 10ms
100 = 20ms 100 = 500% 100 = 20ms
101 = 50ms 101 = 1000% 101 = 50ms
110 = 100ms 110 = 2000% 110 = 100ms
111 = 500ms 111 = 5000% 111 = 500ms

V7656 (Word 2) Parity Stop Bits Baud Rate


pps0 0bbb xaaa aaaa pp s bbb
00 = None 0 = 1 bit 000 = 300
10 = Odd 1 = 2 bits 001 = 600
11 = Even 010 = 1200
011 = 2400
100 = 4800
101 = 9600
110 = 19200
111 = 38400

V7656 (Word 2) cont’d Protocol Port 2 Address


K-Sequence, DirectNET (DirectNET) DirectNET and
& Modbus RTU Modbus RTU
pps0 0bbb xaaa aaaa x aaaaaaa
0 = Hex DirectNET: 1-90
1 = ASCII Modbus RTU: 1-247

V7650 (Word 3) V-memory Address for Data


DL05/DL06 For Non-Sequence (ASCII) only
V7657 (Word 4) Setup and Completion Code
Write K0500 to accept Port 2 setup.
DL05/DL06 When PLC accepts the changes, it changes the value to K0A00 in the same location.
If there is an error it changes the value to K0E00 in the same location.

K-6 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

_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

Port 2 Setup for RLL Using ASCII (Non-Sequence)


Timeout
V7655 (Word 1) RTS On-delay Protocol RTS Off-delay
(in% of std. timeout)
0yyy 0ttt mmmm mxxx yyy ttt mmmmm xxx
000 = 0ms 000 = Base timeout 00010 = Non-Sequence 000 = 0ms
001 = 2ms 001 = Base timeout + 2ms 001 = 2ms
010 = 5ms 010 = Base timeout + 5ms 010 = 5ms
011 = 10ms 011 = Base timeout + 10ms 011 = 10ms
DL05/06 V7655
100 = 20ms 100 = Base timeout + 20ms 100 = 20ms
101 = 50ms 101 = Base timeout + 50ms 101 = 50ms
110 = 100ms 110 = Base timeout + 100ms 110 = 100ms
111 = 500ms 111 = Base timeout + 500ms 111 = 500ms

Port 2 Setup for RLL Using K-Sequence, DirectNET or Modbus RTU

V7656 (Word 2) Parity Data Bits Stop Bits Baud Rate Protocol Mode
ppsd 0bbb aaaa aaaa pp d s bbb aaaa aaaa

00 = None 0 = 8 bits 0 = 1 bit 000 = 300 0111 0000 = No flow control

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

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-7
Appendix K: Introduction to Serial Communications

V7650 (Word 3) V-memory address for data

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.

V7657 (Word 4) Setup and Completion Code

Write K0500 to to accept Port 2 setup.


DL05/06 When PLC accepts the changes, it changes the value to K0A00 in the same location.
If there is an error it changes the value to K0E00 in the same location.

_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-8 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

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.

Step 1: Identify Master Port # and Slave # F 2 0 1


The first Load (LD) instruction identifies the
communications port number on the network master
(DL05) and the address of the slave station. This Slave address (BCD)
instruction can address up to 99 Modbus slaves, or 90 Port number (BCD)
DirectNET slaves. The format of the word is shown Internal port (hex)
to the right. The “F2” in the upper byte indicates the
use of the port on the right on the DL05 PLC, port LD
number 2. The lower byte contains the slave address KF201
number in BCD (01 to 99).

Step 2: Load Number of Bytes to Transfer 6 4 (BCD)


The second Load (LD) instruction determines the
number of bytes which will be transferred between
the master and slave in the subsequent WX or RX # of bytes to transfer
instruction. The value to be loaded is in BCD format
(decimal), from 1 to 128 bytes. LD
K64

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-9
Appendix K: Introduction to Serial Communications

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.

DL05 Memory Bits per unit Bytes


V-memory 16 2
T / C current value 16 2
Inputs (X, SP) 8 1
Outputs 8 1
(Y, C, Stage, T/C bits)
Scratch Pad Memory 8 1
Diagnostic Status 8 1

Step 3: Specify Master Memory Area 4 0 6 0 0 (octal)


The third instruction in the RX or WX sequence is
a Load Address (LDA) instruction. Its purpose is to
Starting address of
load the starting address of the memory area to be master transfer area
transferred. Entered as an octal number, the LDA
instruction converts it to hex and places the result in
LDA
the accumulator. O40600
For a WX instruction, the DL05 CPU sends
the number of bytes previously specified from MSB V40600 LSB
its memory area beginning at the LDA address
specified. 15 0
For an RX instruction, the DL05 CPU reads the MSB V40601 LSB
number of bytes previously specified from the slave,
placing the received data into its memory area 15 0
beginning at the LDA address specified.
NOTE: Since V-memory words are always 16 bits, you may not always use the whole word. For example, if
you only specify 3 bytes and you are reading Y outputs from the slave, you will only get 24 bits of data. In
this case, only the 8 least significant bits of the last word location will be modified. The remaining 8 bits are
not affected.

K-10 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

Step 4: Specify Slave Memory Area


The last instruction in our sequence is the WX or RX SP116
instruction itself. Use WX to write to the slave, and RX LD
to read from the slave. All four of our instructions are KF201
shown to the right. In the last instruction, you must LD
specify the starting address and a valid data type for K64
the slave.
LDA
• DirectNET slaves – specify the same address in the O40600
WX and RX instruction as the slave’s native I/O
address RX
• Modbus DL05 slaves – specify the same address Y0
in the WX and RX instruction as the slave’s native
I/O address

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-11
Appendix K: Introduction to Serial Communications

Communications from a Ladder Program


Typically network SP117 Y1
communications will last longer SET
than 1 scan. The program must
SP116
wait for the communications to LD
finish before starting the next KF201
Port Communication Error
transaction. LD
Port Busy K0003
Port 2, which can be a master,
has two Special Relay contacts LDA
associated with it (see Appendix O40600
D for comm port special
relays). One indicates “Port RX
Y0
busy”(SP116), and the other
indicates ”Port Communication Error”(SP117). The example above shows the use of these
contacts for a network master that only reads a device (RX). The “Port Busy” bit is on while
the PLC communicates with the slave. When the bit is off the program can initiate the next
network request.
The “Port Communication Error” bit turns on when the PLC has detected an error. Use of this
bit is optional. When used, it should be ahead of any network instruction boxes since the error
bit is reset when an RX or WX instruction is executed.
Interlocking Relay
Multiple Read and Write Interlocks SP116 C100
If you are using multiple reads and writes in the RLL LD
KF201
program, you have to interlock the routines to make sure
all the routines are executed. If you don’t use the interlocks, LD
K0003
then the CPU will only execute the first routine. This is
because each port can only handle one transaction at a time. LDA
O40600
In the example to the right, after the RX instruction
is executed, C100 is set. When the port has finished the RX
communication task, the second routine is executed and Interlocking VY0
C100 is reset. Relay C100
If you’re using RLLPLUS Stage Programming, you can put SET
each routine in a separate program stage to ensure proper SP116 C100
LD
execution and switch from stage to stage allowing only one KF201
of them to be active at a time.
LD
K0003

LDA
O40400

WX
VY0

C100
RST

K-12 DL05 Micro PLC User Manual, 6th Edition, Rev. E


Appendix K: Introduction to Serial Communications

Modbus RTU Communications


The Modbus RTU protocol can be used for communication with any device that uses the
Modbus RTU protocol. The protocol is very common and is probably the closest thing to an
“industry standard” protocol in existence. The DL05 can be a Modbus RTU slave on either
port 1 or port 2, and it can be a Modbus RTU master on port 2.
In order to use port 2 for Modbus RTU communications you must first set up 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 Modbus network master operations RX and/or WX instructions must be added to the
program. Modbus addresses can be calculated using the Excel spreadsheet, application note
AN-MISC-010. This application note is located in the Technical Notes PLC Hardware
Communications section of our website found here:

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.

DL05 Micro PLC User Manual, 6th Edition, Rev. E


K-13

You might also like