Join us today!
Using the Right Language
Hello all,
I have been playing around with the TwinCAT programming environment and familiarizing myself with the IEC 61131-3 languages. I can see the advantage of having different languages, but I feel like I am more inclined to using only one or two of them.
For the more experienced users, do you find yourself using a particular language or do you fully leverage TwinCAT's capabilities? To dive a little deeper, would there be an advantage of using one language over another given a particular situation?
Thanks for your time!
Different people have different preferences. But personally and from a source control point of view Structured Text is superior. I explain why in this post. Furthermore, for people with a software background as myself, structured text is the easiest to learn. Plus you get to use most techniques/patterns from traditional software development.
I've never really used ladder diagrams, instruction lists, or sequential function charts, but to me they seem antiquated. They might work for simple machines, but as soon as you need more complex logic I would go with structured text.
My blog: https://cookncode.com/twincat
My code: https://github.com/roald87
@rruiter Thanks for your insight and link. I started with FBD and LD as that's what most of my peers recommended. While I can see a use case for them for simple machines as you say, it started getting hard to maintain and keep track of the code as the program got larger.
I have been enjoyed structured text a lot more and it was an easy transition since I was already reading LD as if statements with AND/OR as the control logic.
I use sequential function charts(SFC) for my state machines and structured text for implementations. SFC makes it really easy to keep track the current state of the machine and it allows technicians to understand at which point machine got stuck. I don't use ladder logic very often since it makes it harder to follow your program. I don't like scrolling through the rungs.
@iotea SFC's look like a great way to get a bird's eye view of the project. If you know the state of the overall program, it helps with tracking down issues.
I used ladder logic (mostly Allen-Bradley) extensively for 15 years prior to getting involved with Beckhoff/TwinCAT. Where this system really shines is dealing with boolean logic. If you have an output driven by a large amount of conditional logic, it's very simple to troubleshoot in ladder where you can graphically see the "flow" of the signal, versus say structured text where it would just be a bunch of AND/OR statements in a mess of parentheses. However--as far as advantages go--that's about it. I find it rather laughable these days to see ladder logic being used for complex state machines and advanced functions like motion control. I think tasks like these are much more suited to structured text, which is my preference now.
When I started with TwinCAT I had the idea that I would use ladder for the parts of my programs that were heavy on the boolean logic, and structured text for everything else. However, I quickly abandoned this and now use ST for everything. (Part of this was just due to the fact that the ladder editor in TwinCAT is abysmal.) I find that doing a state machine with a well-structured case statement in ST is actually much easier to follow and troubleshoot than in ladder logic, and with much less scrolling.
This is all just my opinion of course. Head over to some of the other PLC forums if you want to talk to some die-hard ladder logic folks.
@kolyur I'm on the same boat as you! ST is definitely easier to read. I have met these die hard LD fans you speak of, but I don't understand the fascination with the language. It had its day in the sun and still have some utility, but it is by no means the solution to everything.
Thank you for sharing!
Posted by: @kolyurHead over to some of the other PLC forums if you want to talk to some die-hard ladder logic folks.
:')
My blog: https://cookncode.com/twincat
My code: https://github.com/roald87
- 17 Forums
- 265 Topics
- 932 Posts
- 0 Online
- 688 Members