Advanced Control - alpha-beta-gamma filters

Join Date
Apr 2002
Location
No income tax, no capital gains tax. Freedom!
Posts
8,390
I often see thread about how to 'smooth' velocities. I see all sort of answers. Below is a file that I modified for a PLC type of application. The goal is to calculate positons, velocities and acclerations at fixed time intervals. I am assuming an encoder is being read every 10 millisecond in an interrupt that has jitter with a standard deviation of 1 millisecond. The feed back resolution is assumed to be 0.001 meter.

One difference between the alpha-beta-gamma ( abg ) or Kalman filter and the typical low pass filter is that the Kalman/abg filter estimates ahead and therefore doesn't have the lag that low pass filters have. This estimating ahead give the filter 'inertia' so every little error in the feed back doesn't have a very big effect on the estimated state. Notice that the velocities AND accelerations estimates are a lot more accurate than the unfiltered calculations.

The difference between abg filters and Kalman filter is that Kalman filters calculate the correction gains such that the error between the actual and estimated is minimized. abg filters have a bandwidth that can be adjusted so suit the application but the gains will not update in real time.

ftp://ftp.deltacompsys.com/public/NG/Mathcad%20-%20KalmanAlphaBetaGamaPLC.pdf

Note there are simpler ab filters that just estimate positions and velocities.

abg filters are very good at computing conveyor speeds where the speeds are relatively constant. A motion controller can gear to the position, velocity and acceleration. The velocity and acceleration are used calculate the slave position, velocity and acceleration. This involves unsing the chain rule ( calculus ). The master velociy and acceleration are also to compute the slave velocity and accelerations for feed forwards. Obviously if the master feed back is bouncing all over the place the slaves feed forward will likewise bounce all all over which is not good. One must be able to estimate the master velocity and acceleration accurately for accuate control of the slave. The downside is that abg filter have 'ineritia' which means there will be some lag when the velocity is changing quickly relative to the bandwidth. When the speed is changing rapidly it is best to know what the control signal is. This is the advantage that the motion controller has.
ftp://ftp.deltacompsys.com/public/NG/Mathcad%20-%20KalmanAlphaBetaGamaPLC.pdf

At the bottom of the pdf there are two formulas the simply state how to implement an abg filter. This should be easy to implement on a S7 STL or any PLC that has ST or maybe even compute blocks.
 
3000 Posts!

First: congratulations on your Post # 3K, Peter !

And thanks for the file.It will take some time too digest it, though.

Best regards,
Daniel Chartier
 
Too advanced I'm afraid

Ricatti equation, Linear Quadratic regulator, Kalman filter, Observers, Controlability and Observability matrices... It will take a lot of time for someone to even understand terminology.

Peter told me before about this, but I simply didn't have enough time to take firm grasp at it.
This month I was very busy at work and so I didn't contribute much. I hope that in week or so, I'll have more time and I'll try to understand what Peter is talking about.
I have downloaded some graduate and undergraduate lectures about Kalman's filter and LQR (not sure if they are same thing...), I have willing to learn and who knows, maybe I even figure this out.

Personally I think there are few people on this forum who can understand this. I hope I would, eventually...
 
Raising the high bar and the awareness that it can be jumped.

Pandiani said:
Personally I think there are few people on this forum who can understand this. I hope I would, eventually...
I do this for the few that want to read/study something more than about stupid start up mistakes. The are a few that will strain their brain, like you and Keith and a few others. There is another group that will see what I am doing but may not understand exactly how I am doing it. Even that raises the high bar and expectations.

The implementation formulas at the bottom are not that difficult. They can be executed on a PLC. The implementation can be very efficient if T is assumed to be constant interval. I don't know how efficient a Control Logix is when programmed in ST but I think it could manage. I feel confident a S7 programmer can implement this easily in STL.

More importantly. Why isn't this built into PLC high speed counter cards?
Perhaps Rockwell could just add a function block. They seem to add a few every release.
 
I do this for the few that want to read/study something more than about stupid start up mistakes. The are a few that will strain their brain, like you and Keith and a few others. There is another group that will see what I am doing but may not understand exactly how I am doing it. Even that raises the high bar and expectations.
I think for me it's more understanding the concepts than the details. Implementing a concept is typically easier than coming up with the idea to start with.
 
Peter Nachtwey said:
More importantly. Why isn't this built into PLC high speed counter cards?
Perhaps Rockwell could just add a function block. They seem to add a few every release.

Intresting topic.

1) By just moving the position of a simple BiQuad filter in the feedback loop, how is the performance compared to that of the Kalman/ABG- filter?
2) Was just wondering with a timeing resolution of 10msec, what is the resolution you expect on the position control?
 
Good question. I need to clarify something.

Buletjie said:
Intresting topic.
1) By just moving the position of a simple BiQuad filter in the feedback loop, how is the performance compared to that of the Kalman/ABG- filter?
In a closed loop system a 2 pole Butterworth bi-quad filter will cause phase delay which will reduce the overall bandwidth of the system.

My example pdf was not meant to imply this should be used for closed loop control but rather to estimate the state of something which is not being controlled and using only a 'feedback' device for correcting the estimated position. This would include things like gearing to a conveyor line or even just estimating the speed of a conveyor line.

In my .pdf the state is determined by

xhat=F*xhat+K*(y-xhat) // I am being sloppy because I am leaving out the a priori ( just before ) and post priori ( just after ) details

Note there is no control signal term. Notice the F array in my pdf. This F arrays assumes the state will keep accelerating at what ever rate it did the time before. If the acceleration is 0 it will generate positions that will increment at a constant rate. The in this case the F array knows nothing about the true response of the system. The only way to change the acceleration is to have and error between the measured and estimated position.

For closed loop control

xhat=F*xhat+K*(y-xhat)+G*u(t) // again I am sloppy and left out the just just before and just after notation.

There are two BIG differences between this form an the one above.
First the G matrix is the input coupling matrix and u(t) is the control signal from the PID or CO(t) in the PLC speak. In a closed loop model the control signal has a big affect on the estimated positions as it intuitively should. The other big difference is the nature of the F array. One should have a model of the system ( in this case a two pole model ) to generate F array. This is obtained using system identification during the auto tuning procedure. This F array assumes the velocity and acceleration will decay as time goes on. The non-closed loop F array assumed the acceleration will not change unless there is an error between the measured and estimated position.

2) Was just wondering with a timeing resolution of 10msec, what is the resolution you expect on the position control?
Look at the graphs in the pdf. Specifically look at the estimated position error. It is much less than the measured position error. The estimated position error is less than the resolution of the encoder, 0.001 m. Look at how small the changers are in the estimated position between each update. That is effectively the resolution. The small changes in the error between the updates also means the velocity and acceleration measurements will be MUCH more accurate. Notice that the maximum error in the velocity estimate is about 1/20 of the maximum error in the measured velocity.
The measured acceleration error is frequently around 50 m/sec^2. This is unusable. The estimated acceleration error is at most 0.02 m/sec^2 which is very small when you consider that many have a tough time trying to calculate a velocity.

But, basically it depends on resolution of the computations, the encoder resolution and the filter bandwidth. I modified the pdf for this forum. Normally I have about 5 micron resolution from an SSI rod. The calculations are done using 32 bit floating point and the bandwidth is in the 20Hz range. Roughly I would say it effectively increases the resolution by a factor of about 100 under the condition I normally work with. The estimated velocity and acceleration improvements are even more dramatic than in the PLC pdf I made. This can make a BIG difference when calculating derivatives and feed forwards control output for the slave based on a position data from a master.

Back to question number 1 as it applies only to getting a master positon. If one tries to gear to a master position that is filtered by a 2 pole Butterworth filter the position will lag. Position lag can be a problem in some applications that require accurate registration or phasing. At steady speeds the Butterworth filter will provide about the same filtering as the steady state Kalman/ABG filter. The only advantage of the steady state Kalman/abg filter is that there isn't a lag in the positions at constant velocities. So if you use a bi-quad low pass filter, LPF, now to only compute velocities now you have little to gain with what I am show. However, if you do use a bi-quad LPF this makes you one of the few PLC that does.
A bi-quad lpf would be another function block that Rockwell could add. Buletjie, I bet you use a S7 and have a FB that does this already.
 
Hi

Yip, i've got some exposure to S7.

I think one can definetly incorporate the proposed filter - one usefull place would be with measuring mass of bulk material running on a conveyour. (scale has large range, low resolution)

What is your memory requirements for implementing such a filter? .ex an exponential AVE filter[y(n)=(1-a).y(n-1)+a.x(n) would require two places - for a and y.
Also - quantisizing 32 bit vs 16bit etc. What would the effect be on the Kal/RGB?

Regards
 
I am back, I have been busy helping other and working on my own problems

I have problems that I need to solve too. Every once in a while I must do real work. You should see what I do. There are equations that stretch across pages.

Buletjie said:
Hi

Yip, i've got some exposure to S7.

I think one can definetly incorporate the proposed filter - one usefull place would be with measuring mass of bulk material running on a conveyour. (scale has large range, low resolution)

What is your memory requirements for implementing such a filter? .ex an exponential AVE filter[y(n)=(1-a).y(n-1)+a.x(n) would require two places - for a and y.
Look at the implementation. This would require 3 K gains, 3 states, omegan. The period T. The coefficients in the F array. This is a little more but I don't think this should be a factor in the decision to use the filter or not unless you are down to your last few memory locations which is not normally the case.

Also - quantisizing 32 bit vs 16bit etc. What would the effect be on the Kal/RGB?
I think a lot is lost if you don't use 32 bit floating point. The may be some filtering gains but their is no difference in resolution between a 16 bit analog feed back and a filtered 16 bit analog feed back. If you have a S7 you should use the floating point operations otherwise you are wasting your time . In addition, you will also need to keep track of scaling if you use integers.
 
Peter Nachtwey said:
I have problems that I need to solve too. Every once in a while I must do real work. You should see what I do. There are equations that stretch across pages.
.

Hi Peter, Sorry - thought we're discussing the filter and trying to highlight the requirements.

You're fortunate to have problems that are solvable. :unsure: Please pass some of them on!

Enjoy!
 
Buletjie said:
You're fortunate to have problems that are solvable. :unsure: Please pass some of them on!

Enjoy!

It is not hard to find someONE to complete an "impossible" task. What is hard is to take an "impossible" task and make it so ANYone can complete it.

In a sense, that is what Delta is trying to do with their motion controllers.

Peter,

Do you think this filtering method will work to help fight noise and perhaps some poor mechanical design in a flying shear operation? I'm thinking filter the speed reference coming from the encoder on the line which the shear is trying to sync to.

Or is this really just useful for quantizing errors?

Thanks
 
Last edited:
OT, OK, you asked for it.

I see this signature about don't worry about your math problems because mine are far greater. What I have found the there is a logarithmic scale to the difficult of the problems. Anyway, if you are bored then look at this:
http://groups.google.com/group/sci.math.symbolic/browse_frm/thread/b422cd6569ed971e/0c2a43b3bfec033d?hl=en#0c2a43b3bfec033d

I write code for motion controllers. A while back there were threads about motion control profiles. Norm even worked out the equation for 7th order motion profiles. If one knows the time between the points then 7th order motion profiles are MUCH easier than finding the exact solution for 3rd order motion profiles. Go figure. No one even attempted 3rd order motion profiles in the motion profile threads. They aren't that easy if you really study them.

Anyway I have a problem with 6 equations and 6 unknowns. My Mathcad will not solve it. Someone using Maple tried and got the wrong answer which is worse but at least it is obviously wrong. Nothing is worse that using the wrong equation that are believed to be right because a computer generated them. I am waiting for someone with Mathematica to solve it. If so I will spend the $2500 for Mathematica so fast. I have a trial and error or iterative solution but it takes too much CPU time.

There was a second problem that I posted a link to to show that Mathematica can solve some of the problems. In this case the move is for a short distance. It is so short that the target velocity will not reach the requested velocity and the acceleration will not reach the requested acceleration. Look at the complexity of the math. This is why I laugh when people say they are going to do motion control in a PLC. The PLC is crippled to be sure but the worse part is that it doesn't have the target profile generator necessary to do motion control.

Anyway, it is a sunny day and I should go for a walk.
 
LQR problem - theory

Hello guys,

I'm going to start posting theoretical analysis of LQR (Linear Quadratic Regulator) problem. In the attached file you can read more. This way, I can check and share my knowledge. I hope you'll post a lot of comments. I'll post more as I learn more.

Best regards,

Asim Vodencarevic
 
Hmm, Peter, why did you choose I-PVA controller? I must admit I don't like Mathcad notation, it's difficult to read code.
How exactly Minerr function work? Does it use least square method?
 

Similar Topics

This video shows the things I think about on page 1. I use Laplace transforms a lot. Laplace transforms allow one to express differential...
Replies
2
Views
1,806
Instead of this info getting lost in another thread I will start a new thread. For those that don't know you can search for Advanced Control on...
Replies
8
Views
2,652
sampling data. I will probably use this in a magazine article.
Replies
18
Views
8,385
This topic deserved to be a separate thread with and Advanced Control header. The first video was made from videos a couple of years back. You...
Replies
3
Views
1,519
Hello dear experts! I use WinCC Advanced Runtime V15 as a HMI for the process. I grab values from AB Micro 850 PLC via Modbus TCP. On the HMI...
Replies
2
Views
2,401
Back
Top Bottom