Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Internal Clock Accuracy


  • Please log in to reply
12 replies to this topic

#1 Claus

Claus

    New Member

  • Members
  • Pip
  • 6 posts

Posted 08 April 2011 - 10:02 AM

Hi, I've a problem with the accuracy of the internal clock. At my Netduino, during 24 hours it runs 12 seconds to slow. I want to use the Netduino for ongoing data logging on a SD card and I think it is not usual to synchronise the internal clock every hour. Of course I could use a time correction factor, but I think the ExtendedTimer events won't be touched by this. Is this inaccuracy only due to an inproper crystal? Can the internal clock be adjusted somehow? Can I use an exact running external oscillator to avoid this inaccuracy? Thank you for your help, Claus

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 08 April 2011 - 10:24 AM

have never did a time depending project but I know of the existence of a shield named Real Time Clock Module. Appairently there's a need for such a shield, so I guess it's a common problem.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 08 April 2011 - 12:11 PM

Hi Claus.

Is this inaccuracy only due to an inproper crystal?

12 secs on 24h is about 140ppm, and it could be the crystal imprecision, but it is very bad (typically should be under 100ppm).


Can the internal clock be adjusted somehow?

I don't think so. Due to space problems there is no adjustable capacitor for the crystal.

Can I use an exact running external oscillator to avoid this inaccuracy?

You may create your own hi-precision timing source, but it cannot be used as an alias for the standard timing. That is you could feed an input port with a 1Hz clock, then manage an internal counter every edge.
You will have jittering, but the average must adherent to the time-base.

Cheers
Biggest fault of Netduino? It runs by electricity.

#4 Claus

Claus

    New Member

  • Members
  • Pip
  • 6 posts

Posted 08 April 2011 - 12:51 PM

Hallo Stefan, Thanks for your comment. I use already a DS1307 RTC to set initially the Netduino internal clock. With the inaccuracy of the internal clock I have to do this at least every hour. To set the internal clock from the RTC you have to poll the RTC until a change of the second takes place and then update the internal clock. I want to avoid this often polling, because it may affect the interrupt driven data logging more than necessary. The best solution would be to get the internal clock more accurate. Any idea... ? Thanks in advance Claus

#5 Claus

Claus

    New Member

  • Members
  • Pip
  • 6 posts

Posted 08 April 2011 - 01:27 PM

Hallo Mario, Thank you for your answer as well. I thought of adjusting the internal clock (DateTime.Now) via software. But I fear it isn't possible (or is it?). If only the onboard crystal is accountable for the inaccuracy (is it?) I thougth of applying an external high precision oscillator to the XIN pin of the AT91SAM7X512 (instead of the crystal) by making a little mainboard modification . But the manual is telling something about another timing register setup when an external oscillator is driving the main clock... Has someone experience with this issue? Another approach would be to apply a much more accurate crystal. But this would only make sense, if the internal clock is exactly driven by the Crystal, that means, that a 100% accurate crystal would result in an 100% accurate internal clock. Does anybody know if this is true? Thanks, Claus

#6 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 08 April 2011 - 02:02 PM

I thought of adjusting the internal clock (DateTime.Now) via software. But I fear it isn't possible (or is it?).

That is a good question, but I can't answer at the moment.

I would avoid to modify the board, also because the components are really tiny.

A workaround could be taking advantage by the pin 7 of the RTC, that is a 1Hz square wave, by feeding any of the input port. If you configure that port as "InterruptPort", you will obtain an event on any edge of the 1Hz wave.
Within the service routine, you could increment your own private DateTime field of just one second (using the TimeSpan structure).
Of sure it will not an elegant way, but it is even better than a finger in eye.

Tschuss.
Biggest fault of Netduino? It runs by electricity.

#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 April 2011 - 04:19 PM

I thought of adjusting the internal clock (DateTime.Now) via software. But I fear it isn't possible (or is it?).

You can use Utility.SetLocalTime(...) to set the local time.

#8 Claus

Claus

    New Member

  • Members
  • Pip
  • 6 posts

Posted 08 April 2011 - 05:59 PM

Hallo CW2, sorry, I didn't mean "adjusting the internal clock", I meant "adjusting the accuracy of the internal clock". Is it possible? Thank you, Claus

#9 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 April 2011 - 08:07 PM

sorry, I didn't mean "adjusting the internal clock", I meant "adjusting the accuracy of the internal clock". Is it possible?

I see. I am not aware of any function that could be used to adjust the accuracy of the internal clock (and there is no calibration mentioned in the microcontroller datasheet). Just out of curiosity, what does your program do? Does it call many managed methods that internally call native functions? Or responds frequently to interrupts? This may cause certain time deviation, because the framework uses so called 'slow clock' with resolution ~21 µs for time functions. If you create a trivial program that does nothing (e.g. Thread.Sleep(Timeout.Infinite)) and displays the current time in response to an external event, which may be precisely timed, you should be able to verify whether the time deviation is caused by the oscillator (you will get the discrepancy too) or by the CLR execution engine.

Netduino uses crystal oscillator ABM7-18.432MHZ-10-D2Y, which according to the datasheet has frequency tolerance ±20 ppm and stability ±30 ppm. The microcontroller supports external clock source and also has Real-time Timer, both would require changes in the firmware.

#10 JonnyBoats

JonnyBoats

    Advanced Member

  • Members
  • PipPipPip
  • 155 posts
  • LocationPhillips, ME

Posted 09 April 2011 - 01:33 AM

If you feel comfortable with the electronics try adding some capacitance in parallel with the crystal. Also if you have access to a frequency counter you can check the oscillator frequency. It does seem to me that you should be seeing better accuracy than you are getting, but keep in mind that things like temperature affect frequency.

#11 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 09 April 2011 - 04:04 AM

Netduino uses crystal oscillator ABM7-18.432MHZ-10-D2Y, which according to the datasheet has frequency tolerance ±20 ppm and stability ±30 ppm. The microcontroller supports external clock source and also has Real-time Timer, both would require changes in the firmware.

That is another bad new I won't ever hear, but it seems so...
It seems that the internal RTC is totally software based, without any sync with a MCU timer.
At this point, it is clear that has not any sense adjusting the circuitry around the crystal.
Biggest fault of Netduino? It runs by electricity.

#12 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 26 April 2011 - 01:21 PM

I am not aware of any function that could be used to adjust the accuracy of the internal clock (and there is no calibration mentioned in the microcontroller datasheet).

Note to self: Using a Real-time Timer with Non-calibrated RC Oscillator as a Real-time Clock.

The Application Note describes a method to improve the accuracy of a Realtime Timer when it is used as a Real-time Clock. A special hardware process, "Timing Interval Acquisition" (TIA), has been developed and is embedded in AT91SAM7S and AT91SAM7X products.

#13 leonzha

leonzha

    New Member

  • Members
  • Pip
  • 1 posts

Posted 24 May 2012 - 06:42 AM

"Netduino uses crystal oscillator ABM7-18.432MHZ-10-D2Y, which according to the datasheet has frequency tolerance ±20 ppm and stability ±30 ppm. " i am try to make own pcb with the netdunio plus schemetic. currently, when i plug the usb onto my computer, it says unknown device. but i can upload the netdunio mini firmware through DBUG pins. i think the problem may causing by the main crystal i used. from at91sam7 datasheet Page615. CL (6) Equivalent Load Capacitance Integrated Load Capacitance (XIN and XOUT in series) 20pF CLEXT (6) Maximum external capacitor on XIN and XOUT 10 pF by using ABM7-18.432MHZ-10-D2Y the External Load Capacitance will be 10*10/(10+10)+ 5pf(inconsideration of track...)=10pf, this seem did not consider internal equivalent load capacitance. i am not using this crystal at moment. why this mcu only allow max of 10pf load capacitance? this is not common on market, unless i order it. hope someone help me to understand this. appreciated




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.