Derivative Filter

I want to place a first order filter on the Derivative term of my PID however I am not sure the best way to do this. Would anyone be able to lend a hand. Best Regards shane

Reply to
Shane Hingst
Loading thread data ...

x dot = (x new - x old ) / sampling interval.

Beware though, it is very noise sensitive.

Walter.

Reply to
Walter Driedger

The easiest way to filter the Derivative term is to control the sampling rate. All discrete implementations of the Derivative term are intrinsically filtered by the sample rate. Changes that occur in less time than the sample rate are simply not detected. If you want to maintain a high sample rate for the Proportional term, then go ahead, but artificially lower the sample rate for the Derivative term by using every n-th sample to calculate the Derivative term. This is approximately the same thing as starting with a fast-sampled Derivative term and applying a first-order filter.

-Robert Scott Ypsilanti, Michigan (Reply through newsgroups, not by direct e-mail, as automatic reply address is fake.)

Reply to
Robert Scott

Subsampling the signal does reduce gain, but it will also alias noise components into your derivative, so unless you do some anti-aliasing before you subsample then the only noise reduction that you get is from dividing by a greater sampling interval. You can do better by implementing a derivative that acts like a cascade of a simple derivative with a 1st-order low-pass filter:

xdot = (input - state) * (1 - pole) / sampling interval state = state + (xnow - state) * (1 - pole)

The "pole" in the equations above is the location of the z-domain pole for the filter. For filtering frequencies less than about 1/10th your sampling rate you can use

pole = 1 - 2 * pi * filterF * sample time

In practice you'll have to tune the pole location just as you would any other element of the controller. You'll want to increase the filtering (by setting pole closer to 1) for noisier input data, and decrease it (by setting pole closer to 0) for faster operation. Generally as you increase the derivative gain you'll be increasing the frequency at which the derivative signal needs to be effective and you'll have to increase the frequency by decreasing the pole value.

Reply to
Tim Wescott

Sorry, I answered the wrong question

Walter

Reply to
Walter Driedger

I agree. The "textbook solution" for the derivative part is

U_d(s) = T_d s / (1 + T_f s) E(s)

where U = U_p + U_i + U_d. "Normally", T_f = alpha*T_d where alpha could be e.g. 10 (5-10 my textbook says).

I guess this is more or less what you suggest.

Lars

Reply to
Lars Imsland

--- snip ---

Yes, I'm pretty much giving the discrete-time filter that matches the continuous-time filter that your textbook is defining. The rule for T_f is a bit obscure your definition, I don't see it connected to any physical meaning. What you really want is to place the time constant of your differentiator filter (T_f) to be well below the design settling time of your system.

Of course the meaning of "well below" depends strongly on the system you're controlling...

Reply to
Tim Wescott

Derivative control best helps processes that have substantial inertia and are relatively insusceptible to change.

If the process to which you want to add derivative control is so unstable that the measured variable changes rapidly, it's probably a poor candidate for derivative control in the first place. There may be other control techniques that, if used, would improve controllability. Perhaps just tweaking the proportional and integral responses would do the job.

Reply to
M. Hamill

I don't think the (1-pole) term should be in the xdot calculation

rate(n) = exp(-sPole*T)* rate(n-1)+(1-exp(-sPole*T))*(input(n)-input(n-1))/T

zPole = exp(-sPole*T)

The filter pole should be about 10 to16 times faster ( corner frequency should be16 times higher or time constant should be 16 times shorter). The rate can be then mulitplied by the derivative gain.

Reply to
Peter Nachtwey

-- snip --

-- snip --

My equations (once you correct for the fact that "xnow" and "input" are the same thing) match your equations except that your equations add one time-sample delay and require that you remember both the previous input value _and_ the state of the filter -- do the z transform of each, work out the math, and you'll see. So if you use my form for it then you do need the (1-pole) term.

Reply to
Tim Wescott

PolyTech Forum 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.