element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino internal clock inaccurate??
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 14 replies
  • Subscribers 392 subscribers
  • Views 1033 views
  • Users 0 members are here
  • clock
  • explodedclock
  • brass
  • collectable
  • antique
  • art
  • arduino
  • no4
Related

Arduino internal clock inaccurate??

jonivanart
jonivanart over 9 years ago

Hello! I am a newbie here and fairly new with the Arduino. I am building a piece of art that has a 150 year old clock as the main subject. I am going to use an Arduino to drive a stepper that runs the clock, a DC motor for the Chime drive (For visual effect) and a solenoid for the escapement mechanism also for visual effect. I've heard that the internal clock on the Arduino is inaccurate from others. What will I need to make it have an accurate output?image

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 9 years ago +3 verified
    Hi Jon, Interesting project! Will it not damage the mechanism though? Maybe something like that is worth a lot of money. You didn't say how accurate you wanted : ) Anyway, the Arduino clock is ok, but…
  • Robert Peter Oakes
    Robert Peter Oakes over 9 years ago +2
    It sounds like what you need is a very accurate pulse / time period, not he arduino actually keeping time Using an internet connected NTP client as sugested by shabaz would be an easy way to keep time…
  • jonivanart
    jonivanart over 9 years ago in reply to shabaz +1
    Thanks! To answer the first question. "Will it damage the clock and maybe it's worth a lot of money? I have plans to put the drive on the proper gear with the least amount of drag/pressure on the coupling…
  • shabaz
    0 shabaz over 9 years ago

    Hi Jon,

     

    Interesting project!

    Will it not damage the mechanism though? Maybe something like that is worth a lot of money.

     

    You didn't say how accurate you wanted : )

    Anyway, the Arduino clock is ok, but not spectacular. It may not be precise, and you'll notice time drifting slightly (perhaps a minute per week or a bit more - enough to be irritating).

     

    A nice device is the DS3231, you could expect a minute or two of gain or loss per year; therefore in comparison the Arduino clock is an order of magnitude worse.

    In practice the Arduino clock is more worse than that, because it is affected by change in temperature (the DS3231 is temperature compensated, so affected less).

     

    Actually, after all that, you would have achieved a clock circuit that is still an order of magnitude poorer than the 250-year old Harrison clocks : ) which were only out by a second per month,

    but the DS3231 circuit costs a tiny fraction of course and doesn't take a lifetime to build.

     

    There are other ways to have precision clocks (e.g. GPS based or NTP based) depending on where you wanted to go with this.

     

    Information on how to use the DS3231 is here. One important point is that it has 3.3V logic, not 5V like the Arduino Uno. So you may wish to use a different board than the Uno.

    There are some 3.3V Arduinos, but I have not used them so I wouldn't be able to recommend any. There are Arduinos (and other single board computers such as Raspberry Pi - although this

    could be considered over-the-top for a clock) with network capability or with Ethernet shields, so NTP could be used with them. A google search on 'arduino ntp clock' revealed some hits.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • jonivanart
    0 jonivanart over 9 years ago in reply to shabaz

    Thanks!

    To answer the first question. "Will it damage the clock and maybe it's worth a lot of money?

    I have plans to put the drive on the proper gear with the least amount of drag/pressure on the coupling pieces and gears in the clock.  Also on top of that, I will be making a rubber breakaway/absorption coupling in between. If something get's out of whack and jams the gears, it will separate. As far as the value. The clock was severely damaged in all other aspects other than the gear train and of course no parts available. LOL! I will make it far more valuable than it would have ever been as a collectible clock. To give you an example. the last project will be for sale for at least 6 figures. ;-)

     

    As far as accuracy, a minute per a week wouldn't be bad considering the original would have been about a minute a day. LOL! But seriously, I like the sound of the 1 to 2 minutes per year but I will definetly need some resources to learn how to set the clock module up paired with an Arduino etc., which I'm sure I can find. Is the DS1307 basically the same thing but with the soldering points?

     

    I do plan on purchasing 2 Arduino's as a permanent part of the project that is soldered in and smaller like the Pro mini 328. One will be the "Chime Arduino" and have a music program for the chimes. It will be signal'd by the main Arduino when the chime needs to be sounded off since there aren't enough outputs on the one Arduino for all the electromechanical devices in the project. Also I want to be able to leave the clock running and upload musical programs to the chime Arduino as I write them. On top of that I want to have some signal buttons to make tunes when I push them for show and tell. :-) 

     

    I will also be making a voltage divider circuit to create the power needed for the different devices so making a 3.3v line won't be an issue if needed.

     

    Cool stuff on the arduino ntp clock search!

     

    Thanks again for all the time and info. It is very much appreciated!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Robert Peter Oakes
    0 Robert Peter Oakes over 9 years ago

    It sounds like what you need is a very accurate pulse / time period, not he arduino actually keeping time

     

    Using an internet connected NTP client as sugested by shabaz would be an easy way to keep time with the arduino and will allow for drift over time to be corrected based on how often you re-synce with the NTP server, but between syncs it will drify a little

     

    What I think you really need though is a very precise pulse being sent to the stepper or solenoid, if you count the pulses or steps being sent and compare to the actual time after each NTP server sync, if too many pulses have been sent you can slow down ever so slightly, if too many then speed up a small amount, this way, the clock may be out from time to time but should correct it self automatically

     

    At least theory sounds right image

     

    Good luck

    Peter

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 9 years ago in reply to jonivanart

    Hi Jon,

     

    Great, sounds like an excellent idea with the rubber coupling. DS1307 is more popular than DS3231 for hobbyists, so more chance of finding info on arduino/DS1307 projects. Less accurate than the DS3231, but more than the Arduino on its own, so a good compromise. The DS1307 integrated circuit is available on hobbyist-friendly soldered boards, so no need to solder the IC yourself, you could just get a board.

    As Robert Peter Oakes says, regardless of the method you use to obtain your clock, you'll need a strategy to either directly drive your stepper motor from the clock (hard to do) or perform a compensation (e.g. daily) to correct for any time (probably seconds) gained or lost.

    The way I'd possibly approach that (never tried it) is to keep a local count in a variable (i.e. still use your arduino clock and arduino events/interrupts or whatever constructs arduino's have to pulse your stepper motor), and compare with the RTC (DS3231, 1307, or whatever method you choose) daily (or some other interval e.g. hourly).

    I'd also pre-determine an amount of time (e.g. 1 minute) that would make 1 second invisible to the average observer.

    So, daily or hourly, after the comparison of local vs RTC time, if the delta is (say) one second or more, then for the next minute I would run my local clock at a speed that I can correct for 1 second. After the minute had completed, I would then compare again, and repeat, until the delta is less than one second.

    Anyway, that's just an idea - maybe there are other more refined ways of doing it.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jonivanart
    0 jonivanart over 9 years ago

    Robert Peter Oakes shabaz

    The RTC sounds really cool and I get where you are all coming from but may take a while to get to that level of programming on my part. Another thing is that I don't think the art piece will be near an internet connection either.

    What if I have 2 trigger buttons. One for UP and the other for DOWN? I want to have a LCD to display the time digitally on the back of the clock. Basically, someone come in and check the digital clock with their cell time and toggle the stepper UP or DOWN to set the time about every couple months or so or whenever. This piece will likely be in a museum and I don't want anyone messing with it mechanically but the curator could do it if needed if I set it up like that.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 9 years ago in reply to jonivanart

    Hi Jon,

     

    An LCD and couple of buttons sounds a reasonable approach, although the Arduino has no way of knowing what the mechanical hands are displaying (e.g. there could be a power failure).

    In theory with some additional electronics it could remember the last time before it lost power, but that is getting complicated and may still get out of sync e.g. if someone accidentally turns the

    mechanism by hand.

     

    So, you might want the LCD to just be used to put in a delta (e.g. minus 5 minutes) when the mechanical displayed time needs changing rather than a normal clock time.

    To be honest, if you're just putting in a delta, then you could get away without any display, if you only need precision down to minutes. The operator could just press the 'up' button 5 times and the clock would

    increase by 5 minutes. If you expect there to be a change of daylight savings time too, then personally I would just have two more buttons for that - one to increment by an hour (or to increment by 10 minutes, so

    press it 6 times) and one to decrement by that amount.

    What do you think?

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jonivanart
    0 jonivanart over 9 years ago in reply to shabaz

    I get it. That sounds good. Maybe I'm over thinking it all. LOL! I just thought of something too. This probably would have helped you a few comments back! LOL! I forgot the clock piece has the minute and hour on a mechanical slip system built in for setting the hands without interfering with the gear train.

    What if I just make a start stop button. I just stop the arduino clock when the second hand is on 0/60 mark then manually set the clock ahead a minute and start it when it gets to the that time. or even better make a display menu to ask the hour then minutes then say PRESS TO START. (1 button for up another for down and the 3rd for enter/PRESS TO START)

    Set that and the mechanical hands ahead about 5 minutes to allow time to do it all. Then hit start/enter when it becomes time. After the button for start is pushed it automatically goes to UP or HOLD mode. Up to move time forward and hold to pause it. For HOLD you release the button when time reaches that time.

    Possibly an option for daylight savings time. Daylight HOLD or daylight FORWARD maybe?

    Buttt!! If the power goes out I want it to automatically go to the right time. If possible?? I think I just confused myself! LOL! Seriously tho. Could I somehow put it in the program to do that? If it would too complex then I could just leave that out and just make them reset it if the power goes out...

    Thanks for your time and input. It is really helping me work a lot out already. :-)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 9 years ago in reply to jonivanart

    Hi Jon,

     

    I'd say it is possible to implement pretty much anything (it's software, so everything is possible ; ) although your hardware will need to support certain things like the power failure thing, but we can discuss that in a bit..

     

    Mainly, the issue is the determination of the workflow for the user. With a scheme where the clock is temporarily stopped to allow a manual adjustment, for the user who just wants to trim by a minute or two every week or day, he will need to do a few things - press or hold a button to stop the clock, manually adjust the time (which may be a two-handed operation if he wants to take some care maybe? I have no idea) and then press or release a button. And also he will visually need to confirm that both LCD time and mechanical time look the same with his wristwatch or whatever.

     

    With the earlier scheme, he can just hit the '+' or '-' button x times for the number of observed minutes of error, and walk away.

     

    I'm just concerned if you go through the LCD route, you may still hit scenarios where the LCD time is different to the mechanical displayed time (the power failure example was just one scenario that would cause this, so would accidentally touching the clock hands). You or I would understand there is a limitation that there is no direct self-correcting "linkage" (e.g. optical or magnetic sensing means) between the LCD and mechanical displays, but the average user (e.g. museum staff) would have no idea, technology "just works" for them. So for me, a 4-button solution with +1, -1, +10, -10 sounds cleaner - but I'm not the target user, and I like stripped-down minimal user interfaces lol. Not everyone does!

     

    There is no right or wrong answer, just depends on what you're comfortable with your users doing, but what you propose is feasible to implement technically. I think there are many LCD shields for the Arduino.

     

    Regarding correction on power loss, that requires an RTC and backup battery, and a way of recording the current time every (say) minute to non-volatile memory (e.g. some free bytes of battery-backed SRAM which some RTCs contain), so you can read it and know on power-up what was the last time the device had power. It is complicated to do but feasible. Complicated because you have to cater for scenarios like the SRAM being uninitialized or corrupt due to power failures while it is being written, etc. There are solutions, but requires a fair amount of consideration and coding, and I really have no idea how confident you are with this. If it is not essential then might be worth leaving it out, because it could potentially double the coding effort (or more) for the project.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jonivanart
    0 jonivanart over 9 years ago in reply to shabaz

    That all sounds feasable and definitely easier but how would I implement the chime system and let it know when to go off(Chime) and what type of chime(Hourly or quarterly or both depending on the customer preference)?

    Also I'm going to get real deep into coding soon. Starting next week I will be devoting more time to that so I don't think that will actually be an issue as far as writing all the code eventually but I definitely want to have a good layout to shoot for for sure. I really think us talking about it is getting us there. :-)

    Maybe they should call me if the power goes out? LOL!

    Question then. I thought the battery in the ChronoDot allows it to keep time without power??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 9 years ago in reply to jonivanart

    Hi John,

     

    Yes, the DS1307 board you refer to has a battery, so it will keep time without power.

    I had forgotten about your chime requirement - that complicates things a bit, I think you will need some display and menu to be able to set this, and means your microcontroller does need to know the actual time, rather than just provide accurate steps to the mechanism. I've not used them but I see there are MP3 boards for the Arduino where you can upload your desired sounds. They mostly take a microSD card.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube