Saturday, November 10, 2007

PID Loops And Leak Valves

PID Loops (Proportional, Integral, Differential) are probably the most common kind of control loops in existence. They are easy to set up. If you do them in software they are easy to code. Plus they are fairly robust to changes in the environment. Good stuff.

This all came up as a topic of discussion during a look at what it might take to maintain a constant pressure in a Bussard Test Reactor that had coils about 1/3rd of a meter across. Here is some of the discussion from my side with some corrections and updates:

I'm not familiar with controlled leak valves. (I am more familiar than I was - Controllead Leak Valve). If they are ON/OFF type valves you may be able to get better control of low rates by using 5 or 8 valves in a 1-2-4-8- flow sequence. Kind of a gas flow D to A converter. If you then have a pressure regulator up stream to control the gross flow rates that might be all the flow control you need.

Or it may be way more than you need.

A rough estimate of your needs can be figured by calculating the allowable delta P vs delta T. (pressure vs time). Looking at the volumes involved. The gas dead space in the valve. Valve reaction time. Pumping speed. etc. to find out what ball park you have to play in.

I can help with PID loops (at least at the pseudo code level - actual coding if you use FORTH) if that would do you any good. The main thing is to reduce dead times as much as possible (esp time from valve close signal to flow <10% of open valve flow - or if it is a proportional valve to 10% of its last programmed rate. Same when going from off to on except the relevant number is 90%.). You also have to consider measurement delay including gas diffusion time. It may be that reactors below a certain size are not practical for continuous operation.

Your gas pressure measurement should be as close to the valve as reasonably possible. We can compensate for initial over measurement (i.e peak higher than final value), what is harder to compensate for is the loss of time.

BTW if you code your own loops use the form the Chemical Industry folks use where everything is in terms of overall gain and time parameters. It will simplify your tuning job. Disturbance response tuning is a nice simple way to get into the ball park. Or ask me. We can even make it auto-tune if you like.

Controller output = K ( e + Σe*Δt/Ti + Td*Δe/Δt) where K is gain, e is error from set point Ti is integration time and Td is derivative time and t is just time.

Setting the loop is simple. You input a small step in your process. The slope of the first order response determines you gain K. The dead time determines Ti. Td is 1/10th Ti. In noisy processes Td will make things worse and should be set to zero.

Of course you could do it with independent gains for each term, but that doesn't give you the reality connection thinking about overall gain and time does.

Update: The Step Response method is called the Cohen Coon Tuning Method. Here is one method for using it. None of the numbers used is etched in stone. They represent a particular type of filter operating within a particular frequency range. A more aggressive response with its attendant twitchiness may be just what you want. Or you might wish for a gentler response - easy does it.

BTW with respect to the above method I like to get my response times and amplitudes from the 20% point to the 30% point of ultimate response. Things are pretty linear in that area so no need to resort to natural logs in the calculations. Which is kind of handy if the computing must be done within a short time in a limited memory microprocessor. In any case with PID pretty close is often all that is required to be pretty good. The only time a real plant will operate exactly the same way every time is when it is generated from a formula. In fact the integrator is required because plant resistance to change varies - with time, operating point, settings on other plant controls, wind, rain, sunshine and sun spot cycles. Gain gets you close. Integration zeros out the residual error. Differential prevents you from coming in to the final value too hot. It also helps when the error is getting bigger.

Here is a plant simulator that is some fun to play with.

Wiki is pretty good on PID. When you get down to the bottom they do a good job of relating theoretical PID loop mathematics to useful PID loop mathematics. As far as I know the motor control guys still like the theoretical math and the chemical plant guys like the practical math. I'm a motor guy, but my vote on the subject is with the Chemical Plant control guys.

No comments: