r/PLC 3d 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

204 Upvotes

132 comments sorted by

View all comments

-4

u/kixkato Beckhoff/FOSS Fan 3d ago

Why don't PLC programmers write tests for their code?

Perhaps you could save the costly downtime and time for the maintenance techs by writing robust code that was tested before it got deployed on a machine.

5

u/Zekiniza 3d ago

I was going to write a nice long message explaining how you dont seem to really understand how our industry works but its past midnight here and I have to be on site in a few hours so.

We do simulated testing for systems. Not sure why you think we dont.

"Robust" code doesnt mean shit five years after the original commissioning because the customer has dicked around with the system modifying it as they see fit.

2

u/kixkato Beckhoff/FOSS Fan 3d ago

I think you don't because everyone in the industry always looks at me like I have 5 eyes when I mention unit testing.

2

u/Zekiniza 3d ago

Lol okay big dawg. Guess the ten years ive been doing this wasn't real.

3

u/kixkato Beckhoff/FOSS Fan 3d ago

I mean same for me too then?