Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-14 Thread Nicklas Karlsson
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

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Jack Coats
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).

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Nicklas Karlsson
> > Until this is solved I calculate number of periods and where phase is > > located within period in average for all values each time. It will > > work to calculate by using each value every time even though it use a > > ridiculous amount of clock cycles. > > That's just a hardware counter

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Nicklas Karlsson
> > Until this is solved I calculate number of periods and where phase is > > located within period in average for all values each time. It will > > work to calculate by using each value every time even though it use a > > ridiculous amount of clock cycles. > > That's just a hardware counter

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Erik Christiansen
On 11.04.16 14:52, Nicklas Karlsson wrote: > Diluted old values may better or worse. Problem is I can't get a grip > on howto calculate moving average arrival time within the period. That's one of the two methods presented, isn't it? > Until this is solved I calculate number of periods and where

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Nicklas Karlsson
> On 11 April 2016 at 13:05, Nicklas Karlsson > wrote: > > > 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? > > The

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Nicklas Karlsson
> > 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? > > If the average is over 64 or 128 samples, then the divide is reduced to > a 6 or 7 bit rightshift.

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread andy pugh
On 11 April 2016 at 13:05, Nicklas Karlsson wrote: > 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? The simplest

Re: [Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Erik Christiansen
On 11.04.16 14:05, Nicklas Karlsson wrote: > > 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? If the average is over 64 or 128 samples, then the divide is

[Emc-users] Arrival time Moving average (time, period)

2016-04-11 Thread Nicklas Karlsson
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