The text of a manual · part 9 of 19
Classic 1785 PLC-5 Programmable Controllers User Manual (1785-LT, -LT2, -LT3, -LT4), pages 81 to 90
Pages 81 to 90 of 186
The original document is the PDF (1.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 Allen-Bradley 1785-LT2, Allen-Bradley 1785-LT3, Allen-Bradley 1785-LT4 and Allen-Bradley 1785-LT B
Page 81
Chapter 6 Planning Your System Programs
Table 6.F Processor Status File Addresses This word of the status file:
Arithmetic flags • bit 0= carry • bit 1 = overflow • bit 2= zero • bit 3 = sign Processor status and flags Switch settings: • bits 0 - 5 = DH+ station # • bit 7 = set is scanner; reset is adapter (PLC-5/15, -5/25 only) • bit 11, 12 = HW addressing bit 12 bit 11 0 0 illegal 1 0 1/2-slot 0 1 1-slot 1 1 2-slot • bit 13, 14 = EEPROM bit 14 bit 13 0 0 EEPROM transfer if processor memory bad 0 1 EEPROM transfer disabled 1 1 EEPROM transfer at power-up • bit 15 = set is memory unprotected
S:0
S:1
S:2
S:3 to S:6
S:8 S:9 S:10 S:11 S:12 S:13 S:14 S:16 S:18 S:19 S:20 S:21 S:22 S:23 S:24 S:25 S:26
6-10
Stores:
(PLC-5/12, -5/15, -5/25 only)
Active Node table: Word Bits DH+ Station # 3 0-15 00-17 4 0-15 20-37 5 0-15 40-57 6 0-15 60-77 Last program scan duration (in ms) Maximum program scan duration (in ms) Minor fault bits Major fault bits Fault code storage location Program file where fault occurred Rung number where fault occurred I/O status file number storage location Processor clock year Processor clock month Processor clock day Processor clock hour Processor clock minute Processor clock second Indexed addressing offset I/O adapter image file User control bits for processor start-up routine
Page 82
Chapter 6 Planning Your System Programs
This word of the status file: S:28 S:29 S:30 S:31
Stores: Program watchdog setpoint (in ms) Fault routine file STI setpoint (in ms) STI file number
6-11
Page 83
Chapter
7
Selecting Interrupt Routines
Chapter Objectives
This chapter covers interrupt routines that you can choose to include when you program your system. System Design Determined If you want to read about:
Go to page:
Using programming features
7-1
Writing a fault routine
7-3
Choosing Hardware Placing System Hardware Assigning Addressing Mode, Racks, and Groups
Selecting Interrupt Routines Transferring Discrete and Block Data Calculating Program Timing
Choosing Communication Planning Your System Programs
Using Programming Features
Use your design specification to determine if you need one or more of the following programming features: program execution control power-up routines
If a portion of logic should execute:
Example:
Use:
By doing the following:
Immediately on detecting conditions that require a startup
Restart the system after the system has been shut down
Powerup/Fault Routine
Create a separate file for a controlled start-up procedure for the first time that you start a program or when you start a program after system down time. The processor executes the power-up/fault routine to completion.
Immediately on detecting a major fault
Send critical status to a supervisory processor via DH+ after detecting a major fault
Fault Routine
Create a separate file for a controlled response to a major fault. The first fault detected determines which fault routine is executed. The processor executes the fault routine to completion. If the routine clears the fault, the processor resumes the main logic program where it was interrupted. If not, the processor faults and switches to program mode.
7-1
Page 84
Chapter 7 Selecting Interrupt Routines
Program Execution States User programs in the Classic PLC-5 processor are always in one of the following five states: completed, ready, executing, waiting, or faulted.
Rescheduling Operation
Rescheduling Operation
Ready State Program would be executing if it were of a higher priority; all programs pass through this state; there can be several programs in this state at any given time Waiting State Program is ready for execution but is waiting for some event to occur (such as an input to transition or a timer to complete)
Waiting State While block transfer is taking place, a rescheduling operation is performed and lower-priority programs are executed (unless all other executions are prohibited by a UID/UIE zone around the block transfer)
Rescheduling Operation
Completed State Program has completed execution or has not yet started execution
Executing State Program is executing; only one program can be in this state at one time
Has a new program with a higher priority become ready? (e.g., an MCP, STI, PII)
Yes
No Does the program fault?
Yes
Faulted State A run-time error has occurred within the program
No
Yes
Does the program request a remote block transfer? (STI and PII routines only)
Program counter is adjusted to point to next instruction
Does an appropriate fault routine choose to clear the fault? No Completed State Program has completed execution or has not yet started execution
7-2
No All active user programs are aborted and processor enters faulted state
Yes
Page 85
Chapter 7 Selecting Interrupt Routines
Writing a Fault Routine
You can write a fault routine that the processor runs when it detects a major fault. For example, if your program file becomes corrupted, you can tell the processor to interrupt the current program, run your fault routine and then continue processing the original program. This section shows you how to set and write a fault routine and how to protect your processor from powering up in run mode after a power loss.
Responses to a Major Fault When the processor detects a major fault, the processor immediately interrupts the current program. If a fault routine exists (i.e., specified in S:29 as a fault routine), the processor runs that fault routine program for recoverable faults. Then, depending on the type of fault, the processor: returns to the current ladder program file if the processor can recover from the fault enters fault mode if the processor cannot recover from the fault For example, the rung in Figure 7.3 includes an instruction that causes a major fault. Figure 7.3 Sample Ladder Logic for a Fault A
B
] [
Causes a major fault
C
In the example in Figure 7.3, the processor runs the fault routine after detecting the fault. If the fault routine resets the faulted bits, the processor returns to the next instruction in the program file that follows the one that faulted and outputs on the remainder of the rung. If you do not program a fault routine for fault B, the processor immediately faults. The bits in word 11 of the processor status file indicate the type of major fault. See Table 7.G to determine whether a fault is recoverable.
7-3
Page 86
Chapter 7 Selecting Interrupt Routines
Table 7.G Response to Major Faults (Word 11 of the Status File) This bit:
Indicates this fault:
00
Corrupted program file
01
Corrupted address in ladder program (see fault codes 10-19)
02
Programming error (see fault codes 20-29)
05
Start-up protection fault (see word 26, bit 1) Processor sets bit 5; if your fault routine does not reset this bit, the processor inhibits startup
07
User-generated fault; processor jumped to fault routine (see fault codes 0-9)
08
Watchdog faulted
13
STI file does not contain ladder logic or does not exist
03
Processor detected an SFC fault (see fault codes 74-79)
04
Processor detected an error when assembling a ladder program file (see fault code 70)
09
System is configured wrong; you installed a RAM cartridge but configured the system for an EEPROM or you violated 32-point I/O module placement rules for 1-slot addressing
10
Non-recoverable hardware error
14
Fault routine does not contain ladder logic or does not exist
15
Fault routine program file does not contain ladder logic
And the fault is:
Recoverable the fault routine can instruct the processor to clear the fault and then resume scanning the program.
Not recoverable the processor enters fault mode without scanning the fault routine.
A remote block transfer from a fault routine causes the processor to stop scanning all programs until the block transfer completes. Major Fault Codes Table 7.H lists major fault codes. The processor stores the fault code in word 12 of the processor status file.
7-4
Page 87
Chapter 7 Selecting Interrupt Routines
Table 7.H Major Fault Codes Code
Fault
00-09
Reserved for user-defined fault codes
12
Bad integer operand type, restore new processor memory file
13
Bad mixed mode operation type, restore new processor memory file
14
Not enough operands for instruction, restore new processor memory file
15
Too many operands for instructions, restore new processor memory file
16
Corrupted instruction, probably due to restoring an incompatible processor memory file
17
Can't find expression end; restore new processor memory file
18
Missing end of edit zone; restore new processor memory file
20
You entered too large an element number in an indirect address
21
You entered a negative element number in an indirect address
22
You tried to access an undefined program file
23
You used a negative file number, you used a file number greater than the number of existing files, or you tried to indirectly address files 0, 1, or 2
24
You tried to indirectly address a file of the wrong type
30
You tried to jump to one too many nested subroutine files
31
You did not enter enough subroutine parameters
32
You jumped to an invalid (non-ladder) file
33 1
You entered a CAR routine file that is not 68000 code
34
You entered a negative preset or accumulated value in a timer instruction
35
You entered a negative time variable in a PID instruction
36
You entered an out-of-range setpoint in a PID instruction
37
You addressed an invalid module in a block transfer, immediate input, or immediate output instruction
38
You entered a return instruction from a non-subroutine file
39
FOR instruction with missing NXT
40
The control file is too small for the PID, BTR, BTW, or MSG instruction
41
NXT instruction with missing FOR
42
You tried to jump to a deleted label
44-69
Reserved
70
The processor detected duplicate labels
74
SFC file error detected
75
The SFC has too many active functions
77
SFC missing file or of wrong type for step, action, transition; or Subchart is created but empty; or SC or timer file specified in SFC empty or too small
78
The processor cannot continue to run the SFC after power loss
79
You tried to download an SFC to a processor that cannot run SFCs; or This specific PLC does not support this enhanced SFC
80
You incorrectly installed a 32-point I/O module in a 1-slot configuration (PLC-5/15, -5/25)
81
You illegally set an I/O chassis backplane switch; either switch 4 or 5 must be off
7-5
Page 88
Chapter 7 Selecting Interrupt Routines
Important: If the PLC-5 processor detects a fault in the fault routine (double fault condition), the PLC-5 processor goes directly to fault mode without completing the fault routine.
Programming a Fault Routine If you choose to program a fault routine, first have the fault routine examine the major fault information recorded by the PLC-5 processor and decide whether to do the following before the PLC-5 processor automatically goes to fault mode: set an alarm clear the fault shutdown in an orderly manner On detecting a major fault, the PLC-5 processor immediately suspends the program file it was running and, if programmed, runs the fault routine file once to completion. If the PLC-5 processor does not run a fault routine, or the fault routine does not clear the fault, the PLC-5 processor automatically switches to fault mode. Set an Alarm You may need an alarm to signal when a major fault occurs. Put this rung first in your fault routine program alarm output and combine it with a counter. You can also set an alarm in your fault routine to signal when the fault routine clears a major fault. Clearing the Fault If you decide to clear the fault in the fault routine, place the ladder logic for clearing the fault at the beginning of the fault routine. You can compare the fault code with a reference. Compare fault code with a reference - Identify the possible major faults and then select only those your application will let you safely clear. These are your reference fault codes. From the fault routine, examine the major fault code that the processor stores in S:12. Use an FSC instruction to compare the fault code to the reference file that contains “acceptable” fault codes (word-to-file comparison). If the processor finds a match, the FSC instruction sets the found (.FD) bit in the specified control structure. Use a MOV instruction to clear the fault in S:11. Then jump to the end of the fault routine to quickly complete running the fault routine. 7-6
Page 89
Chapter 7 Selecting Interrupt Routines
In Figure 7.4, #N10:0 is the reference file. Figure 7.4 Example of Comparing a Major Fault Code with a Reference R6:0 RES R6:0 U IN FSC FILE SEARCH/COMPARE
EN
Control
R6:0
Length
20
Position
0
Mode Expression S:12 = #N10:0 R6:0 ] [
MOV
FD
Source
DN
ALL
ER
MOVE Dest
0 S:11 10 JMP
Last rung in fault routine 10 ] LBL [
TND
The processor completes the scan of the fault routine. If the routine clears S:11, the processor returns to the program file and resumes program execution. If the fault routine does not clear S:11, the processor executes the rest of the fault routine and goes into FAULTED mode. Important: If the fault routine clears the major fault, the processor completes the fault routine and returns to the next instruction in the program file that follows the one that contained the faulted instruction. The remainder of the rung is executed. It appears that the fault never occurred. The fault routine execution continues until you correct the cause of the fault.
7-7
Page 90
Chapter 7 Selecting Interrupt Routines
Using Shutdown Logic Shutdown programming should include the following considerations. Store initial conditions and reset other data to achieve an orderly start-up later. Monitor the shutdown of critical outputs. Use looping if needed to extend the single fault routine scan time up to the limit of the processor watchdog timer so that your program can confirm that critical events took place.
Testing a Fault Routine To test a fault routine, use a JSR instruction to jump to the fault routine. Send a fault code as the first input parameter of the JSR instruction. The processor stores the fault code in status word 12 and sets the corresponding bit in word 11. You may detect and set your own faults using fault codes 0-9 or by using the processor-defined fault codes 10-87.
Setting Up a Fault Routine You can write multiple fault routine programs and store them in multiple fault routine files, but the logic processor runs only one fault routine program when the PLC-5 processor detects a major fault. The number of the fault routine the PLC-5 processor runs is stored in word 29 of the processor status file. Typically, you enter a fault routine file number with the programming software and change the specified fault routine file from the ladder program. To set up a fault routine, you need to: enable the fault routine by entering a fault routine file number in the status file create the program file and enter fault routine logic clear a major fault (other than by the fault routine)
Enabling a Fault Routine To enable a fault routine, store the program file number (3-999) of the file that contains the fault routine logic in word 29 of the processor status file. When the processor encounters a major fault, the processor runs the fault routine logic to handle the fault.
7-8