Author Topic: PID control loop: dealing with sensor drift  (Read 3474 times)

0 Members and 1 Guest are viewing this topic.

Offline philpemTopic starter

  • Frequent Contributor
  • **
  • Posts: 335
  • Country: gb
  • That Sneaky British Bloke
PID control loop: dealing with sensor drift
« on: April 05, 2018, 08:10:25 am »
A question for you PID loop experts out there!

I've implemented a PID loop which is doing a decent job of controlling a process. I can get almost any PV value I want, the loop is stable... but there's a catch.

The process measured value ranges from 0 to 10 (give or take). However, the sensor tends to drift a little at the low end -- so if I demand zero, I get 0.02 (say) -- which is fine.

But the constant steadystate error (between 0 and 0.02) causes the integrator to wind up a bit.

So when I next ramp from a setpoint of 0 to (say) 5, the response time is much worse than it should be -- and gets worse depending on how long the unit has been left at SP=0.

I'm toying with a few ideas to deal with the sensor drift, but before I do.. is there an established way for dealing with this problem?

Thanks
Phil / M0OFX -- Electronics/Software Engineer
"Why do I have a room full of test gear? Why, it saves on the heating bill!"
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12268
  • Country: us
Re: PID control loop: dealing with sensor drift
« Reply #1 on: April 05, 2018, 08:30:49 am »
is there an established way for dealing with this problem?

A common feature of industrial controllers is windup limiting (sometimes called "anti-reset windup"). Basically you have a measured value of 0.02 and a set point of 0.00, and this causes the controller output to keep winding up (or down) in an attempt to eliminate that error.

One way to implement windup limiting is to provide a feedback signal whenever the controller output tries to wind beyond the limits. Let's say the controller output has reached zero and wants to keep going downwards. The internal output is allowed to go below zero and become negative. The negative output value is added to the controller error as a compensating term, so that (error + compensation) = 0. At this point the integral action will stop winding down any further.
« Last Edit: April 05, 2018, 08:32:36 am by IanB »
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: PID control loop: dealing with sensor drift
« Reply #2 on: April 05, 2018, 08:48:27 am »
One way to implement windup limiting is to provide a feedback signal whenever the controller output tries to wind beyond the limits. Let's say the controller output has reached zero and wants to keep going downwards. The internal output is allowed to go below zero and become negative. The negative output value is added to the controller error as a compensating term, so that (error + compensation) = 0. At this point the integral action will stop winding down any further.

Easiest way to implement windup limiting - introducing upper/lower limits of integrator state (it shall be done *in* the PID routine). More about that in Tim Wescott paper "PID without PhD". I find it very good reading when have questions about PID.
 
The following users thanked this post: Paul Moir

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4700
  • Country: au
  • Question Everything... Except This Statement
Re: PID control loop: dealing with sensor drift
« Reply #3 on: April 05, 2018, 09:04:25 am »
The first option would be range capping your output value. So when the output is over max, you subtract the excess from the integrator.

The second is integrator reset on pv change. Under normal operation the integrator will have trimmed to zero when stable. So some approaches zero it on a pv change.

The third approach may be changing topology to a response and hold control loop. Which outside certain ranges uses more agressive values to get it close. Then inside the range resets the integrator and uses the slower stable control
 

Offline philpemTopic starter

  • Frequent Contributor
  • **
  • Posts: 335
  • Country: gb
  • That Sneaky British Bloke
Re: PID control loop: dealing with sensor drift
« Reply #4 on: April 05, 2018, 03:18:42 pm »
Thanks guys - plenty to think about here!

The control loop already has windup limiting -- if the control output exceeds the min/max values set, both the output limits and integrator are clipped at the min/max.

I'll have a look at the Wescott paper -- I remember reading it some time ago, perhaps it's time for a refresher!

Rerouter -- I'll have a look at those ideas. Integrator reset on PV change seems counter intuitive though; do you mean reset on setpoint change?  (PV is the measured process value, SP is the target you're aiming for).
As I said above -- the output value is already clamped. I'm toying with adding a smaller clamp value or clamp multiplier (% of min/max) for the integrator as there shouldn't be too much process drift in this application with a nonzero setpoint at steady-state.

Thanks!
Phil / M0OFX -- Electronics/Software Engineer
"Why do I have a room full of test gear? Why, it saves on the heating bill!"
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14623
  • Country: de
Re: PID control loop: dealing with sensor drift
« Reply #5 on: April 05, 2018, 06:21:44 pm »
Clipping the integrator values to a fixed min/max value is a crude way of anti wind up.  A better way is to recalculate the integral part so that the output is just at the edge of saturation. So the regulator would start with a good value once it leaves saturation - however it would also react to noise a little early when at the edge, but this might not be a big issue.

For better response so set-point changes one can add feed forward: that is add a contribution to changes in the SP and maybe the set-point directly. With a programmed set-point profile this might include future planed values for the set-point as well.

Ideally this would be a first approximation of the system, so that the regulator part would only do corrections to this first approximation.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3306
  • Country: gb
Re: PID control loop: dealing with sensor drift
« Reply #6 on: April 06, 2018, 11:35:33 am »
Could you not simply limit the minimum set point to e.g. 0.05 to allow for some sensor drift without integrator windup?
 

Offline philpemTopic starter

  • Frequent Contributor
  • **
  • Posts: 335
  • Country: gb
  • That Sneaky British Bloke
Re: PID control loop: dealing with sensor drift
« Reply #7 on: April 12, 2018, 01:05:06 am »
Could you not simply limit the minimum set point to e.g. 0.05 to allow for some sensor drift without integrator windup?

Alas, there's a customer requirement that the setpoint go down to zero, even if that's impossible... :/


Clipping the integrator values to a fixed min/max value is a crude way of anti wind up.  A better way is to recalculate the integral part so that the output is just at the edge of saturation. So the regulator would start with a good value once it leaves saturation - however it would also react to noise a little early when at the edge, but this might not be a big issue.

For better response so set-point changes one can add feed forward: that is add a contribution to changes in the SP and maybe the set-point directly. With a programmed set-point profile this might include future planed values for the set-point as well.

Ideally this would be a first approximation of the system, so that the regulator part would only do corrections to this first approximation.

Back-calculation? I thought about that, maybe I'll do it on the next spin of my PID loop code. As it turns out, conditional integration works pretty well in this application. Well, that and a threshold below which the control element is forced off and the PID resets...

Thanks guys -- you've given me a bunch of things to think about for V2!
Phil / M0OFX -- Electronics/Software Engineer
"Why do I have a room full of test gear? Why, it saves on the heating bill!"
 

Offline hendorog

  • Super Contributor
  • ***
  • Posts: 1617
  • Country: nz
Re: PID control loop: dealing with sensor drift
« Reply #8 on: April 12, 2018, 06:08:30 am »
Just round the measured value to 1 d.p.?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf