- •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 fb - 21.1
21. FUNCTION BLOCK PROGRAMMING
Topics:
•The basic construction of FBDs
•The relationship between ST and FBDs
•Constructing function blocks with structured text
•Design case
Objectives:
•To be able to write simple FBD programs
21.1INTRODUCTION
Function Block Diagrams (FBDs) are another part of the IEC 61131-3 standard. The primary concept behind a FBD is data flow. In these types of programs the values flow from the inputs to the outputs, through function blocks. A sample FBD is shown in Figure 21.1. In this program the inputs N7:0 and N7:1 are used to calculate a value sin(N7:0) * ln(N7:1). The result of this calculation is compared to N7:2. If the calculated value is less than N7:2 then the output O:000/01 is turned on, otherwise it is turned off. Many readers will note the similarity of the program to block diagrams for control systems.
N7:0 SIN
|
|
|
A |
|
|
* |
|
|
A < B |
|
O:000/01 |
|
|
|
B |
|
|
|
|
|
|
|
N7:1
LN
N7:2
Figure 21.1 A Simple Comparison Program
plc fb - 21.2
A FBD program is constructed using function blocks that are connected together to define the data exchange. The connecting lines will have a data type that must be compatible on both ends. The inputs and outputs of function blocks can be inverted. This is normally shown with a small circle at the point where the line touches the function block, as shown in Figure 21.2.
input |
|
output |
input |
|
|
output |
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inverted input |
inverted output |
|
Figure 21.2 Inverting Inputs and Outputs on Function Blocks
The basic functions used in FBD programs are equivalent to the basic set used in Structured Text (ST) programs. Consider the basic addition function shown in Figure 21.3. The ST function on the left adds A and B, and stores the result in O. The function block on the right is equivalent. By convention the inputs are on the left of the function blocks, and the outputs on the right.
Structural Text Function |
Function Block Equivalent |
|
|
||
|
|
|
|
|
|
|
A |
|
|
|
O |
O := ADD(A, B); |
|
ADD |
|
||
|
|
||||
|
|
|
|||
B |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Figure 21.3 A Simple Function Block
Some functions allow a variable number of arguments. In Figure 21.4 there is a third value input to the ADD block. This is known as overloading.
plc fb - 21.3
Structural Text Function |
Function Block Equivalent |
|
|
||
|
|
|
|
|
|
|
A |
|
|
|
O |
O := ADD(A, B, C); |
|
ADD |
|
||
|
|
||||
|
|
|
|||
B |
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
C |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Figure 21.4 A Function with A Variable Argument List
The ADD function in the previous example will add all of the arguments in any order and get the same result, but other functions are more particular. Consider the circular limit function shown in Figure 21.5. In the first ST function the maximum MX, minimum MN and test IN values are all used. In the second function the MX value is not defined and will default to 0. Both of the ST functions relate directly to the function blocks on the right side of the figure.
Structural Text Function |
Function Block Equivalent |
|
|
||
|
|
|
|
|
|
|
A |
|
|
|
|
|
|
MN |
|
O |
|
|
|
|
|||
O := LIM(MN := A, IN := B, MX := C); |
|
|
LIM |
|
|
|
|
|
|
||
|
B |
|
IN |
|
|
|
|
|
|
||
|
C |
|
MX |
|
|
|
|
|
|
O |
|
|
|
|
|
|
|
|
|
|
|
|
|
O := LIM(MN := A, IN := B); |
A |
|
MN LIM |
|
|
|
|
||||
|
|
|
|||
|
B |
|
IN |
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
Figure 21.5 Function Argument Lists
21.2 CREATING FUNCTION BLOCKS
When developing a complex system it is desirable to create additional function blocks. This can be done with other FBDs, or using other IEC 61131-3 program types.
plc fb - 21.4
Figure 21.6 shows a divide function block created using ST. In this example the first statement declares it as a FUNCTION_BLOCK called divide. The input variables a and b, and the output variable c are declared. In the function the denominator is checked to make sure it is not 0. If not, the division will be performed, otherwise the output will be zero.
|
|
|
FUNCTION_BLOCK divide |
|
|
|
VAR_INPUT |
|
|
|
a: INT; |
|
divide |
|
b: INT; |
|
a |
|
END_VAR |
|
|
VAR_OUTPUT |
|
|
|
||
|
|
|
|
|
c |
|
c: INT; |
|
|
||
|
b |
|
END_VAR |
|
|
IF b <> 0 THEN |
|
|
|
|
|
|
|
|
c := a / b; |
|
|
||
|
|
|
ELSE |
|
|
|
c := 0; |
|
|
|
END_IF; |
|
|
|
END_FUNCTION_BLOCK |
Figure 21.6 Function Block Equivalencies
21.3 DESIGN CASE
21.4SUMMARY
•FBDs use data flow from left to right through function blocks
•Inputs and outputs can be inverted
•Function blocks can have variable argument list sizes
•When arguments are left off default values are used
•Function blocks can be created with ST