Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: Creating a high precision RTC with a Teensy 3.2

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    6

    Creating a high precision RTC with a Teensy 3.2

    Hello,
    Using this type of oscillator (12.8 MHz - Clipped Sine Wave - 0.05ppm):
    https://uk.farnell.com/iqd-frequency...smd/dp/2443045

    I'd like to create an accurate RTC using GPS syncronisation as an initialization of the clock. I would use interruptions to detect edges of the oscillator, and count them.

    My questions are : - Would the Teensy 3.2 be able to detect edges as this oscillator generates a clipped sine wave signal ?
    - Can the Teensy handle such high frequencies as interruption inputs ?

    Thanks.

  2. #2
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    504
    Maybe I misunderstood your aim . . ., but if you add a GPS module, you will have a very accurate RTC! You do not need an extremely expensive TCXO then? The Teensy 3.2 already has a builtin RTC, you only need a 32768kHz 12.5pF crystal and solder it to the board.

  3. #3
    Junior Member
    Join Date
    Sep 2019
    Posts
    6
    Quote Originally Posted by DD4WH View Post
    Maybe I misunderstood your aim . . ., but if you add a GPS module, you will have a very accurate RTC! You do not need an extremely expensive TCXO then? The Teensy 3.2 already has a builtin RTC, you only need a 32768kHz 12.5pF crystal and solder it to the board.
    As my system won't be able to get time from GPS all the time, it needs to keep an accurate track of time while it goes underwater. I need to process underwater acoustic signals so I also need a really precise RTC

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,235
    Quote Originally Posted by brivbl View Post
    Hello,
    Using this type of oscillator (12.8 MHz - Clipped Sine Wave - 0.05ppm):
    https://uk.farnell.com/iqd-frequency...smd/dp/2443045

    I'd like to create an accurate RTC using GPS syncronisation as an initialization of the clock. I would use interruptions to detect edges of the oscillator, and count them.

    My questions are : - Would the Teensy 3.2 be able to detect edges as this oscillator generates a clipped sine wave signal ?
    - Can the Teensy handle such high frequencies as interruption inputs ?

    Thanks.
    Then T3.2 ISR latency for GPIO pin interrupts can only support 1 to 2 MHz.

  5. #5
    Senior Member Wozzy's Avatar
    Join Date
    Jan 2013
    Location
    Philadelphia, Pennsylvania USA
    Posts
    354
    Many of the GPS modules support an extremely precise PPS (Pulse Per Second) signal that can be used to synchronize the Teensy clock.
    Many people are using this signal to create a Stratum 1 NTP Time Server.
    I know that on Ublox GPS modules, you can set the PPS interval to other than one second in firmware.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,061
    Does this Time tracking Teensy - that can't use/see GPS - have any other functions to do ?

    Wouldn't 12.8 MHz feed a Teensy 4 timer/counter? Does T_3.2 have such a pin function?

    Based on T4 Beta thread it seems the T4 could count that? Maybe as Paul noted somewhere add flip flops to drop the count rate?

  7. #7
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,235
    The T3* FTM timers can be fed an external clock, but max frequency is F_BUS/4. So T3.2@120 mhz should work (F_BUS would be 60mhz). FTM timers are only 16-bit so you'd need to handle overflows to get a 32-bit or 48-bit counter.

    T3.6 examplehttps://forum.pjrc.com/threads/40825...for-FTM-timers

    EDIT: maybe not for T3.2. FTM external input pins are PTA18 and 19 (ALT4), but those are the pins for MCU 16mhz crystal. However the FreqCount lib can count pulses on pin 13 (60+MHz) using LPTMR (or at 132MHz).

    PDB can be triggered by external pins (PTC0 or PTC6) https://forum.pjrc.com/threads/24492...DB-on-Teensy-3
    Last edited by manitou; 10-01-2019 at 02:13 AM.

  8. #8
    Junior Member
    Join Date
    Sep 2019
    Posts
    6
    Quote Originally Posted by manitou View Post
    Then T3.2 ISR latency for GPIO pin interrupts can only support 1 to 2 MHz.
    Ok thanks, I just checked and it can't handle more than 2.9MHz with a basic counter interruption handler at max CPU clock (160MHz)

  9. #9
    Junior Member
    Join Date
    Sep 2019
    Posts
    6
    Quote Originally Posted by Wozzy View Post
    Many of the GPS modules support an extremely precise PPS (Pulse Per Second) signal that can be used to synchronize the Teensy clock.
    Many people are using this signal to create a Stratum 1 NTP Time Server.
    I know that on Ublox GPS modules, you can set the PPS interval to other than one second in firmware.
    I use the PPS to synchronize my clock, when my system gets back to the surface, it gets GPS signal and synchronizes automatically on PPS rising edge, but then my system is completely autonomous when it goes back underwater so it has to keep an accurate track of time without any network or satellite

  10. #10
    Junior Member
    Join Date
    Sep 2019
    Posts
    6
    Quote Originally Posted by defragster View Post
    Does this Time tracking Teensy - that can't use/see GPS - have any other functions to do ?

    Wouldn't 12.8 MHz feed a Teensy 4 timer/counter? Does T_3.2 have such a pin function?

    Based on T4 Beta thread it seems the T4 could count that? Maybe as Paul noted somewhere add flip flops to drop the count rate?
    My teensy is logging info to csv files on an SD card, capturing sounds via an hydrophone and a SGTL5000 to a SD card (wav format)

    But if I create a clock, I could do it with a separate teensy and make them communicate via I2C

    Flip flops are interesting, I would use TTL D flip flops (sn74175) since they handle higher frequencies

  11. #11
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,171
    How long is the system going to be underwater?
    Is the oscillator only counted down to keep track of seconds or are you using it for stamping events with a much higher precision than seconds?

    Pete

  12. #12
    Junior Member
    Join Date
    Sep 2019
    Posts
    6
    Quote Originally Posted by el_supremo View Post
    How long is the system going to be underwater?
    Is the oscillator only counted down to keep track of seconds or are you using it for stamping events with a much higher precision than seconds?

    Pete
    The ideal would be several days, then if the precision of the RTC is not sufficient, the system would come back to the surface more often to get a GPS synchronization. The longer it stays undewater, the better.

    The oscillator would do both. Keep track of time accurately and stamping my audio recordings with high precision.

  13. #13
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,397
    How I di it, is to ignore the drift of the RTC, and CPU

    My files are all 1 minute long (closing driven by RTC seconds)
    every header contains the RTC but also millis and micros.
    Further I sample regularly (every 100 ms) the temperature of the CPU that I store with RTC, millis and micros (I also sample other non-acoustic data)

    GPS is fetched while system is at surface.

    with all this stored info it is then possible to reconstruct both the drift in sampling and RTC
    This is all you need for underwater (non-realtime) applications

    (I planned to use a cesium clock, but they do not like temperature above 30 deg C, so they are not practical)
    (others use NTP server that is synced when system is at surface, but week-long underwater system need to be VERY LOW power implementations and all these additional system are power hungry)

  14. #14
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    677
    Quote Originally Posted by WMXZ View Post
    (I planned to use a cesium clock, but they do not like temperature above 30 deg C, so they are not practical)
    I'm curious, there's a cesium clock that's very low power? Also, I would have thought underwater is the one place that a 30 C limit wouldn't be a problem.

  15. #15
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,397
    Quote Originally Posted by JBeale View Post
    I'm curious, there's a cesium clock that's very low power? Also, I would have thought underwater is the one place that a 30 C limit wouldn't be a problem.
    would not call it very low power, but I could run it from Teensy 3.3V (CSAC SA.45s from Symmetricon http://www.prc68.com/I/pdf/Symmetric...AC_updates.pdf)
    on the 30 C limit: it is not the water but before the system gets into the water (say on board a ship in the summer in the Med)
    (BTW, I have seen ocean with more than 30C, close to surface)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •