Posted by S K on 20/09/2023 22:59:45:
Posted by Martin Kyte on 20/09/2023 22:38:42:
Posted by S K on 20/09/2023 21:44:15:
…
Awesome! 🙂
Sounds suspiciously like your function generator synthesises the two channels from the same master clock in which case it’s not surprising they stay in synch.
It almost certainly does, but I don't believe that's an issue.
My concern is about whether the Arduino accurately counts at 5 MHz, or whether it misses clocks, etc., and also if the interrupt for the period registers the time promptly and correctly, i.e., within one 200ns clock, or whether it's noisy in the time domain. A stable output would appear to verify both of these, wouldn't it?
But I should ask: What process would best show that the timing of a period is being recorded accurately?
One fear I still have is that there may be beats or some other bizarre interactions between the 16 MHz Arduino clock and the 5 MHz clock. I think so long as the Nyquist criteria is satisfied there should be none, but how to prove that?
…
I think a stable output is proof of pudding! The Arduino CPUs come with various built-in peripherals including a few counter/timers. Being hardware peripherals makes them mostly independent of the computer.
When set up to do input capture, a hardware counter is clocked by the computer's oscillator, a direct connection unlikely to go wrong.
The Input Capture pin is triggered with the usual logic rules, so provided the rise time and voltages are within spec, that should be reliable too.
An Input Capture event causes the counter value 'now' to be copied. The counter doesn't stop, but the 'now' count is frozen. The event also triggers an interrupt. The interrupt pauses whatever the computer was doing, runs a short user program to process the event, and then restarts the main program. Provided the 'short user program' finishes before the next event, all should be well. With a pendulum period or GPS unit, the events are about a second apart, which is a long time for a computer.
I think the best test is to feed the counter with a known accurate frequency, such as an OCXO. However, Joe put me on to the UBLOX range of GPS Modules, and I bought a MAX M8. These can be programmed to output frequencies other than 1 Hz, not all equally stable, but mostly locked to GPS. I set my M8 to output 10MHz and measured that with an ArdPET fed with GPS seconds from an Adafruit module: it averaged 10MHz over 10 seconds. Then I used the ArdPET to calibrate my OCXO, and watched the OCXO and M8 lissajous on my oscilloscope. This test also showed the frequencies to be identical. The OCXO has to warm up for about 25 minutes before it's stable enough.
Dave