Is there a way to test how a PID will react before putting it online

mxkjk2

Member
Join Date
Apr 2013
Location
Lafayette
Posts
9
I need to make a PID loop to control a 4-20 mA signal to a recycle valve that controls a pressure. Is there a way to test the PID controller sensitivity and stability before giving it control of the valve? This is in RSLogix 5.
 
Yes but you need a model of your plant

There is a technique called system identification that allows you to model a plant. It is pretty simple to model a temperature system by just looking at the response to some steps changes in the control output but modeling pressure is more difficult. You didn't say what material you are trying to control the pressure of and that is very important. Some fluids compress more than others. Also the volume of the compressed fluid is important too. The model will be a differential equation and it will probably be non-linear too. It can be done in a PLC 5 but it will be messy. It would be easier to use a PC or a small micro controller to simulate the pressure system.
 
It is controlling natural gas inlet pressure to a centrifugal compressor. Its flow rate is around 28 MMSCFD. Right now it just makes a step change in the logic, if the pressure goes below x psi then open 5%. We want better and smoother control. I am just afraid of surging the compressor if it closes to quick. What is the best way to set some initial gains? Do I need any inputs other than my pressure set point, the previous scan pressure, the KP and KI?
 
since you have an existing control system which is already providing a measure of control over the process, here's a trick that MIGHT be useful to you ...

go ahead and set up the PID – but aim its CV (Control Variable – output) at an UNUSED address ... specifically, don't tie the output signal to the actual output field device (yet) ...

set up a trend to graph the response of both your EXISTING control – and also the UNUSED response of the PID ... graph the PV (Process Variable - input) signal too ...

note that the PID will NOT actually be controlling the system (yet) – but you can still watch its response on the graph – and compare its action to the response of your existing control ...

the basic idea is that the PID will be looking at exactly the same input signal as your existing control – so in theory you should be able to adjust the PID to provide an identical response to the system ...

with some practice you should be able to "tweak" the gains and other settings of the PID – and try to get its response "pretty close" to the response of the existing control ...

once you've got that step done, you should be able to switch from the existing control over to the PID's control ... naturally you'll want to keep a careful watch over the system when you first put the PID into action – but if you've taken your time with the previous steps, then you PROBABLY won't see too many "OH-MY-GOSH" situations pop up while you make the final tweaks to the system ...

of course you'll want to eventually tune the PID to provide "BETTER" control than your existing system – but I'm betting that having something of a familiar "starting point" will make the adjustments easier than just starting from scratch ...

the trick relies on having TWO separate "controllers" – both of them looking at the SAME input signal – but only ONE of them actually controlling the process ... this approach comes in very handy in various lab experiments when we're interested in comparing the results of one control scheme with another ...

you can see something of an example graph in the following post ...

http://www.plctalk.net/qanda/showthread.php?p=504603&postcount=1

note that the example is showing only the CV-output signals – and not the PV-input signal – but still the picture might help convey the basic ideas that I'm talking about ...

good luck with your project ...
 
Last edited:
I am just afraid of surging the compressor

You should have surge protection for your compressor independent of the pressure control. Usually a very fast acting valve to put the compressor in a recycle condition.
 
Ron that idea should work great, thank you! Micky you are right the anti-surge valves will protect the compressor from surge. Also how do I know which input variables to put where in the jsr. It looks like you put kp's and ki's and the setpoint error in a jsr then it goes to another ladder that uses those values to do the calculation. below is an example of what i have for pid control in my logic. I know i need the kp and ki, the setpoint,and control variable with the previous cv output. what lse do i need and how do i know where to put it in the jsr or sbr?
JiydFoXDNPIuAU5TKZVOkndXEuk4z0chA8N4iWmiK0BbFWmqzBKa6ogh2mYJ238rLO1dMg7oHRIEUqHFKF0SBFKhxShdEgRSocUoXRIEUqHFKF0SJFR0uHrL7yelw4hHpQOKULpkCKUDilC6ZAilA4pQumQIpQOKULpkCKUDilC6ZAilA4pQumQIv8BWE8Z2z11ft4AAAAASUVORK5CYII=
 
this changes everything ...

whoa! ...

this looks like a "roll your own" type PID ... specifically, it does NOT look like a "standard" PID instruction is being used here ...

there is absolutely NO WAY that we can advise you on WHAT to put WHERE with this type of arrangement – not without seeing ALL of your program file (the RSP file) ...

and ...

even WITH the RSP file this is likely to take a LOT of digging to see how it's been designed to work ...

worse case scenario:

the roll-your-own "PID" code COULD BE located in a RECURSIVE loop arrangement ... in other words, the same code MIGHT BE used to control more than one process ... in that case, the various settings (gains, etc.) COULD BE passed into – and out of - the "PID" subroutine as parameters ... this type of arrangement is usually (always?) a NIGHTMARE to troubleshoot – mainly because the values won't "stay still" long enough to be monitored on the screen ... that MIGHT NOT be what you've got there – but it sure looks like it from what you've posted so far ...

quick question:

where did you get this "PID" code – and why aren't you using a standard PID instruction? ... frankly those are plenty confusing enough to suit most people – even without trying to design their own personal form of torture ...

suggestion:

strongly consider posting your entire RSP file (you'll have to zip it first – forum rule) ...
 
Last edited:
Ron, that 'off-line' PID trick is a good one.

However, a function is not recursive unless it calls itself directly or indirectly through another subroutine. I think the term you want is reentrant which means a subroutine can be called from many tasks or interrupts. If there is only one PID call then mxkjk2 should be fine.

I could not see more than the top line or two of mxkjl2's PID so I couldn't verify if the custom PID would work. It looks like it is written is RS500 so rolling your own can make sense since the RS500 PID uses integer math and is a crude implementation of a PID.

mxkjk2 said:
Right now it just makes a step change in the logic, if the pressure goes below x psi then open 5%. We want better and smoother control.
Smoother is easy. If the pressure goes below x/5 psi then open 1%.

This is a simple integrator. You also need to be careful about how often the integrator code is executed. You can see that my suggestion would only respond 1/5 as fast to a change in pressure unless you executed the closed loop routine 5 times more often. Then the valve could open 5% in the same time as before.
 
Ron, that 'off-line' PID trick is a good one.

thank you – but unfortunately it only works when you have "something" already in control of the process – and you just want to get "in the ballpark" settings for a NEW method of control ... (that's precisely the situation that I think the OP is in – so this might be helpful to him) ...

However, a function is not recursive unless it calls itself directly or indirectly through another subroutine. I think the term you want is reentrant which means a subroutine can be called from many tasks or interrupts.

I humbly accept your correction ... your terminology is more accurate for this situation ...

If there is only one PID call then mxkjk2 should be fine.

well, personally I'm still waiting to see whether there's only one JSR calling this subroutine – or more than one ... I'd be willing to bet (pocket change only) that there's more than one "call" – and I'm basing my hunch on the fact that the program is passing parameters ... if there's only ONE "call" involved, then entering the settings directly into the code would have been easier than passing them in and out ...

I could not see more than the top line or two of mxkjl2's PID so I couldn't verify if the custom PID would work.

precisely my point ... we can't tell much at all from where we sit ...

It looks like it is written is RS500

close - but the JSR instruction in RSLogix500 isn't capable of passing parameters ... this has to be RSLogix5 -for the PLC-5 hardware platform ...

so rolling your own can make sense since the RS500 PID uses integer math and is a crude implementation of a PID.

actually the RSLogix5/PLC-5 system does use integer math – and the integers would be even cruder than you're expecting ... specifically, the normal INTEGER-BASED type of PID in RSLogix5 is usually based on analog signals of 12-bit integers – so it would only offer 4096 steps of resolution ... (the PID in the newer RSLogix500 platform usually works with 16384 steps of resolution) ...

but ...

I've got a hunch that our OP has "inherited" this program (with its "home brew" PID control) and that he's trying to take it places where it's never been before ... nothing wrong with that (in fact it's highly recommended) but I think that it's impossible to offer any concrete advice about WHAT to enter WHERE – and what SETTINGS to use for the gains – until we know a LOT more about the system ...

personally I'm in the "wait and see" mode for right now ...
 
Last edited:
Ron you are correct, there are about 20 different instances in which this routine is used for different PID loop calculations. If there is a simpler way to do this I would much rather do it that way. This code was written by a turbine and compressor manufacturer. This is in RSLogix 5. I found the regular PID and am going to use that for the control. The process variable is my suction pressure right...? The control variable should be the output for the valve, what are the control block and tieback, and where are the proportional and integral gains? Pic below.
 
Last edited:
many (most?) people consider PID control to be the "deep end of the pool" ...

without having access to the PLC's program file all we can offer you are generalized hints and tips ...

there's no way to give you specific addresses and detailed procedures without seeing what sections of your processor's memory you have available - and how your analog signals are being addressed - and scaled ...

Chapter 14 in the PLC-5 Instruction Set Reference Manual is the prescribed place to start reading ...

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1785-rm001_-en-p.pdf

you really need to post your entire RSP program file ...
 
Last edited:

Similar Topics

How can I test some PID code I have written for a SLC-500 in RSLogix500, without having an actual processor to test on. I have used Emulate500 to...
Replies
3
Views
1,832
Hi everyone, I am interested in learning about PID Loops. I have not used one in any of my programming yet but want to be ready should it come...
Replies
4
Views
2,100
Hello, I've been tinkering with PIDs for a while now and have a pretty good understanding of all of the terms. I typically set my initial (first...
Replies
5
Views
2,007
Hi, I am using M221 reading from 3 different sensors (modbus rs485) sharing same bus (daisy chain). I am currently using READ_VAR (in total...
Replies
0
Views
85
I am trying motor startup with pf525 drive by using wizard start over ethernet communication but during direction test it's showing control error...
Replies
3
Views
187
Back
Top Bottom