accumulator += nanosecond_offset / 1000;
on each second. Since these variables are all integers, this loop stops working when the offset is under a microsecond. A quick change to store the accumulator scaled by 1000 (and using a 64-bit integer) improved the situation.
This shows the frequency offset (in parts per billion) for the period after starting the slave ptp server. I think that the reason that the oscillation is not symmetric is due to the servo resetting itself in an attempt to avoid oscillation.
This is a zoomed in version of the chart above. It shows a fairly nice convergence to the correct value. Part of the problem is that the PPSI servo only controls using frequency and so it has to use the frequency changes to deal with offset as well.
I also worry about the fact that the code averages the offset and then uses this average as the estimate of the current value (at least that is what I think the code is doing). A little bit of thought will reveal that an average over the last (say) 21 samples is a better estimate for the middle sample than the most recent sample (if you assume that the samples have a time varying component).
Need to think some more about this....
No comments:
Post a Comment