"Bogo process"/plant transfer functions for PID testing

I'm looking for a "bogo process" transfer function for a PID loop plant. That is to say something that's not real hardware but just so I can calibrate the software/ensure that the loop is generating sane values prior to connecting it to a real plant and working on tuning.

The "bogo loop" would just be say PID core -> PWM output/DAC -> analog filter -> back into uP via ADC -> digital filter representing the transfer function of some idealized plant and sensor -> "virtual" ADC -> control value/input summer/error amp -> PID core

Again this isn't to derive any kind of tuning parameters representative of the real world, just to sanity-check the software implementation by e.g. transmitting real-time values at various nodes in the loop over serial to a PC and logging them.

Like maybe a "generic" heater + temperature sensor model or something that generates a vaguely realistic lag for some parameters of thermal time constant, max power output, and Vout/degree for the sensor

Reply to
bitrex
Loading thread data ...

That's mostly confusing. You can do a simple RC model of your system. R is the thermal resistance and C the heat capacity. JL posted some thermal 'cheat sheet' at some time in the past.... That will have no lag in it. The lag you can somewhat guesstimate from the relative positions of the plant and sensor.. closer is less lag.

George H.

Reply to
George Herold

Ok, that makes sense. So to model say some kind of idealized box of air or whatever medium with a heater in it, of some size, immersed in some other medium that conducts heat away, I could maybe use an RCR circuit - series R to model the thermal resistance of the heater element and element to "ambient" thermal resistance, C to model the heat capacity of the box, and an R to "ground" to model the escaping heat energy.

Multiply s-domain transfer function of that by e^(-sT) to add idealized delay of T seconds to model lag time of the sensor. Seems like that should be straightforward enough to discretize (the Z transform of a delayed sequence is just z^(-m) times the Z transform X(z) of the sequence)

Reply to
bitrex

Air is hard, it's non-linear, I'm not sure the RC thing will work. Conduction, convection, turbulence (chaos :^)

George H.

George H.

Reply to
George Herold

I have used Cubie Boards/RasPi/BeagleBone with USB peripherals for this. It works if the plant is slow enough.

You can connect to an Arduino and use PWM out into a lowpass filter for very low latency.

You still need a good model of the "affinity laws" of the plant.

--
Les Cargill
Reply to
Les Cargill

snip

formatting link

Top quality.

Reply to
Long Hair

It doesn't need to be realistic, it's not for tuning, just for ensuring there aren't any bugs in the implementation before trying to connect it to anything real.

Reply to
bitrex

Yeah, that's along the lines I was going for. A "dummy plant" black box providing some reconfigurable input to output transfer function in the analogy of a "dummy load" for an amplifier; if the software isn't generating sane values with an idealized model of e.g. a heater or motor or something then there's little point in taking the time to hooking it up to anything real.

Reply to
bitrex

In the old days they used analog computers for that. Popular book here in Germany claimed these 10 were typical basic test cases for plants:

formatting link
Simulating real plants would be a combination. But not too complex, assuming the controler was limited to PID.

  • thermal loops are very slow, thats bad for OP-AMPs. But nobody would simulate them in real time.
  • one would ad noise. Broadband white noise is not realistic. 1/f seems to be more real world.
    formatting link
  • delay elements are hard with OP-AMPs. There exist

step response, but they are probably good enough for the real world that does not ideal steps either. But one would have to use SC-filters to make the delay easy to program.

  • real world is nonlinear, there it gets realy hard doing simulations with analog circuits.

MfG JRD

Reply to
Rafael Deliano

OK, I guess I'd make a big dummy load of power resistors and turn it on. (I turn down the current limit for the PS when first firing up a board.)

George H.

Reply to
George Herold

I can't provide any empirical evidence that it's a good idea, but I'm pretty sure it's a good idea.

Much of it depends on how much risk you run when you release something.

$DEITY bless engineers in other disciplines but sometimes it's hard to get good reports from other people; this method retires a lot of risk but at some cost.

You have a problem. You write a controller to solve it. You need to test it. You decide to built a test jig for it. Now you have two problems.

--
Les Cargill
Reply to
Les Cargill

Those look darn nice. So many SOICs, so little time :)

--
Les Cargill
Reply to
Les Cargill

Nice link, that's definitely along the lines of what I was looking for.

In the meantime with pen and paper and some help from Maxima CAS I tried to come up with a digital filter model for a simple heater plant with input thermal resistance, heat loss, and a lag time to the sensor:

I'm not a mechanical engineer, I don't know if there are actual names for the various time constants so I made some up. Haven't tested that yet but since the work is done I'll at least give it a try

Reply to
bitrex

I am skeptical about "digital filters" modeling analog systems. The usual digital filter is based on a z^-1 delay element. If the sample rate is to low there are the usual aliasing problems. If its very high there are the funny 0.9999999998 factors. If the sample rate of the model is conveniently the same as that of the controller then one gets fooled what the real noise floor later will be. Simplified simulations are "doomed to succeed". There is the variant ( rarely mentioned in literature ) using an integrator instead of the z^-1 and thereby simulating the analog state-space circuit on a computer on a reasonably high sampling rate. That will work somewhat better.

Very simplified: up 1970 classical linear theory ruled and there wasn't more to it then PIDs and biquads. There are nice old books that explain the world that way: Doebelin "System Dynamics modeling and response" Merrill 1972 ( best ) Cannon "Dynamics of Physical Systems" McGrawHill 1967 Shearer "introduction to System Dynamics" Addison Wesley 1967 But if you do real applications the world splits up in "motors" "cars" "aerospace" "chemical plants" with different much more complicated models and divergent terminology.

If you stick with "thermal" you will soon find simple lumped parameter models will not fit real world data. Modelling diffusion with analog circuits leads to large analog circuits that are better simulated in software then done in hardware:

formatting link
One can skip the analog model and do equations on the computer, but soon the connection to the real hardware gets lost.

The expensive and tricky alternative are scale models. They have gone out of favour since the 60ies, but are still used in windtunnels.

MfG JRD

Reply to
Rafael Deliano

Great, that's perfect. I'm not looking for "bugs" in the controller-plant interface I'm hunting bugs in the software e.g. do I ever get a situation where a function tries to perform 0.0/0.0? No sane real world system should ever encounter a state where the controller attempts to divide floating point 0 by floating point 0 and return NaN, that's a software implementation error.

Reply to
bitrex

In diffusion-dominated situations the phase shift increases without bound with frequency, so adding derivative terms doesn't help. To get a stable loop you have to slow it down and use PI instead. That doesn't take a whole lot of theory--you can easily get within a factor of 2 using a simple integrator-plus-delay plant model, and then tweak it a bit from there. (I just finished doing that for my laser control board.)

Passive convection cooling is fairly mildly nonlinear (factors of 2 over the usual ambient temperature range, iirc) and heating is pretty linear if you use TECs or PWMed resistance heaters.

So the old-style methods are pretty competitive, except maybe in cases where a factor of 2 in bandwidth is super important and lots of engineering time is available.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
 Click to see the full signature
Reply to
Phil Hobbs

In my experiments with "virtual" models of heaters + sensors so long as there aren't any accidental floating point exceptions (whoops, yeah that did happen to me, and amazingly not even in code I wrote myself the author of a certain library made it very easy to inadvertently feed some zeros into the derivative term of the controller in the right order to get a 0.0/0.0) they seem pretty straightforward to do via the rough guidelines given in Tim Wescott's paper.

Proportional alone gets you fast response but undershoots the target for reasonable values. Add integral and it's a little slower but nails the target, even if the target is say slowly decreasing while the plant value is coming up. Too much integral and you get bad oscillations, just a lil integral seems to go a long way.

Reply to
bitrex

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.