KalleOlsen
Member
No, long time from math lessons? How did the precedence go when there is a power and multiply:handball:
Omega**2.0*T => (Omega^2.0)*T
Thanks Turpo!
Maths? I know all numbers there is. 0 to 9.
Kalle
No, long time from math lessons? How did the precedence go when there is a power and multiply:handball:
Omega**2.0*T => (Omega^2.0)*T
// Step 0
VAR
Omega: REAL;
T: REAL;
END_VAR
T:=_LoopTime ;
Omega:=PI2*Hz;
IF FilterSelect=0 THEN
K0:=3.0*Omega*T; // CRITICALLY DAMPED
K1:=3.0*Omega**2.0*T;
K2:=Omega**3.0*T;
ELSEIF FilterSelect=1 THEN
K0:=2.0*Omega*T; // BUTTERWORTH
K1:=2.0*Omega**2.0*T;
K2:=Omega**3.0*T;
ELSE
K0:=2.089582*Omega*T; // MINIMUM IAE
K1:=1.479222*Omega**2.0*T;
K2:=Omega**3.0*T;
END_IF
x0:=_Axis[1].TarPos; // start at the reference position
x1:=0.0; // assume initial velocity is 0
x2:=0.0; // assume iniitial acceleration is 0
// STEP 1
VAR
T: REAL; // controller update interval
err: REAL; // error between actual and estimated position
x0p: REAL; // estimated or predicted position
END_VAR
T:=_LoopTime ; // cache the loop time to avoid multipe GSVs
x0p:=((( 0.5*x2*T)*T+x1)*T+x0); // calculate estimated or predicted position
err:=_Axis[1].TarPos-x0p; // calculate error beween actual and estimated position
x0:=x0p+K0*err; // update position
x1:=x1+(x2*T+K1*err); // update velocity
x2:=x2+K2*err; // update acceleration
Kalle, you really care about phase delay on such a system? You aren't going to use the derivative are you? That is what the ABG filter provides. If you don't need the derivative or close to 0 phase delay you can simply cascade a bunch of low pass filters together to filter the signal.
You must be referring to Pavel Holoborodko's Smooth Noise Robust Differentiator website. That is good stuff but I can't see where I can use it because the ABG filter works much better for motion control.Awesome, Peter. I have to DL your attachment and take a look at it; I've very interested in this stuff, and in fact I was looking up ABG filters a few months ago and I came across you in several sites I visited - you get around!
We control air cylinders too. A four pole Butterworth filter works just fine in these cases because a little phase delay is not a big deal with such a slow system.I have an air cylinder with an electropneumatic regulator and a linear position sensor, and I want to modify the air pressure to create a velocity. Well, so the first question becomes, "What is the cylinder velocity?"
Yes but you just made things a lot more complicated when you are trying to control a system using a Kalman or ABG filter. Now you need to have a model of the system. In my simple example I was not controlling the wheel. I was simply trying to estimate the velocity and acceleration accurately. There is a big difference because now you need a model.This is exactly what a Kalman or AB filter was originally intended to do... given a series of position measurements, estimate velocity. And, in fact, an AB or ABG filter does an awesome job of providing a useable velocity output.
They were not teaching this stuff 30 years ago. I learned most on my own in the last 15 years when DSPs because available. Until then why bother if it cost too much to implement?I played around a lot in Excel - man I wish there had been computers when I was learning this stuff in school 30 years ago - and I then actually implemented an AB filter in an Allen-Bradley uLogix PLC.
As I pointed out above the ABG filter is simple because one is simply estimating velocity and acceleration. The my example of the ABG filter assumes that the position, velocity and acceleration will continue to do what it did last time. That is not true in most systems. If the control signal is turned off the system will decelerate to a stop. When controlling an actuator a better model should be developed that takes into account the control signal and how the actuator or plant will respond as the control signal changes. Then a good model can be developed. Unfortunately this requires a LOT of math and is not practical to do inside a PLC. It must be done in the programming software.I have an air cylinder with an electropneumatic regulator and a linear position sensor, and I want to modify the air pressure to create a velocity. Well, so the first question becomes, "What is the cylinder velocity?" This is exactly what a Kalman or AB filter was originally intended to do... given a series of position measurements, estimate velocity. And, in fact, an AB or ABG filter does an awesome job of providing a useable velocity output.
Paul, as stated above, you need to have a model and use an observer. This takes a little extra effort but it pays off in excellent control. The controller can generate accurate velocities and accelerations. The feed back is a MDT rod and the resolution is about 0.0005 inches.I have an air cylinder with an electropneumatic regulator and a linear position sensor, and I want to modify the air pressure to create a velocity. Well, so the first question becomes, "What is the cylinder velocity?" This is exactly what a Kalman or AB filter was originally intended to do... given a series of position measurements, estimate velocity. And, in fact, an AB or ABG filter does an awesome job of providing a useable velocity output.
Paul T
I was hoping to see more questions. Is it clear or confusing?
Obviously it is mathemagic in action.