Clock striking mechanism: clock precision

I own an old clock with claves inside, but without the original striking mechanism. It was sold some years ago and replaced by a AA-powered clock that doesn't strike. I build a small device from LEGO that can strike the rods and is powered by a 3.3V DC-Motor.

Now I want to the atmega to power the motor every hour for a few seconds to strike the claves. The atmega328 is set on a breadboard with a 16MHz quartz and powered by a step-up-converter from an AA battery at around 3.3V.

When I measured the power consumption without the step-up-converter (3.3V from an Arduino Uno), it took around 6 mA (~8d in an AA-battery). This is why I spend some effort into learning about the sleep mode and watchdog mechanics.

So, at the moment I let the Atmega sleep for 1s, increase a counter, check if the counter is above 60*60s (=1h) and power the motor for 3s if it is, otherwise send it back to sleep. This seems to reduce the power consumption below 0.1mA. However, I already noticed that 1s sleep mode is not exactly 1s. When I let it trigger the motor every minute, I noticed a 6s deviation.

Now I let the device run over a day, log the motor-triggers in putty with a timestamp and plan to add/subtract the delay in the software.

Is this a reasonable approach, or should I, for example, invest in an RTC-chip, like DS3231, and instead of increasing a counter check the time there?

Here is the sketch-code: clockHitter - Pastebin.com

The watchdog oscillator is not intended for accurate timekeeping, and accuracy is temperature-dependent.
You'd be better off using an RTC.

If the clock is intended to chime every hour what about using a sensor that detects the position of the minute hand when it gets to 12?

The Arduino could sleep for 55 minutes after it finished chiming.

Nick Gammon's power saving tutorial may be useful?

...R

The DS3231 is a nice accurate clock , I’d go for that - unless your existing clock could be made to produce a digital output ( eg opto pickup) on the hour, that could be an input to the Arduino .

dediggefedde:
Is this a reasonable approach, or should I, for example, invest in an RTC-chip, like DS3231, and instead of increasing a counter check the time there?

You should probably invest in an RTC.

By the way, your code doesn't actually strike the hours (once for 1 o'clock, twice for 2 o'clock, etc.), does it?

Thanks for all the quick answers!

> Calibration progress
I have now 4 timestamps that imply that I have 0:5:53 offset each hour ±1s. In the worst case, even with calibrating this might cause 50s delay per day... Which also will get worse if the weather changes. ^^

> coupling the existing clock as a time giver
I would like to avoid damaging the wooden dial. And I don't see any other way of coupling them than by making a hole in the dial (either for photosensor or for cables).

> code doesn't actually strike the hours
line 88 counts up timer each second. If at line 69 timer is over or equal 6060 but under 6060+3 (written as if(timer%(60*60)<3) ) then the motor is powered. This should result in it getting triggered for 3s every hour.
Also line 69 triggers the motor if timer>126060, which should be every 12h. If the timer exceeds 12h + 23s in line 78, it will be reduced by 1260*60 in line 79.
Line 51-68 and 90-92 can be ignored as long as you don't push the button.

> use an DS3231
I would then let the system sleep for 50 minutes and then check the timer... or I could synchronize the internal timer with the clock every 20 min to increase the sleeptime...
Can I also power the DS3231 via the stepup-converter or do I need the additional battery here?

dediggefedde:
...
> use an DS3231
I would then let the system sleep for 50 minutes and then check the timer... or I could synchronize the internal timer with the clock every 20 min to increase the sleeptime...
Can I also power the DS3231 via the stepup-converter or do I need the additional battery here?

Running an RTC along side your clock should work and be accurate enough (a few seconds a month). You can power it with 3 or 5 volts. The button battery keeps the RTC running when the main power is shut off. Without it, the time will need to be reset when you change the clock's batteries. The RTC's battery will last many years before it needs to be replaced.

Bear in mind any error may change with time , temperature and voltage - so correcting for internal clock errors is not a long term solution . I have a Chinese DS2321 board that is about a minute out after 18 months