The text of a manual · part 44 of 60
DL205 PLC User Manual, Volume 1 of 2, pages 431 to 440
Pages 431 to 440 of 598
The original document is the PDF (12 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 D2-04TD1, AutomationDirect D2-08TD2, AutomationDirect D2-16ND3-2, AutomationDirect D2-32ND3, Konnect-It D2-04TD1, Koyo D2-04TD1, Konnect-It D2-08TD2, Koyo D2-08TD2, and 5 more models
Page 431
Chapter 5: Standard RLL Instructions
MRX Number of Elements
1 2 3 MRX Exception Response Buffer 4 Exception Response Buffer Operand Data Type DL260 Range 5 6 MRX Example DL260 port 2 has two Special Relay contacts associated with it (see Appendix D for comm 7 port special relays). One indicates “Port busy” (SP116), and the other indicates ”Port Communication Error” (SP117). The “Port Busy” bit is on while the PLC communicates 8 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 9 is reset when an MRX or MWX instruction is executed. Typically, network communications will last longer than one CPU scan. The program must 10 wait for the communications to finish before starting the next transaction. 11 12 13 14 A B C D Number of Elements
Operand Data Type
DL260 Range
V-memory
V
Constant
K
V-memory
V
All (see page 3-56) Bits: 1-2000 Registers: 1-125
All (see page 3-56)
This rung does a Modbus read from the first 32 coils of slave address number one. It will place the value into 32 bits of the master starting at C0.
1
Port 2 Busy Bit
Instruction Interlock Bit
SP116
C100
MRX
CPU CPU/DCM Slot: K2 Port Number: K1 Slave Address: 01 - Read Coil Status Function Code: K1 Start Slave Memory Address: C0 Start Master Memory Address: K32 Number of Elements: 584/984 Mode Modbus Data Type: V400 Exception Response Buffer: Instruction Interlock Bit C100
RST
DL205 User Manual, 4th Edition, Rev. D
5-207
Page 432
Chapter 5: Standard RLL Instructions
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
The Modbus Write to Network (MWX) instruction is used to write a block of data from the network master’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.
DS Used HPP N/A
5-208
•P ort Number: must be DL260 Port 2 (K2) •S lave Address: specify a slave station address (0 to 247) •F unction Code: The following Modbus function codes are supported by the MWX instruction: 05 – Force Single coil 06 – Preset Single Register 15 – Force Multiple Coils 16 – Preset Multiple Registers •S tart Slave Memory Address: specifies the starting slave memory address where the data will be written •S tart Master Memory Address: specifies the starting address of the data in the master that is to be written to the slave •N umber 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 •M odbus Data Format: specifies Modbus 584/984 or 484 data format to be used
DL205 User Manual, 4th Edition, Rev. D
Page 433
Chapter 5: Standard RLL Instructions •E xception Response Buffer: specifies the master memory address where the Exception Response will be placed (6-bytes in length). See the table on the following page. The exception response buffer uses 3 words. These bytes are swapped in the MRX/MWX exception response buffer V-memory so: V-Memory 1 Hi Byte = Function Code Byte (Most Significant Bit Set) V-Memory 1 Lo Byte = Address Byte V-Memory 2 Hi Byte = One of the CRC Bytes V-Memory 2 Lo Byte = Exception Code V-Memory 3 Hi Byte = 0 V-Memory 3 Lo Byte = Other CRC Byte
MWX Slave Memory Address MWX Slave Address Ranges Function Code
Modbus Data Format
05 - Force Sinlge Coil 05 - Force Single Coil 06 - Preset Single Register
484 Mode 584/984 Mode 484 Mode
06 - Preset Single Register
584/984 Mode
15 - Force Multiple Coils 15 - Force Multiple Coils 16 - Preset Multiple Registers
484 Mode 584/984 Mode 484 Mode
16 - Preset Multiple Registers
584/984 Mode
Slave Address Range(s) 1-999 1-65535 4001-4999 40001-49999 (5 digit) or 400001-465535 (6 digit) 1-999 1-65535 4001-4999 40001-49999 (5 digit) or 4000001-465535 (6 digit)
MWX Master Memory Addresses MWX Master Memory Address Ranges Operand Data Type Inputs Outputs Control Relays Stage Bits Timer Bits Counter Bits Special Relays V-memory Global Inputs Global Outputs
DL260 Range 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 (see page 3-56) 0-3777 0-3777
DL205 User Manual, 4th Edition, Rev. D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5-209
Page 434
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-210
MWX Number of Elements Number of Elements Operand Data Type V-memory
V
Constant
K
DL260 Range all (see page 3-56) Bits: 1-2000 Registers: 1-125
MWX Exception Response Buffer Exception Response Buffer Operand Data Type V-memory
V
DL260 Range all (see page 3-56)
MWX Example DL260 port 2 has two Special Relay contacts associated with it (see Appendix D for comm port special relays). One indicates “Port busy” (SP116), and the other indicates ”Port Communication Error” (SP117). 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 MRX or MWX instruction is executed. Typically, network communications will last longer than one CPU scan. The program must wait for the communications to finish before starting the next transaction. This rung does a Modbus write to the first holding register 40001 of the slave address 1. It will write the values to V2000. This particular function code only writes to one register. Use Function Code 16 to write to multiple registers. Only one network instruction (WX, RX, MWX, MRX) can be enabled in each one scan. That is the reason for the interlock bits. For using many network instructions on the same port, look at using the shift register instruction. Port 2 Busy Bit
Instruction Interlock Bit
SP116
C100
1
MWX CPU CPU/DCM Slot: K2 Port Number: K1 Slave Address: 05 - Force Single Coil Function Code: 40001 Start Slave Memory Address: V2000 Start Master Memory Address: n/a Number of Elements: 584/984 Mode Modbus Data Type: V400 Exception Response Buffer: Instruction Interlock Bit C100
RST
DL205 User Manual, 4th Edition, Rev. D
Page 435
Chapter 5: Standard RLL Instructions
ASCII Instructions (DL260)
1 2 3 4 Reading ASCII Input Strings 5 There are several methods which the DL260 can use to read ASCII input strings: 1) A SCII IN (AIN) – This instruction configures port 2 for raw ASCII input strings with parameters such as fixed and variable length ASCII strings, termination characters, byte swapping options, and 6 instruction control bits. Use barcode scanners, weight scales, etc., to write raw ASCII input strings into port 2 based on the (AIN) instruction’s parameters. 7 2) embedded ASCII strings directly to V–memory from an external HMI or similar master device via a supported communications protocol using the CPU ports, H2–ECOM or D2–DCM 8 module. The AIN instruction is not used in this case. 3) a DL260 PLC is a master on a network, the Network Read instruction (RX) can be used to read embedded ASCII data from a slave device via a supported communications protocol using port 2, 9 H2–ECOM or D2–DCM module. The RX instruction places the data directly into V–memory. Writing ASCII Output Strings 10 The following instructions can be used to write ASCII output strings: 1) from V–memory (PRINTV) – Use this instruction to write raw ASCII strings out of port 2 11 to a display panel or a serial printer, etc. The instruction features the starting V–memory address, string length, byte swapping options, etc. When the instruction’s permissive bit is enabled, the 12 string is written to port 2. 2) to V–memory (VPRINT) – Use this instruction to create pre–coded ASCII strings in the PLC (i.e. alarm messages). When the instruction’s permissive bit is enabled, the message is loaded 13 into a pre–defined V–memory address location. Then use the PRINTV instruction to write the pre–coded ASCII string out of port 2. American, European and Asian Time/Date stamps are 14 supported. Additionally, if a DL260 PLC is a master on a network, the Network Write instruction (WX) A can be used to write embedded ASCII data to an HMI or slave device directly from V–memory via a supported communications protocol using port 2, H2–ECOM or D2–DCM module. B C D
230 240 250-1 260
DS Used HPP N/A
The DL260 CPU supports several instructions and methods that allow ASCII strings to be read into and written from the PLC communications ports. Specifically, port 2 on the DL260 can be used for either reading or writing raw ASCII strings, but cannot be used for both on the same CPU. The DL260 can also decipher ASCII embedded within a supported protocol (K–Sequence, DirectNET, Modbus, Ethernet) via the CPU ports, H2–ECOM or D2–DCM module. ASCII character tables and descriptions can be found at www.asciitable.com.
DL205 User Manual, 4th Edition, Rev. D
5-211
Page 436
Chapter 5: Standard RLL Instructions
Managing the ASCII Strings
The following instructions can be helpful in managing the ASCII strings within the CPU’s 1 V-memory: ASCII Find (AFIND) – Finds where a specific portion of the ASCII string is located in 2 continuous V-memory addresses. Forward and reverse searches are supported. ASCII Extract (AEX) – Extracts a specific portion (usually some data value) from the ASCII 3 find location or other known ASCII data location. Compare V-memory (CMPV) – This instruction is used to compare two blocks of 4 V-memory addresses and is usually used to detect a change in an ASCII string. Compared data types must be of the same format (i.e., BCD, ASCII, etc.). Swap Bytes (SWAPB) – usually used to swap V-memory bytes on ASCII data that was written 5 directly to V-memory from an external HMI or similar master device via a communications protocol. The AIN and AEX instructions have a built–in byte swap feature. 6 7 ASCII Input (AIN) The ASCII Input instruction allows the CPU to receive ASCII strings through the specified communications port and places the string into a series of specified V-memory registers. The 8
ASCII data can be received as a fixed number of bytes or as a variable length string with a termination character(s). Other features include Byte Swap preferences, Character
9 specified Timeout, and user-defined flag bits for Busy, Complete and Timeout Error. 10 11 12 13 14 A B C D 230 240
250-1 260
DS Used HPP N/A
5-212
DL205 User Manual, 4th Edition, Rev. D
Page 437
Chapter 5: Standard RLL Instructions AIN Fixed Length Configuration
1 •P ort Number: must be DL260 port 2 (K2). 2 • Destination: specifies where the ASCII string will be placed in V–memory. • Length: specifies the length, in bytes, of the fixed-length ASCII string the port will receive. • Timeout: if the amount of time between incoming ASCII characters exceeds the set 3 time, the specified Timeout Error bit will be set. No data will be stored at the Data Destination V– memory location. The bit will reset when the AIN instruction permissive bits are disabled. None 4 selection disables this feature. • Character Timeout: if the amount of time from when the AIN is enabled to the time the first character is received exceeds the set time, the specified First Character Timeout bit will be set. The 5 bit will reset when the AIN instruction permissive bits are disabled. None selection disables this feature. 6 • Swap: swaps the high–byte and low–byte within each V–memory register of the Fixed Length ASCII string. See the SWAPB instruction for details. 7 • Bit: is ON while the AIN instruction is receiving ASCII data. • Bit: is set once the ASCII data has been received for the specified fixed length and reset 8 when the AIN instruction permissive bits are disabled. • Timeout Error Bit: is set when the Character Timeout is exceed. See Character Timeout explanation above. 9 • Character Timeout Error Bit: is set when the First Character Timeout is exceeded. See First Character Timeout explanation above. 10 Parameter DL260 Range 11 12 13 Discrete Bit Flags Description 14 A B C D • Type: select fixed length based on the length of the ASCII string that will be sent to the CPU port.
Data Destination Fixed Length Bits: Busy, Complete, Timeout Error, Overflow
SP53 SP71 SP116 SP117
All V-memory (See page 3 -56) K1-128 C0-3777
On if the CPU cannot execute the instruction On when a value used by the instruction is invalid On when CPU port 2 is communicating with another device On when CPU port 2 has experienced a communication error
DL205 User Manual, 4th Edition, Rev. D
5-213
Page 438
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-214
AIN Fixed Length Examples Fixed Length example when the PLC is reading the port continuously and timing is not critical. Fixed Length example when character to character timing is critical.
DL205 User Manual, 4th Edition, Rev. D
Page 439
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 AIN Variable Length Configuration: 7 •L ength Type: select Variable Length if the ASCII string length followed by termination characters will vary in length. 8 • Number: must be DL260 port 2 (K2). •D ata Destination: specifies where the ASCII string will be placed in V–memory. 9 • Variable Length: specifies, in bytes, the maximum length of a Variable Length ASCII string the port will receive. • Timeout: if the amount of time between incoming ASCII characters exceeds the set 10 time, the Timeout Error bit will be set. No data will be stored at the Data Destination V–memory location. The Timeout Error bit will reset when the AIN instruction permissive bits are disabled. 11 None selection disables this feature. • Character Timeout: if the amount of time from when the AIN is enabled to the time the first character is received exceeds the set time, the specified First Character Timeout bit will be set. The 12 bit will reset when the AIN instruction permissive bits are disabled. None selection disables this feature. 13 • Swap: swaps the high–byte and low–byte within each V–memory register of the Varaible Length ASCII string. See the SWAPB instruction for details. 14 • Code Length: consists of either 1 or 2 characters. Refer to the ASCII table in Appendix G. A • Error Bit: is set when the ASCII data received exceeds the Maximum Variable Length specified. • Bit: is ON while the AIN instruction is receiving ASCII data. B • Bit: is set once the ASCII data has been received up to the termination code characters. It will be reset when the AIN instruction permissive bits are disabled. C • Timeout Error Bit: is set when the Character Timeout is exceed. See Character Timeout explanation above. D • Character Timeout Error Bit: is set when the First Character Timeout is exceeded. See First Character Timeout explanation above.
DL205 User Manual, 4th Edition, Rev. D
5-215
Page 440
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5-216
Parameter Data Destination Max. Variable Length Bits: Busy, Complete, Timeout Error, Overflow
DL260 Range All V-memory (See page 3-56) K1-128 C0-3777
AIN Variable Length Example AIN Variable Length example used to read barcodes on boxes (PE = photoelectric sensor).
DL205 User Manual, 4th Edition, Rev. D