Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 37 of 53

DL06 Micro PLC User Manual, Volume 1 of 2, pages 360 to 369

Pages 360 to 369 of 524

The original document is the PDF (6.4 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 Direct Logic DL06 and Koyo DL06 D0-06DD1

Page 360

Chapter 5: Standard RLL Instructions - MODBUS

MRX Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

DL06 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 1 CPU scan. The program must wait for the communications to finish before starting the next transaction. This rung does a MODBUS read from the first 32 coils of slave address number six. It will place the values into 32 bits of the master starting at C0.

X1

C100 SET

Port 2 busy bit SP116 4

5–206

Instruction Interlock bit C100

MRX CPU/DCM Slot: CPU Port Number: K2 Slave Address: K6 Function Code: 01 - Read Coil Status Start Slave Memory Address: 1 Start Master Memory Address C0 Number of Elements 32 Modbus Data type 584/984 Mode Exception Response buffer V400

Instruction Interlock bit C100 RST

See Chapter 4 “Network Master Operation (using MRX/MWX) Instructions)” for an RLL example using multiple Read and Write Interlocks.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

Page 361

Chapter 5: Standard RLL Instructions - MODBUS

MODBUS Write to Network (MWX) DS5

Used

HPP

N/A

The MODBUS Write to Network (MWX) instruction is used to write a block of data from the network masters’s (DL06) memory to MODBUS memory addresses within a slave device on the network. The instruction allows the user the 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. • CPU/DCM: select either CPU or DCM module for communications • Slot Number: select PLC option slot number if using DCM module • Port Number: must be K2 when using CPU port 2 • 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 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

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–207

Page 362

Chapter 5: Standard RLL Instructions - MODBUS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

MWX Slave Address Ranges MWX Slave Address Ranges Function Code

MODBUS Data Format

Slave Address Range(s)

05 – Force Single 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 585/984 Mode 484 Mode

16 – Preset Multiple Registers

584/984 Mode

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 Address Ranges

MWX Number of Elements

MWX Exception Response Buffer

5–208

MWX Master Memory Address Ranges Operand Data Type

DL06 Range

Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Y Control Relays . . . . . . . . . . . . . . . . . . . . . . . . . . C Stage Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . S Timer Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T Counter Bits . . . . . . . . . . . . . . . . . . . . . . . . . . CT Special Relays. . . . . . . . . . . . . . . . . . . . . . . . . SP V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . V Global Inputs . . . . . . . . . . . . . . . . . . . . . . . . . GX Global Outputs . . . . . . . . . . . . . . . . . . . . . . . . GY

0–1777 0–1777 0–3777 0–1777 0–377 0–377 0–777 all 0–3777 0–3777

Number of Elements Operand Data Type V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . V Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K

DL06 Range all Bits: 1–2000 Registers: 1–125

Number of Elements Operand Data Type V–memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

DL06 Micro PLC User Manual, 3rd Edition Rev. A

DL06 Range all

Page 363

Chapter 5: Standard RLL Instructions - MODBUS

MWX Example DL06 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 1 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 slave address number six. It will write the values over that reside in V2000. This particular function code only writes to 1 register. (Use Function Code 16 to write to multiple registers). Only one Network instruction (WX, RX, MWX, MRX) can be enabled in one scan. That is the reason for the interlock bits.

X1

C100

2

SET Port 2 busy bit SP116

3

Instruction Interlock bit C100

MWX CPU/DCM Slot: CPU Port Number: K2 Slave Address: K6 Function Code: 06-Preset Single Register Start Slave Memory Address: 40001 Start Master Memory Address: V2000 Number of Elements: n/a Modbus Data type: 584/984 Mode Exception Response Buffer: V400

Instruction Interlock bit C100 RST

See Chapter 4 “Network Master Operation (using MRX/MWX) Instructions)” for an RLL example using multiple Read and Write Interlocks.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–209

Page 364

Chapter 5: Standard RLL Instructions - ASCII

ASCII Instructions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

The DL06 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 DL06 can be used for either reading or writing raw ASCII strings, but cannot be used for both at the same time. The DL06 can also decipher ASCII embedded within a supported protocol (K–Sequence, DirectNet, Modbus) via the CPU port.

Reading ASCII Input Strings There are several methods that the DL06 can use to read ASCII input strings. 1) ASCII 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 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. 2) Write embedded ASCII strings directly to V–memory from an external HMI or similar master device via a supported communications protocol using the CPU ports. The AIN instruction is not used in this case. 3) If a DL06 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. The RX instruction places the data directly into V–memory.

Writing ASCII Output Strings

5–210

The following instructions can be used to write ASCII output strings: 1) Print from V–memory (PRINTV) – Use this instruction to write raw ASCII strings out of port 2 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 string is written to port 2. 2) Print 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 into a pre–defined V–memory address location. Then the (PRINTV) instruction may be used to write the pre–coded ASCII string out of port 2. American, European and Asian Time/Date stamps are supported. Additionally, if a DL06 PLC is a master on a network, the Network Write instruction (WX) 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.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

Page 365

Chapter 5: Standard RLL Instructions - ASCII

Managing the ASCII Strings The following instructions can be helpful in managing the ASCII strings within the CPUs V–memory: • ASCII Find (AFIND) – Finds where a specific portion of the ASCII string is located in continuous V–memory addresses. Forward and reverse searches are supported. • ASCII Extract (AEX) – Extracts a specific portion (usually some data value) from the ASCII find location or other known ASCII data location. • Compare V–memory (CMPV) – This instruction is used to compare two blocks of 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 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.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–211

Page 366

Chapter 5: Standard RLL Instructions - ASCII

ASCII Input (AIN)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

DS5

Used

HPP

N/A

5–212

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 ASCII data can be received as a fixed number of bytes or as a variable length string with a specified termination character(s). Other features include, Byte Swap preferences, Character Timeout, and user defined flag bits for Busy, Complete and Timeout Error. AIN Fixed Length Configuration • Length Type: select fixed length based on the length of the ASCII string that will be sent to the CPU port • CPU/DCM: select either CPU or DCM module for communications • Slot Number: select PLC option slot number if using DCM module • Port Number: must be K2 when using CPU port 2 • Data Destination: specifies where the ASCII string will be placed in V–memory • Fixed Length: specifies the length, in bytes, of the fixed length ASCII string the port will receive • Inter–character Timeout: if the amount of time between incoming ASCII characters exceeds the set 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. 0ms selection disables this feature. • First 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 bit will reset when the AIN instruction permissive bits are disabled. 0ms selection disables this feature. • Byte 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. • Busy Bit: is ON while the AIN instruction is receiving ASCII data • Complete Bit: is set once the ASCII data has been received for the specified fixed length and reset when the AIN instruction permissive bits are disabled. • Inter–character Timeout Error Bit: is set when the Character Timeout is exceeded. See Character Timeout explanation above. • First Character Timeout Error Bit: is set when the First Character Timeout is exceeded. See First Character Timeout explanation above.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

Page 367

Chapter 5: Standard RLL Instructions - ASCII

Parameter Data Destination Fixed Length Bits: Busy, Complete, Timeout Error, Overflow

All V–memory K1–128 C0–3777

AIN Fixed Length Examples Fixed Length example when the PLC is reading the port continuously and timing is not critical

AIN Complete AIN CPU/DCM Slot: Port Number: Data Destination: Fixed Length Interchar. Timeout: First Char. Timeout: Byte Swap: Busy: Complete: Interchar. Timeout Error: First Char. Timeout Error:

C1 1

AIN Complete C1

CPU K2 V2000 K32 None None None C0 C1 C2 C3

Data Read C100

2

OUT

Fixed Length example when character to character timing is critical AIN Complete C1 5

Intercharacter timeout C2

CPU/DCM Slot: Port Number: Data Destination: Fixed Length Interchar. Timeout: First Char. Timeout: Byte Swap: Busy: Complete: Interchar. Timeout Error: First Char. Timeout Error:

CPU K2 V2000 K32 20ms None All C0 C1 C2 C3

AIN Complete C1 6

Data Read C100 OUT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–213

Page 368

Chapter 5: Standard RLL Instructions - ASCII

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

AIN Variable Length Configuration: • Length Type: select Variable Length if the ASCII string length followed by termination characters will vary in length • CPU/DCM: select either CPU or DCM module for communications • Slot Number: select PLC option slot number if using DCM module • Port Number: must be K2 when using CPU port 2 • Data Destination: specifies where the ASCII string will be placed in V–memory • Maximum Variable Length: specifies, in bytes, the maximum length of a Variable Length ASCII string the port will receive • Inter–character Timeout: if the amount of time between incoming ASCII characters exceeds the set 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. 0ms selection disables this feature. • First 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 bit will reset when the AIN instruction permissive bits are disabled. 0ms selection disables this feature. • Byte Swap: swaps the high–byte and low–byte within each V–memory register of the Variable Length ASCII string. See the SWAPB instruction for details. • Termination Code Length: consists of either 1 or 2 characters. Refer to Appendix G, ASCII Table. • Busy Bit: is ON while the AIN instruction is receiving ASCII data • Complete 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. • Inter–character Timeout Error Bit: is set when the Character Timeout is exceeded. See Character Timeout explanation above. • First Character Timeout Error Bit: is set when the First Character Timeout is exceeded. See First Character Timeout explanation above. • Overflow Error Bit: is set when the ASCII data received exceeds the Maximum Variable Length specified.

5–214

DL06 Micro PLC User Manual, 3rd Edition Rev. A

Page 369

Chapter 5: Standard RLL Instructions - ASCII

Parameter Data Destination Fixed Length Bits: Busy, Complete, Timeout Error, Overflow

All V–memory K1–128 C0–3777

AIN Variable Length Example AIN variable length example used to read barcodes on boxes (PE = photoelectric sensor) Box present PE C5 9

C6 10

AIN Complete C1 11

Scan code C6 SET AIN CPU/DCM Slot: Port Number: Data Destination: Maximum Variable Length: Interchar. Timeout: First Char. Timeout: Byte Swap: Termination Codes : Overflow Error: Busy: Complete: Interchar. Timeout Error: First Char. Timeout Error:

CPU K2 V2000 K40 100ms 2000ms All but null OD C4 C0 C1 C2 C3

Scan code C6 RST

Intercharacter Timeout C2 Firstcharacter Timeout C3

AIN Overflow error C4

AIN Complete C1 12

Data Read C100 OUT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–215