Right now the spec for the clock is 200 µs.
I think I can turn the spec for the v5 hardware down to 100 µs.
Recall that the accuracy spec consists of two parts: the ISR latency for the PPS signal, and the display raster update time. You have to account for both, because at the end of the PPS ISR, you've updated the "registers" that display the time, but you have to potentially wait for an entire raster cycle to occur before the display actually changes.
Right now, the raster cycle displays all 8 digits, and there are four brightness periods for each digit, meaning a full raster cycle takes 32 interrupts, and they happen at 320 kHz.
If you flip that around, so that the brightness cycles happen outside and the digit rasters happen inside, then the display raster frequency jumps from 10 kHz to 40 kHz, which means a full raster cycle takes not 100 µs, but 25.
Now, there's a problem: this only works at full brightness. If you dim the display, then there will be somewhere between 25 µs and 75 µs periods of time when the display is not visible. The workaround for that is to give the code outside of the raster ISR the ability to override the raster cycling and have it start from zero right away. In principle, this should only happen once every 10th of a second (or once a second if tenths are not displayed), so the glitch in display brightness should not wind up being visible.
I'm going to test this idea and see what the impact is.
EDIT:
Turns out today is an excellent day to test changes, seeing as how it's DST transition day. For the purpose of most of the code, the fact that it's the transition month probably is what matters the most.
The issue with this new display mechanism is that the high side switch has a turn-off specification of 2 µs. Well, with the interrupt timer for display rastering hitting every 100 counts, that means those interrupts are 3.125 µs apart. If you try and put a delay in, then essentially the main loop never gets a chance to run at all.
The workaround is to, unfortunately, cut the raster rate in half and stick an empty slot between each lit-up slot. This also winds up reducing the brightness a bit, but frankly the maximum brightness was pretty bright, and the loss isn't too noticeable. The four brightness levels are still meaningful.
With this change, the latency of the PPS ISR is now 26 µs. With the worst-case display update time of 50 µs, that means that the accuracy now is 76 µs, better than twice as good as it was. But more to the point, because the digit raster order goes from least-significant to most, the only really high latency digits are the least important ones. In general, you can count on the 100 ms and 1 second digit to be updated within 12.5 µs of the end of the ISR, or 38.5 µs after PPS.
Unfortunately, these changes require the v5 display rastering system, so the improvements can't be ported back to the MAX6951 hardware.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.