View Single Post
Old February 4th, 2022, 06:26 PM   #89
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: The land of the woke and the home of the broke
Posts: 7,966
Quote:
Originally Posted by Taylor Turner View Post
Checking the rate of stuffs

Code:
//Sets sample rate
tonr(tSampleRate);
tSampleRate.PRE := 100;

if not tSampleRate.DN then
    tSampleRate.Reset := 0;
    tSampleRate.TimerEnable := 1;
else
    tSampleRate.Reset := 1;
    tSampleRate.TimerEnable := 0;
    rAcceleration[1] := rAcceleration[0];
    rVelocityEMA[1] := rVelocityEMA[0];
    rVelocity[1] := rVelocity[0];
    rPosition[2] := rPosition[1];
    rPosition[1] := rPosition[0];
    rPosition[0] := LocalIOHere;
    rVelocity[0] := (rPosition[1]-rPosition[0])*(60*1000)/tSampleRate.PRE;
    rAcceleration[0] := (rVelocity[1]-rVelocity[0])*(60*1000)/tSampleRate.PRE;
    rJerk := (rAcceleration[1]-rAcceleration[0])*(60*1000)/tSampleRate.PRE;
end_if;


//Filter
rAlpha := 1;

rVelocityEMA[0] := trunc((rAlpha*rVelocity[0]+(1-rAlpha)*rVelocityEMA[1])*100)/100;
I would like to see a trend of your calculations. The problem I see is that there is nothing that guarantees the samples are taken at equal intervals. That messes up the calculations due to sample jitter.


The RMC200 has an alpha-beta-gamma and alpha-beta-gamma-delta filter built in. These far not available on the RMC150 and RMC75.


Check this out.
https://deltamotion.com/peter/Videos/AlphaBetaGamma.mp4
The alpha-beta-gamma filter is just a simplified form of a steady state Kalman filter.

https://www.kalmanfilter.net/alphabeta.html
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote