The text of a manual · part 20 of 59
Mini-PLC-2/02, 2/16, 2/17 Processor (cat. no. 1772-LZ, LZP, LX, LXP, LW, LWP) User Manual: 12 - Data Manipulation and Compare Instructions
Pages 157 to 169 of 492, from Mini-PLC-2/02, 2/16, 2/17 Processor (cat. no. 1772-LZ, LZP, LX, LXP, LW, LWP) User Manual
The original document is the PDF (2.5 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 Allen-Bradley 1772-LX / LXP
Page 157
Chapter
12
Data Manipulation and Comparison Instructions
Chapter Objectives
In this chapter, you will read about two types of instructions used to transfer and compare data and how to use these instructions to perform operations of data that is stored in the data table. These types of instructions are: transfer instructions compare instructions
Get
A Get instruction accesses all 16 bits of one word in the data table. It displays a three digit hexadecimal value of the lower 12 bits (bits 0 – 13) of the chosen word. The Get instruction is programmed in the condition area of the ladder diagram rung and it can be located at the beginning of a rung or with one or more conditions preceding it. A Get instruction always accesses the word which it addresses. It is not a “condition” that determines rung logic continuity and it is always true and intensified. 111 11
130 G 238 address
040 PUT 000 value
In a selectable timed interrupt, the Get instruction is the first instruction in the subroutine area. See chapter 22 for more information.
ATTENTION: Use the Get instruction in the subroutine area carefully because unintended subroutine execution can cause unexpected machine operation.
12-1
Page 158
Chapter 12 Data Manipulatuion and Comparison Instructions
Put
A Put instruction receives all 16 bits of data from the immediately preceding Get instruction and stores the data at the specified data table word location. Use with a Get instruction to form a data transfer rung. This instruction is programmed in the output side of the ladder diagram rung. This instruction can have the same address as other instructions in the program. It must be immediately preceded by a Get instruction. 111 11
130 G 238 address
040 PUT 000 value
When rung conditions become: True A Get instruction transfers data to the Put instruction. The lower 12 bits are displayed in hexadecimal beneath the Put instruction. Bits 14-17 are transferred but not displayed. False Because the Put instruction is retentive, any change in Get instruction data does not change Put instruction data. Keystrokes Enter a Get or Put instruction by performing the following steps. 1.
Press -[G]- or -(PUT)-.
2.
Enter <address>.
Important: Step 3 is not needed for a Put instruction. 3.
Enter <data> if appropriate.
Removing a GET instruction Remove a GET instruction by performing the following steps. 1.
Position the cursor over the Get instruction you are going to remove.
2.
Press [REMOVE] -[G]-.
Removing a PUT instruction The only way you can remove a Put instruction is to remove the whole rung. See chapter 24. 12-2
Page 159
Chapter 12 Data Manipulation and Comparison Instructions
Editing a Get Instruction on a Partially Completed Rung 1.
Enter the next instruction.
2.
Position the cursor over the GET instruction.
3.
Press -[G]- or any other appropriate instruction type key.
4.
Enter <address>.
5.
Enter <data> if appropriate.
Editing a Get or Put Instruction in a Completed Rung 1.
Position the cursor over the GET or PUT instruction.
2.
Press -[G]-, -(PUT)-, or any other appropriate instruction type key.
3.
Enter <address>.
Important: Step 4 is not needed for a PUT instruction. 4.
Compare Instructions
Enter <data> if appropriate.
There are four compare instructions: Equal To Less Than Get Byte Limit Test
Equal To
An Equal To comparison is made with the Get and Equal To instructions. The Get value is the changing variable and is compared to the reference value of the Equal To instruction for an equal to condition. When the Get value equals the Equal To value, the comparison is true and logic continuity is established. It determines the rung condition. A Get/Equal To compares only the lower 12 bits to the immediately preceding Get instruction. 120 03
030 G YYY
035 = 100
010 reference value
02
When YYY equals 100, the Get/Equal To comparison is true and 010/02 is energized. 12-3
Page 160
Chapter 12 Data Manipulatuion and Comparison Instructions
If the rung condition becomes: True False
If there is equality. If there is no equality.
Keystrokes Enter an Equal To instruction by performing the following steps. 1.
Press -[=]-.
2.
Enter <address>.
3.
Enter <reference value> if appropriate.
Removing an Equal To Instruction Remove an Equal To instruction by performing the following steps. 1.
Position the cursor over the Equal To instruction you are going to remove.
2.
Press [Remove] -[=]-.
Editing a Completed Rung Edit an Equal To instruction by performing the following steps.
Less Than
1.
Position the cursor over the Equal To instruction.
2.
Press -[=]- or any other appropriate instruction type key.
3.
Enter <address>.
4.
Enter <reference value> if appropriate.
The Less Than instruction compares the data in your specified address with the data stored at another address in memory. It determines the rung condition. A Less Than instruction compares only the lower 12 bits to the immediately preceding Get instruction. It is programmed after the Get instruction in the condition side of the ladder diagram rung. 120 01
12-4
030 G YYY
037 = 654
010 reference value
02
Page 161
Chapter 12 Data Manipulation and Comparison Instructions
When YYY is less than 654, the Get/Less Than comparison is true and 010/02 is energized. The rung condition becomes: True False
If the get value is less than the reference value stored in the Less Than instruction. If the get value is equal to or greater than the less than value.
Keystrokes Enter a Less Than instruction by performing the following steps. 1.
Press -[<]-.
2.
Enter <address>.
3.
Enter <reference value>.
Removing the Less Than Instruction Remove a Less Than instruction by performing the following steps. 1.
Position the cursor over the Less Than instruction.
2.
Press [REMOVE] -[<]-.
Editing a Completed Rung You can edit a Less Than instruction by performing the following steps.
Limit Test
1.
Position the cursor over the Less Than instruction.
2.
Press -[<]- or any other appropriate data comparison instruction.
3.
Enter <address>.
4.
Enter <reference value> if applicable.
The Limit Test checks to see if an octal value of a byte is between two reference limit values that are also octal.
12-5
Page 162
Chapter 12 Data Manipulatuion and Comparison Instructions
Programmed with a Get Byte instruction located in the condition area of the ladder diagram. Do not place compare instructions between the Get Byte and Limit Test instruction. The Get Byte and Limit Test instructions work only with octal values (ranging from 000 to 377). There are two cases for comparison: Case 1. Lower Limit YYY Upper Limit 010
120 0451 050 200 B L 170 06 YYY8
05 3778 False 2008
YYY8 True 1708 False 000
If YYY is equal to or greater than 170 and equal to or less than 200, the comparison is true and logic continuity is established. If YYY is less than 170 or greater than 200, the comparison is false and logic continuity is not established.
12-6
Page 163
Chapter 12 Data Manipulation and Comparison Instructions
Case 2. Lower Limit - YYY - Upper Limit 010
120 0451 050 170 B L 200 06 YYY8
05 3778
YYY8 True 2008 False 1708
YYY8 True 000
If YYY is equal to or less than 200 and equal to or greater than 170, the comparison is false and logic continuity is not established. If YYY8 is greater than 200 or less than 170, the comparison is true and logic continuity is established. Keystrokes Enter a Limit Test instruction by performing the following steps. 1.
Press -[L]-.
2.
Enter <address>.
3.
Enter <upper limit>.
4.
Enter <lower limit>.
Editing a Completed Rung Edit the Limit Test comparison by performing the following steps. 1.
Positions the cursor over the limit instruction you are going to edit.
2.
Press -[L]-.
3.
Enter <address>.
4.
Enter <upper limit>.
5.
Enter <lower limit>.
12-7
Page 164
Chapter 12 Data Manipulatuion and Comparison Instructions
Operations Involving Transfer and Comparison Instructions
You can perform four operations involving transfer and comparison instructions. equal to or less than greater than equal to or greater than get byte/put
Equal To or Less Than
The Equal To/Less Than comparison is made using the Get, Less Than, Equal To, and branching instructions. The Get value is the changing value. The Less Than and Equal To instructions are assigned a reference value. When the Get value is either less than or equal to the value at Less Than and Equal To instructions, the comparison is true and logic continuity is established. 120 030 037 G < 04 YYY 237 037 = 237
010 02
If YYY is equal to or less than 237 the Get/Less Than or Equal To comparison is true an 010/02 is energized. Important: Only one Get instruction is required for a parallel comparison. The Less Than and Equal To instructions are programmed in parallel branches. Keystrokes Enter an Equal To or Less Than comparison by performing the following steps.
12-8
1.
Press -[G]-.
2.
Enter <address>.
3.
Enter <reference value>.
4.
Press [ ]
5.
Press -[<]-.
6.
Enter <address>.
7.
Enter <reference value>.
8.
Press [ ].
Page 165
Chapter 12 Data Manipulation and Comparison Instructions
9.
Press -[=]-.
10. Enter the same address as that entered for the Less Than instruction. 11. Enter <reference value>. 12. Press [ ] 13. Press -( )-. 14. Enter <address>. Editing the Operation See the editing for the Get, Less Than, Equal To, and branching instructions.
Greater Than
A Greater Than comparison is also made with the Get/Less Than pair of instructions. This time the Get instruction BCD value is the reference and the Less Than instruction BCD value is the changing value. The Less Than value is compared with to the Get value for a greater than condition. When the Less Than value is greater than the Get value, the comparison is true and logic continuity is established. 120 030 010 G < 03 000 YYY
010 02 reference value
If YYY is greater than 100 the Get/Greater Than comparison is true and 010/02 is energized. Keystrokes Enter a Greater Than comparison by performing the following steps. 1.
Press -[G]-.
2.
Enter <address>.
3.
Enter <reference value>.
4.
Press -[<]-.
5.
Enter <address>.
6.
Enter <reference value>.
12-9
Page 166
Chapter 12 Data Manipulatuion and Comparison Instructions
Editing the Operation See the editing for the Get and Less Than instructions
Equal To or Greater Than
This comparison is made using the Get, Less Than, Equal To, and branching instructions. The Get value is assigned a reference value. The Less Than and Equal To values are changing and are compared to the Get value. When the Less Than and Equal To values are greater than or equal to the Get value, the comparison is true and logic continuity is established. 120 030 042 G < 05 440 YYY 042 = YYY
010 02 reference value
If YYY is equal to or greater than 440 the Get/Equal To or Greater Than comparison is true and 010/02 is energized. Keystrokes Enter an Equal To or Greater Than comparison by performing the following steps. 1.
Press -[G]-.
2.
Enter <address>.
3.
Enter <reference value>.
4.
Press [ ].
5.
Press -[=]-.
6.
Enter <address>.
7.
Enter <reference value>.
8.
Press [ ].
9.
Press -[<]-.
10. Enter <address>. 11. Enter <reference value>. 12. Press [ ]. 13. Press -( )-. 14. Enter <address>.
12-10
Page 167
Chapter 12 Data Manipulation and Comparison Instructions
Editing the Operation See the editing Get, Less Than, Equal To, and branching instructions.
Get Byte
The Get Byte instruction addresses either the upper or lower byte of a data table word. A 1 is entered after the word address for the upper byte; a 0 is entered for the lower byte. The Get Byte instruction accesses 1 byte (instead of word) from one address in the data table. The data is displayed in octal format. The Get Byte instruction can be programmed with a Limit Test instruction located in the condition area of the ladder diagram rung. Do not place compare instructions between the Get Byte and Limit Test instructions. Use with a Put instruction to transfer either the upper or lower byte to the upper or lower byte of the Put instruction address. Keystrokes Enter a Get Byte instruction by performing the following steps. 1.
Press -[B]-.
2.
Enter <address>.
3.
Enter <byte designation>.
Editing the Operation Edit the Get Byte instruction by performing the following steps.
Get Byte/Put
1.
Position the cursor over -[B]-.
2.
Press -[B]-.
3.
Enter <address>.
4.
Enter <byte designation>.
The Get Byte instruction can be programmed either at the beginning of the rung or with one or more condition instructions preceding it. Condition instructions, however, should not be programmed after a Get Byte instruction. When one or more condition instructions precede the Get Byte instruction, they determine whether the rung is true or false.
12-11
Page 168
Chapter 12 Data Manipulatuion and Comparison Instructions
The Get Byte instruction addresses either the upper or lower byte of a data table word. A 1 is entered after the word address for an upper byte; a 0 is entered for the lower byte. There are two ways to perform a Get Byte/Put instruction. Case 1. One Get Byte XXXD B
040 PUT ZZZ ZZZZ
YYY8
16 only these three letters are displayed
The Get Byte instruction is programmed in the condition area of the ladder rung. It tells the processor to make a duplicate of all 8 bits in the addressed byte. When the rung containing the Get Byte/Put instructions goes true, the data is transferred to both the upper and lower byte of the word address of the Put instruction. Case 2. Two Get Bytes XXXD XXXD B B
040 PUT BCC BBCCC 16
WWW8 YYY8 XXX WWW YYY D word address octal values - upper or lower byte only these three letters are displayed
0 - lower byte 1 - upper byte
Two Get Byte instructions are programmed in the condition area of the ladder rung. It tells the processor to make a duplicate of all 8 bits in each addressed byte. When the rung containing the Get Byte/Put instructions goes true, the data from the first get byte is transferred into the upper byte of the addressed Put instruction. Also, the data from the second get byte is transferred into the lower byte of the addressed Put instruction. Keystrokes Enter a Get Byte/Put instruction by performing the following steps. 1.
Press -[B]-.
2.
Enter <address>.
3.
Enter <byte designation>.
Important: Repeat steps 1, 2 and 3 when using two Get Byte instructions.
12-12
Page 169
Chapter 12 Data Manipulation and Comparison Instructions
4.
Press -(PUT)-.
5.
Enter <address>.
Editing the Operation Edit a Get Byte/Put instruction by performing the following steps. 1.
Position the cursor over -[B]-.
2.
Press -[B]-.
3.
Enter <address>.
4.
Enter <byte designation>.
Important: Repeat steps 2, 3 and 4 when using two Get Byte instructions. 5.
Press -(PUT)-.
6.
Enter <address>.
12-13