Ladder PID

A recent job required a very basic control loop. which I wrote into the PLC ladder program. But it just got me thinking, how I could write a
full PID loop in ladder.
I know most PLC's have some kind of PID function built in, but I'm curious as to what it would take to write it all in ladder logic.
anyone got any URL's I could take a look at?
sQuick..
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Wed, 14 Jan 2004 01:51:06 -0000, the renowned "sQuick"

Conceptually, you could use a timed "relay" to trigger a calculation from the setpoint and PV. For example, for a slow temperature control loop you might choose 1 second intervals and recalculate the output. Especially simple if your Ti and Td are specified in seconds. The difference equations for PID are well covered in the literature, at least the textbook kind without some of the fancier overshoot inhibit and autotune features of commercial controls.
Best regards, Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
snipped-for-privacy@interlog.com Info for manufacturers: http://www.trexon.com
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
They don't. Ladder logic is complied into machine code. A PID controller is a function block that is also compiled directly into machine code. It is simply a block placed into the middle of a ladder.
Walter.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Yes, in can be done in Ladder, but these days you would be wasting your time. Just for your interest, I once (circa 1982) used PID control in an Allen Bradley 2/30 - an old PLC with no PID functionality as standard. The code was provided by Allen Bradley in a paper document and then had to be typed in and debugged (there was an error in the document as well as my typing) The first step was to write sub routines for higher precision maths than the standard 4 digit functions that the standard instruction set provided, because otherwise quantisation errors, especially in the differentiation and integration, would cause huge poblems It used a lot of Get and Put instructions! Basically Get the Input, Set Point and historical values and Put them into fixed memory locations Call the PID Subroutine, which worked on fixed memory locations Then Get the Output value and Put it into the Output channel, and also Gget the intermediate/historical values and Put them into the memory assigned for the PID Francis

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Not if the PLC does not offer the right type of PID for your application.
What does it take?
Shift the errors find the current error mulitply the current error by a coefficient add the result to the last output mulitply the previous error by a coefficient add the result to the last output mulitply the presious error before that by a coefficient add the result to the last output add bias limit the output copy the result to the output.
When the parameters are changed or the system starts then the coefficients must be calculated from the update rate, gains or time constants.
That isn't too much to do. Now what is the right type of PID? Most people blindly use what ever is available as a built in function of the PLC never giving it a second thought or even realizing it should be a question.
Peter Nachtwey
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

I've written full PIDs in Siemens S7 IEC 1131 ladder logic.
I don't beleive I would have been able to do it in ladder the previous generation of PLCs known as S5.
The S7/IEC 1131 ladder landguage has a binary result bit that can be used to activate subsequent opperations. Thus a comparison opperation produces a true of false that can be used to enable a conditional move in a rung whose purpose is to clamp say the output of a PID for purposes of anti windeup control.
In the less sophisticated ladder languages you would have to resort to jumps and a mnemonic style PLC assembler often called statement list.
Some parts of my PID looked ugly so about 20% of it I rewrote in Statement list.
Always use the type that is clearest to understand.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Ultimately you can do anything with anything. But that does not mean that the result is very attractive. You can write piety in a data base and do book keeping in a CAD program. I suspect writing a PID controller in pure ladder logic would be about as useful. Inevitably you will be bring in jumps, calculations, etc. all of which are accessories to the basic ladder concept. Once you do that, why not get a PLC which has a PID controller as one of its accessory functions. Reinventing the wheel may be amusing but using the best available tools to carry out a required function pays better.
If you have nothing better to do, remember that RLD (relay ladder diagrams) are Boolean functions and can do ANYTHING any logic gate can do. If you put enough gates together you can re-invent a computer and even run space invaders. But why, when you can get the shareware for free?
Walter

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

diagrams)
put
Just the challenge of it, I suppose.
I remember getting great enjoyment playing 'Ping-Pong' on a PLC/5, programmed up by a bored BHP Engineering Cadet a while back and using output module LEDs as the playing field and a couple of spare inputs for the controls. 'Space Invaders' on a ControlLogix would be cool..
"It's a demonstration of the control system's flexibility and performance!!", we told the client, who promptly asked if he could have a go too.
A pity I don't have the time (or the inclination) these days... ;-)
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

you
space
output
have a go

Years ago I considered writing Space Invaders on a PLC-5/40 with Remote I/O color Panelview 1200 (the old text-only model). With only 13K of 48K RAM used by the conveyor system, it certainly had the free memory and display update speed. What it lacked were characters that looked like the bunkers being demolished.
Mike
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Sometimes you just have to use your imagination!. :-)
It would be great if someone had a web site you could download PLC Games from. (How about it Walter??).
It would certainly cheer up a few stolid clients I know! ..besides, PLC/5, ControlLogix, S7-400, etc. have *way* too much processing power to run just your typical factory only. ;-)
Cameron:-)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

output
go
Actually I did something awfully close once. A refinery had a set of 200 GPM water canons around a unit handling hydrofluoric acid. (The unit handled HF, not the water canons!) I rigged these up to be controlled from a touchscreen DCS. The screen had a display consisting of a site layout c/w the locations of the water canons and all the HF detectors. By touching one of the canon images, then a spot on the screen, then ENTER, a pre-recorded set of co-ordinates would be loaded into the canon controller which would then use position feed back to direct the canon to the appropriate location. 2500 GPM fire water pumps would start up in sequence in response to header pressure and pre-emtively in response to the number of canons activated. There were also setpoint limits to avoid blowing holes into the pavement. finally, touching the canon and then PARK would point the canon up, move the nozzle in and out to flush it, shut if off, and then point it to the ground to prevent freezing.
Unfortunately it was winter and I never got to try this thing live. What a blast! There were also TV cameras with monitors in the control room. "See Bob walking along beside that heat exchanger? Get him!" the system was quite capable of washing Bob into the river, stripping insulation off pipes, etc.
Actually I programmed all the logic in a Honeywell 620 PLC. What a dog. Just goes to show you can program anything in anything if you have to.
Walter.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

a
from
c/w
one
location.
the
ground
a
"See
pipes,
Great stuff! I would have liked to see that!
One installation I did had a 500kVA standby gen set mounted beside the path from the office to the control room. The best I ever did was remote starting the diesel via CCTV just as the boss walked past the exhaust pipe in his neat white cover-alls.. The operators thought that was great fun! Needless to say, I only did it once..
Things we do.. ;-)

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

better.
Isn't that IT stuff.? Strictly not my bag.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.