- •16. ADVANCED LADDER LOGIC FUNCTIONS
- •16.1 INTRODUCTION
- •16.2 LIST FUNCTIONS
- •16.2.1 Shift Registers
- •16.2.2 Stacks
- •16.2.3 Sequencers
- •16.3 PROGRAM CONTROL
- •16.3.1 Branching and Looping
- •16.3.2 Fault Detection and Interrupts
- •16.4 INPUT AND OUTPUT FUNCTIONS
- •16.4.1 Immediate I/O Instructions
- •16.4.2 Block Transfer Functions
- •16.5 DESIGN TECHNIQUES
- •16.5.1 State Diagrams
- •16.6 DESIGN CASES
- •16.6.1 If-Then
- •16.6.2 Traffic Light
- •16.7 SUMMARY
- •16.8 PRACTICE PROBLEMS
- •16.9 PRACTICE PROBLEM SOLUTIONS
- •16.10 ASSIGNMENT PROBLEMS
- •17. OPEN CONTROLLERS
- •17.1 INTRODUCTION
- •17.3 OPEN ARCHITECTURE CONTROLLERS
- •17.4 SUMMARY
- •17.5 PRACTICE PROBLEMS
- •17.6 PRACTICE PROBLEM SOLUTIONS
- •17.7 ASSIGNMENT PROBLEMS
- •18. INSTRUCTION LIST PROGRAMMING
- •18.1 INTRODUCTION
- •18.2 THE IEC 61131 VERSION
- •18.3 THE ALLEN-BRADLEY VERSION
- •18.4 SUMMARY
- •18.5 PRACTICE PROBLEMS
- •18.6 PRACTICE PROBLEM SOLUTIONS
- •18.7 ASSIGNMENT PROBLEMS
- •19. STRUCTURED TEXT PROGRAMMING
- •19.1 INTRODUCTION
- •19.2 THE LANGUAGE
- •19.3 SUMMARY
- •19.4 PRACTICE PROBLEMS
- •19.5 PRACTICE PROBLEM SOLUTIONS
- •19.6 ASSIGNMENT PROBLEMS
- •20. SEQUENTIAL FUNCTION CHARTS
- •20.1 INTRODUCTION
- •20.2 A COMPARISON OF METHODS
- •20.3 SUMMARY
- •20.4 PRACTICE PROBLEMS
- •20.5 PRACTICE PROBLEM SOLUTIONS
- •20.6 ASSIGNMENT PROBLEMS
- •21. FUNCTION BLOCK PROGRAMMING
- •21.1 INTRODUCTION
- •21.2 CREATING FUNCTION BLOCKS
- •21.3 DESIGN CASE
- •21.4 SUMMARY
- •21.5 PRACTICE PROBLEMS
- •21.6 PRACTICE PROBLEM SOLUTIONS
- •21.7 ASSIGNMENT PROBLEMS
- •22. ANALOG INPUTS AND OUTPUTS
- •22.1 INTRODUCTION
- •22.2 ANALOG INPUTS
- •22.2.1 Analog Inputs With a PLC
- •22.3 ANALOG OUTPUTS
- •22.3.1 Analog Outputs With A PLC
- •22.3.2 Pulse Width Modulation (PWM) Outputs
- •22.3.3 Shielding
- •22.4 DESIGN CASES
- •22.4.1 Process Monitor
- •22.5 SUMMARY
- •22.6 PRACTICE PROBLEMS
- •22.7 PRACTICE PROBLEM SOLUTIONS
- •22.8 ASSIGNMENT PROBLEMS
- •23. CONTINUOUS SENSORS
- •23.1 INTRODUCTION
- •23.2 INDUSTRIAL SENSORS
- •23.2.1 Angular Displacement
- •23.2.1.1 - Potentiometers
- •23.2.2 Encoders
- •23.2.2.1 - Tachometers
- •23.2.3 Linear Position
- •23.2.3.1 - Potentiometers
- •23.2.3.2 - Linear Variable Differential Transformers (LVDT)
- •23.2.3.3 - Moire Fringes
- •23.2.3.4 - Accelerometers
- •23.2.4 Forces and Moments
- •23.2.4.1 - Strain Gages
- •23.2.4.2 - Piezoelectric
- •23.2.5 Liquids and Gases
- •23.2.5.1 - Pressure
- •23.2.5.2 - Venturi Valves
- •23.2.5.3 - Coriolis Flow Meter
- •23.2.5.4 - Magnetic Flow Meter
- •23.2.5.5 - Ultrasonic Flow Meter
- •23.2.5.6 - Vortex Flow Meter
- •23.2.5.7 - Positive Displacement Meters
- •23.2.5.8 - Pitot Tubes
- •23.2.6 Temperature
- •23.2.6.1 - Resistive Temperature Detectors (RTDs)
- •23.2.6.2 - Thermocouples
- •23.2.6.3 - Thermistors
- •23.2.6.4 - Other Sensors
- •23.2.7 Light
- •23.2.7.1 - Light Dependant Resistors (LDR)
- •23.2.8 Chemical
- •23.2.8.2 - Conductivity
- •23.2.9 Others
- •23.3 INPUT ISSUES
- •23.4 SENSOR GLOSSARY
- •23.5 SUMMARY
- •23.6 REFERENCES
- •23.7 PRACTICE PROBLEMS
- •23.8 PRACTICE PROBLEM SOLUTIONS
- •23.9 ASSIGNMENT PROBLEMS
- •24. CONTINUOUS ACTUATORS
- •24.1 INTRODUCTION
- •24.2 ELECTRIC MOTORS
- •24.2.1 Basic Brushed DC Motors
- •24.2.2 AC Motors
- •24.2.3 Brushless DC Motors
- •24.2.4 Stepper Motors
- •24.2.5 Wound Field Motors
plc advanced functions - 16.14
16.3.2 Fault Detection and Interrupts
The PLC can be set up to run programs automatically using interrupts. This is routinely done for a few reasons;
•to deal with errors that occur (e.g. divide by zero)
•to run a program at a regular timed interval (e.g. SPC calculations)
•to respond when a long instruction is complete (e.g. analog input)
•when a certain input changed (e.g. panic button)
These interrupt driven programs are put in their own program file. The program file number is then put in a status memory S2 location. Some other values are also put into status memory to indicate the interrupt conditions.
A fault condition can stop a PLC. If the PLC is controlling a dangerous process this could lead to significant damage to personnel and equipment. There are two types of faults that occur; terminal (major) and warnings (minor). A minor fault will normally set an error bit, but not stop the PLC. A major failure will normally stop the PLC, but an interrupt can be used to run a program that can reset the fault bit in memory and continue operation (or shut down safely). Not all major faults are recoverable. A complete list of these faults is available in PLC processor manuals.
Figure 16.15 shows two programs. The default program (file 2) will set the interrupt program file to 3 by moving it to S2:29 on the first scan. When A is true a compute function will interpret the expression, using indirect addressing. If B becomes true then the value in N7:0 will become negative. If A becomes true after this then the expression will become N7:-10 +10. The negative value for the address will cause a fault, and program file 3 will be run. In fault program status memory S2:12 is checked the error code 21, which indicates a bad indirect address. If this code is found the index value N7:0 is set back to zero, and S2:11 is cleared. As soon as S2:11 is cleared the fault routine will stop, and the normal program will resume. If S2:11 is not cleared, the PLC will enter a fault state and stop (the fault light on the front of the PLC will turn on).
plc advanced functions - 16.15
S2:1/15 - first scan
program file 2
A
B
program file 3 |
|
EQU |
|
|
|
|
SourceA S2:12 |
|
|
|
|
SourceB 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Figure 16.15 A Fault Recovery Program
MOV
Source 3
Dest S2:29
CPT
Dest N7:1
Expression
N7:[N7:0] + 10
MOV
Source -10
Dest N7:0
MOV
Source 0
Dest N7:0
CLR
Dest. S2:11
A timed interrupt will run a program at regular intervals. To set a timed interrupt the program in file number should be put in S2:31. The program will be run every S2:30 times 1 milliseconds. In Figure 16.16 program 2 will set up an interrupt that will run program 3 every 5 seconds. Program 3 will add the value of I:000 to N7:10. This type of timed interrupt is very useful when controlling processes where a constant time interval is important. The timed interrupts are enabled by setting bit S2:2/1 in PLC-5s.
plc advanced functions - 16.16
S2:1/15 - first scan
program file 2
program file 3
Figure 16.16 A Timed Interrupt Program
MOV
Source 3
Dest S2:31
MOV
Source 500
Dest S2:30
ADD
SourceA I:000
SourceB N7:10
Dest N7:10
Interrupts can also be used to monitor a change in an input. This is useful when waiting for a change that needs a fast response. The relevant values that can be changed are listed below.
S:46 - the program file to run when the input bit changes
S:47 - the rack and group number (e.g. if in the main rack it is 000) S:48 - mask for the input address (e.g. 0000000000000100 watches 02) S:49 - for positive edge triggered =1 for negative edge triggered = 0
S:50 - the number of counts before the interrupt occurs 1 = always up to 32767
Figure 16.17 shows an interrupt driven interrupt. Program 2 sets up the interrupt to run program file 3 when input I:002/02 has 10 positive edges. (Note: the value of 0004 in binary is 0000 0000 0000 0100b, or input 02.) When the input goes positive 10 times the bit B3/100 will be set.
plc advanced functions - 16.17
S2:1/15 - first scan
program file 2
program file 3
Figure 16.17 An Input Driven Interrupt
MOV
Source 3
Dest S2:46
MOV
Source 002
Dest S2:47
MOV
Source 0004
Dest S2:48
MOV
Source 1
Dest S2:49
MOV
Source 10
Dest S2:50
B3/100
When activated, interrupt routines will stop the PLC, and the ladder logic is interpreted immediately. If the PLC is in the middle of a program scan this can cause problems. To overcome this a program can disable interrupts temporarily using the UID and UIE functions. Figure 16.18 shows an example where the interrupts are disabled for a FAL instruction. Only the ladder logic between the UID and UIE will be disabled, the first line of ladder logic could be interrupted. This would be important if an interrupt routine could change a value between N7:0 and N7:4. For example, an interrupt could occur while the FAL instruction was at N7:7=N7:2+5. The interrupt could change the values of N7:1 and N7:4, and then end. The FAL instruction would then complete the calculations. But, the results would be based on the old value for N7:1 and the new value for N7:4.