Professional Documents
Culture Documents
Bryan - Programmable Controllers Theory and Implementation - 387-429
Bryan - Programmable Controllers Theory and Implementation - 387-429
Bryan - Programmable Controllers Theory and Implementation - 387-429
L.A. Bryan
E.A. Bryan
SECTION PLC The IEC 1131 Standard and CHAPTER
3 Programming Programming Language 10
Custom Report
Conditions Function Block
to trigger report
Finished
Report
Values Temp_Var
passed from Variable_1
variables Press_Var
Variable_2
IF REPORT THEN
Message “Target Temperature:”:=Variable_1
Message “Actual Temperature:”:=Variable_2
END_IF
Figure 10-13. Report generation function block created using structured text.
1 TRANSITION
ACTION
1 Trans_1
2 Trans_2
3 Empty_Batch (FBD)
3 Trans_3
the PLC to execute a certain control function during that step. An action
may be programmed using any one of the four IEC 1131-3 languages. After
the PLC executes a step/action, it must receive a transition before it will
proceed to the next step. A transition can take the form of a variable input,
a result of a previous action, or a conditional IF statement (e.g., IF
Temp_1≥100). So, for the application shown in Figure 10-15, the PLC will
execute action 2 only after step 1 receives a valid input and transition 1
1 LS_Reach
2 Action_2
2 IF Temp_1≥100
3 Action_3
3 PB_Return
occurs (i.e., the limit switch LS_Reach triggers). After the PLC finishes action
2, it will wait for transition 2 (IF Temp_1≥100) to occur and then move to
step 3.
As mentioned earlier, the sequential function chart language has its origin in
the French standard Grafcet, a flowchart-like programming language. The
Grafcet graphic language also uses steps, transitions, and actions, which
operate in the same manner as in SFC. In Grafcet, when a step is active, the
processor scans the I/O logic and program pertinent to the step’s action, as
well as the logic for the transition immediately after it (i.e., the transition
that deactivates the step and action).
Start
Trans_1 OFF
1 ?
1 Trans_1 ON
Step 2 Action
2 Action_2
2 Trans_2 OFF
Trans_2
?
3 Action_3
ON
3 Trans_3 Step 3 Action
action will occur until the At_Top_LS command is satisfied, at which time,
the process will stop and the Return_Solenoid output will reset for another
sequence. Figures 10-17b and 10-17c illustrate the timing diagram as
implemented in Grafcet and SFC, respectively. Both of these programming
languages graphically represent the timing diagram implementation using
Outputs Activation
Advance_Solenoid
Clamp_Solenoid
Drill_Motor
Return_Solenoid
LS
LS
S
U
_L
_L
n_
t_
c_
th
op
en
itio
Se
ep
_T
es
os
0_
_D
At
_P
Pr
_1
At
rt_
In
er
rt_
Pa
m
Pa
Ti
Transitions
(a)
(a)Timing
Timing diagram
diagram
1 Wait 1
Part_Present_LS Part_Present_LS
2 Advance_Solenoid 2 Advance_Solenoid:=True
3 Clamp_Solenoid 3 Clamp_Solenoid:=True
At_Depth_LS At_Depth_LS
Clamp_Solenoid Clamp_Solenoid:=True
4 4
Drill_Motor Drill_Motor:=True
5 Return_Solenoid 5 Return_Solenoid:=True
At_Top_LS At_Top_LS
(b)(b)Grafcet
Grafcet (c) IEC
IEC1131-3
1131-3SFC
SFC
Figure 10-17. Comparison of (a) a timing diagram with its associated (b) Grafcet
and (c) SFC programs.
steps, actions, and transitions. The actions represent the activation of the
solenoid and drill motor, while the transitions represent the limit switch inputs
and timer status.
The major difference between Grafcet and SFC is that Grafcet employs only
written action statements, such as Open_Variable (e.g., Open_Valve) to
implement its action blocks and turn devices ON and OFF. SFC, on the
other hand, implements actions in a number of ways using LD, IL, ST, and
FBD or a combination of these languages, including custom function blocks.
For example, in action 2 of the Grafcet program in Figure 10-17b, the
statement Advance_Solenoid indicates the turning ON of the field device
associated with the output variable assigned to Advance_Solenoid. In other
words, if an output variable is stated in a Grafcet action, it will become
TRUE or ON. In the SFC-equivalent program in Figure 10-17c, the step 2
instruction indicates that the Advance_Solenoid will be equal to TRUE
(ON). Thus, SFC does not actually contain a statement of the output
variable, but rather an instruction that turns the device ON or OFF (TRUE
or FALSE) during that action.
Main
SFC Macrostep SFC
Program Program
Macrostep
One of the greatest advantages of sequential function charts is that they are
easier to troubleshoot than standard ladder diagram programs. For example,
in the sequential function chart shown earlier in Figure 10-17c, if the action
Clamp_Solenoid (solenoid ON) at step 3 does not make the transition to step
4, it is easy to recognize that a problem occurred at the transition after step 3,
which corresponds to the activation of the At_Depth_LS transition. Thus, an
SFC pinpoints the step or transition where a fault occurs.
Figure 10-19 shows a simple ladder diagram and its FBD, ST, and IL
language equivalents. Note that the ST language (see Figure 10-19c) uses two
operators, AND and &, to denote the AND function. The := symbol is used in
an ST program to assign an output variable (e.g., Valve_3) to a logic
expression. In instruction list (see Figure 10-19d), the first instruction
(instruction LD) loads the status of variable Limit_S_1 to the accumulator
register, which IL calls the result register. The second instruction (instruc-
tion AND) ANDs the status of Limit_S_1 with the variable Start_Cycle and
stores the outcome back in the result register. The third instruction (instruc-
tion ST) stores the contents of the result register as the output variable,
Valve_3. This process is similar to Boolean programming language.
Inputs Output
(a)
(a) Ladder
Ladder diagram (LD)
diagram (LD)
Function
Inputs Block Output
Start_Cycle &
(b)
(b)Function block diagram
Function block diagram(FBD)
(FBD)
Input
Output Logic Expression
(c)
(c)Structured text (ST)
Structured text (ST)
(d)
(d) Instruction list(IL)
Instruction list (IL)
Figure 10-19. Implementation of a simple program in (a) ladder diagram, (b) function
block diagram, (c) structured text, and (d) instruction list.
#Language=LD
#ENDlanguageLD
#Language=ST
If Motor Then Light_Out
Else DL_Motor_Off
#ENDlanguageST
#Language=FBD
a
b & OR
LS
#ENDlanguageFBD
#Language=IL
LD LS1
AND LS2
STR Motor
#ENDlanguageIL
EXAMPLE 10-3
SOLUTION
Figure 10-23 illustrates the timing diagram of the limit switch input. It
shows that a 50 msec delay (shown in blue) should exist in the OFF-
to-ON and ON-to-OFF transitions to filter any bouncing signals. Timers
can be used to implement both delays.
ON 1
OFF 0
OFF ON ON OFF
LS_Before
1
50 msec
Valid_LS
50 msec
0
Debounce FBD
LS Valid_LS
LS_Before OUT
102
(Latch/Unlatch)
Valid_LS
101 U102
U
1
LS_Before
0
1 DT
Set
0
50 msec
1
LS_Before
0
1 DT
Reset
0
DT 50 msec
1 DT
Valid_LS
0
50 msec
Figure 10-25. Timing diagram for the ladder circuit in Figure 10-24.
switch signal after passing through the debouncing circuit. Figure 10-
26 illustrates the same type of debouncing filter implementation using
FBD. Note that the output of the set/reset (S/R), or bistable, block will
LS TON_1 S/R
LS_Before Valid_LS
IN OUT S OUT
PR AR R
TON_2
IN OUT
50 msec T_Delay
constant PR AR
50 msec
50 msec T_Delay
T_Delay constant
constant
(a) LS2_Before
Valid_LS2
IN OUT
T_Delay
LS3_Before
Valid_LS3
IN OUT
T_Delay
(b)
Figure 10-27. (a) FBD as an encapsulated custom block and (b) a custom block used
to debounce three limit switch signals.
SFC F ORMAT
IN
Step Beginning Macrostep
Transition
Ending Macrostep
Jump to a Step OUT
Y12
IN
1 30
10 15
1
10 15 30
2
2 11 16 31
3 31
11 16
3
12 17 32
4 OUT
4 12 17
X10
Figure 10-29. Three SFCs representing a control process.
12 Start_Batch
(a) Level 1
12 Batch_Complete
12 (Start_Batch)
Level:=Switch_Level Structured
If Level Then Motor:=True Text
(b) Level 2 Batch_Time:=t#8M
Tstart (Batch_Time)
12 (Batch_Complete)
Batch_Time≥Timeout
Figure 10-30. (a) Level 1 and (b) level 2 sequential function charts.
10 Condition X10
10 Condition Y10
11 Condition X11
11 Condition Y11
Time: a1 a2
9 9
1
Y9
10 10 0
(a)
1
a1—Step a2—Step is active X10
not active after transition 0
Time: b1 b2
12 12
1
X12
(b) 12 12 0
1
b1—Step b2—Step is not Y12
is active active after transition 0
Figure 10-32. (a) An inactive step activated by a transition and (b) an active step
deactivated by a transition.
EXAMPLE 10-4
3 3 3
4 4 4
SOLUTION
Figure 10-34 shows the timing diagrams for each of the three stages
in Figure 10-33. When step 3 is active (with token), X3 is ON and its
action will be executed. Once the transition IN_1 occurs (Y3 goes from
OFF to ON), the token passes to step 4 for execution of its action; thus,
X4 becomes ON. Step 4 will remain active (ON) until transition IN_2
(Y4) becomes TRUE, at which time, the control token will pass to the
next step. Note that a transition does not need to remain ON once the
token is passed to the next step down the chart. For example, the
transition Y3 signal turned OFF immediately after passing the token to
step 4; the dotted line in the timing diagram indicates this.
a b c
3 3 3 1
X3
0
3 IN_1 3 IN_1 3 IN_1 1
Y3
0
4 4 4
1
X4
0
4 IN_2 4 IN_2 4 IN_2
1
(a)
(a) (b)
(b) (c)
(c) Y4
0
T RANSITIONS
1
10 10 10 Y10
0
1
A 0
1
B 0
9 A AND B 9 A AND B 9 A AND B 1
Y9 0
10 1
10 10 X10 0
1
C 0
10 C AND D 10 C AND D 10 C AND D
1
D 0
1
Y10 0
One Scan
Figure 10-36. Leading- and trailing-edge transition pulses.
1
10 Y10
0
1
11 Mix_Batch X11
0
1
11 TMR/X11/100 sec Y11 100 sec
0
(a)
(a)
1
Y10
0
10
1
X11
0
11 Lower_Part
1
Y11 10 sec
0
11 TMR/X11/10 sec AND Down_Pos
1
Down_Pos
0
(b)
(b)
Figure 10-37. (a) A timed transition and (b) a timed transition combined with a
Boolean logic function.
The signal that triggers a transition may be the result of an external variable
or a step’s output. For example, in Figure 10-38, step 10’s action instructions
(in this case, an LD, ST, and FBD control sequence) control the status of the
transition Time_Up, which will move control execution to the next step.
When step 10 becomes active, the Mix_Start action begins, and the processor
scans all the I/O in the action and executes the program as described by the
action’s instructions. If Mix_Rdy is TRUE (in the LD part of the action),
then the motor will be turned on for 30 seconds as specified by the timer.
Once the 30 seconds have elapsed, the timer’s Boolean output variable
Time_Up, which is defined as an internal Bool variable, will be TRUE,
initiating the transition to the next step.
Level_2_OK Mix_Rdy
10 Mix_Start
LD Program
12 ACTION_1
applies for a normally closed device in a PLC using IEC 1131-3 program-
ming—all normally closed devices should be programmed as normally open,
regardless of the language used.
1
9 Trans_9 Y9
0
1
10 X10 One Scan
0
10 LS_1 1
(a) Y10
0
11 1
X11
0
1
9 Trans_9 Y9
0
1
10 X10
0
(b)
10 NOT LS_1 1
Y10
0
11 1
X11
0
Figure 10-40. The transition from step 10 to step 11 will (a) occur in one scan
unless (b) transition 10 is programmed as NOT LS_1.
Figure 10-41 illustrates a simple start/stop hardwired motor circuit and its
timing diagram. When the momentary normally open start push button is
pressed and the normally closed stop push button is not pressed, the motor will
be ON and its motor contacts M1-1 will seal the start push button, meaning
that the motor will remain ON until the stop PB is pressed. When the stop PB
is pressed, the circuit will lose continuity and the motor will turn OFF.
Logically speaking, as shown in the timing diagram in Figure 10-41, the
motor will be ON if both the start PB (wired as normally open) and the stop
PB (wired as normally closed) are ON (1), in other words, start is ON
(Start=1) and stop is NOT OFF (Stop=1). Therefore, the logic expression that
will turn M1 ON is M1=Start AND Stop.
1
Stop
0
L1 L2
Start PB 1
Stop PB Start
0
M1
1
M1-1 M1-1
0
1
Motor
0
Figure 10-41. A hardwired start/stop motor circuit and its timing diagram.
1
Start
0
1
1 Stop
0
1
1 Start_AND_Stop Y1
0
2 Motor:=True 1
X2
0
2 NOT_Stop 1
Motor
0
1
Y2
0
EXAMPLE 10-5
PLC Motor_1
Motor 1 O
N.O. I u
Start 1 n t
p p
N.C.
Stop 1 u u
t t
Motor 2 O Motor_2
N.O.
I u
Start 2 n t
p p
N.O. u
Stop 2 u
t t
SOLUTION
Figure 10-44 shows the SFC charts for the two push button stations,
while Figure 10-45 shows the corresponding timing diagrams. Note
that the logic for the transitions that turn the motors ON is different. For
Motor_1, the logic takes into consideration that the normally closed
stop push button is wired as normally closed. For Motor_2, the logic
shows that the stop push button is a normally open push button wired
as open to an input module.
PLC Motor_1
Motor 1 Chart 1 O
N.O. I 1
u
Start 1 n t
p 1 Start_1 AND Stop_1
p
N.C.
Stop 1 u 2 Motor_1:=True u
t t
2 Not_Stop_1
Chart 2
Motor 2 3 O Motor_2
N.O.
I u
Start 2 n 3 Start_2 AND NOT Stop_2
t
p p
N.O. u 4 Motor_2:=True
Stop 2 u
t 4 Stop_2 t
1
Start_1
0
1
Stop_1
0
(a)
1
X2 X2=Start_1 AND Stop_1
0
1
M_1
0
1
Start_2
0
1
Stop_2
0
(b)
1
X4 X4=Start_2 AND NOT Stop_2
0
1
M_2
0
Figure 10-45. Timing diagrams for (a) Motor_1 and (b) Motor_2.
10 (Motor M_1)
M1-1
So far, we have only discussed sequential function charts that have one link
between their steps and transitions. However, SFCs can have multiple links
between these program elements (see Figure 10-47). These multiple links can
be one of two types:
• divergences
• convergences
10 10
10 One 10 20
link Multiple
11 between links 11 21
each between
step steps
11 11 21
12 13
12 13
(a) (b)
Figure 10-47. An SFC with (a) one link between the steps and transitions and (b)
multiple links between steps and transitions.
A divergence is when an SFC element has many links going out of it, while
a convergence is when an element has many links coming into it. Both
divergences and convergences can have either OR or AND configurations,
which relate to the Boolean logic operators of the same name.
Figure 10-49 shows an SFC with an OR divergence after step 1. Once step 1
is activated, either step 10 or 20 can be activated if either transition 1 or 2 is
triggered. These two transitions have mutually exclusive triggering condi-
1
OR Divergence
1 2 (one step to several transitions)
10 20
10 20
11 30
11 30
OR Convergence
(several transitions to one step)
12
12
tions, so that the token advances in only one branch of the divergence.
Therefore, if transition 1 is triggered, step 10 becomes active; if transition 2
is triggered, step 20 becomes active.
An OR convergence, also called a single convergence, is used to link several
transitions to the same step (see Figure 10-50). An OR convergence is the
opposite of an OR divergence; it “converges” several transitions to one step.
Referring to Figure 10-49, this SFC illustrates an OR convergence in
addition to an OR divergence. The OR convergence indicates that either of
two links, one containing transition 11 and the other containing transition 30,
can pass the control token to step 12. Because of the mutually exclusive
requirement of the transition triggers, OR convergences and divergences are
well suited for programming alarm circuit SFCs like the one shown in
Figure 10-51. In this program, if the circuit is working properly after
initialization, the program will begin the control sequence (transition 1 to step
20); whereas if an error occurs, the program will initiate an alarm action
(transition 2 to step 30), which will sound an alarm until the alarm acknowl-
edgment is triggered (transition 30). From step 1, the program can pass the
token through only one path (either transition 1 or 2), but not both, because
of the logical mutual exclusivity of the OR programming.
1 Initialize
20 Start_Motor_M1 30 Alarm
20 M1_Started 30 Acknowledge
21 Start_Run
21 Time_Up
22 Stop_Motor_M1
22 M1_Stopped
1
AND Divergence
(one transition to several steps)
40 50
40 50
41 51
AND Convergence
2 (several steps to one transition)
10
10
AND divergences and convergences are ideal for running control programs
in a synchronized, parallel manner. For example, Figure 10-55 illustrates a
sequential function chart depicting two processes that occur in parallel (at
the same time). When transition 1 becomes active, it diverts activity to two
program sections, each controlling one of the processes. Each program
section, Process1 and Process2, must be completed (steps 21 and 31 active)
before transition 2 can occur, transferring control back to step 1. Note that in
an SFC transition like transition 2, which has the trigger variable True, the
transition is always triggered. When used in an application, this type of AND
convergence transition simply waits for both processes to finish before
transferring control to the next step.
1 Initialize
1 Run
20 Process1 30 Process2
20 End_of_Process1 30 End_of_Process2
21 Wait_for_Process2 31 Wait_for_Process1
2 True
Figure 10-55. An SFC using AND convergences and divergences to run two
processes in parallel.
S UBPROGRAMS
IN
OUT
with the ability to have a main program with one or more subprograms
organized in a “father-child” relationship (see Figure 10-58). A father
program can “call” (i.e., jump to) any of the child programs in a process, but
a child program can only have one father program.
Main
Program Subprogram 1 Subprogram 2
(Father) (Child) (Child)
Entry Entry
Return Return
Action that calls
subprogram 1 and
subprogram 2
states that the variable Actual_Weight will be equal to the value computed by
the subprogram SP_Weighing (SP denotes subprogram), which receives the
data values of the variables Max_Wt and Tare_Wt from the main program.
1
Program computes Max_Wt and Tare_Wt
Return
4 3
Variable Actual_Weight Value of Actual_Weight
is returned to the main is computed and becomes
program. the variable Actual_Weight.
The syntax for calling subprograms may differ slightly from one software
system to another. Nevertheless, all subprograms execute a small routine and
then return a desired computed value to the main program. Figure 10-60
illustrates how an SFC program calls a subprogram from an instruction in
one of its actions. In this example, step 11’s action (Action_11) has several
ST
10 Program
Instructions
Subprogram
SP_Check_Start
11 (Action_11) Init_Value:=SP_Check_Start
Return
End of ST
12 Program Instructions
Figure 10-61 illustrates several subprogram example calls using other lan-
guages. The SUBPROG_1 subprogram will be called and executed once it is
found directly in the program (IL and ST) or once the conditions are satisfied
(LD and FBD). Remember that the subprogram can be written in any of the
languages, regardless of the calling language. The PLC’s manufacturer can
provide IEC 1131-3 software system specifications for properly passing and
receiving subprogram parameters.
IL Language ST Language
10
SUBPROG_1 New_Value:=SUBPROG_1
11 (Action_11)
LD Language FBD Language
A
SUBPROG_1
A B SUBPROG_1
12
B &
OR
Sample
Figure 10-61. Subprogram calls in IL, ST, LD, and FBD languages. SUBPROG_1 is
defined as a subprogram during the program structure definition.
Subprogram_Name();
This syntax specifies the subprogram name and the return condition (), which
is a Boolean result that triggers the transition. The value returned by the
subprogram yields the following conditions:
1 (Initialize)
Subprograms
1 ErrEval( ); 2 EvalCond( );
20 (Alarm) 20 (Process)
20 Acknowledge 30 Process_End
Action:
Result_Variable:=Sub_Program();
End_Action;
Action (P):
1 Init:=SP_Initialize( );
End_Action;
20 (Alarm) 30 (Process)
Acknowledge True
B OOLEAN A CTIONS
20 (Boolean_Action) 1
Bool_Var_1
0
Bool_Var_1;
20 1
/Bool_Var_2; Bool_Var_2
Bool_Var_3(S); 0
Bool_Var_4(R); 1
Bool_Var_3
0
1
Bool_Var_4
0
1
Y20
0
or in another step; however, it keeps the variable as TRUE, even when the step
is deactivated. Conversely, the reset (R) parameter resets the variable to
FALSE when the step activity is TRUE. The reset action remains FALSE
until the variable is set. Figure 10-65 shows a similar example with different
variables. Note that the Solenoid_2(R) instruction resets the variable Sole-
noid_2, which was set to ON in a previous action.
1
Y19
0
1
19
X20
0
20 (Boolean_Action) 1
Motor_1
0
Motor_1;
20 1
/Motor_2; Motor_2
Solenoid_1(S); 0
Solenoid_2(R); 1
Solenoid_1
0
1
Solenoid_2
0
1
Y20
0
EXAMPLE 10-6
Using SFC Boolean actions, implement a chart that will turn ON and
OFF two pilot lights according to the timing diagram shown in Figure
10-66. In the timing diagram, PLight_1 is ON for one second while
PLight_2 is OFF, then PLight_1 is OFF for one second while PLight_2
is ON. Assume that a normally open push button labeled as Start
initiates the pilot light sequence and that a normally open push button
labeled as Reset resets the whole operation, turning both pilot lights
OFF. Include a light enable (Light_EN) pilot light indicator that is ON
at the start of the operation and OFF when the operation is reset.
Start PLight_1
ON
OFF
Reset PLight_2 ON
OFF
1 sec 1 sec
SOLUTION
Figure 10-67 illustrates the desired timing diagram of the two inputs
(Start and Reset) and the three pilot lights (PLight_1, PLight_2, and
Light_EN). Figure 10-68 depicts the SFC implementation of this
timing diagram, where the initial step sets both PLight_1 and PLight_2
to an OFF (FALSE) state. Once the Start push button is pushed, the
token passes to step 2, which has no action, and continues to the
1
Start
0
1
Reset
0
1
Light_EN
0
1
PLight_1
0
1
PLight_2
0
1 sec 1 sec
Figure 10-67. Timing diagram for the SFC implementation in Example 10-6.
1 (Initialize)
PLight_1:=False
PLight_2:=False
1 Start
2 Reset 4 Not_Reset
3 (Reset) 10 (ON1_OFF2)
Light_En(R); PLight_1;
/PLight_2;
Light_EN(S);
3 True 10 TMR/X10/1 sec
11 (OFF1_ON2)
/PLight_1;
PLight_2;
11 TMR/X11/1 sec
Figure 10-68. SFC implementation of the two pilot lights in Figure 10-66.
The implementation of the previous example could have been done many
different ways using Boolean actions. For instance, instead of using the
/PLight_2 and /PLight_1 instructions in steps 10 and 11, the program could
have specified only the ON conditions of PLight_1 and PLight_2 in steps
10 and 11, respectively, letting the transition trigger turn OFF the variables.
A stand-alone action could also have been programmed to detect the reset
function and send the program back to step 1 in the main chart. Figure 10-69
Chart 1
1 (Initialize)
PLight_1:=False If Reset Then F/Chart_1;X1
PLight_2:=False
1 Start Stand–Alone Action
2 (ON1_OFF2)
PLight_1;
2 TMR/X2/1 sec
3 (OFF1_ON2)
PLight_2;
3 TMR/X3/1 sec
Figure 10-69. Implementation of the process in Example 10-6 using a stand-alone action.
P ULSE A CTIONS
10 (Pulse_Action_Ex)
Action (P):
10 •
•
•
Instructions
11 •
•
•
11 End_Action;
The notation (P) indicates a pulse action. A pulse action may be represented
in a timing diagram as shown in Figure 10-71, where its execution is shown
at the start of the step activity. Figure 10-72 illustrates a typical SFC with a
1
Step Activity
0
Pulse Action 1
Execution 0
1 (Initialize)
Action (P):
Count:=0
1 CMD End_Action;
2 (Counting)
Action (P):
Count:=Count+1;
2 NOT_CMD End_Action;
3 CMD
N ORMAL A CTIONS
1
Step Activity
0
Normal Action 1
Execution 0
10 (Normal_Action_Ex)
Action (N):
10 •
•
•
Instructions
11 •
•
•
11 End_Action;
1 (Initialize)
Action (P):
R_Count:=0;
End_Action;
1 Start_Counting
2 (Count_Step)
Action (N):
If Cmd_Cnt AND NOT (Last_Cmd) Then
R_Count:=R_Count+1;
End_If;
Last_Cmd:=Cmd_Cnt;
End_Action;
2 Stop_Counting
EXAMPLE 10-7
SOLUTION
1
Start_ Counting
0
1
X2
0
1
Stop_Counting
0
1
Cmd_Cnt
0
1
Last_Cmd
0
1
R_Count
0
nt t nt t
C ou oun C ou oun
s t t C =1 d d C =2
1 f 1s nt n
f 2 of 2n ount
g of o o u o
d ing End R_C
nin En R_C
e gin g inn
B Be
SFC A CTIONS
Syntax Description
Batch_Mix Batch_Pump
1
1 Start
20 Level_Full
30 Batch_Pump (R);
2 Continue
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.
Syntax Description
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.
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.
PC
(“Soft PLC”) I/O Devices
IEC 1131-3
Software 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.