Is it less CPU load demanding to program with ST or FBD or is it the same?
After endless discussions with various engineers about cpu load when programming with text vs FB .
I cannot see that there should be any difference if you choose ST or FBD. the load should be the same.
Anybody know where I can find more information about this?
I cannot see that there should be any difference if you choose ST or FBD. the load should be the same.
Anybody know where I can find more information about this?
Voted best answer
This is good question.
I would say Martin87 is right.
However you can write more efficient ST code than CBM can compile from FBD. For example you can connect FB.OutPin directly at input pin of another function that is impossible in FBD within one Tab.
See manual 3BSE042835-610 Library Object Style Guide for guidelines on how to write efficient code.
AC800M specialists tend to recommend ST for developing library objects because ST is considered the most efficient language.
I would say Martin87 is right.
However you can write more efficient ST code than CBM can compile from FBD. For example you can connect FB.OutPin directly at input pin of another function that is impossible in FBD within one Tab.
See manual 3BSE042835-610 Library Object Style Guide for guidelines on how to write efficient code.
AC800M specialists tend to recommend ST for developing library objects because ST is considered the most efficient language.
Source: 3BSE042835-610 manual
Answers
it compiles down to the same machine code.
As Kamil and Martin are both "sort of" correct. The reason that FBD is - very slightly - less efficient than ST is because FBD really *IS* Structured Text underneath. If you directly open the source code XML files with the Open Interface or Compact CB, you will see the FBD program written directly in Structured Text.
However, the Function Block version requires more "hidden variables" to make the connections between function calls. Every link between an FBD function Block uses a hidden variable - so there is an extra "move" instruction and a few extra bytes of memory required for every connection.
Yes, FBD and ST compile down to the same thing. But FBD uses slightly more memory and more instructions. You can write ST more efficiently than you can write FBD. But of course, its also possible to write bad ST that takes more memory than required. But usually FBD is usually much easier to read and debug - so customers and field service engineers like it. Troubleshooting and debugging is much easier so there's a big saving in commissioning and fault finding time.
However, the Function Block version requires more "hidden variables" to make the connections between function calls. Every link between an FBD function Block uses a hidden variable - so there is an extra "move" instruction and a few extra bytes of memory required for every connection.
Yes, FBD and ST compile down to the same thing. But FBD uses slightly more memory and more instructions. You can write ST more efficiently than you can write FBD. But of course, its also possible to write bad ST that takes more memory than required. But usually FBD is usually much easier to read and debug - so customers and field service engineers like it. Troubleshooting and debugging is much easier so there's a big saving in commissioning and fault finding time.
Add new comment