Building Sequential Function Charts

In this chapter, we will implement a Sequential Function Chart (SFC) routine and break down the steps, actions, transitions, and branches that are used to construct it. We will also work with the online editing capabilities of SFC routines. Just as we have seen with the other IEC languages, SFC shares many of the common elements of other languages, but allows us to structure our programs in a different way. SFC programs are very well suited to running batches and cycles that follow a sequential step process or decision tree.

In this chapter, we will cover the following topics:

  • Introducing SFCs
  • Applying SFCs
  • Using the SFC editor
  • Building a backwash SFC routine

We will start this chapter with an overview of SFCs and their typical use within an industrial control system solution.

Technical requirements

To complete this chapter, you will need to create a Rockwell automation support account by going to https://www.rockwellautomation.com/account/create-account.

The account is free and the material we will be reviewing in this chapter is publicly available to anyone who is registered with Rockwell Automation.

You will also need a copy of RSLogix or Studio 5000 that has a license for Emulate 5000to program your project. You can either purchase this from your local distributor or request a time-limited trial version. You can find a local distributor for Rockwell Automation products at https://locator.rockwellautomation.com/.

Introducing SFCs

SFCis another IEC 61131-3 language that allows you to program visually using a flowchart construct. The IEC SFC language is based on the GRAFCET language, which was the original industrial automation flowchart programming language. In some regions and within some companies, you will find that the terms SFC and GRAFCET are used interchangeably. Like other IEC-based languages, it can share commonIEC elements and reference tags, as well as objects created in other languages, with your Logix program. SFC is a powerful, high-level language, similar to Function Block Diagram. Often, you can create the equivalent functionality of 40 Ladder Logic rungs in a few SFC steps. An SFC routine (again like Function Block) will typically have more computational overhead than the same routine developed using low-level languages such as ladder logic or structured text. SFC routines are very easy to debug and maintain because of their compact visual design. SFC has its strengths and weaknesses, like other IEC languages. An automation professional will select the correct language to meet the particular challenges of the process they face. It is not uncommon for automation professionals to realize that they have selected the wrong language for a particular task and rewrite the routine in a different IEC language.

In the next section, we will jump right into the typical use cases for SFC before we start to explore the features of the SFC editing environment.

Applying SFCs

As the name implies, SFC is well-suited for sequential step processes. You will also find that SFC is popular within batch processes as it closely aligns with the step-by-step requirements of batching. It is particularly useful when paired with other IEC languages. Within SFC routines, you use structured text for any logical expressions, assignments, or other constructs. By using the structured text function—JSR—(or similar functions), you can reference ladder logic, Function Block, structured text, or even other SFC routines. SFC can be used as a high-level program flow controller (business logic), and the detailed step logic can be created in separate routines. Structuring a program in this way will make it easy to follow, troubleshoot, and modify in the future.

Now that we understand when it is best to use SFC programming, we will discuss the SFC editing environment in the next section.

Using the SFC editor

The SFC editor appears in the Routine window of Logix Designer and is the development environment for writing SFC routines. Within an SFC routine, the SFC elements are created in an area called a sheet, and the sizes of the sheets directly correspond with the standard metric or English printer page sizes (similar to the Function Block diagram sheets). This allows the sheets to be easily printed, presented, and even signed like a typical engineering drawing. It is helpful to think of each sheet as a drawing paper for a single device. Unlike Function Block diagram sheets, you cannot divide your SFC into multiple named sheets. However, the SFC routine is not limited in size as a Function Block routine is. You can expand the size of the SFC routine to have up to 175 x 175 cross-reference grid blocks. An SFC routine can span multiple sheets horizontally and vertically. The specified sheet size makes it easier to organize the way the SFC routine appears when printed. You can see the sheet size divisions as solid gray lines on your SFC routine. The SFC editor window allows you to add the SFC elements from the SFC element group, drag them around the sheet, and connect the flow of the SFC elements using wires. The following screenshot shows an SFC routine window in RSLogix 5000:

In the following section, we will describe the use of SFC steps within the SFC editor to create our program flow diagrams.

Defining the SFC steps

Steps are the main building blocks of SFC routines. A step is associated with the logic to be executed at a specific point in your process. A step is represented by a rectangle shape in an SFC routine with a pin at the top and bottom. Steps can be referenced just like Function Block elements and contain a number of properties, as follows:

  • .T: This property is the length of time that the step has been active for.
  • .PRE: This property is the preset amount of time to run a step for.
  • .DN: This property is the Boolean flag that triggers high once the timer reaches the preset amount of time.
  • .X: This is a bit that is ON the entire time that the step is executing.

There are also a number of alarm properties that can be configured and triggered if a step runs too long or not long enough. The complete list of step properties can be found in the Help documentation by selecting a step element and pressingF1on the keyboard.

All SFC routines must have an initial step defined in order to run. The initial step is indicated with a double line around its rectangle shape. You can specify which step you would like to be the initial step by right-clicking on it and checking Initial Step.

The following screenshot shows two Step elements; on the left-hand side is the initial step, and on the right-hand side is a normal step:

Now that we understand the important role that steps play in an SFC program, we will introduce SFC actions in the following section.

Defining the SFC actions

Actions are associated with a step and contain the structure text code used to perform functions such as starting a pump. You can associate multiple actions with a single step. There are two types of actions:

  • Non-Boolean: These actions allow you to execute the structured text code or reference other routines using the JSR function.
  • Boolean: These actions set a Boolean tag value to true when it is ON. This action will require other logic to monitor this tag value in order to execute.

The following diagram shows a non-Boolean action on the left-hand side and a Boolean action on the right:

Each action element and its properties can be referenced and monitored. Action elements have the following properties:

  • .A: This property means that the Boolean property is ON when the action is active.
  • .T: This property is the length of time that the action has been active for.
  • .PRE: This property is the preset amount of time to run an action.
  • .Count: This property is the number of times the action has been active.

There are also a number of other properties that can be monitored on actions. The complete list of action properties can be found in the Help documentation by selecting an action element and pressingF1on the keyboard.

Actions also use qualifiers to determine when they should start and stop. By default, each action is set to non-stored qualifiers, which means it will execute when the step is associated with its execution.

The following qualifiers are available for actions:

Symbol

Name

Description

N

Non-stored

This qualifier starts when the step is activated and stops when the step is deactivated.

P1

Pulse (rising edge)

This qualifier starts when the step is activated and executes only once.

L

Time-limited

This qualifier starts when the step is activated and stops when the timer runs out or when it is deactivated.

S

Stored

This qualifier starts when the step is activated and stays active until a reset action property is triggered.

SL

Stored and time-limited

This qualifier starts when the step is activated and stays active until a reset action property is triggered or the timer runs out. It does not deactivate when the step is deactivated.

D

Time-delayed

This qualifier starts the action for a predefined amount of time after the step is active and while the step is still active. It stops when the step is deactivated.

DS

Delayed and stored

This qualifier starts the action for a predefined amount of time after the step is active and while the step is still active. It stays active until an action reset property is triggered.

SD

Stored and time-delayed

This qualifier starts when a specific amount of time has passed after the step is activated, even if the step is deactivated before this action. It stays active until an action reset property is triggered.

P

Pulse

This qualifier executes the action once when the step is activated and again when the step is deactivated.

P0

Pulse (falling edge)

This qualifier starts when the step is deactivated and executes only once.

R

Reset

This qualifier resets (turns off) an action and can be used to reset some of the other action qualifiers.

We are now familiar with SFC steps and actions. In the following section, we will introduce two more important SFC elements: transitions and branches.

Defining SFC transitions and branches

Transitions are used to bind steps to other steps and specify a structured text logical condition (which could also include a jump to a subroutine function) that must be true in order to proceed. A branch is a wire that connects to multiple transitions or steps. Branches and transitions work together to control the flow of an SFC sequence. There are three types of transitions/branches:

  • Sequence transition: This transition provides a logical expression between each step.
  • Selection branch transition: This transition provides a logical expression that will direct the step flow to one of many steps (similar to an OR expression). Additional steps can be added to a selection branch by right-clicking on it and selecting Extend Branch.
  • Simultaneous branch step: This transition executes two or more steps at the same time (similar to an AND expression). Additional steps can be added to a simultaneous branch by right-clicking on it and selecting Extend Branch.

The following diagram illustrates the visual style of each transition and branch type:

In the next section, we will discuss the final element of an SFC program, the Stop element, which ends the execution of our program flow.

Defining the SFC Stop element

The SFC Stop element stops the execution of an entire SFC routine or a particular branch of an SFC routine and waits for a restart to be triggered.

The following diagram demonstrates the use of a Stop element in an SFC routine:

Now that we have covered all the basic elements of the SFC programming language, we will create our own SFC backwash routine in the following exercise.

Building a backwash SFC routine

In this section, we will demonstrate the use of an SFC by building a backwash process using a step-by-step guide. The backwash process will be run to flush out the filters used in our process once they become too dirty. Let's follow these steps to do so:

  1. First, we will need to declare our new routine. Right-click on the MainProgram scope in the Controller Organizer pane and select New Routine:

  1. In the New Routine form that appears, enter or select the following values:
    • Name: BACKWASH
    • Description: Backwash Sequence
    • Type: Sequential Function Chart

Then, click on OK:

  1. In order for our newly created routine to be executed with each scan of the controller, we will need to add a reference to it in the MainRoutine program, which is executed with each scan of MainTask.
  2. Double-click on our MainRoutine program to display the MainRoutine ladder logic.
  3. Now, we can simply copy and paste one of the JSR ladder rungs we created earlier and change the value to point at our BACKWASH SFC routine.
  4. Right-click on the left-hand side of the last ladder rung (where the rung number is displayed) and select Copy (or press Ctrl + C). Right-click below the last rung and select Paste (or press Ctrl + V).
  5. Now, double-click on the Routine Name parameter of the JSR element and select our newly added BACKWASH routine:

  1. Now, we will return to our BACKWASH SFC by double-clicking on it in the Controller Organizer pane.
  1. As we have learned, the base unit of any SFC routine is a step. Certainly, we are planning to have more than one step in our routine, so it is wise to add a transition as well. We can add our first SFC step and transition at the same time by clicking on the Step + Transition icon in the SFC element group:

  1. You will see Step_000 and Tran_000 appear in the SFC editor window:

  1. Add an action to Step_000. Right-click on Step_000 and select Add Action (alternatively, you can select the Action element from the SFC element group toolbar above our routine):

  1. Now, we will add the initialization values for our SFC routine using the structured text syntax. Double-click on the box with the ? symbol at the bottom of Action_000 and enter the following structured text:
          BACKWASH_START_PB:=0; 
BACKWASH_FLT:=0;
        

The following screenshot shows the values of BACKWASH_START_PB (a push button for testing the backwash process) and BACKWASH_FLT (a variable that holds the fault condition for the backwash process) as 0 in Step_000:

  1. A red icon with an X symbol will appearto the side of Action_000 to indicate that there is an error with the structured text we have added. The error is due to theBACKWASH_START and BACKWASH_FLT tags not yet being declared in our routine. We can easily add these tags by right-clicking on the BACKWASH_START_PB tag in the Action_000box and selecting the New Tag "BACKWASH_START_PB" option.
  2. 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: MainProgram
  3. Repeat the same process for the second new tag by right-clicking on the BACKWASH_FLTtag and clicking on the New Tag form. Enter the following properties:
    • Name: BACKWASH_FLT
    • Description: BACKWASH SEQUENCE FAULT
    • Type: BOOL
    • Scope: MainProgram
  1. Next, we will add the transition conditional value, which will start our backwash sequence. Double-click on the Tran_000 question mark and enter the following structured text logical statement (which is equivalent toBACKWASH_START_PB=1):
          BACKWASH_START_PB
        

The following screenshot shows the addition of the transition action to the SFC logic:

  1. Next, we can add an action to Step_001 that will represent our backwashprocess.
At this stage, we can easily add a structured-text JSR function to call a separate ladder logic, Function Block, structured text, or even another SFC routine. By combining SFC and the JSR function, we can control the flow of our program from SFC. This technique is very helpful when developing and debugging complex batching or sequencing programs.
  1. Right-click on Step_001 and select Add Action:

  1. Now, we will add our action element's structured text code by double-clicking on the ? symbol in Action_001 and entering the following structured text code:
          FC1001_SP:=100; 
        
  1. We will also need to add the new FC1001_SPtag by right-clicking on it and selecting the New Tag option.
  2. Configure the new tag with the following properties:
    • Name:FC1001_SP
    • Description: FLOW CONTROLLER 1001 SETPOINT
    • Type: DINT
    • Scope: MainProgram

The following diagram shows the completed SFC with the newly added FC1001_SPtag:

  1. Let's add a delay to our Step_001 box in order to give our backwash time to complete. Right-click on Step_001 and select the Step Properties menu option. In the Step Properties form, set the Preset field to 30000ms (30 seconds) and click on OK:

  1. 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. A selection branch diverge executes one sequence or another sequence (OR), while a simultaneous branch diverge will execute two sequences in parallel (AND):

  1. The next piece of development work is to add our backwash sequence steps. Select the Tran_000 transition box, and then click on the Step element icon in the SFC element group above our SFC routine. The Step_001 step box will be added and automatically connected to Tran_000 (because we selected the transition before adding our new step):
  1. Our sequence will automatically reset and await another backwash if the flow controller valve position (FC1001_PV) has been 100 percent opened. Select Tran_001 and click on the ? icon to set the logical statement, which will execute this selection branch.

Type the following structured text logical statement:

          FC1001_PV=100
        

We will also need to add the FC1001_PV tag to our program by right- clicking on it and selecting New Tag

  1. In the New Tagwindow, enter the following field values:
    • Name: FC1001_PV
    • Description: FLOW CONTROLLER 1001 VALVE POSITION VALUE
    • Scope: MainProgram
  2. We want our sequence to reset after it has completed the backwash, so we will connect a wire from our transition, Tran_001, to the top SFC element in our sequence, Step_000. Click on the connector box under Trans_001 and drag it to the connector box on top of Step_000:

  1. If our valve fails to open, we want to raise a fault before resetting our sequence. Select Tran_002, click on the question mark, and enter the following structured text logical statement:
          FC1001_PV<>100 
        
  1. In order to raise a fault, we need to add a step. Select Tran_002 and click on the Step element icon.
  2. Add an action to our newly created step, Step_002, by right-clicking on it and selecting Add Action.
  3. Double click on the ? icon of our newly added action and add the following structured text code:
          BACKWASH_FLT:=1; BACKWASH_START_PB:=0;
        

The following screenshot shows the completed action code added to the SFC step:

The fault bit will prevent the backwash sequence from running again until the problem is investigated and the fault bit is reset.

  1. Finally, in order to make our sequence easy to understand, let's add a textbox comment. Click on the Text Box element in the SFC element group toolbar to add it to the sequence diagram and drag it to the right of the sequence. Enter the following comment:
          Backwash fault triggered if valve FC1001 fails to open.
        

The following screenshot shows the textbox comment added to our SFC program:

In the Errors panel, you should see the following output:

          Verifying Routine: MainProgram - BACKWASH... 

Complete - 0 error(s), 0 warning(s) 
        

If you do encounter an error, double-click on the error message to be taken to the exact location of the problem.

In the last exercise, we kept the default names for our steps, actions, and transitions. It is easy to rename the SFC elements to make the sequence easier to read and maintain. You can double-click on the existing name of a step, action, or transition and type in a new name to rename it.

  1. The complete SFC routine should be verified to ensure that there are no errors or warnings. From the drop-down menu, navigate to Logic | Verify | Routine.

We have now completed our first SFC routine to support a simple backwash operation. The previous exercise covered SFC steps, actions, transitions, and the stop element in a single program.

Summary

In this chapter, we explored SFCs and their typical uses within an automation project. We looked at the few core elements that make up an SFC and created a simple backwash process routine. The use of SFCs varies from industry to industry; however, there are certain cases where leveraging the IEC SFC construct can greatly simplify the creation and debugging of a program.

As with the previous IEC languages that we have covered in this book, selecting the appropriate language for your application is like selecting the correct tool to solve the problem you are facing. Although some programmers will only ever write in ladder logic, there are many advantages to using the full range of IEC languages where appropriate.

In the next chapter, we will identify ways to organize and control the scan frequency of a routine using tasks and programs.

Questions

The following questions can be used to test your retention of the concepts introduced in this chapter. You can find the answers to these questions in the back of the book under Assessments:

  1. What is the name of the IEC language that allows you to program visually using a flowchart construct and is based on the GRAFCET language?
  2. What SFC element is considered to be the main building block of SFC routines, is associated with the logic to be executed at a specific point in the process, and is represented by a rectangle shape with a pin at the top and bottom?
  3. What SFC element is associated with a step and contains the structure text code used to perform functions such as starting a pump?
  4. What SFC element is used to bind steps to other steps and specify a structured text logical condition that must be true in order to proceed?
  5. What SFC element is a wire that connects to multiple transitions or steps?
  6. What SFC element stops the execution of an entire SFC routine (or a particular branch of an SFC routine) and waits for a restart to be triggered?

Further reading

For more information about SFC programming within the Logix platform, please take a look at the Logix 5000 Controllers Sequential Function Charts Rockwell document at https://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm006_-en-p.pdf.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.69.255