Peter Nachtwey
Member
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.
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.