teensy 3 crystal freq check with NTP and GPS

Status
Not open for further replies.

manitou

Senior Member+
Paul notes that teensy 3.0 uses 16mhz crystal with 15ppm accuracy. I've used an NTP-host to periodically query an MCU's millis() to check frequency of the crystal. My teensy crystal was within -5 ppm of NTP host. Also you can do a similar check with a GPS module, e.g. Sparkfun EM-406A, tying its pps pulse to attachInterrupt()
and get micros() in the ISR -- (one change required for teensy was I had to set pinMode(pin,INPUT) for the interrupt pin. i didn't need that on UNO/DUE/maple). Results of crystal and resonators tests can be found at

https://github.com/manitou48/crystals

Each crystal is a little different, so your measurements may vary. Frequency is affected by temperature, voltage, age, and load capacitance.
 
I got TinyGPS library examples to work with Sparkfun EM-406A GPS, using Serial2 instead of SoftwareSerial. The GPS is a 5v device, but its Tx/Rx and pps signals are about 2.87v (from specs and verified with scope), so you can connect the GPS to the teensy 3.0 without levelers.

simple_test output

Code:
LAT=36.021870 LON=-84.207123 SAT=6 PREC=160 CHARS=67963 SENTENCES=561 CSUM ERR=0
LAT=36.021870 LON=-84.207123 SAT=6 PREC=160 CHARS=68367 SENTENCES=563 CSUM ERR=0
LAT=36.021870 LON=-84.207123 SAT=6 PREC=160 CHARS=68566 SENTENCES=565 CSUM ERR=0
LAT=36.021870 LON=-84.207123 SAT=6 PREC=160 CHARS=68769 SENTENCES=567 CSUM ERR=0
...
 
Hold on, does the Teensy 3 now ship with an on-board crystal? I don't think so - the pictures here also suggest that there is no 32.768kHz crystal present.

FWIW, similar and only slightly more expensive crystals can maintain a 5PPM frequency spec for only $0.70 each. I have yet to attempt/enable the trimming in conjunction with a GPS module but I expect it to be pretty awesome. Especially if it turns out that one can use the on-board temp sensor in the teensy as part of a temp-compensated setup.
 
I believe he's measuring the accuracy of the 16 MHz crystal, which is used (via the PLL) to create the main clocks in the chip. The millis() count depends on the main clock.

That's actually an awesome idea to use NTP... wish I would have thought of that. It a whole lot cheaper and probably even more accurate that checking with an oscilloscope (which probably doesn't have a 5ppm accurate time reference) or most types of frequency counters (the ones under $2000... without a special oven regulated reference crystal).
 
Good point, Paul and apologies for getting it wrong. I don't think that the main chip can be 'trimmed' the way that the RTC can?

If it can be trimmed, it could allow for a NTP or GPS-trimmed clock... and with the use of the on-board thermal measurement, even a temp-compensated main clock. However, I wonder whether using the on-chip clock is accurate enough - thus, I use a 2k2 NTC with 1% accuracy thermistor underneath the Teensy, in conjunction with a low-drift resistor, all at a ~$1 price point.

I hope that the RTC compensation will be reasonably close to that of a DS3231, allowing for +/- 2.5PPM performance, if not better since the underlying crystal is allegedly already within 5PPM. Another thing about the DS3231 (IF I am reading the data sheet correctly) is that the accuracy is not nearly as guaranteed after being installed as with the bare chip... which is not that helpful.
 
Last edited:
I do not believe there's any automatic trimming for the main clock, like there is in the RTC.

Perhaps it could be implemented in software, by reconfiguring the systick timer for one extra or one less count on regular intervals?
 
For my purposes, the accuracy of the main clock is less relevant than the RTC. The cost of getting the RTC enabled ($0.70 crystal), temperature compensated (NTC + resistor ~$1) is very low compared to the cost of implementing a DS3231 type solution ($9 plus a lot more board space and two analog signal wires lost instead of just one). What redeems the DS3231 to some extent is that the temperature-related trimming is automatic while the teensy would require a periodic check and trim, as necessary.

I have a GPS sensor that I plan on using to measure trim requirements between -10*C and 40*C. If that turns into something that can be 'mapped' easily, then the bulk of the work is done. I do similar work on the MCP3421, where a NTC and an array of precision resistors help minimize non-linearities.
 
I believe he's measuring the accuracy of the 16 MHz crystal, which is used (via the PLL) to create the main clocks in the chip. The millis() count depends on the main clock.

Do Teensy 2.0 and ++2.0 use the same grade (15ppm) for their 16MHz crystal oscillator? Asking because I wonder what the accuracy limits are on FreqCount and FreqMeasure. I'm also wondering about measuring the temperature and compensating for the temperature dependence of the crystal.

Is there a part number/spec sheet?
 
Do Teensy 2.0 and ++2.0 use the same grade (15ppm) for their 16MHz crystal oscillator?

Yes, Teensy 2.0, Teensy++ 2.0 and Teensy 3.0 all use exactly the same crystal.

I'm also wondering about measuring the temperature and compensating for the temperature dependence of the crystal.

I'd be really curious to hear how that works out, if you try it?

The built-in temperature sensor on the 32U4 chip is pretty much worthless. You'll probably need a thermistor or chip like the DS18B20.

Is there a part number/spec sheet?

Yes, here it is.
 

Attachments

  • NX3225SA.pdf
    87.3 KB · Views: 680
FWIW, the Teensy 3 on-board MCU clock crystal tested here was within 4PPM, using a PPS signal from a Fastrax 501 GPS receiver.

It's a shame that the NX spec sheet doesn't list the slope, nor the inversion point for the crystal. I suppose one could infer it using a PPS signal while heating the teensy. For my RTC crystal, the rate of change, i.e. -0.34 + 0.006PPM * (current temp - 25*C)^2, is so low that even a moderately inaccurate temperature sensor would be good enough (i.e. the minimum adjustment possible on the RTC time base is 0.11PPM).
 
Last edited:
Yes, Teensy 2.0, Teensy++ 2.0 and Teensy 3.0 all use exactly the same crystal.
The built-in temperature sensor on the 32U4 chip is pretty much worthless. You'll probably need a thermistor or chip like the DS18B20.

I wouldn't say that if you can calibrate it based on the tech sheet with an second sensor it will work well.
 
Teensy 3.0 has a better on-chip temperature sensor.

I honestly haven't use it yet, so I'm not sure how well it really works. It's also inside the silicon which dissipates about 150 mW, so its temperature might not track the crystal well enough to be useful. Maybe?
 
Teensy 3.0 has a better on-chip temperature sensor. It's also inside the silicon which dissipates about 150 mW, so its temperature might not track the crystal well enough to be useful. Maybe?

Depends a bit on the overall usage pattern, no? If the VIN-VUSB connection is cut, I'd wager that the power dissipation could drop dramatically since the regulator is not only dissipating heat for the chip but also for any attached LED's, the bootloading chip, and so on. I use MCP1702's externally to develop a stable 3.3V source even if it isn't strictly required.

But I totally agree that the chip sensor may not be representative enough for the temperature of the rtc crystal unless you somehow thermally bond the crystal to the chip (thermal epoxy?). FWIW, I use a DHT22 to sample humidity and temperature on-board. An NTC on a analog channel could also work well enough.
 
Status
Not open for further replies.
Back
Top