Now that I have a steady oscillation, I can use the internal Quartz oscillator of the RP2040 to test my setup.
Of course, that is not precise and also has a temperature coefficient, but for development I think that this is enough. Once the Process is settled, I can use an external and more precise reference with the same tools.

With a time reference of 1MHz (which I consider already high), the time between a single clock cycle at 440Hz is 2272.727µs. This poses a resolution problem, in where a single tick (µs) already can't resolve the exact (expected) frequency.
So I instead measure the time that 440 oscillations take, which adds a factor of 440 on top of the resolution while still being around one measurement a second. I like to see seconds updating actually every second :D
The process of finding some optimum was the usual data-science way: Fiddling around in python until something makes sense!
The whole development is currently too long to write up for me, but basically I apply a simple polynom of the form `f(temp) = x1 + x2*temp + (x3*temp)^2`. This already finds a correlation and improves the estimation by a factor of 50:

But, as you can slightly make out in Figure 2, the temp vs. period graph is not linear but has some "loops".
This is caused by the tuning fork being of some considerable mass!
It takes longer to get to temperature on temp changes than the faster sensor picks up. So I added a dampening model that adds a "low pass" to the temperature. This took a lot longer, because this dampening function is non-linear and can't be optimized by scipy. Well, it perhaps can, but I don't know how and the math is starting to get over my head :F
... So I track minima and maxima, and sample the mean time difference between temperature and frequency response, and linearize between some guessed sample points before optimizing the tempco polynom:

So you know see the "damp factor". Please excuse the damp vs dampening misuse, I am not a native speaker :D
Anyway, you can see the much more linear green dots in Figure 4 (correlation Data). The blue dots are the undampened samples. This actual measurement run went on for 5 Days, standing directly at a south-facing window, which I consider being the worst position, as sometimes the temperature goes from 20 Degrees up to 45 degrees (celsius)! But this is probably good for calibration :)
I suspect the sunlight being the last factor that I can't get out, so another run was recorded in a more calm environment, which surprisingly resulted in a much more linear behavior and thus less error at, tested in the application phase, around 10µs/s. Success!
Now on to the display and final touches, and perhaps also an external reference to compensate the internal reference's drift that these runs could not consider.
PP
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.