Mitsubishi iQ-F and SFC Programming
As yet another example of the amazing flexibility and power that Mitsubishi’s iQ-F Controller, Mitsubishi has now added Sequential Function Chart programming to the FX5U and FX5UC compact, cost effective PLCs.
If you have been a PLC programmer for a long time you have probably programmed in ladder logic, and most likely Function Block Diagram languages (FBD) which has also been called Structured Ladder programming. You might have even used Structured text (ST) programming. But have you ever tried SFC? If you have a project where the machine acts very sequentially, SFC can’t be beat for making troubleshooting the sequence easier and faster.
Let’s explore all of the available languages in the FX5U and FX5UC PLCs.
The first is Ladder programming and it is the classic language for PLC programming which comes from classic relay logic. Ladder Logic is very easy to read for standard input and output logic if all you need are inputs, outputs, timers and counters. Once you go beyond simple logic, Ladder programming can start to look and feel kind of clunky. As you can see below, once we start trying to add Function Blocks into ladder, the classic clean look and feel starts to get broken up. The simple Set/Reset block really feels out of place.
That’s where Function Block Diagram (FBD) programming starts to show it’s power. It is much cleaner and easier to read when we start using larger function blocks. It also lends itself well to Object Oriented Programming techniques.
We also have Structured Text programming available to us. For those who have done extensive PC programming, a text based language may feel much more comfortable, but for PLC programmers there are still significant advantages to this language. For performing complex math or string manipulation, Structured Text (ST) language makes for a very clean, compact, easy to read language.
So with having 3 languages already, why would we need or want a fourth? First, let’s examine what SFC programming is. The name gives it away: Sequential Function Chart. SFC is represented as a flow chart format with Blocks, Actions, and Decisions (transitions).
An SFC program starts at an initial step, executes the next step every time the relevant transition becomes TRUE, and ends a series of operations at an end step.
1. When starting a block, the initial step (1) is activated first and then the action (2) is executed. After execution of the action (2), the program checks whether the next transition (3) has become TRUE.
2. The program executes only the action (2) until the transition (3) becomes TRUE. When the transition (3) becomes TRUE, the program ends the action (2), deactivates the initial step (1), and activates the next normal step (4).
3. After execution of the action of the normal step (4), the program checks whether the next transition has become TRUE. If the next transition does not become TRUE, the program repeats the execution of the action of the normal step (4).
4. When the transition becomes TRUE, the program ends the action, deactivates the step (4), and activates the next step (5).
5. Every time the transition becomes TRUE, the program activates the next step and ends the block when it finally activates the end step (6).
So where would I use SFC and why? If you’ve ever written ladder and used STL (Step Ladder) instructions or if you’ve ever written your own State Machine logic, then you’ve basically written SFC programs without knowing it. However, SFC has some advantages over STL and State Machine Logic in plain ladder.
With SFC, only the ACTIVE block is scanned. This means that the CPU can scan much faster and is much more efficient. Not only is your scan time reduced (often by very significant amounts), when monitoring SFC, you can see which step or steps are active very quickly and easily and jump right to a very small section of code to see what is going on.
In previous generations of PLCs, the logic inside SFC had to be written in Ladder programming. Now with the iQ-R and iQ-F PLCs, the code resides in an Action. Each Step can have up to 4 Actions tied to it, and each Action can be written in any of the standard three languages.
With the latest release of GX Works3 Programming software (Version 1.070Y) we now have SFC available to us on the FX5U and FX5UC series PLCs. If you have a PLC with serial number 1.7X or later, you can update the firmware to version 1.220 and take advantage of this powerful language.
I hope this brief introduction into SFC has piqued your interest. Now go write some code!