The text of a manual · part 21 of 68
DL405 User Manual: Chapter 4: System Design and Configuration, pages 165 to 172
Pages 165 to 172 of 608, from DL405 User Manual
The original document is the PDF (8.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the AutomationDirect D4-08B-1, AutomationDirect D4-08ND3S, AutomationDirect D4-16TA, PLC Direct D4-16TD2, AutomationDirect D4-32ND3-1, Konnect-It D4-08B-1, Koyo D4-08B-1, Konnect-It D4-08ND3S, and 6 more models
Page 165
System Design and Configuration If Your MODBUS Host Software Requires an Address ONLY
4--25
Some host software does not allow you to specify the MODBUS data type and address. Instead, you specify an address only. This method requires another step to determine the address, but it’s still fairly simple. Basically, MODBUS also separates the data types by address ranges as well. So this means an address alone can actually describe the type of data and location. This is often referred to as “adding the offset”. One important thing to remember here is that two different addressing modes may be available in your host software package. These are: S 484 Mode S 584/984 Mode We recommend that you use the 584/984 addressing mode if your host software allows you to choose. This is because the 584/984 mode allows access to a higher number of memory locations within each data type. If your software only supports 484 mode, then there may be some PLC memory locations that will be unavailable. The actual equation used to calculate the address depends on the type of PLC data you are using. The PLC memory types are split into two categories for this purpose. S Discrete -- X, GX, SP, Y, CR, S, T (contacts), C (contacts) S Word -- V, Timer current value, Counter current value In either case, you basically just convert the PLC octal address to decimal and add the appropriate MODBUS addresses (as required). The table below shows the exact equation used for each group of data. DISCRETE DATA TYPES
Memory Type Global Inputs (GX)
PLC Range (Octal) GX0
GX1746
GX1747 --
GX3777
Inputs (X)
X0
--
Special Relays (SP)
SP0
Global Outputs (GY)
1001
--
1999
Address (584/984 Mode)
Data Type
10001
--
10999
Input
------
11000
--
12048
Input
X1777
------
12049
--
13072
Input
--
SP777
------
13073
--
13584
Input
GY0
--
GY3777
Outputs (Y)
Y0
--
Control Relays (CR)
C0
Timer Contacts (T)
1
--
2048
1
--
2048
Output
Y1777
2049
--
3072
2049
--
3072
Output
--
C3777
3073
--
5120
3073
--
5120
Output
T0
--
T377
6145
--
6400
6145
--
6400
Output
Counter Contacts (CT)
CT0
--
CT377
6401
--
6656
6401
--
6656
Output
Stage Status Bits (S)
S0
--
S1777
5121
--
6144
5121
--
6144
Output
DL405 User Manual, 4th Edtition
System Design and Configuration
--
Address (484 Mode)
Page 166
4--26
System Design and Configuration
WORD DATA TYPES PLC Range (Octal)
Registers
Input/Holding (484 Mode)*
Input/Holding (585/984 Mode)*
V--memory (Timers)
V0
--
V377
3001/4001
30001/40001
V--memory (Counters)
V1000
--
V1177
3513/4513
30513/40513
V--memory (Data Words)
V1200
-- V1377
3641/4641
30641/40641
V--memory (Data Words)
V1400
-- V1746
3769/4769
30769/40769
V--memory (Data Words)
V1747
-- V1777
------
31000/41000
V--memory (Data Words)
V2000
-- V7377
------
41025
V--memory (Data Words)
V10000 -- V17777
------
44097
*MODBUS: Function 04 (New feature) The DL450 will support function 04 read input register (Address 30001). To use function 04, put the number ’4’ into the most significant position (4xxx). Four digits must be entered for the instruction to work properly with this mode. LD K101 LD K4128 LDA O4000
The Maximum constant possible is 4128. This is due to the 128 maximum number of Bytes that the RX/WX instruction can allow. The value of 4 in the most significant position of the word will cause the RX to use function 04 (30001 range).
System Design and Configuration
RX Y0
1. Refer to the Memory Mapping section of this manual for the correct memory mapping size. Some of the addresses shown above might not pertain to your CPU. 2. For an automated MODBUS/Koyo address conversion utility, download the file modbus_conversion.xls from our website, www.automationdirect.com.
DL405 User Manual, 4th Edition
Page 167
System Design and Configuration
4--27
Example 1: V2100 584/984 Mode
Find the MODBUS address for User V location V2100. 1. Find V--memory in the table. 2. Convert V2100 into decimal (1088). 3. Add the MODBUS starting address for the mode (40001).
Example 2: Y20 584/984 Mode
Find the MODBUS address for output Y20. PLC Addr. (Dec) + Start Address + Mode 1. Find Y outputs in the table. Y20 = 16 decimal 2. Convert Y20 into decimal (16). 16 + 2048 + 1 = 2065 3. Add the starting address for the range (2048). 4. Add the MODBUS address for the mode (1).
Example 3: T10 Current Value 484 Mode
Find the MODBUS address to obtain the current value from Timer T10. 1. Find Timer Current Values in the table. 2. Convert T10 into decimal (8). 3. Add the MODBUS starting address for the mode (3001).
Example 4: C54 584/984 Mode
Find the MODBUS address for Control Relay PLC Addr. (Dec) + Start Address + Mode C54. C54 = 44 decimal 1. Find Control Relays in the table. 44 + 3072 + 1 = 3117 2. Convert C54 into decimal (44). 3. Add the starting address for the range (3072). 4. Add the MODBUS address for the mode (1).
PLC Address (Dec.) + Mode Address V2100 = 1088 decimal 1088 + 40001 = 41089
PLC Address (Dec.) + Mode Address TA10 = 8 decimal 8 + 3001 = 3009
System Design and Configuration
DL405 User Manual, 4th Edtition
Page 168
4--28
System Design and Configuration
Network Master Operation
430 440 450
This section describes how the DL450 can communicate on a MODBUS or DirectNET network as a master. For MODBUS networks, it uses the MODBUS RTU protocol, which must be interpreted by all the slaves on the network. Since MODBUS and DirectNET are master / slave networks, the master station must initiate requests for network data transfers. This section teaches you how to design the required ladder logic for network master operation. Master
Slave #1
Slave #2
Slave #3
System Design and Configuration
MODBUS RTU Protocol, or DirectNET
When using the DL450 CPU as the master station, you use simple RLL instructions to initiate the requests. The WX instruction initiates network write operations, and the RX instruction initiates network read operations. Before executing either the WX or RX commands, we will need to load data related to the read or write operation onto the CPU’s accumulator stack. When the WX or RX instruction executes, it uses the information on the stack combined with data in the instruction box to completely define the task, which goes to the port. It’s possible to use both Port 1 and Port 3 for either MODBUS or DirectNET, and to use either or both as masters. You must tell the WX and RX instructions the intended port for each communications transaction.
Master
Slave WX (write) RX (read) Network
Network 1 Network 2
To summarize, the RLL instructions identify the following items. 1. Port number on the master (Port 1 or 3), and the slave station address. (LD instruction) 2. Amount of data (in bytes) you want to transfer. (LD instruction) 3. Area of memory to be used by the master. (LDA instruction) 4. Area of CPU V-memory to be used in communication with the slave, and whether it is a write or read operation. (WX or RX instruction) 5. Interlocks for communication timing for multiple WX and RX routines.
DL405 User Manual, 4th Edition
Page 169
System Design and Configuration
Step 1: Identify Master Port # and Slave #
Step 2: Load Number of Bytes to Transfer
The first Load (LD) instruction identifies the communications port number on the network master (DL450) and the address of the slave station. This instruction can address up to 90 MODBUS slaves, or 90 DirectNET slaves. The format of the word is shown to the right. The “F” in the upper nibble tells the CPU the port is internal to the CPU (and not in a slot in the base). The second nibble indicates the port number, 1 or 3. The lower byte contains the slave address number in BCD (01 to 90). 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 instruction. The value to be loaded is in BCD format (decimal), from 1 to 128 bytes.
F
1
0
4--29
1
Slave address (BCD) Port number (BCD) Internal port (hex) LD KF101
1
2
8
(BCD)
# of bytes to transfer LD K128
The number of bytes specified also depends on the type of data you want to obtain. For example, the DL405 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. DL 205 / 405 Memory
Bytes
V--memory T / C current value
16 16
2 2
Inputs (X, GX, SP)
8
1
Outputs (Y, C, Stage, T/C bits)
8
1
Scratch Pad Memory
8
1
Diagnostic Status
8
1
Bits per unit
Bytes
Data registers T / C accumulator
8 16
1 2
I/O, internal relays, shift register bits, T/C bits, stage bits
1
1
Scratch Pad Memory
8
2
Diagnostic Status(5 word R/W)
16
10
DL305 Memory
DL405 User Manual, 4th Edtition
System Design and Configuration
Bits per unit
Page 170
4--30
System Design and Configuration
The third instruction in the RX or WX sequence is a Load Address (LDA) instruction. Its purpose is to load the starting address of the memory area to be transferred. Entered as an octal number, the LDA instruction converts it to hex and places the result in the accumulator. For a WX instruction, the DL450 CPU sends the number of bytes previously specified from its memory area beginning at the LDA address specified. For an RX instruction, the DL450 CPU reads the number of bytes previously specified from the slave, placing the received data into its memory area beginning at the LDA address specified.
Step 3: Specify Master Memory Area
4
0
6
0
0
(octal)
Starting address of master transfer area LDA O40600
MSB
V40600
LSB
15
0
MSB
V40601
LSB
15
0
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. The last instruction in our sequence is the WX or RX instruction itself. Use WX to write to the slave, and RX to read from the slave. All four of our instructions are shown to the right. In the last instruction, you must specify the starting address and a valid data type for the slave. The RX instruction reads data from the slave starting at the address specified. The WX instruction writes data to the slave starting at the address specified.
System Design and Configuration
Step 4: Specify Slave Memory Area
S S S
SP112
LD KF101 LD K128 LDA O40600 RX Y0
DirectNET slaves -- specify the same address in the WX and RX instruction as the slave’s native I/O address MODBUS DL405 or DL205 slaves -- specify the same address in the WX and RX instruction as the slave’s native I/O address MODBUS 305 slaves -- use the following table to convert DL305 addresses to MODBUS addresses
DL305 Series CPU Memory Type--to--DL405 Series CPU Memory PLC Memory type
305 base address
405 base addr.
PLC Memory Type
305 base address
405 base addr.
TMR/CNT Current Values
R600
V0
TMR/CNT Status Bits
CT600
GY600
I/O Points
IO 000
GY0
Control Relays
CR160
GY160
Data Registers
R401, R400
V100
Shift Registers
SR400
GY400
Stage Status Bits (D3--330P only)
S0
GY200
DL405 User Manual, 4th Edition
Page 171
4--31
System Design and Configuration
Communications from a Ladder Program
In some applications, the DL450 CPU as a network master will communicate only periodically to slaves(s) on the network. However, most applications will probably want to make a “continuous” update of memory areas from a slave to the master. This normally means starting the task on each PLC SCAN. However, a single WX or RX network communication will probably last longer than one PLC scan time. And we must wait before executing another RX or WX until the port has finished transmitting the previous WX or RX data.
Port Communication Error SP113
Y1 SET
SP112
LD KF101 LD K0003
Port Busy
LDA O40600 RX Y0
Each port which can be a master has two Special Relay contacts associated with it (see Appendix D for comm port special relays).One indicates “Port busy”, and the other indicates ”Port Communication Error”. The example above shows the use of these contacts for a network master that only reads a device (RX). The Port Busy contact ensures one network transaction finishes before we begin another. Use of the communication error SP relay is optional. If used, be sure to place it at the beginning of the communication routines, because a comm error relay is always reset (turned off) whenever an RX or WX instruction using the same port executes. Multiple Read and Write Interlocks
Interlocking Relay SP112 C100
LD KF101 LD K0003 LDA O40600
Interlocking Relay SP112 C100
RX Y0 C100 SET LD KF101 LD K0003 LDA O40400 WX Y0 C100 RST
DL405 User Manual, 4th Edtition
System Design and Configuration
If you’re using multiple reads and writes in the RLL program, you have to interlock the routines to make sure all the routines are executed. If you don’t use the interlocks, then the CPU will only execute the first routine. This is because each port can only handle one transaction at a time. In the example to the right, after the RX instruction is executed, C0 is set. When the port has finished the communication task, the second routine is executed and C0 is reset. If you’re using RLL PLUS Stage Programing, you can just put each routine in a separate program stage to ensure proper execution. In most cases, RLL PLUS is a much more efficient way to create an automation program. The DirectNET manual provides a master/slave example with both RLL and Stage program descriptions (they are easily adapted for use with MODBUS).