The text of a manual · part 14 of 70
SLC 500 Instruction Set Reference Manual, pages 131 to 140
Pages 131 to 140 of 694
The original document is the PDF (7.2 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 1747-L514
Page 131
Program Flow Instructions
6-5
You must program each subroutine in its own program file by assigning a unique file number (3 to 255) IMPORTANT
Fixed and SLC 5/01 specific - The JSR instruction cannot be programmed in nested output branches. A compiler error will occur if a rung containing multiple outputs with conditional logic and a JSR instruction is encountered.
Using SBR The target subroutine is identified by the file number that you entered in the JSR instruction. This instruction serves as a label or identifier for a program file as a regular subroutine file. This instruction has no control bits. It is always evaluated as true. The instruction must be programmed as the first instruction of the first rung of a subroutine. Use of this instruction is optional; however, we recommend using it for clarity.
Using RET This output instruction marks the end of subroutine execution or the end of the subroutine file. It causes the controller to resume execution at the instruction following the JSR instruction. If a sequence of nested subroutines is involved, the instruction causes the processor to return program execution to the previous subroutine. The rung containing the RET instruction may be conditional if this rung precedes the end of the subroutine. In this way, the controller omits the balance of a subroutine only if its rung condition is true. Without an RET instruction, the END instruction (always present in the subroutine) automatically returns program execution to the instruction following the JSR instruction in your calling ladder file.
TIP
The RET instruction terminates execution of the DII subroutine (SLC 5/03 and higher processors), STI subroutine, I/O event-driven interrupt subroutine, and the user fault routine (SLC 5/02 or higher processor).
Publication 1747-RM001G-EN-P - November 2008
Page 132
6-6
Program Flow Instructions
Master Control Reset (MCR) Use MCR instructions in pairs to create program zones that turn off all the non-retentive outputs in the zone. Rungs within the MCR zone are still scanned, but scan time is reduced due to the false state of non-retentive outputs.
(MCR)
Table 6.3 Controller Function
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
•
•
If the MCR Rung that Starts the Zone is
Then the Controller
True
Executes the rungs in the MCR zone based on each rung’s individual input condition (as if the zone did not exist).
False
Resets all non-retentive output instructions in the MCR zone regardless of each rung’s individual input conditions.
MCR zones let you enable or inhibit segments of your program, such as for recipe applications. When you program MCR instructions, note that: • you must end the zone with an unconditional MCR instruction. • you cannot nest one MCR zone within another. • do not jump into an MCR zone. If the zone is false, jumping into it activates the zone. • always place the MCR instruction as the last instruction in a rung.
Processor Operation Do not jump (JMP) into an MCR zone. Instructions that are programmed within the MCR zone starting at the LBL instruction and ending at the END MCR instruction are always evaluated as though the MCR zone is true, regardless of the true state of the Start MCR instruction. If the zone is false, jumping into it activates the zone from the LBL to the end of the zone.
Publication 1747-RM001G-EN-P - November 2008
Page 133
Program Flow Instructions
ATTENTION
6-7
If you start instructions such as timers or counters in an MCR zone, instruction operation ceases when the zone is disabled. Re-program critical operations outside the zone if necessary. The TOF timer activates when placed inside of a false MCR zone. The MCR instruction is not a substitute for a hard-wired master control relay. We recommend that your programmable controller system include a hard-wired master control relay and emergency stop switches to provide I/O power shut down. Emergency stop switches can be monitored but should not be controlled by the ladder program. Wire these devices as described in the installation manual. SLC 5/03 and higher processors - When online and an unmatched MCR instruction exists in your program, the END instruction acts as the second unconditional MCR instruction and all of the rungs following the first MCR instruction execute via the current MCR instruction state. You can save the program while online if unmatched MCR instructions exist. However, if you are offline and unmatched MCR instructions exist, an error will occur.
This instruction, when its rung is true, stops the processor from scanning the rest of the program file, updates the I/O, and resumes scanning at rung 0 of the main program (file 2). If this instruction’s rung is false, the processor continues the scan until the next TND instruction or the END statement. Use this instruction to progressively debug a program, or conditionally omit the balance of your current program file or subroutines.
Temporary End (TND)
(TND)
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
•
TIP
If you use this instruction inside a nested subroutine, execution of all nested subroutines is terminated.
•
Output Instruction
Publication 1747-RM001G-EN-P - November 2008
Page 134
6-8
Program Flow Instructions
When this instruction is executed, it causes the processor to enter the Suspend Idle mode and stores the Suspend ID in word 7 (S:7) of the status file. All outputs are de-energized.
Suspend (SUS)
Use this instruction to trap and identify specific conditions for program debugging and system troubleshooting.
SUS Suspend Suspend ID
0
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
•
•
Output Instruction
Entering Parameters Enter a suspend ID number from -32,768 to + 32,767 when you program the instruction. When the SUS instruction is executed, the programmed suspend ID, S:7 (word 7), as well as the program file ID, S:8 (word 8), from which the SUS instruction executed is placed in the system status file.
Immediate Input with Mask (IIM)
This instruction allows you to update data prior to the normal input scan. When the IIM instruction is enabled, the program scan is interrupted. Data from a specified I/O slot is transferred through a mask to the input data file, making the data available to instructions following the IIM instruction in the ladder program.
Entering Parameters IIM Immediate Input w/Mask Slot I:1.0 Mask 0FF00h Length 1
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
•
•
Input Instruction
Slot - Specify the input slot number and the word number pertaining to the slot. Word 0 of a slot need not be specified. Fixed and SLC 5/01 processors can have up to 8 words associated with the slot. The SLC 5/02 and higher processors can have up to 32 words associated with the slot (0 to 31). For 16 I/O controllers, O:0/0 to 5 are valid and O:0/6 to 15 are considered unused outputs. (They do not physically exist). For 32 I/O controllers, O:0/0 to 11 are valid and O:0/12 to 15 are considered unused outputs.
Example I:2
Inputs of slot 2, word 0
I:2.1
Inputs of slot 2, word 1
I:1
Inputs of slot 1, word 0
Mask - Specify a hexadecimal constant or register address. For the mask, a 1 in an input’s bit position passes data from the source (physical input) to the destination (input image table). A 0 inhibits data from passing from the source to the destination.
Publication 1747-RM001G-EN-P - November 2008
Page 135
Program Flow Instructions
6-9
Refer to Entering Mask Values on page 5-17 for information about entering mask. Length - For SLC 5/03 and higher processors, this parameter is used to transfer more than one word per slot. Valid value is from 1 to 32.
This instruction allows you to update the outputs prior to the normal output scan. When the IOM instruction is enabled, the program scan is interrupted to transfer data to a specified I/O slot through a mask. The program scan then resumes.
Immediate Output with Mask (IOM)
Entering Parameters IOM Immediate Output w/Mask Slot O:2.0 Mask 00FFh Length 1
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
Output Instruction
•
•
Slot - Specify the slot number and the word number pertaining to the slot. Word 0 of a slot need not be specified. Fixed and SLC 5/01 processors can have up to 8 words associated with the slot. The SLC 5/02 and higher processors can have up to 32 words associated with the slot (0 to 30). For 16 I/O controllers, O:0/0 to 5 are valid and O:0/6 to 15 are considered unused outputs. (They do not physically exist). For 32 I/O controllers, O:0/0 to 11 are valid and O:0/12 to 15 are considered unused outputs.
Example O:2 O:1 O:2.1
Outputs of slot 2, word 0 Outputs of slot 1, word 0 Outputs of slot 2, word 1
Mask - Specify a hexadecimal constant or register address. For the mask, a 1 in the output bit position passes data from the source (output image table) to the destination (physical output). A 0 inhibits the data from passing from the source to the destination. Refer to Entering Mask Values on page 5-17 for information about entering mask. Length - For SLC 5/03 and higher processors, this parameter is used to transfer more than one word per slot. Valid value is from 1 to 32.
Publication 1747-RM001G-EN-P - November 2008
Page 136
6-10
Program Flow Instructions
I/O Refresh (REF)
Using an SLC 5/02 Processor
(REF) SLC 5/02 Processor
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
The REF instruction has no programming parameters. When it is evaluated as true, the program scan is interrupted to execute the I/O scan and service communication portions of the operating cycle (write outputs, service comms, read inputs). The scan then resumes at the instruction following the REF instruction. You are not allowed to place a REF instruction in an STI subroutine, I/O subroutine, or user fault subroutine.
Output Instruction
ATTENTION
The watchdog and scan timers are reset when executing the REF instruction. You must insure that an REF instruction is not placed inside a non-terminating program loop. Do not place an REF instruction inside a program loop unless the program is thoroughly analyzed.
Using SLC 5/03 and Higher Processors REF Refresh I/O Channel 0 Channel 1
Yes No
Operation of the REF instruction in the SLC 5/03 and higher processors is the same as the SLC 5/02 processor. However, when using the SLC 5/03 and higher processors, you can also select a specific communication channel to be serviced. • SLC 5/03 processor. – channel 0 is RS-232/DF1 Full-duplex, DF1 Half-duplex (master or slave), DF1 Radio Modem, DH-485, or ASCII – channel 1 is DH-485 • SLC 5/04 processor. – channel 0 is RS-232/DF1 Full-duplex, DF1 Half-duplex (master or slave), DF1 Radio Modem, DH-485, or ASCII – channel 1 is DH+ • SLC 5/05 processor. – channel 0 is RS-232/DF1 Full-duplex, DF1 Half-duplex (master or slave), DF1 Radio Modem, DH-485, or ASCII – channel 1 is Ethernet You are not allowed to place a REF instruction in a DII subroutine, STI subroutine, I/O subroutine, or user fault subroutine.
Publication 1747-RM001G-EN-P - November 2008
Page 137
Chapter
7
Application Specific Instructions
This chapter contains general information about the application specific instructions and explains how they function in your application program. Each of the instructions includes information on: • what the instruction symbol looks like. • how to use the instruction.
Table 7.1 Application Specific Instructions Instruction Mnemonic
Instruction Name
Purpose
Page
BSL and BSR
Bit Shift Left and
Loads a bit of data into a bit array, shifts the pattern of data through the array, and unloads the last bit of data in the array. The BSL shifts data to the left and the BSR shifts data to the right.
7-4
Bit Shift Right
1
SQO and SQC
Sequencer Output and Sequencer Compare
Controls sequential machine operations by transferring 16-bit data through a mask to image addresses.
7-6
SQL
Sequencer Load
Captures referenced conditions by manually stepping the machine through its operating sequences.
7-12
RHC
Read High Speed Clock
Provides a high performance time-stamp for performance diagnostics and preforming calculations such as velocity.
7-17
TDF
Compute Time Difference
Calculates the number of 10 µs “ticks” between any two time-stamps captured using the RHC instruction.
7-17
FBC
File Bit Comparison
7-18
DDT
Diagnostic Detect
Used to monitor machine or process operations to detect malfunctions.
RPC
Read Program Checksum
Copies the program checksum from processor memory or from the memory module into the data table.
7-18 7-23
Publication 1747-RM001G-EN-P - November 2008
Page 138
7-2
Application Specific Instructions
These instructions simplify your ladder program by allowing you to use a single instruction or pair of instructions to perform common complex operations.
About the Application Specific Instructions
In this chapter you will find a general overview preceding groups of instructions. Before you learn about the instructions in each of these groups, we suggest that you read the overview that precedes each section. This chapter contains the following overviews. • Bit Shift Instructions Overview • Sequencer Instructions Overview • RHC/TDF Instructions Overview
The following general information applies to bit shift instructions.
Bit Shift Instructions Overview
Entering Parameters Enter the following parameters when programming these instructions. • File is the address of the bit array you want to manipulate. You must use the file indicator (#) in the bit array address. • Control is the control element that stores the status byte of the instruction and the size of the array (in number of bits). Note that the control address should not be used for any other instruction. Table 7.2 Control File Structure 15
14
13
12
Word 0
EN
DN
Word 1
Size of bit array (number of bits)
Word 2
Reserved
Publication 1747-RM001G-EN-P - November 2008
11
10
ER
UL
09
08
07
06
Not Used
05
04
03
02
01
00
Page 139
Application Specific Instructions
7-3
Status bits of the control element may be addressed by mnemonic. They include: – Unload Bit UL (bit 10) stores the status of the bit exited from the array each time the instruction is enabled. – Error Bit ER (bit 11), when set, indicates the instruction detected an error such as entering a negative number for the length or position. Avoid using the output bit when this bit is set. – Done Bit DN (bit 13), when set, indicates the bit array has shifted one position. – Enable Bit EN (bit 15) is set on a false-to-true transition of the rung and indicates the instruction is enabled. When the register shifts and input conditions go false, the enable, done, and error bits are reset. • Bit Address is the address of the source bit that the instruction inserts in the first (lowest) bit position (BSL) or the last (highest) bit position (BSR). • Length (size of bit array) is the number of bits in the bit array, up to 2048 bits. A length value of 0 causes the input bit to be transferred to the UL bit. A length value that points past the end of the programmed file causes a runtime major error to occur.
TIP
If you alter a length value with your ladder program, make certain that the altered value is valid.
The instruction invalidates all bits beyond the last bit in the array (as defined by the length) up to the next word boundary
TIP
If a String element address is used for the file parameter, the maximum length for SLC 5/03 and higher processors is 672 bits. Additionally, String element boundaries cannot be crossed.
Publication 1747-RM001G-EN-P - November 2008
Page 140
7-4
Application Specific Instructions
Effects on Index Register S:24 The shift operation clears the index register S:24 to zero.
BSL and BSR are output instructions that load data into a bit array one bit at a time. The data is shifted through the array, then unloaded one bit at a time.
Bit Shift Left (BSL) Bit Shift Right (BSR)
Use BSL BSL Bit Shift Left File Control Bit Address Length
#B3:1 R6:14 I:1/4 58<
BSR Bit Shift Right File Control Bit Address Length
#B3:2 R6:15 I:1/6 28<
EN
When the rung goes from false-to-true, the processor sets the enable bit (EN bit 15) and the data block is shifted to the left (to a higher bit number) one bit position. The specified bit at the bit address is shifted into the first bit position. The last bit is shifted out of the array and stored in the unload bit (UL bit 10). The shift is completed immediately.
DN
EN DN
For wraparound operation, set the position of the bit address to the last bit of the array or to the UL bit, whichever applies.
Fixed SLC SLC SLC SLC SLC 5/01 5/02 5/03 5/04 5/05 •
•
•
•
•
•
Output Instructions
The figure below illustrates how the Bit Shift Left instruction works. BSL BIT SHIFT LEFT File #B3:1 Control R6:14 Bit Address I:22/12 Length 58
(EN) (DN)
Source Bit I:22/12 Data block is shifted one bit at a time from bit 16 to bit 73.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 INVALID 73 72 71 70 69 68 67 66 65 64
58 Bit Array #B3:1
Unload Bit (R6:14/10)
If you wish to shift more than one bit per scan, you must create a loop in your application using the JMP, LBL, and CTU instructions.
Publication 1747-RM001G-EN-P - November 2008