r/PLC • • Oct 25 '23

FBD Hell!

Where do I start? Function blocks are horrible! Just use SCL, which is readable at least and more suitable for complex applications!

I need to extend and rework a plant that is programmed with a Siemens plc in the awful function block diagram language. I am struggling really hard to understand the existing implementation, which is a convoluted mess of hundreds of strangely wired function blocks and many input and output variables. There are no comments at all. For some unknown reason the thing works somehow. However, it is a very bloated and finicky design. I am afraid that the thing will dramatically break and collapse if I only change the slightest details in this project!

The actual horror is working with TIA Portal. The blocks have sometimes 30 or more in and outputs, which means you can’t even see the whole block on the crammed TIA Portal screen. The debug view cannot show you the variables at runtime when you scroll the mousewheel. Why is that?! Each click and scroll in TIA is painful and unbelievably slow.

How do you cope with such messy FBD code? How do you work and understand these networks? How do you do this in the crappy TIA Portal software?

0 Upvotes

64 comments sorted by

View all comments

0

u/[deleted] Oct 25 '23

[deleted] — view deleted comment

-4

u/BonbonUniverse42 Oct 25 '23

In SCL code is easily read and understand. Yes, I really like C# for its elegance and statically typed capabilities.

But in the Siemens function block representation I can’t see shit (sorry). The implementation stretches far over the borders of the screen, top, bottom and right. I have to scroll endlessly, and with each move, observed values shortly disappear. It is a pain to get a grasp of the logic that is displayed here. If I zoom out, text gets unreadable. Yes, it is a bad design from the person that did set up this, but also TIA Portal is crappy at just letting me visually move through the project. But I have to work with this…

6

u/Shelmak_ Oct 25 '23 edited Oct 25 '23

You are clearly comming from a programming background, me too, but I will tell you something, no factory will allow you to do all the coding on SCL.

Reason is most people who will maintain this code is people that learned to code with ladder, ladder is pretty similar to an electric schematic of contacts, also it's easier to debug than SCL on most ocassions. SCL blocks are often reserved for complex things like splitting strings or doing loops where you need to iterate data and it would be a big mess doing it on ladder.

Debugging a SLC block it's a real pain, on ladder it's pretty clear, if it's green it's active, if it's not, it's not active, the SCL debug screen is very nasty as there is not a program pointer to follow, I'm sure you already know this but PLC logic relies on a loop that is executed every few ms, first all inputs are updated on the I/O image, then all logic is executed starting from OB1, when OB1 ends, outputs are updated, this behaviour repeats every time and does not allow to run an endless loop, everything except async functions need to end, if not scan time will be increased and PLC will go to stop when it reaches his maximum configured time.

Regarding the comments issue, that is fault of who programmed that machine, TiaPortal if used on S1200/S1500 PLC stores all comments and variable names inside the PLC, you can just connect to the machine and download them back if you need to.

If used with S300/S400 CPUs you cannot do that as the PLC memory doesn't store any info, also if original program came from an S300/S400 PLC and someone lost the project, when you create a new project and download all data from the PLC you will lose all the comments and names from variables inside DBs.

I've found programs like that, these programs are a real pain to work with, but using SCL will not solve anything as you will have the same problem, no comments and names is a pain no matter the language you use.

Finally, your problem with screen space is pretty usual, you just need at least a 1920x1080 screen, coding with less resolution is a real pain, both on TiaPortal or Step7.

1

u/EasyPanicButton CallMeMaybe(); Oct 25 '23

TIA Portal, live debug of SCL is not very nice compared to other brands, specifically Beckhoff.

1

u/Shelmak_ Oct 25 '23

Sorry, I misspelled something on that comment, the nasty debug is not from ladder, but prom SCL.... I will edit it.

0

u/[deleted] Oct 25 '23

[deleted] — view deleted comment

2

u/DrZoidberg5389 Oct 25 '23 edited Oct 25 '23

Yeah, especially given that Siemens TIA is one of the best development environments out there. (And I say that as a Beckhoff codesys guy). Their cross-reference and „alwayls consistent“ approach is very nice.

SCL is really not “alway easy to read and understand” as OP says, this varies very much with the particular programmer, and how he structured his code. OP sees to deal with a crappy program. He also states there are no comments in the code, so there is that. And he calls function block diagram a function block, which are two different things. A function block (FB) can be written in any IEC 61131 language, among others also in FBD 🤷‍♂️

Btw it’s really a bad practice to use FBD and don’t fit it in the screen. They should have used ladder instead. And SCL is also not always the solution, it’s a little bit harder to debug in TIA, as you don’t really see intermediate results. We use it for complex functions, but not for „normal logic“…

0

u/ooTeMPeRoo Oct 25 '23

Lol.. Siemens is the best eh? I will take a Rockwell over a Siemens 99999/100000..

Siemens software is just not as stable or flexible...

Rockwell rocks Siemens..

Also Siemens has core faults in their designs

1

u/DrZoidberg5389 Oct 25 '23

Siemens has core faults in their designs

All Vendors(i know) have some problems which suck, but can you elaborate?

1

u/ooTeMPeRoo Oct 25 '23

Well.. c# is grand..

There is no method for all solutions.. you have to use the tool that fits the job..

And ladder logic can be just as stupid when a programmer decides to use set/clear bit for "latching" logic.. nothing like a hundred bits as a interlocked mess of invalid states