simple-pid
simple-pid copied to clipboard
Using PID to monitor/correct Xtal frequency wrt other/reference system.
I have a project for an Open-Source LTC box, similar to Lock-it or Tenticle-Sync. Multiple boxes communicate 'time' with an audio signal and then are expected to remain in sync. The issue I have is the the Pico's clock is not precision, and I want to add some synchronization method.... https://github.com/mungewell/pico-timecode
The basics are that each box is effectively a cascade counter, implemented in the PIO blocks, which count according to the PIO clock divider. I have already implemented a way to adjust the divider, and to monitor the timing difference between 'local' LTC and that received from the reference. This kind of looks like this....
When monitoring the moment each frame (local vs reference) starts I get a 'delta time' (in us). I tried feeding this into a PID instance, expecting the output to produce a 'correction' value which would stabilize over time to a non-zero value...
Q. Is this correct thinking? - because I couldn't get it to work like that.... it never seems to settle.
It's worth noting that the measured time value is from the local clock, so it would appear that the reference is wrong... but is in-fact the correct one.
When starting a session the units are 'Jam Synced' together; which gets the clocks and phase the same. After some time they will drift apart. I believe that if the clock rate(s) are the same, then we will not need to monitor/correct the phase as it will just be correct.