61131-3, Sequential Function Chart... Anyone using it?

AutomationTechBrian

Lifetime Supporting Member
Join Date
Jul 2013
Location
St. Cloud, MN
Posts
669
I'm working on my 61131-3 knowledge for some up-coming projects, and there is an automated saw on the list that would probably be the perfect project to use Sequential Function Chart instead of Ladder (current program).

I've never used SFC.... Is anyone using it for programming, and do you have thoughts to share? Part of the problem is that I'm a visual learner, and I haven't ever seen a SFC program to dissect it. I'm hoping to find some examples somewhere.

Any thoughts or good knowledge links are appreciated.
 
It is pretty simple in most cases to implement and very useful for applications that have a sequence.
Its implementation varies from PLCs and I only have experience with B&R's SFC.
The program structure will consist of Step blocks and transitions. The step blocks will house the code that you would like to run during each respective step. The code in the step block can be whatever you want. You could have an SFC program with ladder in each step, or ladder in one step and structured text in another.

The transitions handle how the program progresses to each step. A good example would be your saw application. You will most likely have a step that advances the saw to cut your material. The transition from that step would most likely be a prox sensor that detects that the saw is at full stroke. This transition would then "transition" to the next step, where your code retracts the saw blade. Another transition can then be used to detect that the saw has retracted fully.

What you may find when going down the SFC road is the handling of outputs and how you will keep them on from step to step. Common practice is to latch-unlatch the outputs but there are other ways you can do it.

Steps will have their own status bits that you can use to see if the step is currently executing, first run of the step, and last run of the step. **Depending on manufacturer.

You can use these statuses to control your outputs in a separate ladder file. If you use structured text, you are inherently latching and unlatching the outputs.
 
Among good practices is to initially put exaggerated timers on your steps, so you can visually track your sequence during testing.

Also make sure to put a "step done bit" condition (X#.DN) at transitions after each step, otherwise scan will just zip through the step before completion.

If you diverge branches (the equivalent of an XOR sort of), make sure your entry transitions are mutually exclusive, or that there is absolutely no way that a scan can access more than one branch at once. Divergent branches fork out from a step, and converge back onto another one, as such:
SFC-example.png

Your sequences are to loop back to your initial step as shown above.

You'll observe that I haven't put a X_037.DN transition, that is because in this program I'm using the "active state (.X)" of steps 29 or 34 (called from another SFC routine) as my transitions. Often comes in handy to be able to do this.

Simultaneous branches fork out from a transition onto multiple steps, and converge back to another transition.

I've learned SFC through french documentation, so unless you're familiar with the language, there is unfortunately not much I can share in the way of documentation.
 
Last edited:
When available I make extensive of them. They offer 2 advantages:

1) Separation of concerns - Allows you to keep your sequencing/steps separate from other things such as Outputs, Timers, and math logic

2) Makes phone troubleshooting much easier - No need to walk a non-programmer through ladder code, just ask them to look at the SFC and tell you which block is blue. Then you have drastically narrowed down problems that cause things like a machine stopping

SFC is not a complete ladder replacement. You still use some ladder or ST if you prefer, as the backend language. SFC mostly gives you an easy visual tool for doing sequencing or state machine programming.

You can really appreciate SFC if you ever implemented a state machine in ladder code, then realized you needed to insert steps. Not only does it take longer, but your nice addressing scheme and program structure now starts to get hacked up. In SFC, it's simple, quick, and clean to insert steps.
 
I like using SFC with a single boolean tag to trigger transition between steps instead of an integer to keep track of a sequence.


Then I use the SFC_Step.X tags in the rest of the program logic to know which step is active.



A sequence which transitions through a bunch of steps can be programmed in ladder or FB and the programmer can see the logic which triggers all of the transitions in one program section.



I avoid putting any logic in the transitions because it makes the program hard to read as I then have to open a bunch of different windows to see what logic is hidden inside the transition.


I have seen programs in my same problem domain (hydro power plant controls) that used SFC step actions and it was rather difficult to figure out how the program worked.
 
You can really appreciate SFC if you ever implemented a state machine in ladder code, then realized you needed to insert steps. Not only does it take longer, but your nice addressing scheme and program structure now starts to get hacked up. In SFC, it's simple, quick, and clean to insert steps.


I like to use a self-healing sequencer inside of phase manager to handle heavy sequencing (all in ladder). You can have jumps inside the sequence that you can copy and paste with no overhead. Saves a lot of time when you are asked ”can you make x, y, do z?"
 
I like it as part of a complete program; you'll always need ST or LAD to accompany it, but it does a great job.
A couple of things to be aware of:
1. IEC actions execute at least twice. When you're finding counters are 1 more than you expected, you'll see this!
2. Each Step needs some Exception handling in its transition. If you're moving a VSD forward waiting for a prox, then that step needs a 'Get-out' if the VSD faults for instance. The net result of this is Steps (IMO) need at least two transitions following it; one for the proper sequence, and one to get you to a state where faults can be handled.

I like it, but it's a bit Marmite with people I talk to.
 
Ot

I like it, but it's a bit Marmite with people I talk to.

FYI, from Wikipedia:

Marmite (/ˈmɑːrmaɪt/ MAR-myte) is a British food spread produced by Unilever. Marmite is made from yeast extract, a by-product of beer brewing. Other similar products include the Australian Vegemite, the Swiss Cenovis, and the German Vitam-R.

Marmite is a sticky, dark brown food paste with a distinctive, powerful flavour, which is extremely salty. This distinctive taste is reflected in the marketing slogan: "Love it or hate it." Such is its prominence in British popular culture that the product's name has entered the English language as a metaphor for something that is an acquired taste or tends to polarise opinions.
 
I'm taking all of the comments in. Thanks!

I've spent a lot of drive time thinking about using SFC since posting this. It seems perfect for a couple of projects coming up. I went looking for YouTube videos and found one in Yaskawa's offerings, which is great. I like their "MotionWorks IEC" series, and I'll probably do one of my upcoming projects with their PLC and Servo drive. I'm a very visual learner, and these videos are gold to me.

https://www.youtube.com/watch?v=OzAxCNoGbt0&t=946s

BTW, Marmite.... I see I'm not the only one who looked that up! Lol
 
I use it all the time. It can take complex systems and make the code quite simple and easy to follow. Once service techs learn how to read it they love it as well. Program control can be a bit tricky until you have some experience or understanding of the instructions. I use ladder managers to monitor conditions then make the sfc executive the actions. I also use a time delayed action on almost every step so I can manipulate dwell time and pauses very easily. Once you get use to it you will use it for lots of things.
 

Similar Topics

Hello, I have a small programming task that I need help solving. I have to: * Create an analog input (4-20v)and a digital output * The analog...
Replies
45
Views
25,060
I was poking through the Stackoverflow PLC Tag when I saw this answer to a question about converting a Real to a DWord and back again. What...
Replies
8
Views
2,887
I am looking for some expert advice. I have always made function blocks both with inputs and outputs and without inputs or outputs. I make the...
Replies
21
Views
6,703
Hello and happy new year! I would like to further understand who needs to design by this standard and is it a requirement for everyone or only...
Replies
3
Views
1,774
So Ladder is easy to read graphically, most everything can be coded in ladder, and it represents wiring diagrams the closest. SCL and ST are good...
Replies
5
Views
1,711
Back
Top Bottom