Question about DS3231 RTC accuracy and the SQW pin over ~60

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lachlan_
 
Posts: 4
Joined: Tue May 17, 2022 5:03 am

Question about DS3231 RTC accuracy and the SQW pin over ~60

Post by lachlan_ »

I am working on a project using a data acquisition device with a very high sample rate (10k-30kHz). However, the device is time-agnostic and the actual sample rate often has a small amount of error compared with the reported sample rate, so I'd like to estimate the actual sample rate. I want to know if I can use the DS3231 RTC to send an oscillating signal from the SQW pin to the DAQ device, so that I can take two signals which are a known time apart (by counting the number of oscillations between them), find the number of samples between these two signals, and given a known time and number of samples calculate a sample rate. I read on the DS3231 data sheet that it's accuracy is +/-2 ppm. I'm only concerned with how well it can keep time over the course of 60 mins at max, so that would be accuracy within +/-7ms/hr. For me, this is a workable level of accuracy.

My main questions about the RTC are about how the SQW pin functions as I'm pretty unfamiliar with this kind of device. Am I right in that I can expect an error of about max ~7ms per hour? Also, is the 1Hz signal that is generated on the SQW pin as accurate over this duration? And finally, how accurate is the timing between the individual SQW oscillations? Is the 2ppm accuracy something that only emerges at long timescales, or is the time between consecutive square wave pulses reflective of this accuracy as well?

Thanks

User avatar
sj_remington
 
Posts: 997
Joined: Mon Jul 27, 2020 4:51 pm

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by sj_remington »

The DS3231 measures the ambient temperature and uses a switched capacitor circuit to keep the oscillator within 2 ppm. The temperature sensor has rather low resolution, and there may be errors during switching that could significantly affect the time between two successive cycles of a 1 Hz output.

Exhaustive DS3231 test data have been published on web, so do your research.

The obvious better choices are a TCXO module (temperature controlled crystal oscillator, available commercially) or a GPS 1 PPS output, which is stable and accurate to within a few nanoseconds.

User avatar
lachlan_
 
Posts: 4
Joined: Tue May 17, 2022 5:03 am

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by lachlan_ »

sj_remington wrote:The DS3231 measures the ambient temperature and uses a switched capacitor circuit to keep the oscillator within 2 ppm. The temperature sensor has rather low resolution, and there may be errors during switching that could significantly affect the time between two successive cycles of a 1 Hz output.

Exhaustive DS3231 test data have been published on web, so do your research.

The obvious better choices are a TCXO module (temperature controlled crystal oscillator, available commercially) or a GPS 1 PPS output, which is stable and accurate to within a few nanoseconds.
Thanks for the reply. I have looked into community DS3231 tests, however a lot of the results are inconsistent with each other. I guess there is probably some degree of use variability, maybe some of which is related more to the testing environment than variability in the unit itself, and variability between units from different manufacturers. However a lot of the reported accuracies I've found are double to triple that reported on the datasheet, so I figured I'd try get something a little more conclusive from the adafruit forums.

I am not very knowledgeable about this, but I'm sure you're right about the GPS receiver. However the room I need to set this up in does not get reception, I'd be surprised if it was able to receive GPS signal, and I thought that for the PPS signal to be accurate it needs to be referenced to the GPS timestamp? But if I'm wrong about this and the PPS output of GPS receivers are accurate to <1 ppm even without a reference then maybe this would be a good solution for me.

And again, not very knowledgeable but I thought the DS3231 had an integrated TCXO, which was the main reason I was considering this RTC over others. Am I misunderstanding something?

User avatar
sj_remington
 
Posts: 997
Joined: Mon Jul 27, 2020 4:51 pm

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by sj_remington »

I thought the DS3231 had an integrated TCXO
Yes, a relatively low quality one intended for low power consumer devices. It would be more accurate to call it a "temperature corrected" crystal oscillator, as the correction is discontinuous.

This TCXO, to pick a random example, costs only $4.35 and has 1 PPM accuracy. 0.1 PPM is available at a price. https://www.mouser.com/ProductDetail/EC ... ka7Q%3D%3D

You can put a GPS module wherever it will have a clear view of the sky, and use twisted pair cabling to bring the 1 PPS signal to the instrument room, or even the entire serial output stream, which has a time and date stamp.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by adafruit_support_mike »

Fair warning: precision timing is a systems problem, not a device problem. Specs like "1ppm accuracy" mean "under the specified operating conditions, this device will not contribute more than 1ppm of error to signals connected to it" not "using this device will guarantee 1ppm accuracy at the output".

All oscillators are sensitive to noise in their supply voltage, especially periodic noise that syncs up with some off-nominal modal frequency of the crystal or MEMS element. You'll get much better results from a well-filtered battery supply than from a noisy switcher or the same supply that powers a bunch of motors.

User avatar
lachlan_
 
Posts: 4
Joined: Tue May 17, 2022 5:03 am

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by lachlan_ »

sj_remington wrote:
I thought the DS3231 had an integrated TCXO
Yes, a relatively low quality one intended for low power consumer devices. It would be more accurate to call it a "temperature corrected" crystal oscillator, as the correction is discontinuous.

This TCXO, to pick a random example, costs only $4.35 and has 1 PPM accuracy. 0.1 PPM is available at a price. https://www.mouser.com/ProductDetail/EC ... ka7Q%3D%3D

You can put a GPS module wherever it will have a clear view of the sky, and use twisted pair cabling to bring the 1 PPS signal to the instrument room, or even the entire serial output stream, which has a time and date stamp.
Ok thanks a lot for clarifying that. I'll look into other TCXOs. As far as the GPS modules go, that's as I expected, but unfortunately the room is a good 20m from the nearest window/edge of the building

User avatar
lachlan_
 
Posts: 4
Joined: Tue May 17, 2022 5:03 am

Re: Question about DS3231 RTC accuracy and the SQW pin over

Post by lachlan_ »

adafruit_support_mike wrote:Fair warning: precision timing is a systems problem, not a device problem. Specs like "1ppm accuracy" mean "under the specified operating conditions, this device will not contribute more than 1ppm of error to signals connected to it" not "using this device will guarantee 1ppm accuracy at the output".

All oscillators are sensitive to noise in their supply voltage, especially periodic noise that syncs up with some off-nominal modal frequency of the crystal or MEMS element. You'll get much better results from a well-filtered battery supply than from a noisy switcher or the same supply that powers a bunch of motors.
Ok thanks for that info. I did check the specified operating conditions in the datasheet and that seems to line up with my intended usage. I'm not super knowledgeable about electrical noise, but I'd only have it connected to an arduino (or I could connect it directly to a 5V power source) which would power it (and nothing else), and otherwise it's only interaction would be to initiate/stop the square wave output. The arduino in turn is connected to a PC, and both the PC and the DAC that the RTC would feed its signal to are connected to the same ground. The DAC itself is extremely sensitive to electrical noise so I've already spent a lot of time grounding things properly and ensuring any electrical noise is minimized - but I'm not sure if this is sufficient to mitigate the concern you raised. Of course I can always just hook the arduino Vout line up to something and see if there is any noise there before I connected the RTC as well.

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”