I got it and it is indeed very simple. Subtract a receival time "n" steps back 
in time from "last" receival time, divide and accumulate this time:
  dt = (tArrival(-1) - tArrival(-n))/n;
  tEstimated = tEstimated + dt;

Jitter on a singel arrival time will be divided by "n" and "tEstimated" will 
slowly adapt to clock drift. I think this algorithm will work great but any 
comments are welcome.

Regards Nicklas Karlsson


On Mon, 11 Apr 2016 07:17:20 -0500
Jack Coats <j...@coats.org> wrote:

> My knee-jerk algorithm would say subtract one average from the total of all
> averages, add in the new period, and divide by the number in the average.
> If programming in assembler I would go with 128 rather than 100 steps to
> keep the division easy (rotate a copy of the accumulator right 7 bits).
> Divide can be costly if done in hardware.
> 
> The 'right way' is probably to keep a list and re-add them each time just
> having a FIFO queue for the individual timings. ... Also speed things up
> keep the 'total' in an accumulator, and process using the 'knee-jerk'
> method, but subtracting the entry about to rotate out of the queue before
> adding the new one.  You still have the divide of the accumulation to do.
> 
> I hope this helps.
> 
> On Mon, Apr 11, 2016 at 7:05 AM, Nicklas Karlsson <
> nicklas.karlsso...@gmail.com> wrote:
> 
> > I have made some work on a micro controller based stepper generator and
> > steps are now generated.
> >
> > To keep stepper generator in sync with linuxcnc there is a need to
> > calculate average phase and period of the message arrival times. I expect
> > the same algorithm is rather useful to have then working with linuxcnc for
> > other purposes and I will send the source code once implemented if somebody
> > else is interested in it.
> >
> > Is is rather straightforward to calculate from for example the last 100
> > arrival times but a moving average algorithm would be preferred to reduce
> > CPU load. Do anybody have any ideas?
> >
> >
> > Regards Nicklas Karlsson
> >
> >
> > ------------------------------------------------------------------------------
> > Find and fix application performance issues faster with Applications
> > Manager
> > Applications Manager provides deep performance insights into multiple
> > tiers of
> > your business applications. It resolves application problems quickly and
> > reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/
> > gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532
> > _______________________________________________
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> >
> 
> 
> 
> -- 
> ><> ... Jack
> 
> The Four Boxes of Liberty - "There are four boxes to be used in the defense
> of liberty: soap, ballot, jury and ammo. Please use in that order."
> "Whatever you do, work at it with all your heart"... Colossians 3:23
> "Anyone who has never made a mistake, has never tried anything new." -
> Albert Einstein
> "You don't manage people; you manage things. You lead people." - Admiral
> Grace Hopper, USN
> "The most dangerous phrase in the language is "We’ve always done it this
> way"-- Admiral Grace Hopper, USN
> "Tell me and I forget. Teach me and I remember. Involve me and I learn." -
> Ben Franklin
> ------------------------------------------------------------------------------
> Find and fix application performance issues faster with Applications Manager
> Applications Manager provides deep performance insights into multiple tiers of
> your business applications. It resolves application problems quickly and
> reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/
> gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to