The text of a manual · part 45 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 423 to 432
Pages 423 to 432 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 423
Chapter 5: Standard RLL Instructions - Message
Print Message (PRINT) Print Message instruction prints the embedded text 230 The or text/data variable message to the specified 240 communications port (2 on the DL250–1/260 CPU), 250-1 which must have the communications port configured. 260 DS Used HPP N/A
Data Type Constant
A aaa
“Hello, this is a PLC message”
DL250-1 Range
DL260 Range
A aaa aaa
K
2
2
You may recall from the CPU specifications in Chapter 3 that the DL250–1 and DL260 ports are capable of several protocols. To configure a port using the Handheld Programmer, use AUX 56 and follow the prompts, making the same choices as indicated below on this page. To configure a port in DirectSOFT, choose the PLC menu, then Setup, then Setup Secondary Comm Port. • Port: From the port number list box at the top, choose “Port 2”. • Protocol: Click the check box to the left of “Non-sequence”, and then you’ll see the dialog box shown below.
• Memory Address: Choose a V-memory address for DirectSOFT to use to store the port setup information. You will need to reserve nine words in V-memory for this purpose. Select “Use for printing only” if it applies. • Baud Rate: Choose the baud rate that matches your printer. • Stop Bits, Parity: Choose number of stop bits and parity setting to match your printer.
Then click the button indicated to send the Port 2 configuration to the CPU, and click Close. See Chapter 3 for port wiring information to connect your printer to the DL2501/260.
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
5–201
Page 424
Chapter 5: Standard RLL Instructions - Message
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–202
Port 2 on the DL250–1/260 has standard RS232 levels, and should work with most printer serial input connections. Text element - this is used for printing character strings. The character strings are defined as the character (more than 0) ranged by the double quotation marks. Two hex numbers preceded by the dollar sign means an 8-bit ASCII character code. Also, two characters preceded by the dollar sign is interpreted according to the following table: #
Character code
Description
1 2 3 4 5 6 7
$$ $” $L or $1 $N or $n $P or $p $R or $r $T or $t
Dollar sign ($) Double quotation (“) Line feed (LF) Carriage return line feed (CRLF) Form feed Carriage return (CR) Tab
The following examples show various syntax conventions and the length of the output to the printer. Example: ” ” Length 0 without character ”A” Length 1 with character A ” ” Length 1 with blank ” $” ” Length 1 with double quotation mark ”$R$L” Length 2 with one CR and one LF ”$0D$0A” Length 2 with one CR and one LF ”$$” Length 1 with one $ mark In printing an ordinary line of text, you will need to include double quotation marks before and after the text string. Error code 499 will occur in the CPU when the print instruction contains invalid text or no quotations. It is important to test your PRINT instruction data during the application development. The following example prints the message to port 2. We use a PD contact, which causes the message instruction to be active for just one scan. Note the $N at the end of the message, which produces a carriage return / line feed on the printer. This prepares the printer to print the next line, starting from the left margin. X1
PRINT K2 “Hello, this is a PLC message.$N”
DL205 User Manual, 4th Edition, Rev. A
Print the message to Port 2 when X1 makes an off-to-on transition.
Page 425
Chapter 5: Standard RLL Instructions - Message V-memory element – this is used for printing V-memory contents in the integer format or real format. Use V-memory number or V-memory number with “:” and data type. The data types are shown in the table below. The Character code must be capital letters.
1 NOTE: There must be a space entered before and after the V-memory address to separate it from the text 2 string. Failure to do this will result in an error code 499. 3 # Character code Description 4 5 6 Example: V2000 Print binary data in V2000 for decimal number 7 V2000 : B Print BCD data in V2000 V2000 : D Print binary number in V2000 and V2001 for decimal number 8 V2000 : D B Print BCD data in V2000 and V2001 V2000 : R Print floating point number in V2000/V2001 as real number 9 V2000 : E Print floating point number in V2000/V2001 as real number with exponent 10 Example: The following example prints a message containing text and a variable. The “reactor temperature” labels the data, which is at V2000. You can use the : B qualifier after the V2000 11 if the data is in BCD format, for example. The final string adds the units of degrees to the line of text, and the $N adds a carriage return / line feed. 12 13 14 V-memory text element – this is used for printing text stored in V-memory. Use the % A followed by the number of characters after V-memory number for representing the text. If you assign “0” as the number of characters, the print function will read the character count from the first location. Then it will start at the next V-memory location and read that number B of ASCII codes for the text from memory. Example: C V2000 % 16 16 characters in V2000 to V2007 are printed. V2000 % 0 The characters in V2001 to Vxxxx (determined by the number in D V2000) will be printed. 1 2 3 4 5 6
X1 none :B :D :DB :R :E
16-bit binary (decimal number) 4 digit BCD 32-bit binary (decimal number) 8 digit BCD Floating point number (real number) Floating point number (real number with exponent)
PRINT K2 “Reactor temperature = ” V2000 “deg. $N” ^ ^
Message will read: Reactor temperature = 0156 deg.
Print the message to Port 2 when X1 makes an off-to-on transition. ^ represents a space
DL205 User Manual, 4th Edition, Rev. A
5–203
Page 426
Chapter 5: Standard RLL Instructions - Message
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–204
Bit element – this is used for printing the state of the designated bit in V-memory or a relay bit. The bit element can be assigned by the designating point (.) and bit number preceded by the V-memory number or relay number. The output type is described as shown in the table below. #
Data format
Description
1 2 3 none : BOOL : ONOFF
Print 1 for an ON state, and 0 for an OFF state Print “TRUE” for an ON state, and “FALSE” for an OFF state Print “ON” for an ON state, and “OFF” for an OFF state
Example: V2000 . 15 Prints the status of bit 15 in V2000, in 1/0 format C100 Prints the status of C100 in 1/0 format C100 : BOOL Prints the status of C100 in TRUE/FALSE format C100 : ON/OFF Prints the status of C100 in ON/OFF format V2000.15 : BOOL Prints the status of bit 15 in V2000 in TRUE/FALSE format The maximum numbers of characters you can print is 128. The number of characters for each element is listed in the table below: Element type Text, 1 character 16 bit binary 32 bit binary 4 digit BCD 8 digit BCD Floating point (real number) Floating point (real with exponent) V-memory/text Bit (1/0 format) Bit (TRUE/FALSE format) Bit (ON/OFF format)
Maximum Characters 1 6 11 4 8 13 13 2 1 5 3
The handheld programmer’s mnemonic is “PRINT”, followed by the DEF field. Special relay flags SP116 and SP117 indicate the status of the DL250–1/260 CPU ports (busy, or communications error). See the appendix on special relays for a description. NOTE: You must use the appropriate special relay in conjunction with the PRINT command to ensure the ladder program does not try to PRINT to a port that is still busy from a previous PRINT or WX or RX instruction.
DL205 User Manual, 4th Edition, Rev. A
Page 427
Chapter 5: Standard RLL Instructions - Modbus
Modbus RTU Instructions (DL260)
1 The Modbus Read from Network (MRX) instruction is used by the DL260 network master 2 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 3 Code, slave station address, starting master and slave memory addresses, number of elements to transfer, Modbus data format and the Exception Response Buffer. 4 5 6 7 8 9 10 • Port Number: must be DL260 Port 2 (K2) 11 • Slave Address: specify a slave station address (1 to 247) • Function Code: The following Modbus function codes are supported by the MRX instruction: 12 01 – Read a group of coils 13 02 – Read a group of inputs 03 – Read holding registers 14 04 – Read input registers 07 – Read Exception status A • 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 B will be placed. See the table on the following page. • Number of Elements: specifies how many coils, inputs, holding registers or input registers will be C read. See the table on the following page. • Modbus Data Format: specifies Modbus 584/984 or 484 data format to be used D
Modbus Read from Network (MRX)
230 240 250-1 260 DS Used HPP N/A
DL205 User Manual, 4th Edition, Rev. A
5–205
Page 428
Chapter 5: Standard RLL Instructions - Modbus
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–206
• Exception 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
MRX Slave Memory Address MRX Slave Address Ranges Function Code
Modbus Data Format
Slave Address Range(s)
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 ExceptionStatus
484 and 584/984 Mode
1-999 1-65535 1001-1999 10001-19999 (5 digit) or 100001165535 (6 digit) 4001-4999 40001-49999 9 (5 digit) or 4000001-465535 (6 digit) 3001-3999 30001-39999 (5 digit) or 3000001365535 (6 digit) n/a
MRX Master Memory Addresses MRX 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
DL205 User Manual, 4th Edition, Rev. A
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
Page 429
Chapter 5: Standard RLL Instructions - Modbus
MRX Number of Elements
1 2 3 MRX Exception Response Buffer Exception Response Buffer 4 Operand Data Type DL260 Range 5 MRX Example 6 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 7 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 8 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. 9 Typically network communications will last longer than one CPU scan. The program must wait for the communications to finish before starting the next transaction. 10 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. A
5–207
Page 430
Chapter 5: Standard RLL Instructions - Modbus
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
• Port Number: must be DL260 Port 2 (K2) • Slave Address: specify a slave station address (0 to 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 be 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
DL205 User Manual, 4th Edition, Rev. A
Page 431
Chapter 5: Standard RLL Instructions - Modbus • Exception 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. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–209
Page 432
Chapter 5: Standard RLL Instructions - Modbus
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 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 wait for the communications to finish before starting the next transaction.
DL205 User Manual, 4th Edition, Rev. A