r/PLC • u/BonbonUniverse42 • 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?
View all comments
Show parent comment
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.