The text of a manual · part 23 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 4: System Design and Configuration, pages 205 to 214
Pages 205 to 214 of 592, from DL205 PLC User Manual, Volume 1 of 2
The original document is the PDF (13 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 PLC Direct D2-08ND3 and Koyo D2-08ND3
Page 205
Chapter 4: System Design and Configuration
Network Master Operation
230 240 250-1 260
This section describes how the DL250–1 and DL260 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. Both Modbus and DirectNET are single master/multiple slave networks. The master is the only member of the network that can initiate requests on the network. This section teaches you how to design the required ladder logic for network master operation.
Master
Slave #1
Slave #2
Slave #3
Modbus RTU Protocol, or DirectNET
When using the DL250–1 or DL260 CPU as the master station, you use simple RLL Master instructions to initiate the requests. The WX instruction initiates network write operations, and the RX instruction initiates network read operations. Before executing Slave either the WX or RX commands, we will need to load data related to the read or WX (write) write operation onto the CPU’s accumulator stack. When the WX or RX RX (read) instruction executes, it uses the information Network on the stack combined with data in the instruction box to completely define the task, which goes to the port. The following step-by-step procedure will provide the information necessary to set up your ladder program to receive data from a network slave.
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
4–41
Page 206
Chapter 4: System Design and Configuration
Step 1: Identify Master Port # and Slave #
F
1
0
1
The first Load (LD) instruction identifies the 1 communications port number on the network master (DL250-1/260) and the address of the Slave Address (BCD) 2 slave station. This instruction can address up to CPU bottom port (BCD) 99 Modbus slaves, or 90 DirectNET slaves. The Internal port (hex) format of the word is shown to the right. The 3 “F1” in the upper byte indicates the use of the bottom port of the DL250-1/260 PLC, port 4 number 2. The lower byte contains the slave address number in BCD (01 to 99). 5 1 2 8 Step 2: Load Number of Bytes to Transfer The second Load (LD) instruction determines 6 the number of bytes which will be transferred # of bytes to transfer between the master and slave in the subsequent WX or RX instruction. The value to be loaded is 7 in BCD format (decimal), from 1 to 128 bytes. The number of bytes specified also depends on 8 the type of data you want to obtain. For example, the DL205 Input points can be accessed by V-memory locations or as X input locations. However, if you only want X0 – X27, you’ll have 9 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. 10 Bits per unit Bytes 11 V-memory DL205/405 Memory T / C current value 12 Inputs (X, SP) Outputs (Y, C, Stage, T/C bits) Pad Memory 13 Scratch Diagnostic Status 14 DL305 Memory Bits per unit Bytes registers A Data T / C accumulator I/O, internal relays, shift register bits, B T/C bits, stage bits Scratch Pad Memory C Diagnostic Status(5 word R/W) D LD KF101
LD K128
4–42
DL205 User Manual, 4th Edition, Rev. A
16 16 8 8 8 8
2 2 1 1 1 1
8 16
1 2
1
1
8 16
2 10
Page 207
Chapter 4: System Design and Configuration
Step 3: Specify Master Memory Area
4
0
6
0
0
1 Starting address of 2 master transfer area 3 4 V40600 MSB LSB 5 15 0 V40601 MSB LSB 6 15 0 7 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 8 this case, only the 8 least significant bits of the last word location will be modified. The remaining 8 bits are not affected. 9 Step 4: Specify Slave Memory Area 10 The last instruction in our sequence is the WX or SP116 RX instruction itself. Use WX to write to the slave, LD KF101 and RX to read from the slave. All four of our 11 instructions are shown to the right. In the last LD instruction, you must specify the starting address K128 12 and a valid data type for the slave. • DirectNET slaves – specify the same address in the LDA WX and RX instruction as the slave’s native I/O 13 O40600 address • Modbus DL405 or DL205 slaves – specify the same RX 14 address in the WX and RX instruction as the slave’s Y0 native I/O address A • Modbus 305 slaves – use the following table to convert DL305 addresses to Modbus addresses DL305 Series CPU Memory Type–to–Modbus Cross Reference B PLC Base Modbus PLC Memory PLC Base Modbus PLC Memory Type Address Base Address Type Address Base Address C TMR/CNT Current Values I/O Points D Data Registers 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 DL250-1/260 CPU sends the number of bytes previously specified from its memory area beginning at the LDA address specified. For an RX instruction, the DL250-1/260 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.
Stage Status Bits (D3-330P only)
R600
V0
IO 000 R401,R400 S0
GY0 V100 GY200
(octal)
LDA O40600
TMR/CNT Status Bits Control Relays Shift Registers
CT600
GY600
CR160 SR400
GY160 GY400
DL205 User Manual, 4th Edition, Rev. A
4–43
Page 208
Chapter 4: System Design and Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 4–44
Communications from a Ladder Program Typically, network communications will last Port Communication Error longer than one scan. The program must wait for the communications to finish before SP117 Y1 starting the next transaction. SET Port 2, which can be a master, has two SP116 Special Relay contacts associated with it. LD KF201 One indicates “Port busy”(SP116), and the other indicates ”Port Communication LD Port Busy Error”(SP117). The example above shows K3 the use of these contacts for a network master that only reads a device (RX). The LDA O40600 “Port Busy” bit is on while the PLC communicates with the slave. When the bit RX is off the program can initiate the next Y0 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.
Multiple Read and Write Interlocks If you are 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, C100 is set. When the port has finished the communication task, the second routine is executed and C100 is reset. If you’re using RLLPLUS Stage Programming, you can put each routine in a separate program stage to ensure proper execution and switch from stage to stage allowing only one of them to be active at a time.
Interlocking Relay SP116
C100
LD KF201 LD K3 LDA O40600
Interlocking Relay
SP116
C100
RX Y0 C100 SET LD KF201 LD K3 LDA O40400 WX VY0 C100 RST
DL205 User Manual, 4th Edition, Rev. A
Page 209
Chapter 4: System Design and Configuration
Network Modbus RTU Master Operation (DL260 only)
1 2 3 4 Master 5 6 Slave #1 Slave #2 Slave #3 7 8 Modbus RTU Protocol 9 Modbus Function Codes Supported The Modbus function code determines whether the access is a read or a write, and whether to 10 access a single data point or a group of them. The DL260 supports the Modbus function codes described below. 11 Modbus Function Code Function DL205 Data Types Available 12 13 14 A B C D This section describes how the DL260 can communicate on a Modbus RTU network as a
230 master using the MRX and MWX read/write instructions. These instructions allow you to 240 enter native Modbus addressing in your ladder logic program with no need to perform octal conversions. Modbus is a single master/multiple slave network. The master is the 250-1 toonlydecimal member of the network that can initiate requests on the network. This section teaches 260 you how to design the required ladder logic for network master operation.
01
Read a group of coils
02
Read a group of inputs
05
Set / Reset a single coil (slave only)
Y, C, T, CT
15
Set / Reset a group of coils
Y, C, T, CT
03, 04
Y, C, T, CT X, SP
Read a value from one or more registers
V
06
Write a value into a single register (slave only)
V
07
Read Exception Status
V
08
Diagnostics
V
16
Write a value into a group of registers
V
DL205 User Manual, 4th Edition, Rev. A
4–45
Page 210
Chapter 4: System Design and Configuration
1
2
3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Modbus Port Configuration In DirectSOFT, choose the PLC menu, then Setup, then “Secondary Comm Port”. 230
• Port: From the port number list box at the top, choose “Port 2”.
240
• Protocol: Click the check box to the left of “MODBUS” (use AUX 56 on the HPP, and select “MBUS”), and then you’ll see the dialog box below.
250-1 260
• Timeout: Amount of time the port will wait after it sends a message to get a response before logging an error.
• RTS On Delay Time: The amount of time between raising the RTS line and sending the data. • RTS Off Delay Time: The amount of time between resetting the RTS line after sending the data. • Station Number: For making the CPU port a Modbus master, choose “1”. The possible range for Modbus slave numbers is from 1 to 247. Each slave must have a unique number. At powerup, the port is automatically a slave, unless and until the DL06 executes ladder logic MWX/MRX network instructions which use the port as a master. Thereafter, the port reverts back to slave mode until ladder logic uses the port again. • Baud Rate: The available baud rates include 300, 600, 900, 2400, 4800, 9600, 19200, and 38400 baud. Choose a higher baud rate initially, reverting to lower baud rates if you experience data errors or noise problems on the network. Important: You must configure the baud rates of all devices on the network to the same value. Refer to the appropriate product manual for details. • Stop Bits: Choose 1 or 2 stop bits for use in the protocol. • Parity: Choose none, even, or odd parity for error checking. • Echo Suppression: Select the appropriate radio button based on the wiring configuration used on port 2.
Then click the button indicated to send the Port configuration to the CPU, and click Close.
4–46
DL205 User Manual, 4th Edition, Rev. A
Page 211
Chapter 4: System Design and Configuration
RS–485 Network (Modbus only) RS–485 signals are for longer distances (1000 meters max.), and for multi-drop networks.
230 Use termination resistors at both ends of RS–485 network wiring, matching the impedance 240 rating of the cable (between 100 and 500 ohms). 250-1 260 Termination Resistor
TXD+ / RXD+
TXD+ / RXD+
TXD+ / RXD+
TXD– / RXD– Signal GND
6
11
1
RTS+ TXD+
RTS–
RXD+
RTS–
RXD+
Cable: Use Belden 9842 or equivalent
CTS+
CTS+ CTS–
CTS–
15
5
11 7
0V
RTS+ TXD+
RXD–
1
7
0V
Signal GND
Signal GND
RXD–
6
TXD– / RXD–
TXD– / RXD–
5 10
10
15 TXD–
TXD–
DL260 CPU Port 2
DL260 CPU Port 2
RS–232 Network Normally, the RS–232 signals are used for shorter distances (15 meters max), for communications between two devices. Port 2 Pin Descriptions (DL260 only)
6 1 GND RXD TXD CTS RTS
ASCII Device
11
Signal GND
7 2
TXD RXD
3 4
RTS CTS
5
10
15
CPU Port 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
5V TXD2 RXD2 RTS2 CTS2 RXD2– 0V 0V TXD2+ TXD2 – RTS2 + RTS2 – RXD2 + CTS2 + CTS2 –
5 VDC Transmit Data (RS-232) Receive Data (RS-232) Ready to Send (RS–232) Clear to Send (RS–232) Receive Data – (RS–422/RS-485) Logic Ground Logic Ground Transmit Data + (RS–422/RS–485) Transmit Data – (RS–422/RS–485) Request to Send + (RS–422/RS–485) Request to Send – (RS–422/RS–485) Receive Data + (RS–422/RS–485) Clear to Send + (RS422/RS–485) Clear to Send – (RS–422/RS–485)
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
4–47
Page 212
Chapter 4: System Design and Configuration
1 2
3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Modbus Read from Network (MRX) 230 240 250-1 260
4–48
The Modbus Read from Network (MRX) instruction is used by the DL260 network master to read a block of data from a connected slave device and to write the data into V–memory addresses within the master. The instruction allows the user to specify the Modbus Function Code, slave station address, starting master and slave memory addresses, number of elements to transfer, Modbus data format and the Exception Response Buffer.
• Port Number: must be DL260 Port 2 (K2) • Slave Address: specify a slave station address (1–247) • Function Code: The following Modbus function codes are supported by the MRX instruction: 01 – Read a group of coils 02 – Read a group of inputs 03 – Read holding registers 04 – Read input registers 07 – Read Exception status • Start Slave Memory Address: specifies the starting slave memory address of the data to be read. See the table on the following page. • Start Master Memory Address: specifies the starting memory address in the master where the data will be placed. See the table on the following page. • Number of Elements: specifies how many coils, input, holding registers or input registers will be read. See the table on the following page. • Modbus Data Format: specifies Modbus 584/984 or 484 data format to be used • Exception Response Buffer: specifies the master memory address where the Exception Response will be placed. See the table on the following page.
DL205 User Manual, 4th Edition, Rev. A
Page 213
Chapter 4: System Design and Configuration
MRX Slave Memory Address MRX Slave Address Ranges Function Code
Modbus Data Format
01 – Read Coil 01 – Read Coil 02 – Read Input Status
484 Mode 584/984 Mode 484 Mode
02 – Read Input Status
584/984 Mode
03 – Read Holding Register
484 Mode
03 – Read Holding Register
584/984
04 – Read Input Register
484 Mode
04 – Read Input Register
584/984 Mode
07 – Read Exception Status
484 and 584/984 Mode
Slave Address Range(s) 1–999 1–65535 1001–1999 10001–19999 (5 digit) or 100001–165535 (6 digit) 4001–4999 40001–49999 (5 digit) or 4000001–465535 (6 digit) 3001–3999 30001–39999 (5 digit) or 3000001–365535 (6 digit) n/a
MRX Master Memory Addresses MRX Master Memory Address Ranges Operand Data Type
DL260 Range
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Control Relays . . . . . . . . . . . . . . . . . . . . . . . . . . . Stage Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Timer Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Counter Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Special Relays. . . . . . . . . . . . . . . . . . . . . . . . . . . . V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Global Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . Global Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . .
X Y C S T CT SP V GX GY
0–1777 0–1777 0–3777 0–1777 0–377 0–377 0–777 All 0–3777 0–3777
MRX Number of Elements Number of Elements Operand Data Type
DL260 Range
V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
V K
All (see page 3-56) Bits:1–2000 Registers: 1-125
MRX Exception Response Buffer Exception Response Buffer Operand Data Type V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DL260 Range V
All (see page 3-56)
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 4–49
Page 214
Chapter 4: System Design and Configuration
1
2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Modbus Write to Network (MWX) 230 240 250-1 260
4–50
The Modbus Write to Network (MWX) instruction is used to write a block of data from the network masters’s (DL260) memory to Modbus memory addresses within a slave device on the network. The instruction allows the user to specify the Modbus Function Code, slave station address, starting master and slave memory addresses, number of elements to transfer, Modbus data format and the Exception Response Buffer.
• Port Number: must be DL260 Port 2 (K2) • Slave Address: specify a slave station address (0–247) • Function Code: The following Modbus function codes are supported by the MWX instruction: 05 – Force Single coil 06 – Preset Single Register 08 – Diagnostics 15 – Force Multiple Coils 16 – Preset Multiple Registers • Start Slave Memory Address: specifies the starting slave memory address where the data will be written. • Start Master Memory Address: specifies the starting address of the data in the master that is to written to the slave. • Number of Elements: specifies how many consecutive coils or registers will be written to. This field is only active when either function code 15 or 16 is selected. • Modbus Data Format: specifies Modbus 584/984 or 484 data format to be used. • Exception Response Buffer: specifies the master memory address where the Exception Response will be placed.
DL205 User Manual, 4th Edition, Rev. A