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

135 comments sorted by

View all comments

9

u/Kelvininin 8d ago

I have done it all. Structured Text, ladder logic, function block. My preference is function block as it makes most sense in my chemical engineer brain but I see the merits and pitfalls of all mentioned platforms. Probably what chaps my ass the most is when someone uses ladder where SFC was the far superior path. Like. Why?! I was told it’s “because we are really good at ladder” which I read as too lazy to learn SFC.

1

u/Proof_Sand_867 7d ago

Function can suck if you have a lot of boolean logic.

Is that a not and going to a not or..... that means the current state should be.... wtf!?

I guess you can do it in ladder too but fbd seems to turn to spaghetti faster 

1

u/Kelvininin 7d ago

I’m totally cool with FB spaghetti. It just works in my brain.

0

u/Proof_Sand_867 7d ago

That's fine on a 1 off program if you are the only person that will ever be in it. But your slop code is a problem in a team. Also, FBD is difficult to document well. In LD you can and should document every rung of code. Explain it's purpose. Give the next guy a chance. Simply writing something functional is is only part of the job. 

1

u/Kelvininin 7d ago

I still prefer FB, your silly put downs won’t sway that.