mungewell / pico-timecode

A budget friendly LTC/TimeCode device built from a RaspberryPi Pico - using the PIO blocks and MicroPython
https://github.com/mungewell/pico-timecode
MIT License
37 stars 0 forks source link

Replacing XTAL with a more accurate one #4

Open mungewell opened 9 months ago

mungewell commented 9 months ago

It would seem that the stock XTAL (with current code implementation) is not meeting the timing accuracy required - less than 1frame drift in 8hours.

Fortunately we can replace the XTAL with a more accurate TCXO module. I have 2 candidate parts:

The 2nd is more accurate/precise, but with a slightly different frequency it might mean more work. The Pico's SDK has a override for building at different frequencies, so a custom build of microPython is likely needed. The boot-rom also expects 12.0MHz, so using this part might mean that USB is not functional - and 'we' might have to rely on the SWD interface to program the board.

2nd part is also bigger.... vlcsnap-2024-02-17-11h08m43s089

mungewell commented 9 months ago

Looking at the Pico's schematic, we can see that the XTAL is fed from the CPU via a series drive resistor (R14), and has a couple of matching caps (C16 and C17) - all of which are not needed for a TCXO module. Isolating the pads for the XTAL may give us more mounting options. pico_xtal

We can also pull a VCC from the caps next to the CPU. (revised) pico_closeup

mungewell commented 9 months ago

Firstly - Highly recommended that you program the Pico BEFORE replacing components, that way you'll have indications of a working board (flashing LED/serial output/etc)...

12.0MHz 3V0 - https://www.digikey.ca/en/products/detail/ilsi/i538-2o7-12-000-mhz/13682056 replacement_12 0_xtal

This has a different footprint, we can see that the part should be rotated:

Once the part is placed, add a small 'fly-wire' from small cap near CPU to Pin 4 of the TCXO module. Double check this is not shorted to ground before power-up. replacement_12 0_xtal_cut

Not my best soldering, but it seems to work. Real test will take more time to evaluate it's timing performance. replacement_12 0_xtal_done

I also realized that I order the WRONG part for a 3V0 (not 3V3) VCC - oh well will try it anyway...

Mouser have an equivalent for 3V3, but wants to sell a full real of qty 3000. https://www.mouser.ca/ProductDetail/ABRACON/I738-2P3-12.000MHz?qs=vmHwEFxEFR%2FD2ZfWbp716g%3D%3D

mungewell commented 9 months ago

I have some results.... but not sure what it going on with some 'strangeness'.

Ultimately the 'accuracy' of the tracking is dependent on the system choosing the correct 'micro-adjust', where is modulates between adjacent fractional clock dividers. This is not (presently) compensated with temp, but that is something which might be possible.

I have recently changed this code, and now the system measures the 'phase' in frame duration - considering a wrap point at +/-0.5 (ie +/-40 bits of LTC data).

Anyhow.... I purchased an UltraSync One, and used this as the reference for testing. rejam2-e

rejam2-t

Note: the point where 'micro-adjust' fixes is where I manually stopped calibration ('CX' mode), and restarted the monitor ('RX' mode).

So the one with the modified XTAL has a weird step, this was also seen in other data-sets from this board. But it does not seem to be present in non-modified board recorded at the same time. Regardless these plots (with a well chosen 'micro-adjust' value) show less than 4bits drift in ~5hrs (noting 80bits would be 1 frame).

My conclusion is that the (noted incorrect voltage) TCXO does not function correctly, and I will look at the alternatives - including the 12.8MHz I have on hand.

mungewell commented 8 months ago

After spending some time digging through DigiKey, I think that this might be the 'Best' replacement... "ECS-TXO-3225-120-TR" https://www.digikey.ca/en/products/detail/ecs-inc/ECS-TXO-3225-120-TR/5357946?s=N4IgTCBcDaIKIGEDKBaAKgDQPIoMxjAFYUBGMABnQCUQBdAXyA

There is also this (much more expensive) 12.8MHz part with really low PPM that will fit on the footprint. "LFTCXO075793REEL" https://www.digikey.ca/en/products/detail/iqd-frequency-products/LFTCXO075793REEL/8633985?s=N4IgTCBcDaIDIDEAqBhAGgeQAwHYCsOAnAMwBKAouXCALoC%2BQA

The following is a suggestion to modify the Pico PCB, should it ever be relaid:

By adding 2 resistor footprints to connect to pin 2 of the XTAL, we could configure the board to take either a passive XTAL or a (user performed modification) TCXO. Only extra one resistor, connecting to ground, would be fitted for mass production.

pico_schematic_mod

mungewell commented 8 months ago

Another candidate for the 'ugly mod' competition.... But this ($15) module is certainly holding it's own, showing less than 0.25 frames drift in 20hrs... though it's been at that value for hours, so maybe (at least some of) the drift is from initial warm up. IMG_20240306_180737402 IMG_20240306_180606988_HDR

I also learnt a lot about how the USB doesn't work after you change XTAL frequency (to 12.8MHz for this). You can upload a special build of microPython with SWD interface, but the bootloader will be forever broken.

mungewell commented 8 months ago

I was able to automate the testing of the stock XTAL, where performance is inferred from what the unit determines the 'calibration' value to be. This conclusively shows that the calibration DOES change with temperature.

The temp shown is not itself calibrated, but shows first plot at ambient (purple trace before I realized unit(s) were in the sun) and then second plot in the freezer.

ttyACM0_combo ttyACM0_combo

Note: the fractional part of the calibration value represents modulating the between smallest fractional values of the PIO divider, ie between '1562+(128/256)' and '1562+(127/256)'.

So a 'calibration delta' of 1.0, would be roughly equivalent to 2.5PPM XTAL variance.

Note: Temp vs Freq will not be linear, it depends on XTAL type. Some plots are 'S' shaped.

mungewell commented 1 month ago

So after being away for a while, I have amassed more hardware and improved the code/testing scripts.... IMG_20241014_131224724

This takes a reference Timecode from the UltraSync One, splits/amplifies it to the 4 test units. The USB hub support power management, test scripts running on PC turn the units off/on to cycle/restart the calibration process and record the resultant data.

I have been running a few tests and this plot definitely shows a correlation between temp in the top plot and changing (computed) calibration in the lower plot. combo_ttyACM2_anot

As the selected calibration moves from the value required by particular XTAL and temperature, the resultant timecode will slowly drift from perfect.

Note: the calibration value is defined in two parts, the integer value define the clock division value in the smallest possible difference in value (on the PIO clocks this is 1/256th of a divider). The fractional part of the calibration value is a duty factor, for dithering between one divider value, and the next (depending on sign).

So for 30fps, and a calibration value of -0.3 the code will dither between 1562.5 (1562 + 128/256) for 70% of the time and 1562.50390625 (1562 + 129/256) for 30% of the time.

This gives 'apparent divisor' of 1562.501171875; about 1.00000075 speed adjustment from nominal XTAL frequency, or about 0.75 PPM.

mungewell commented 1 month ago

A little glimpse into how calibration process runs.... cal_ttyACM0_anot

mungewell commented 1 month ago

I don't have a temp chamber, but I 'folded up' my test rig up and put in a box... along with a USB load tester to add 7.5W of heating. IMG_20241017_125558040_HDR IMG_20241017_134007393_HDR

This resulted in a little warming which definitely shows up in the calibration. combo_ttyACM3

This pushed the calibration spread to quite a bit, over 1 unit!!

A Pico with the XTAL replaced with TCXO faired much better: combo_ttyACM0

mungewell commented 1 month ago

I modified a total of 6 boards with TCXO's, although I struggled with recreating my 'ugly' mod. I actually found it easier to stand the TCXO on end, and fly-wire 3.3v to power it... maybe not mechanically sound, but good enough for now.

TCXO_mod

I'm trying to understand the best way(s) to validate these, on the outset it looks like they are much better than the stock XTAL, but there still seems to be some temperature variance....

This is the one I used: https://www.digikey.ca/en/products/detail/ecs-inc/ECS-TXO-3225-120-TR/5357946