The text of a manual ยท part 38 of 45
Enhanced and Ethernet PLC-5 Programmable Controllers User Manual: Appendix D - Instruction Set Quick Reference, pages 311 to 320
Pages 311 to 320 of 388, from Enhanced and Ethernet PLC-5 Programmable Controllers User Manual
The original document is the PDF (5.1 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 1785-L20B and Allen-Bradley 1785-L40B
Page 311
Instruction Set Quick Reference
Instruction
Description Negate NEG
NEG NEGATE Source Dest
N7:3 3 N7:12 -3
Dest
When the input conditions are true, take the opposite sign of the Source (N7:3) and store the result in the Destination (N7:12). This instruction turns positive values into negative values and negative values into positive values. Status Bit
Sine SIN
SIN SINE Source
D-11
F8:11 0.7853982 F8:12 0.7071068
Description
C sets if the operation generates a carry; otherwise resets
V sets if overflow is generated; otherwise resets
Z sets if the result is zero; otherwise resets
S sets if the result is negative; otherwise resets
When input conditions go true, take the sine of the value in F8:11 and store the result in F8:12. Status Bit
Description
C always resets
V sets if overflow is generated;
otherwise resets Z sets if the result is zero;
otherwise resets S sets if the result is negative;
otherwise resets
SQR SQUARE ROOT Source N7:3 25 Dest N7:12 5
Square Root SQR
When the input conditions are true, take the square root of the Source (N7:3) and store the result in the Destination (N7:12). Status Bit
Description
C always resets
V sets if overflow occurs during floating point to integer conversion; otherwise resets
Z sets if the result is zero; otherwise resets
S always reset
Publication 1785-UM012D-EN-P - July 2005
Page 312
D-12
Instruction Set Quick Reference
Instruction
Description Sort SRT
SRT SORT File Control Length Position
#N7:1 R6:0 4 0
STD STANDARD DEVIATION File #N7:1 Dest N7:0 Control R6:0 Length 4 Position 0
Publication 1785-UM012D-EN-P - July 2005
When the input conditions go from false-to-true, the values in N7:1, N7:2, N7:3.and N7:4 are sorted into ascending order.
Status Bits: EN-Enable DN-Done Bit ER-Error Bit Standard Deviation STD Status Bits: EN - Enable DN - Done Bit ER - Error Bit
When the input conditions go from false-to-true, take the standard deviation of the values in file #N7:1 and store the result in the Destination (N7:0). Status Bit
Description
C always resets
V sets if overflow is generated; otherwise resets
Z sets if the result is zero; otherwise resets
S always resets
Page 313
Instruction Set Quick Reference
Instruction
Description Subtract SUB
SUB SUBTRACT Source A Source B Dest
N7:3 3 N7:4 1 N7:12 2
Dest
When the input conditions are true, subtract the value in Sour B (N7:4) from the value in Source A (N7:3) and store the result the Destination (N7:12). Status Bit
Tangent TAN
TAN TANGENT Source
D-13
Description
C sets if borrow is generated; otherwise resets
V sets if underflow is generated; otherwise resets
Z sets if the result is zero; otherwise resets
S sets if the result is negative; otherwise resets
When input conditions go true, take the tangent of the value in F8:15 and store the result in F8:16.
F8:15 0.7853982
Status Bit
Description
F8:16 1.000000
C always resets
V otherwise resets
Z
S
XPY X TO POWER OF Y Source A N7:4 5 Source B N7:5 2 Dest N7:6 25
X to the power of Y XPY sets if overflow is generated; sets if the result is zero;
otherwise resets sets if the result is negative;
otherwise resets
When input conditions go true, take the the value in N7:4, raise it to the power stored in N7:5, and store the result in Status Bit
Description
C always resets
V otherwise resets
Z
S sets if overflow is generated; sets if the result is zero;
otherwise resets sets if the result is negative;
otherwise resets
Publication 1785-UM012D-EN-P - July 2005
Page 314
D-14
Instruction Set Quick Reference
Logical Instructions Instruction
Description AND
AND BITWISE AND Source A Source B Dest
D9:3 3F37 D9:4 00FF D9:5 0037
Source ASource BResult 000 100 010 111 NOT Operation
NOT NOT Source A
D9:3 00FF D9:5 FF00
Dest
BITWISE INCLUSIVE OR Source A D9:3 3F37 Source B D9:4 00FF Dest D9:5 3FFF
XOR BITWISE EXCLUSIVE OR D9:3 Source A 3F37 Source B D9:4 3F37 Dest D9:5 0000
When the input conditions are true, the controller performs a NOT (takes the opposite of) operation (bit-by-bit) on the Sourc (D9:3) and stores the result in the Destination (D9:5). The trut table for a NOT operation is: SourceDestination 01 10
OR
OR
When the input conditions are true, the controller performs an AND operation (bit-by-bit) between Source A (D9:3) and Sourc B (D9:4) and stores the result in the Destination (D9:5). The truth table for an AND operation is:
When the input conditions are true, the controller performs an OR operation (bit-by-bit) between Source A (D9:3) and Source (D9:4) and stores the result in the Destination (D9:5). The trut table for an OR operation is: Source ASource BResult 000 101 011 111
Exclusive OR XOR
When the input conditions are true, the controller performs an exclusive OR operation (bit-by-bit) between Source A (D9:3) an Source B (D9:4) and stores the result in the Destination (D9:5) The truth table for an XOR operation is: Source ASource BResult 000 101 011 110
Status Bit
Descriptio
C always
V always
Z sets if the result is zero; otherwise
S sets if the most significant bit (bit 15 for decimal or bit 17 for octal) is set (1); otherwise resets
Publication 1785-UM012D-EN-P - July 2005
Page 315
Instruction Set Quick Reference
D-15
Conversion Instructions Instruction
Description Convert from BCD FRD
FRD FROM BCD Source Dest
D9:3 0037 N7:12 37
Convert to BCD TOD
TOD TO BCD Source Dest
N7:3 44 D9:5 0044
DEG RADIANS TO DEGREE Source F8:7 0.7853982 Dest F8:8 45
Convert to Degrees DEG
When the input conditions are true, convert the BCD value in the Source (D9:3) to a integer value and store the result in the Destination (N7:12). The source must be in the range of Status Bit
Description
C always resets
V always resets
Z sets if the destination value is zero; otherwise resets
S always resets
When the input conditions are true, convert the integer value in Source (N7:3) to a BCD format and store the result in the Status Bit
Description
C always resets
V sets if the source value is negative or greater than 9999 (i.e. outside of the range of 0-9999)
Z sets if the destinationvalue is zero; otherwise resets
S always resets
When the input conditions are true, convert radians (the value in Source A) to degrees and stores the result in the Destination (Source times 180/p). Status Bit
Description
C always resets
V sets if overflow generated; otherwise resets
Z sets if result is zero; otherwise resets
S sets if result is negative; otherwise resets
Publication 1785-UM012D-EN-P - July 2005
Page 316
D-16
Instruction Set Quick Reference
Instruction
Description
RAD DEGREES TO RADIAN N7:9 Source Dest
Convert to Radians RAD
45 F8:10 0.785398
When the input conditions are true, convert degrees (the value in Source A) to radians and stores the result in the Destination (Source times p/180). Status Bit
Description
C always resets
V sets if overflow generated; otherwise resets
Z sets if result is zero; otherwise resets
S sets if result is negative; otherwise resets
Bit Modify and Move Instructions Instruction
Description Move MOV
MOV MOVE Source Dest
N7:3 20 F8:12 20.000000
When the input conditions are true, move a copy of the value in Source (N7:3) to the Destination (F8:12), converting from one data type to another This overwrites the original value in the Destination. Status Bit
Description
C always resets
V sets if overflow is generated during floating point-to-integer conversion; otherwise resets
Z sets if the destination value is zero; otherwise resets
S
MVM MASKED MOVE Source D9:3 478F Mask D9:5 00FF Dest D9:12 008F
Publication 1785-UM012D-EN-P - July 2005
Masked Move MVM sets if result MSB is set; otherwise resets
When the input conditions are true, the controller passes the value in the Source (D9:3) through the Mask (D9:5) and stores t result in the Destination (D9:12). This overwrites the original value in the Destination. Status Bit
Description
C always resets
V always resets
Z sets if the result is zero; otherwise resets
S sets if most significant bit of resulting value is set; otherwise resets.
Page 317
Instruction Set Quick Reference
Instruction
D-17
Description
BTD BIT FIELD DISTRIB Source N7:3 0 Source bit 3 Dest N7:4 0 Dest bit 10 Length 6
Bit Distribute BTD
When the input conditions are true, the controller copies the number of bits specified by Length, starting with the Source bit (3) of the Source (N7:3), and placing the values in the Destination (N7:4), starting with the Destination bit (10).
File Instructions Instruction FAL FILE ARITH/LOGICAL Control R6:1 Length 8 Position 0 Mode ALL Dest #N15:10 Expression #N14:0 - 256
Description File Arithmetic and Logic FAL Status Bits: EN - Enable DN - Done Bit ER - Error Bit
When the input conditions go from false-to-true, the controller reads 8 elements of N14:0, and subtracts 256 (a constant) from each element. This example shows the result being stored in the eight elements beginning with N15:10. The control element R6:1 controls the operation. The Mode determines whether the controller performs the expression on all elements in the files (ALL) per program scan, one element in the files (INC) per false-to-true transition, or a specific number of elements (NUM) per scan. The FAL instruction can perform these operations: add (+), subtract (-), multiply (*), divide (|), convert from BCD (FRD), convert to BCD (TOD), square root (SQR), logical and (AND), logical or (OR), logical not (NOT), exclusive or (XOR), negate (-), clear (0), move, and the new math instructions (see the CPT list).
FSC FILE SEARCH/COMPARE Control R9:0 Length 90 Position 0 Mode 10 Expression #B4:0 <> #B5:0
File Search and Compare FSC Status Bits: EN - Enable DN - Done Bit ER - Error Bit IN - Inhibit Bit FD - Found Bit
When the input conditions go from false-to-true, the controller performs the not-equal-to comparison on 10 elements between files B4:0 and B5:0. Mode determines whether the controller performs the expression on all elements in the files (ALL) per program scan, one element in the files (INC) per false-to-true transition, or a specific number of elements (NUM) per scan. Control element R9:0 controls the operation. When the corresponding source elements are not equal (element B4:4 and B5:4 in this example), the controller stops the search and sets the found .FD and inhibit .IN bits so your ladder program can take appropriate action. To continue the search comparison, you must reset the .IN bit. To see a list of the available comparisons, see the comparisons listed under the CMP instruction.
Publication 1785-UM012D-EN-P - July 2005
Page 318
D-18
Instruction Set Quick Reference
Instruction
Description File Copy COP
COP COPY FILE Source Dest Length
#N7:0 #N12:0 5
When the input conditions are true, the controller copies the contents of the Source file (N7) into the Destination file (N12). The source remains unchanged. The COP instruction copies the number of elements from the source as specified by the Length. As opposed to the MOV instruction, there is no data type conversion for this instruction.
File Fill FLL
FLL FILL FILE Source Dest Length
Publication 1785-UM012D-EN-P - July 2005
N10:6 #N12:0 5
When the input conditions are true, the controller copies the value in Source (N10:6) to the elements in the Destination (N12). The FLL instruction only fills as many elements in the destination as specified in the Length. As opposed to the MOV instruction, there is no data type conversion for this instruction.
Page 319
Instruction Set Quick Reference
D-19
Diagnostic Instructions Instruction FBC FILE BIT COMPARE Source #I:031 Reference #B3:1 Result #N7:0 Cmp Control R6:4 Length 48 Position 0 Result Control R6:5 Length 10 Position 0
DDT DIAGNOSTIC DETECT Source #I:030 Reference #B3:1 Result #N10:0 Cmp Control R6:0 Length 20 Position 0 Result Control R6:1 Length 5 Position 0
Description File Bit Compare FBC Status Bits: EN - Enable DN - Done Bit ER - Error Bit IN - Inhibit Bit FD - Found Bit
When the input conditions go from false-to-true, the controller compares the number of bits specified in the CMP Control Length (48) of the Source file (#I:031) with the bits in the Reference file (#B3:1). The controller stores the results (mismatched bit numbers) in the Result file (#N7:0). File R6:4 controls the compare and file R6:5 controls the file that contains the results. The file containing the results can hold up to 10 (the number specified in the Length field) mismatches between the compared files. Note: To avoid encountering a possible run-time error when executing this instruction, add a ladder rung that clears S:24 (indexed addressing offset) immediately before a FBC instruction.
Diagnostic Detect DDT Status Bits: EN - Enable DN - Done Bit ER - Error Bit IN - Inhibit Bit FD - Found Bit
When the input conditions go from false-to-true, the controller compares the number of bits specified in the CMP Control Length (20) of the Source file (# I:030) with the bits in the Reference file (#B3:1). The controller stores the results (mismatched bit numbers) in the Result file (#N10:0). Control element R6:0 controls the compare and the control element R6:1 controls the file that contains the results (#N10:0). The file containing the results can hold up to 5 (the number specified in the Length field) mismatches between the compared files. The controller copies the source bits to the reference file for the next comparison. The difference between the DDT and FBC instruction is that each time the DDT instruction finds a mismatch, the controller changes the reference bit to match the source bit. You can use the DDT instruction to update your reference file to reflect changing machine or process conditions. Note: To avoid encountering a possible run-time error when executing this instruction, add a ladder rung that clears S:24 (indexed addressing offset) immediately before a DDT instruction.
DTR DATA TRANSITION Source I:002 Mask 0FFF Reference N63:11
Data Transition DTR
The DTR instruction compares the bits in the Source (I:002) through a Mask (0FFF) with the bits in the Reference (N63:11). When the masked source is different than the reference, the instruction is true for only 1 scan. The source bits are written into the reference address for the next comparison. When the masked source and the reference are the same, the instruction remains false.
Publication 1785-UM012D-EN-P - July 2005
Page 320
D-20
Instruction Set Quick Reference
Shift Register Instructions Instruction
Description
BSL BIT SHIFT LEFT File #B3:1 Control R6:53 Bit Address I:022/12 Length 5
BSR BIT SHIFT RIGHT File #B3:2 Control R6:54 Bit Address I:023/06 Length 3
N60:1 #N60:3 R6:51 64 0
Publication 1785-UM012D-EN-P - July 2005
Bit Shift Right BSR Status Bits: EN - Enable DN - Done Bit ER - Error Bit UL - Unload Bit
Status Bits: EN - Enable Load DN - Done Bit EM - Empty Bit FIFO Unload FFU
FFU FIFO UNLOAD FIFO Dest Control Length Position
Status Bits: EN - Enable DN - Done Bit ER - Error Bit UL - Unload Bit
FIFO Load FFL
FFL FIFO LOAD Source FIFO Control Length Position
Bit Shift Left BSL
#N60:3 N60:2 R6:51 64 0
Status Bits: EU - Enable Unload DN - Done Bit EM - Empty Bit
If the input conditions go from false-to-true, the BSL instruction shifts the number of bits specified by Length (5) in File (B3), starting at bit 16 (B3:1/0 = B3/16), to the left by one bit position. The source bit (I:022/12) shifts into the first bit position, B3:1/0 (B3/16). The fifth bit, B3:1/4 (B3/20), is shifted into the UL bit of the control structure (R6:53).
If the input conditions go from false-to-true, the BSR instruction shifts the number of bits specified by Length (3) in File (B3), starting with B3:2/0 (=B3/32), to the right by one bit position. The source bit (I:023/06) shifts into the third bit position B3/34. The first bit (B3/32) is shifted into the UL bit of the control element (R6:54).
When the input conditions go from false-to-true, the controller loads N60:1 into the next available element in the FIFO file, #N60:3, as pointed to by R6:51. Each time the rung goes from false-to-true, the controller loads another element. When the FIFO file (stack) is full, (64 words loaded), the DN bit is set. See page F-8 for a description of prescan activities for this instruction. When the input conditions go from false-to-true, the controller unloads an element from #N60:3 into N60:2. Each time the rung goes from false-to-true, the controller unloads another value. All the data in file #N60:3 is shifted one position toward N60:3. When the file is empty, the EM bit is set. See page F-8 for a description of prescan activities for this instruction.