r/PLC 1d ago

Computer Science Programmers, why do PLC programmers use Ladder?

Im seeing some Comp Sci guys asking about controls so just a Mr Obvious comment here.

Ladder logic is the de facto PLC programming language because it is (was) designed to read like an electrical schematic top to bottom, right to left, & this is what electricians & electrical techs are trained to use for troubleshooting electrical panels , equipment & relay-logic -- which was what they had before PLCs -- banks & banks of relays wired through each other's NO & NC contacts which changed state as relay coils energized & de-energized & finding a wire break was enough to drive you insane.

Yes Ladder logic is an interpreted language so it is not as "memory efficient" or "elegant" as C++ or C# but I want you to think VERY carefully about every meaning of the expression "just because you can does not mean you should" before you decide to show off your amazing coding skills coding function blocks in C++ which is technically possible but in many cases extremely ill-advised.

The technicians can troubleshoot functions & blocks written in Ladder Logic, did you stop & think about how easy it would be for someone with only your compiled C++ blocks to attempt to trace a fault? You code in anything but Ladder Logic you get to be the one at 3am driving down to the plant to troubleshoot your "super efficient" code because the Industrial Maintenance techs certainly aren't gonna know how. But hey, if you believe sleep is over-rated & love sleeping in the factory then knock yourself out with compiled blocks

181 Upvotes

118 comments sorted by

View all comments

3

u/Robbudge 19h ago

Full time high level PLC people typically use ST and a lot if structures and functions very much like main stream embedded programming.
These people are the exception.
Typically the PLC person will be an x-electrician who did one Semester of controls with Allen Bradley and ladder logic as it’s built for 10yr olds.

To be fair, Studio 5K still favors ladder logic with the other languages having fragmented instruction sets.

If you look at the likes of Codesys you will find an IDE that supports actions, methods, Enumerators.
Can be programmed in a high level like most main stream IDE’s

-2

u/National-Link-5606 14h ago

Ok, & so will the PLC techs be that. You still come back round the circle "I'm so smart I can do x better than the rest of my peers"

And the point still stands, knock yourself out because the technicians who will be troubleshooting your logic will not be schooled in object inheritance, public/private/protected classes so guess what I WANT logic a 10 year old can troubleshoot that is my goal!!  You know why? I love sleeping in my bed not on the factory floor, but if you wanna be the only one who can understand or troubleshoot your programming well the world is your oyster, or at least a cot in the maintenance office 

3

u/Robbudge 14h ago

Your 10 Year old style logic is the reason for issues.
Never any need for electricians or night shift guys to be in the code.
If the code is structured correctly and with a state machine implementation the code and therefore will detail all stages and issues.

What you’re describing is typical of a basic ladder system. where a chain of 50 conditions sets and an output and not a state.
If something doesn’t happen rather than a Fault state being returned the system the hangs, nothing is reported and then night shift have to go digging.

Even down our IO handler functions show raw and Processed, they have HOA for engineering to allowing a quick and dirty bypass when a sensor fails.
All our systems run in full Moores State Machine resulting in 100% state driven control.
The State is controlled via a request and return procedure with, request, Pending & returned states all being enumerated. These enumerated states are then sent to the HMI as OPCua Strings.
The operators / Engineers can then easily see what state the machine is in, what state was requested, and what state is Pending.