Teensy uSD Data Logger Project --> The high performance, battery operated data logger

Status
Not open for further replies.
[BANG BANG BANG!]

There's those pesky uC companies beating on the door… again! :)

Finally got around to characterizing the RTC crystal approach with a CFS206, as promised. I used a GPS receiver to time the MCU crystal and the RTC crystal and a HTU21 temperature / humidity sensor to determine the PPM error vs. temperature. 50-odd measurements later, a least squares calculation distills the data points into a equation for a parabola that has a high degree of correlation.
ppm_error.png

Not that this approach is for everyone -
a) the MCU has to be on all the time (the TXO RTC can do this automagically)
b) temperature-based refreshes of the variables in question may interfere with other tasks.
c) having a accurate on-board temperature sensor is likely a requirement. The HTU21 is great - and I needed it anyway for humidity measurements.
d) You have to run the rig through a calibration routine with a GPS receiver. Takes time but factors can be stored once in EEPROM and forgotten. Accounts for all deltas…

So, plenty of reasons to stick to a TXO RTC, but I had fun showing that this approach can also work for my application. Despite all this, I may still make room on a daughter-board for your TXO RTC to give my colleagues the opportunity to eschew the need for GPS calibration.

Code:
Welcome. Prepare to wait 0 seconds for CIC register to run out.
Now waiting for PPS signal acquisition.
Done.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.77PPM @ 22.83*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.77PPM @ 22.81*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.76PPM @ 22.75*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.75PPM @ 22.68*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.76PPM @ 22.70*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.75PPM @ 22.62*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.73PPM @ 22.43*C.
Actual MCU-RTC PPM delta: 6.80PPM, Predicted delta: 6.70PPM @ 22.21*C.
Actual MCU-RTC PPM delta: 6.40PPM, Predicted delta: 6.65PPM @ 21.87*C.
Actual MCU-RTC PPM delta: 6.40PPM, Predicted delta: 6.55PPM @ 21.24*C.
Actual MCU-RTC PPM delta: 6.60PPM, Predicted delta: 6.45PPM @ 20.77*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 6.37PPM @ 20.41*C.
Actual MCU-RTC PPM delta: 6.40PPM, Predicted delta: 6.29PPM @ 20.10*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 6.20PPM @ 19.79*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 6.13PPM @ 19.52*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 6.04PPM @ 19.25*C.
Actual MCU-RTC PPM delta: 6.40PPM, Predicted delta: 5.96PPM @ 18.99*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 5.88PPM @ 18.75*C.
Actual MCU-RTC PPM delta: 6.20PPM, Predicted delta: 5.79PPM @ 18.49*C.
Actual MCU-RTC PPM delta: 6.00PPM, Predicted delta: 5.70PPM @ 18.27*C.
Actual MCU-RTC PPM delta: 5.80PPM, Predicted delta: 5.61PPM @ 18.03*C.
Actual MCU-RTC PPM delta: 5.80PPM, Predicted delta: 5.52PPM @ 17.81*C.
Actual MCU-RTC PPM delta: 5.60PPM, Predicted delta: 5.43PPM @ 17.59*C.
Actual MCU-RTC PPM delta: 5.60PPM, Predicted delta: 5.34PPM @ 17.38*C.
Actual MCU-RTC PPM delta: 5.60PPM, Predicted delta: 5.25PPM @ 17.17*C.
Actual MCU-RTC PPM delta: 5.40PPM, Predicted delta: 5.16PPM @ 16.96*C.
Actual MCU-RTC PPM delta: 5.20PPM, Predicted delta: 5.06PPM @ 16.75*C.
Actual MCU-RTC PPM delta: 5.60PPM, Predicted delta: 4.96PPM @ 16.54*C.
Actual MCU-RTC PPM delta: 5.00PPM, Predicted delta: 4.86PPM @ 16.35*C.
Actual MCU-RTC PPM delta: 5.00PPM, Predicted delta: 4.77PPM @ 16.15*C.
Actual MCU-RTC PPM delta: 5.00PPM, Predicted delta: 4.66PPM @ 15.95*C.
Actual MCU-RTC PPM delta: 5.00PPM, Predicted delta: 4.56PPM @ 15.76*C.
Actual MCU-RTC PPM delta: 4.80PPM, Predicted delta: 4.46PPM @ 15.56*C.
Actual MCU-RTC PPM delta: 4.80PPM, Predicted delta: 4.36PPM @ 15.38*C.
Actual MCU-RTC PPM delta: 4.40PPM, Predicted delta: 4.25PPM @ 15.18*C.
Actual MCU-RTC PPM delta: 4.60PPM, Predicted delta: 4.14PPM @ 15.01*C.
Actual MCU-RTC PPM delta: 4.40PPM, Predicted delta: 4.04PPM @ 14.82*C.
Actual MCU-RTC PPM delta: 4.20PPM, Predicted delta: 3.93PPM @ 14.64*C.
Actual MCU-RTC PPM delta: 4.20PPM, Predicted delta: 3.81PPM @ 14.45*C.
Actual MCU-RTC PPM delta: 4.20PPM, Predicted delta: 3.70PPM @ 14.27*C.
Actual MCU-RTC PPM delta: 3.80PPM, Predicted delta: 3.59PPM @ 14.10*C.
Actual MCU-RTC PPM delta: 3.80PPM, Predicted delta: 3.48PPM @ 13.93*C.
Actual MCU-RTC PPM delta: 3.80PPM, Predicted delta: 3.37PPM @ 13.75*C.
Actual MCU-RTC PPM delta: 3.60PPM, Predicted delta: 3.26PPM @ 13.58*C.
Actual MCU-RTC PPM delta: 3.60PPM, Predicted delta: 3.15PPM @ 13.43*C.
Actual MCU-RTC PPM delta: 3.60PPM, Predicted delta: 3.04PPM @ 13.26*C.
Actual MCU-RTC PPM delta: 3.60PPM, Predicted delta: 2.92PPM @ 13.09*C.
Actual MCU-RTC PPM delta: 3.40PPM, Predicted delta: 2.82PPM @ 12.94*C.
Actual MCU-RTC PPM delta: 3.20PPM, Predicted delta: 2.70PPM @ 12.79*C.
Actual MCU-RTC PPM delta: 3.20PPM, Predicted delta: 2.59PPM @ 12.63*C.
Actual MCU-RTC PPM delta: 3.00PPM, Predicted delta: 2.49PPM @ 12.49*C.
Actual MCU-RTC PPM delta: 2.80PPM, Predicted delta: 2.38PPM @ 12.34*C.
Actual MCU-RTC PPM delta: 2.80PPM, Predicted delta: 2.28PPM @ 12.21*C.
Actual MCU-RTC PPM delta: 2.00PPM, Predicted delta: 2.12PPM @ 12.00*C.
Actual MCU-RTC PPM delta: 2.40PPM, Predicted delta: 1.97PPM @ 11.81*C.
Actual MCU-RTC PPM delta: 2.60PPM, Predicted delta: 2.05PPM @ 11.91*C.

The resolution for the above data is not the greatest because I was running the Teensy on a 5 second update loop per MCU / RTC cycle, so the PPMs measured increment in 0.2PPMs. But generally within 0.5PPM despite changing temperatures and likely could be better if the time constant were longer.
 
Last edited:
Not that this approach is for everyone

Unless you have very expensive test equipment on hand and a large bank account.:cool:

BTW ... great effort! Now, what's your sleep current draw?


BANG BANG BANG!

There's those pesky uC companies beating on the door… again!

Bill collectors.:cool:
 
Last edited:
Ha ha ha. And here I thought the uC companies were beating a path here because a open-loop temperature compensated crystal seems to behave predictably enough to allow 1ppm performance or better. Oh well. Re-ran the tests tonight with a longer test period and a table-mat to slow the heat transfer. Now up to r^2 of 0.999 - this curve is good for a sub 0.5PPM error for any individual reading and 0.03PPM over the course of 2 hours of data logging across changing temperatures.
ppm_error.png

And if you think about it, the DS323X series does exactly the same thing… it measures temperature, and then uses a open-loop control algorithm to adjust its outputs as needed. All in a little package with a I2C or SPI interface. Essentially, a Attiny 45 with a adequate on-board chip temperature sensor and a high-quality crystal (MEMS or otherwise)… and value-priced to reflect all the features it brings to the table. If the temperature sensor were more accurate and the updates more frequent (i.e. more often than once every 64 seconds), I'd expect that the DS323X series could exceed +/- 2PPM in terms of accuracy, though at the price of higher power consumption and lower VBAT life whenever the VBAT is providing power. At least that seems to be the most logical design tradeoff the team had to make.

The good news is, having a good clock around for calibration is pretty inexpensive - a $34 GPS receiver and it's PPS signal is a atomic clock on the cheap and no issues with latency like with NTP or computer-based clocks. The on board temperature sensor (HTU21) has a accuracy tolerance of 0.3*C vs. 2*C for the DS323X series… and since it stays with the crystal, any offsets will remain perfectly compensated. There is the issue of aging causing drift, but it seems easy enough to fix - just re-run the calibration program once a year to calculate new factors for the correction curve… Calibration, BTW, is something the DS323X series would also theoretically benefit from - hence the aging registers.

Given the level of effort of calibrating (time, not cost is the issue) I'm still interested in giving folk the option to use the DS3232 you identified. Or, how to share one PPS output among many boards. A batch process of self-calibrating boards (requiring no more than cursory supervision for let's say 8hrs) may be OK. For example, we could use a rocketscream PID reflow oven controller board as a sous-vide crystal calibration cooker! :)

My board never gets to sleep, BTW. It's purpose is power measurement of appliances 24/7 and you can't get the granularity we need re data when it's not on 24/7. Being line powered, power draw is a secondary concern. The on-board power supply is good for ~1.5A @ 5V, most of which is designed to be used by daisy-chained devices, not the board with the power supply.

Next steps include thinking of ways to reduce the processing overhead required to keep the crystal calibrated, i.e. for example a sub-routine that gets triggered once a minute to check on the temperature and to change the pre scalar settings for the RTC_TCR registers if warranted. Lastly, ideally, turn the whole thing into a library so that the programs that need it aren't cluttered with tons of crystal-related code. Have never written a library though (danger, will robinson, danger!) :D
 
Last edited:
The Maxim-IC I2C RTC DS3232MZ+ has a temperature compensation range between -40C to +85C. :cool: This is why we chose this TCXO RTC so the uSD data logger could operate in extreme temperatures and still be accurate.:cool:
BTW ...Your TCXO RTC crystal clone has what range?:(:confused:
 
Last edited:
The Maxim-IC I2C RTC DS3232MZ+ has a temperature compensation range between -40C to +85C.

Yes, a range that exceeds the recommended temperature range of any common Alkaline, Lithium-Ion, NiCd, NiMH, etc. cell I know of. You were going to power your logger with a battery, right? Energizer recommends -18 to 55*C for its alkaline cells, for example. Sure, you could operate outside that range and be OK, for all I know, but the manufacturer is making no guarantees. The alternative is to buy extended temperature range cells and pay the premium.

Also, if I were you and you want to certify your product at -40*C, I'd test it there. All battery types have a severely reduced available capacity at that temperature and may not be able to provide the juice you need to run your logger reliably. Conversely, at 85*C, I'd start to worry about the batteries overheating.

Your TCXO RTC crystal clone has what range?

So far, this one sample has been tested from about 0*C to about 40*C, which seems adequate for the indoor conditions I expect my device to encounter. Many appliances do not tolerate being operated in sub freezing conditions, and thankfully there are few to no places in the US that regularly reach 40+*C indoors. Even so, the fit to the curve seems pretty amazing (for this sample of one, so I wouldn't dare make any conclusions on that basis).

More testing with more crystals seems warranted if we want to go the route of using the compensated crystal approach in production. And, designing for a fallback with a DS3232 seems like a pretty good insurance policy. So, congrats on your data logger and I wish you great success with it.
 
Last edited:
We made it, on contract, for data logging in the wild blue yonder. One power source you forgot to mention is general purpose Supercapacitors (operating temperature range: -40°C to +70°C) :cool:
 
Another way to beat a dead horse eg watch crystal ...

You can also factory trim the Teensy 3 RTC digitally using a "GPS disciplined" oscillator.
As a result the accuracy at room temperature (whatever it was in our lab when we calibrated it!)
is better than 2ppm (parts per million). This translates to about 63 seconds per year.

http://en.wikipedia.org/wiki/GPS_disciplined_oscillator

An additional error comes in due to the temperature coefficient of the 32,768Hz timing crystal.

In a real application, this means that a clock built using a regular 32 kHz tuning fork crystal will
keep good time at room temperature, lose 2 minutes per year at 10 degrees Celsius above (or below)
room temperature and lose 8 minutes per year at 20 degrees Celsius above (or below) room temperature
due to the quartz crystal.
 
Hi there t3andy! I am currently logging data in the laboratory using Arduino Uno and DS18B20 digital temperature sensors. I need to set up a field data logger that will operate for months. I found this thread, and it looks like exactly what I need. Can you help me with the parts list and tell me if the low power consumption beta test proved the setup could be semi reliable for my project? Thanks.
 
t3andy...thanks, I did not see the other thread with the information about the Duff library. So, the parts list has not changed from post number one, other than the booster? And, the schematic dated 8/1/13 is the latest?
 
Status
Not open for further replies.
Back
Top