SFC A CTIONS
SFC A CTIONS
An SFC action is a child-type SFC sequence program that can be activated (started) or deactivated (killed) when the step is active. Remember that a child program belongs to a father, or main, program. SFC actions may have normal, set, or reset parameters that influence the operation of the SFC action (see Table 10-3). Figure 10-77 illustrates a batching process SFC that uses SFC actions. The main SFC program has two child programs, Batch_Mix and Batch_Pump, which are activated by the main (father) program. The main SFC program uses normal, set, and reset operands.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
Table 10-3. Syntax for SFC action parameters.
Main Chart
Child Charts
Batch_Mix Batch_Pump
1 1 Start
10 Batch_Mix (N);
20 Batch_Pump (S);
20 Level_Full
30 Batch_Pump (R);
2 Continue
Figure 10-77. Batching process implemented using SFC actions.
Once Start is triggered, the SFC activates both of the child programs. The Batch_Mix program has a normal (nonstored) parameter, while the Batch_Pump program has set and reset parameters. The Batch_Pump pro- gram becomes active as soon as step 20 is activated. It remains active until the signal Level_Full is turned ON, activating step 30 and resetting, or killing, the Batch_Pump program.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
SFC actions may be started or killed using any of the programming languages, depending on the IEC 1131-3 software system manufacturer. The syntax differs slightly from one system to another and may take the form shown in Table 10-4. The start and kill instructions have the same effects as the set (S) and reset (R) parameters, respectively. Figure 10-78 illustrates an SFC action using structured text. The starting and killing of the child program can be either nonstored or pulse actions, but in this example, the
( T R U E ) o r i n a c t i v e ( F A L S E ) . Table 10-4. Alternative syntax for SFC action parameters.
Main Chart
Child Chart
Batch_Pump
1 Start
2 (First_Action_Start)
10 (First_Action_Status)
Action (P):
Action (N):
Start (Batch_Pump);
If Status (Batch_Pump)=0
End_Action;
Then
Message:=“Batch Stopped”;
Else
2 Level_Full
Message:=“Batch Running”; End_If; End_Action; 3 (First_Action_Kill)
Action (P): Kill (Batch_Pump); End_Action;
3 Continue
Figure 10-78. An SFC action programmed using ST and alternative SFC action syntax.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
start and kill of the Batch_Pump program are both pulse actions. The status action (step 10) is a nonstored action used to send a message, perhaps to a display, to inform the operator of whether the batch is running or not running.
1 0 -5 I E C 1 1 3 1 -3 S O F T WA R E S YSTEMS
In addition to the implementation of the IEC 1131-3 in PLCs, many manufacturers of software systems provide the IEC 1131-3 standard in different hardware platforms and operating systems, such as Windows and Unix. These software systems emulate the operation of a programmable controller (i.e., they are software PLCs or “soft PLCs”) in the hardware platform being used (e.g., a PC). They support either a third-party I/O system or one or more of a PLC manufacturer’s I/O through the use of built-in drivers that communicate with an I/O rack (see Figure 10-79).
PC (“Soft PLC”)
I/O Devices
IEC 1131-3 Software System
Figure 10-79.
A software PLC interfaced with I/O devices.
The Paradym-31 software system from Wizdom Controls, Inc. provides an IEC 1131-3 graphical programming environment in a Windows-based soft- ware platform. This system allows the user to employ LD, FBD, or a custom- built function block language to program the actions in the SFC application. The user must program custom function blocks in C code. In fact, the Paradym-31 system compiles the entire IEC 1131 program in an ANSI C code and then downloads it to a hardware platform or to a third-party controller and its system.
Another software system, which offers a full implementation of all five IEC 1131-3 languages, is ISaGRAF from TranSys, Inc. and CJ International. This system provides a thorough set of instructions for all languages and several SFC-type actions. ISaGRAF also allows the user to test or simulate a PLC program in a personal computer, making it easier to debug an entire application or parts of it without actual hardware and I/O connections. ISaGRAF can run in a variety of operating systems, including OS-9, VRTX, VXWorks, ControlWare, DOS, and Windows NT. This software package can also transfer a control program to a programmable controller using a PortPack tool driver. Table 10-5 lists the ISaGRAF set of instructions for each of the IEC 1131-3 languages.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
L ADDER D I AGRAM S Y M BOLS
N IO T C Description E Type
S T RU CT U RED T EX T O PERAT ORS AN D S TAT EM EN T S
Symbol
Operators
Normally open contact (examine-ON)
g ro C Normally closed contact (examine-OFF) L Output coil
Boolean
• NOT: Boolean negation
• AND(&): logical AND
m ra
• OR: logical OR
• XOR: logical exclusive-OR
in
g —(SET)—
NOT, or inverted, output coil
• REDGE: rising-edge detection
Set output coil
• FEDGE: falling-edge detection
In Reset output coil
u • Subtraction: – s
d —(RET)—
Return—used as the conditional end of a program
• Multiplication: tri ×
or to return from a ladder diagram subprogram
a • Division: /
—(JMP)—
Jump to a label “LAB”
lT • Less than: <
I N ST RU CT I ON L
I ST O PERAT ORS
Comparison
• Greater than: >
t& • Less than or equal to: <= w • Greater than or equal to: >=
Operator Modifier Operand
Description
LD
Variable, constant
Loads operand
w id
• Equal to: =
e • Not equal to: <> o
ST
Variable
Stores current result
.in Sets to TRUE
Bool variable
Basic statements • Assignment (:+)
u • RETURN statement s o
Bool variable
Resets to FALSE
m Boolean AND
AND (&)
N(
Bool variable
• IF-THEN-ELSE structure
Bool variable
Boolean OR
• CASE statement
lte • WHILE iteration statement n x y
a XOR
N(
Bool variable
Exclusive-OR
• REPEAT iteration statement
ADD
Variable, constant
Addition
t.c • FOR iteration statement o
MUL
SUB
Variable, constant
Subtraction
m DIV
Variable, constant
Multiplication
• EXIT statement
1 • TSTART–TSTOP: timer control
Variable, constant
Division
Extensions
-8 • SYSTEM function 0 T
GT
Variable, constant
Test:>
GE (
Variable, constant
Test:>=
• OPERATE function
-7 ro C IE 5 LE
EQ
Variable, constant
Test:=
Controls the
• GSTART: starts an SFC program
Variable, constant
Test:<=
2 LT
execution of SFC • GKILL: kills an SFC program
ra 1
m 3 -8 1 3 JMP
Variable, constant
Test:<
child programs 1 • GFREEZE: freezes an SFC program m
Jump to a label
• GRST: restarts a frozen program
in S
RET
Returns from subprogram
• GSTATUS: gets current status of an SFC program
) Delayed operation/execution Acesses the status • GSnnn.x: Boolean value that represents the g n a u rd Note: N is used for negation (NOT) of the operand.
a g n a ( is used to indicate that the operation is to be delayed.
of an SFC step
activity of the step
• GSnnn.t: time elapsed since last activation of the e d
C is used to indicate a conditional operation.
step ( nnn is the reference number of the SFC step)
Table 10-5. ISaGRAF instruction set.
F U N CT I ON B LOCK D I AGRAM O PERAT ORS AN D F U N CT I ON S
3 T C N IO
Standard Operators
Functions
Standard Function Blocks
P P Data manipulation
• Assignment
Boolean
• SR: set dominant bistable
ro L g C
ra m Boolean operations
• Analog negation
• RS: reset dominant bistable
• Boolean AND
• R_Trig: rising-edge detection
• Boolean OR
• F_Trig: falling-edge detection
in g
• Boolean exclusive-OR
• SEMA: semaphore
In
Arithmetic operations
• Addition
Counting
• CTU: up counter
d • Subtraction
• CTD: down counter
u s • CTUD: up/down counter • Multiplication
tri • TON: ON-delay timing a Logic operations
• Division
Timers
lT • TOF: OFF-delay timing
• Analog bit-to-bit AND mask
e • TP: pulse timing x
• OR mask
t& • CMP: full comparison function block
• Exclusive-OR mask
Integer analogs
ww
Comparison tests
V • Less than or equal to
• Less than
• StackInt: stack of integer analogs
w id
Real analogs
• AVERAGE: running average for N samples
e • HYSTER: Boolean hysteresis on difference of reals .in o
• Greater than
• Greater than or equal to
• LIM_ALRM: high/low limit alarm with hysteresis
d C • Equal to
• INTEGRAL: integration over time
m • DERIVATE: differentiation according to time p
• Not equal to
Data conversion
• Convert to Boolean
a tri a • Convert to integer analog
• PID: proportional-integral-derivative control
lte Signal generation • BLINK: blinking Boolean signal n x y
t.c • Convert to timer o
• Convert to real analog
• SIG_GEN: signal generator
• Convert to message
m Other message concatenations 1 • System access
-8 • Operate I/O channel
h 0 T 0 P e IE -7
Standard Functions
Math
Trigonometric Register control Data manipulation
Data conversion
String management g ro C
5 2 • Absolute value
• Arc cosine
• Rotate left
• Minimum
• Character → ASCII code
• Get string length ra 1
m -8 1
• Exponent
• Arc sine
• Rotate right
• Maximum
• ASCII code 3 → character • Insert string m 1
3 • Power calculation
• Arc tangent
• Shift left
• Limit
• Delete substring g in S
a L n • Square root
• Shift right
• Modulo
• Replace substring n a • Multiplexer (4 or 8 entries) d g
Array manipulation
• Find substring
• Sine
• Create array of integer values • Extract left, middle, or part u rd
• Truncate decimal part • Tangent
• Binary selector
• Odd parity
• Read/write array element
• Get time of day
• Random value
Table 10-5 continued. R
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
PLC L ANGUAGES S IMILAR TO THE
I E C 1 1 3 1 -3
PLC manufacturers may adapt their programmable controller languages to embrace some of the qualities of the IEC 1131-3 standard. These qualities usually reflect the ease of programming found when using sequential function charts to encapsulate parts of a ladder program into an action. This added software versatility enhances a programmable controller system tremen- dously by speeding up program development, minimizing interlocking sequences, and reducing system troubleshooting time.
For instance, PLC Direct, a PLC manufacturer, offers programmable controllers with both standard ladder programming language instructions (RLL—relay ladder logic) and RLL Plus, which is their software language that incorporates some of the features of sequential function charts. In fact, the RLL Plus language closely follows the activation of a horizontal flow- chart. As an example, let’s examine a machine press application. The sequence chart in Figure 10-80 shows the sequential steps for implementing the pressing and stamping routine, which can be programmed using either standard ladder diagrams (see Figure 10-81a) or RLL Plus (see Figure 10- 81b). The highlighted sections of the program in Figure 10-81a indicate the interlocking requirements for the operation shown in the flowchart. While both the ladder diagram and the RLL Plus programs implement the same control and use the same inputs and outputs, the RLL Plus program is much easier to understand and troubleshoot. For example, if the press system stops at SG S0003 (stage step 0003) and the coil output does not jump to SG S0004 (stage step 0004), then the fault must have occurred in either the Press Down output (Y1) or the Lower Limit input (X4). By investigating just this area of the PLC program, rather than the whole ladder diagram, the troubleshooting technician can find the fault more quickly.
The RLL Plus programming language, like sequential function charts, ex- ecutes each stage’s ladder diagram actions when that stage is active. When the control program starts, the initial stage (ISG) is activated. Jump instructions, driven by the ladder diagram contacts that form the transition logic, pass the token from stage to stage. The last rung in the active stage performs the transition logic. The RLL Plus software also supports divergences and convergences, along with the use of timers and counters in the implementa- tion of transitions. Subroutine implementations are also available through the use of call instructions in the stage programming. Figure 10-82 presents the stage (SFC step) instructions typically used with the RLL Plus program- ming language.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
Press Arm
Part Detection Sensor
Machine Press
Operation (0) The machine is inactive (1) The operator presses the Start PB to start the machine. (2) The machine checks for a part. If the part is present, the process
continues. If it is not, the conveyor moves until a part is present. (3) A clamp locks the part in place. (4) The press stamps the part. (5) The clamp is unlocked and the finished piece is moved out of the press. (6) The process stops if the machine is in one-cycle mode or continues
if it is in automatic mode.
Step 4 Step 5
Start PB
X0 Clamp Y0
Part Present
X1 Press Y1
Part Locked
X2 Conveyor Y2
X3
Part Unlocked
X4
Lower Limit
X5
Upper Limit
X6
Conveyor Indexed
X7
One-Cycle Switch
Note: For this PLC an X denotes an input and a Y denotes an output. Figure 10-80. Pressing and stamping routine.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
Executes all rungs left to right, top to bottom
Only executes logic in stages that are active
S0000 Wait for start
C0
C0 C3 X11
Start S1
X0 Part
S0001 Check for a part
Part Present S2
Part Present
S0002 Lock the clamp
Clamp
Clamp SET Y0
Part Locked
Press
Limit
Conveyor Complete
X4 X6 C1 SG S0003 Press the part
Down Y1
Lower Limit
S0004 Unlock the clamp
X2 X4 C1 Y1
Top Limit Clamp
Part Unlocked S5
S0005 Index the conveyor C1 X5 C2 Move
Conveyor Moved
Complete Unlocked Conveyor Conveyor
C1 X3 X6 S0006 One cycle or automatic?
Run
One Cycle S0
JMP
X7
C0 Index
*wired N.C.
Figure 10-81. Pressing/stamping routine programmed in (a) ladder diagrams and (b) RLL Plus. SG denotes a stage step and ISG denotes an initial stage step.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
Initial Stage (ISG ) The initial stage instruction is used to signal the starting point of the user
ISG application program. The ISG instruction will be active on power up and
S aaa
PROGRAM to RUN transitions. ( aaa = Stage memory location)
Stage (SG)
Stage instructions are used to create structured programs. They are program SG
segments that can be activated or deactivated with control logic.
S aaa
( aaa = Stage memory location)
Jump (JMP)
The JMP coil deactivates the active stage and activates a specified stage when S aaa
there is power flow to the coil.
JMP
( aaa = Stage memory location)
Not Jump (NJMP)
S aaa The NJMP coil deactivates the active stage and activates a specified stage when there is no power flow to the coil. NJMP
( aaa = Stage memory location)
Converge Stages (CV)
Converge stages is a group of stages that, when all stages are active, will activate another stage specified by the associated converge jump(s) (CVJMP).
CV S aaa One scan after the CVJMP is executed, the converge stages will be deactivated.
( aaa = Stage memory location)
Converge Jump (CVJMP)
S aaa The CVJMP coil deactivates the active CV stages and activates a specified
stage when there is power flow to the coil.
CVJMP
( aaa = Stage memory location)
C aaa
Block Call/Block/Block End (BCALL w/BLK and BEND)
BCALL The BCALL coil activates a block of stages when there is power flow to the coil.
BLK is the label that marks the beginning of a block of stages. BEND is the BLK
label used to mark the end of a block of stages.
C aaa
( aaa = C memory location)
BEND
Figure 10-82. RLL Plus stage instructions.
Referring to Figure 10-81b, note that the program uses set and reset output instructions (SG2 and SG4, respectively) to turn ON and OFF the clamp (output Y0). Just like in an SFC, this is required because standard outputs in
a stage are turned OFF once the control token has been passed to another stage. In this case, set and reset parameters were used because the clamp output solenoid needed to be ON from stage 2 through stage 4. Figure 10- 83a shows the equivalent sequential function chart diagram of the program shown in Figure 10-81b. Figure 10-83b illustrates the flowchart of the process, which closely resembles the operation of the SFC program.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
Begin
0 Initial Stage IS00 Wait_for_Start
Start N PB
Start
Stage S01
SG 01
1 Check_for_Part
Check for Part
N Part Present
NOT Part_Present
Part_Present
Stage 02
2 Lock_the_Clamp
SG 02 Lock the Clamp
Part_Locked
Part N Locked
Stage 03 3 Press_the_Part Y SG 03
Press the Part
Lower_Limit
Lower N Limit
4 Stage 04
Unlock_the_Clamp
Y SG 04
Part_Unlocked
Unlock the Clamp
Part N Unlocked ?
Stage S05 5 Index_the_Conveyor
Y SG 05
Index (move) Conveyor
Conveyor_Moved
Conveyor N
6 Stage S06
Moved?
Check_Mode One_Cycle_or_Auto
Y SG 06
Check Mode
One_Cycle
NOT One_Cycle
One Cycle or Auto
Figure 10-83. (a) An SFC program for the press/stamp control program and (b) its
corresponding flowchart.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
E X AM PLE 1 0 -8
Referencing Figures 10-81b and 10-83a, implement an additional stage that monitors a normally closed stop push button and resets the completed pressing operation. This stage should be monitored at all times and, upon activation (i.e., after resetting all outputs), should return to the initial stage.
S OLU T I ON
The monitoring stage of the Stop PB must be activated as soon as the Start PB is pressed, which is when the program starts executing control. Figure 10-84 illustrates the Stop PB monitoring implementa- tion. Note that stage S500 is ON (set) as soon as Start is pressed in the initial stage. As the PLC scans the control program during execution,
Only executes logic in stages that are active ISG
S0000
Wait for start
When Start is pressed, stage 500 is set and program
X0 S1
execution continues in stages.
JMP SG
S0001
Check for a part
Part Present
S2 JMP
X1 Part Present
Lock the clamp Clamp
Set Y0
Part Locked
Monitor for stop
Stop
Y0–Y2
RST
If the N.C. stop PB is pressed, outputs Y0–Y2 and stages
X10
S0–S6
S0–S6 are reset. Program
RST
control goes to initial stage.
S0 JMP
Figure 10-84. Implementation of a stop-monitoring block.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
it also scans the Stop signal, which if pressed, resets all outputs (Y0 to Y2) and stages (S0 to S6) and then jumps to the initial stage (S0). Figure 10-85 shows the equivalent SFC level 1 implementation chart. Note that in the SFC, stage (step) 499 has been included so that a parallel AND divergence can be implemented and the Stop PB can be scanned (the actions in steps 4 and 5 do not execute any instructions). As the NOT Stop transition occurs (NOT Stop because of the normally closed wiring), the token passes to stage 500 for a one scan reset of all outputs, then, the token goes back to the initial stage.
0 Initial Stage IS00 Wait_For_Part
Wait/Monitor
Check_for_Part
Stop_Signal
NOT Part_Present
Part_Present
NOT Stop
Stage 502 2 Lock_the_Clamp
Stage 500 Reset_Outputs
Part_Locked Stage 503
Always_True
Press_the_Part Lower_Limit 4 Stage 504
Unlock_the_Clamp Part_Unlocked
5 Stage 05 Index_the_Conveyor
Conveyor_Moved 6 Stage 06
Check_Mode One_Cycle_or_Auto
One_Cycle
NOT One_Cycle
Figure 10-85. SFC level 1 implementation of Figure 10-84.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
1 0 -6 S U M M A RY
The IEC 1131-3 standard provides PLC users with tremendous advantages in both the programming and troubleshooting of a control system. Although not all PLC manufacturers offer an IEC 1131-3 language for their products, the trend is leaning toward the use of an SFC-type of structured programming, including one or more of the programming languages, in most PLCs.
PLCs and software systems that support all or part of the IEC 1131 standard have better documented programs than other systems because of the structure required to implement the control program. Other IEC 1131-3 characteris- tics, such as the necessity to declare variables to the I/O system, provide immediate benefits to anyone who is troubleshooting the system. The same holds true for anyone else who must modify the program after installation.
Even though the IEC 1131-3 programming method reduces program design time, users must employ a few guidelines to obtain maximum benefits from the method. Table 10-6 lists some rules that will help to obtain the maximum benefits of IEC 1131-3 programming and troubleshooting. For PLC users and programmers, one of the most important advantages associated with the IEC 1131-3 is the option to choose the language for the programming and implementation of the control system.
P ROGRAM M I N G G U I DELI N ES
• Be consistent in the definition of the control outputs and routines that will
take place in actions. • Define variables with proper, easy-to-reference names, especially the I/O
variables. • Be consistent in the programming of transitions. For instance, program
transition conditions from inside the actions or from external inputs to avoid double usage of transition variables within steps.
• Interlocking should be done, when possible, in the transitions. Do not perform interlocking in one action for another action, since one action may be ON while the other one is OFF.
• Document the actions and transitions properly so that troubleshooting personnel understands how the machine or process is being controlled.
T ROU BLESH OOT I N G G U I DELI N ES
• When there is a malfunction, locate the step that is active at that time. • Find out the status of the transition elements that form the logic after the
step where the operation halted. If it is an external input variable, check for hardware connections and interfacing; if it is an internal variable (coil, contact), check the step logic to see if the triggering signal is occurring.
• The active step and its following transition are generally the location in the program where a fault may occur and where the program stops.
Table 10-6. Rules for IEC 1131-3 programming and troubleshooting.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
One of the greatest obstacles to achieving a programming standard common to all PLCs is that PLC manufacturers cautiously protect their proprietary ways of using ladder and function block instructions in order to maintain competitive advantages. This, however, does not mean that PLC manufacturers will not evolve their languages into IEC 1131-3–type lan- guages that are transportable within their own family of PLCs. In the future, IEC 1131-3 “translators” (see Figure 10-86), which will be able to transport an IEC 1131-3 program from one PLC to another via PC software, may solve the transportability problem between different PLC brands. Regardless of potential and present obstacles, the IEC 1131 standard will surely set the pace for all PLC manufacturers wanting to continue their quest for improvement in control programming, troubleshooting, and system training.
Translator Software
IEC 1131-3
IEC 1131-3
Figure 10-86. IEC 1131-3 translator.
K EY action T ERMS Boolean action
Boolean variable convergence divergence function block diagram (FBD) IEC 1131 standard IEC 1131-3 programming standard instruction list (IL) integer variable ladder diagram language (LD) macrostep normal action pulse action real variable
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
S ECTION PLC The IEC 1131 Standard and C HAPTER 3 Programming
Programming Language 10
sequential function charts (SFC) SFC action stand-alone action step structured text (ST) subprogram transition
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
This page intentionally left blank.
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com