Ladder (logic)

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

joaquins

Well-known member
Joined
Feb 25, 2012
Messages
1,927
Location
Argentina
Why?? Who said it was a nice language? Why is still an industrial standard?

  I find my self working with it now and just don't get it. It's barely better than assembler for simple steps, one sentence replaces a few but are harder to code. For more complex steps it does a bit more but still not good and I find no way to do a decent code (legible and tidy) compared to other languages.

  I do understand that replacing a few relays it makes sense as you just think as they where relays, but once you are tuning a few machines, compensating, feedback, handling network tasks with RS485 and so on it gets ridiculous. I know it has some applications but having a PLC running at 200MHz for 100k steps and only being able to code it like so doesn't make sense for me. Am I missing something? Any thoughts or experiences?

JS
 
I had a Close Encounter with some PLC (that's Programmable Logic Controller, very different from, and no relation to, a PLD/Programmable Logic Device) in the early 1980s. This was some industrial company's CMOS controller (I think it was Omron) that emulated the ladder logic relay things that had been in use for long before that. I was just out of college and had some decent concepts of Good Programming, having learned Pascal and done some significant programming in it (which I found was much better than FORTRAN and BASIC). I saw this thing, it had an LCD display, up to 50 steps, and you could enter the function at each step as a number or something. I recognized it as a horrible way of doing whatever it was we wanted to do. The guy wanting me to do this insisted this was standard industrial stuff and there was nothing wrong with it, but he was my college roommate and I knew his major/almost only programming experience was in BASIC, he thought that was "enough to know programming" but he was missing some fundamental knowledge (also, I had read through much of the first three Knuth books, he had no idea who Knuth was).

Yes, this stuff is appalling, and it's hard to believe this is still done. It's rare that anyone writes assembly language thesedays because high-level languages (C and C++) and compilers are readily available and plenty good enough. I'm surprised there's no high level language in common use for these PLC things.

You say it's "barely better than assembler" but I disagree - I wrote thousands of lines of 6502 code, starting on the KIM-1. Maybe it's just because of my knowledge and experience, but I think assembly is a lot easier.

Anyway, good luck with whatever it is you have to do.
 
> this thing, .., up to 50 steps

They are not supposed to be "steps" (sequential).

A Relay Ladder is PARALLEL logic. You have up to 50 horizontal lines on your wiring diagram.

This really does make a LOT of sense in many industrial problems. The 50 lines control many things that are only distantly related. The finger-safety switch has nothing to do with the heater thermostat, except they are on the same machine.

Computers can not think 50 thoughts simultaneously.

But they can think 50 thoughts sequentially faster than a relay can clack. And most of these applications didn't run any faster than that.

Early ladder emulators made it possible to sell CPUs into the large rich relay-ladder market.

Relay ladder may still be the best representation of many large yet simple problems. My old oil burner was all relay logic. My new gas burner does the same things in a CPU. While I could sit down (ouch) and write a procedural program to cycle through the sensors and diddle the valves and motors, ladder logic is just as good.

A really great ladder-logic emulator WILL NOT STALL. Non-trivial procedural programs like to do that (my browser was hanging last night, and I used to get paid to re-start stuck servers). If my burner opens the gas, but stalls before it powers the spark, and never gets around to the flame-out sensing, my house would blow up. I do not know if they got that right.
 
benb said:
Yes, this stuff is appalling, and it's hard to believe this is still done. It's rare that anyone writes assembly language thesedays because high-level languages (C and C++) and compilers are readily available and plenty good enough. I'm surprised there's no high level language in common use for these PLC things.
  My first reaction when someone explained to me how ladder was -oh, a programming language for "people who doesn't know to program"- Intended to solve problems for electricians used to wire a lot of relays replacing those hardware stuff with just the drawing and a µC. The more I use it the more I confirm that's the only thing it might be good for. And there are many things that are backwards in the softwares, like what you would expect to be download or upload the code from/to the device. People who doesn't understand programming at all do understand some basic stuff on the ladder program, nothing at all on the assembler code. The thing is, at the end of the day you end up calling someone who does know programming to write the code, and for them (us) it's harder to do it in ladder than in C for example.

You say it's "barely better than assembler" but I disagree - I wrote thousands of lines of 6502 code, starting on the KIM-1. Maybe it's just because of my knowledge and experience, but I think assembly is a lot easier.

Anyway, good luck with whatever it is you have to do.
  I don't have a lot of experience, but some, with assembler and I have nothing against it. I meant barely shorter code and more efficient to write, from there to better, tidier or more useful there's a long way. I probably agree with you.

I've done something (industrial application) with arduino, I miss so much writing C right now. Now I'm automating a different factory, working a lot over RS485 for 3 VFDs and 1 HMI. I've already sorted out those and need to sort out a Panasonic servo driver control which I probably never get the RS485 connection so I need to work it out differently. I hope to have it all running for next week. I guess I'm here just to make catharsis.

JS
 
PRR said:
> this thing, .., up to 50 steps

They are not supposed to be "steps" (sequential).

A Relay Ladder is PARALLEL logic. You have up to 50 horizontal lines on your wiring diagram.

This really does make a LOT of sense in many industrial problems. The 50 lines control many things that are only distantly related. The finger-safety switch has nothing to do with the heater thermostat, except they are on the same machine.
  They call it steps, I didn't name them... steps in a ladder, makes sense  :eek:

  In my case I have up to 30.000 "steps" but they actually call steps the addresses on the program memory for what I can see on the compiled program, barely related to the actual ladder lines.
Computers can not think 50 thoughts simultaneously.

But they can think 50 thoughts sequentially faster than a relay can clack. And most of these applications didn't run any faster than that.

Early ladder emulators made it possible to sell CPUs into the large rich relay-ladder market.

Relay ladder may still be the best representation of many large yet simple problems. My old oil burner was all relay logic. My new gas burner does the same things in a CPU. While I could sit down (ouch) and write a procedural program to cycle through the sensors and diddle the valves and motors, ladder logic is just as good.
  I understand why it might be useful and why it started to exist. I don't understand why there isn't any other option in the industry, and how they don't provide an alternative developing option. A C compiler and a library with the specific functions would be great, for instance. It does make sense to have a 10 or 20 I/O device with 50 wiring diagram lines. It doesn't make sense to have a 200MHz 16 bit micro with 60kB of program written like this.
A really great ladder-logic emulator WILL NOT STALL. Non-trivial procedural programs like to do that (my browser was hanging last night, and I used to get paid to re-start stuck servers). If my burner opens the gas, but stalls before it powers the spark, and never gets around to the flame-out sensing, my house would blow up. I do not know if they got that right.

  There are tools and functions able to stall a program in ladder, so, it's still on the programmer to make a reliable code. I do have quite a few of this cares over the modbus network to do myself. Checking all the communications are done properly it's on me. Doing it in ladder doesn't ensure you nothing, unless is a really simple program which would still be simple and safe done in C or fortran. Stall your programs all you want and use a watchdog.

JS
 
As you have all touched on, ladder was developed as a tool so that relay (and hydraulic and pneumatic) logic was easily implemented in the new and amazing (at the time) PLC's, by non-programmers.

Thing is, the control system industry is very slow to change.... the PLC programming and development environments for even the biggest vendors seem like they were programmed 15 years ago (there are exceptions). This is understandable though because if your plant is working, don't risk lost production by trying to fix it, or learn new tools. And if you are building a new plant or expanding, use what your employees already know.

But there are other languages for PLC's which are part of the development suites for all the big players... including FBD (functional body diagram) and ST (structured text). Structured text is the closest to a "computer language" and is essential to use if you are doing lots of maths, or array stuff.

Note that traditional computer languages would generally not work for PLC's as a PLC has a completely different set of requirements and works differently to a PC. Timing is critical, and it needs to look at masses of inputs, outputs and peripherals using a range of protocols. And never ever stop.

For the programming I have done I prefer ST, as there was generally lots of maths involved, But I have just finished on a very large mining construction project (right from early design through to commissioning) and (much to my frustration) ladder was the required language. I/O count was in the 10's of thousands. Glad I was not actually doing the code....

T

 

Latest posts

Back
Top