In the following recipe, we will demonstrate the usage of a Sequential Function Chart (SFC) by building a backwash process using a step-by-step guide.
First, we will need to declare our new routine. Right-click on MainProgram of Controller Organizer and select New Routine.
In the New Routine form that appears, enter or select the following:
Name:
BACKWASH
Description:
Backwash Sequence
Type: Sequential Function Chart
Then click on OK.
In order for our newly created routine to be executed with each scan of the PLC, we will need to add a reference to it in MainRoutine that is executed with each Scan of MainTask. Repeat Steps 3 to 7 of the Building Ladder Diagram programs recipe (or copy and paste the existing JSR), but use the routine name
BACKWASH
in the JSR element.Now we will add an Action to
Step_000
that was created by default. Right-click onStep_000
and select Add Action.Now we will add the initialization values for our SFC using ST syntax. Double-click on the box with ? at the bottom of Action_000 and enter the following structured text as shown in the following screenshot:
BACKWASH_START_PB:=0; BACKWASH_FLT:=0;
An icon with a red cross will appear to the side of Action_000, indicating that there is an error with the ST we have added. The error is due to the fact that
BACKWASH_START
andBACKWASH_FLT
do not yet exist in our program.We can easily add these values by right-clicking on the
BACKWASH_START_PB
tag in theAction_000
box and selecting the New Tag "BACKWASH_START_PB" option.The New Tag form will appear, which will allow us to create our new tag as follows:
Name:
BACKWASH_START_PB
Description:
START BACKWASH PUSH BUTTON
Type: BOOL
Scope: FirstController
Repeat the same process for the second new tag by right-clicking on the tag
BACKWASH_FLT
and the New Tag form and entering the following values:Name:
BACKWASH_FLT
Description:
BACKWASH SEQUENCE FAULT
Type: BOOL
Scope: FirstController
Next, we will add the Transition conditional value that will start our Backwash sequence. Double-click on the
Tran_000
question mark and enter the following logical statement (which is equivalent toBACKWASH_START_PB=1
)BACKWASH_START_PB
.Now we can add our backwash sequence step. Select the Transition box Tran_000 and then click on the Step element icon in the SFC element group above our SFC program. The step box,
Step_001
, will be added and automatically connected toTran_000
(because we selected it before adding our new step).Next, we can add an action to
Step_001
that will represent our backwash process. Right-click onStep_001
and select Add Action.Now we will add our action ST to the action element by double-clicking on ? in
Action_001
and enteringFC1001_SP:=100;
.Let's add a delay to
Step_001
in order to give our backwash time to complete. Right-click on Step_001 and select the Step Properties menu option. On the Step Properties form, set the Preset field to30000
ms (30 seconds). Click on OK.Next, we will add a Selection Branch Diverge in order to reset our sequence or trigger a fault if there is a problem. Select
Step_001
and then click on the Selection Branch Diverge Element icon just above our sequence chart. The icon is shown in the following screenshot:A Selection Branch Diverge can also allow you to execute one or another sequence, while Simultaneous Branch Diverge will execute two sequences in parallel. Our sequence will automatically reset and await another backwash if the valve has successfully opened, 100 percent. Select Tran_001 and click on the ? icon to set the logical statement that will execute this Selection Branch. Type in the following structured text logical statement:
FC1001_PV=100
.We want our sequence to reset after it has completed the backwash, so we will connect a flow line from our transition
Tran_001
to the top element in our sequence,Step_001
. Click on the connector box underTrans_001
and drag it to the connector box on top of Step_000.If our valve fails to open, we want to raise a fault before resetting our sequence. Select Tran_002, click on ?, and enter the following structured text logical statement;
FC1001_PV<>100
.In order to raise a fault, we will need to add a Step. Select
Tran_002
and click on the Step Element icon.Add an action to our newly created step,
Step_002
, by right-clicking and selecting Add Action.Double-click on ? of our newly added action and add the following ST code:
BACKWASH_FLT:=1; BACKWASH_START_PB:=0;
In order to make our sequence easy to understand, let's add a Text Box comment. Click on the Text Box element to add it to the sequence diagram and drag it to the right of the sequence. Enter in the following comment:
Backwash fault triggered if valve FC1001 fails to open.
The previous programs we have developed are ideal for a single state whereas SFC routines are well suited for more complex processes that require simultaneous operations. SFCs are steps that are connected to transitions. A flow line will connect the step and transition in the sequence. Transitions are the triggers between each step and each step acts as a collection of actions. A Selection Branch Diverge will follow one or the other path and a Simultaneous Branch Diverge will execute two sequences at the same time.
More information on SFC can be found in the Rockwell publication Logix5000 Controllers Sequential Function Charts available at http://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm006_-en-p.pdf. In the interest of saving time in the last exercise, I did not follow the best practice of providing useful names to the steps and transitions.