Crazy Clock

A replacement controller for Lavet stepper clock movements

Similar projects worth following
Starting from
nsayer has 2318 orders / 163reviews
Ships from United States of America
Simple, run-of-the-mill wall clocks with second hands that step from one second to the next are driven by a Lavet stepper motor clock movement. Once you know how they work, it's relatively simple to design a microcontroller based replacement for the electronic part of the movement. If you do that, you can make the clock tick any way you want.

There are presently thirteen different firmware loads for the Crazy Clock. Five of them are "alternate timebase" clocks. They tick at a faster or slower rate so that a complete revolution of the hands occurs in more or less time than a normal Solar day. The rest of the clocks are "novelty" clocks. They tick at a long term average of 86400 ticks per day, but they alter the timing of the ticks for humorous effect.

At the end of the gear train of a Lavet stepper motor based clock movement is a gear with a permanent magnet attached to it. The gear sits in a stator with a coil wound around it. The coil is (ordinarily) pulsed at 1 Hz with alternating polarity. That causes the magnet to rotate 180°, which in turn causes the second hand to move 6° (one second's worth).

If you cut the traces on the board that lead to the chip from the battery and to the coil, and then tack on wires to those traces, you can wire in an alternative controller that can make the clock tick any way you want.

If you really want to have the minimum possible impact on how the movement works, it's desirable to reuse the AA battery holder built-in to such movements. Although a single AA battery starts out providing 1.5 volts, as it discharges, the voltage will drop even though it is still capable of putting out enough current to drive the movement acceptably. But a cheap microcontroller, like an ATTiny45, won't operate properly even on 1.5 volts, much less anything lower. Even more critical is the fact that varying the supply voltage may have a detrimental impact on the oscillator frequency. The solution is a boost converter to make a higher, stable voltage out of whatever voltage the battery is producing. The boost converter need only be capable of a burst current of about 5 mA, and most of the time the controller will draw less than 100 nA. This is because we strategically turn most of the internal peripherals off and put the controller to sleep most of the time. The boost converter chip is the XC9140C331MR-G. It's capable of providing at least 40 mA (at 0.8V in), but it remains highly efficient even at the low currents drawn by the crazy clock most of the time. The boost converter circuit is quite small - It's a SOT-23-5 chip, two ceramic caps and an inductor. Because the microcontroller runs at 3.3 volts instead of the original 1.5 volts, we place a 100 ohm series resistor on both outputs. Most of the coils out there have a resistance of around 200 ohms, so the total series resistance of 200 ohms drops the voltage presented to the coil down to close to the original 1.5 volts. The flyback diode array is just outside of series resistors. The flyback diodes prevents the negative coil collapse voltage from being presented to the controller, which would potentially damage it.

We use the AVR's "idle" sleep mode, because we use a timer interrupt to wake the controller at 10 Hz, and idle mode is the deepest sleep available that allows the timer to run. Every time the controller wakes up, it makes a decision whether to tick or not and then goes back to sleep.

The timer is driven by the clock's 32.768 kHz crystal. Because that crystal is also the controller's execution clock, it takes very little power even when it's not sleeping. But obtaining a 10 Hz interrupt source from a 32.768 kHz source requires some tricky arithmetic. The timer is configured with a divide-by-64 prescale setting, resulting in a 512 Hz counting rate. To go from 512 Hz to 10 Hz we must divide by 51 1/5. To do that, we count to 52 once, and then count to 51 four times. Some of the intervals will be about 2 ms longer, but for this application, that's not significant. The only downside to having such a slow system clock is that the ISP programming clock must be no faster than a quarter of the system clock, so programming must be done at no faster than 8 kHz. Most of the firmware is just a little more than 1KB, so it takes upwards of 15 seconds to load.

The accuracy required to keep a clock reasonably close to the correct time is quite demanding. Even a pedestrian standard of 10 parts per million (about 26 seconds in 30 days) requires at least calibrating each manufactured batch of boards. The result of the calibration is a standard average drift factor. Each individual board can be expected to run within 10 parts per million of this standard drift due to the manufacturing tolerances of the crystal, but...

Read more »

Standard Tesselated Geometry - 1.27 MB - 12/15/2021 at 09:05


Standard Tesselated Geometry - 1.62 MB - 12/15/2021 at 09:05



Schematic for T44 QFN generic variant

Adobe Portable Document Format - 25.22 kB - 03/09/2021 at 00:17



Eagle schematic for T44 QFN generic variant

sch - 159.39 kB - 03/09/2021 at 00:15



Eagle board file for T44 QFN generic variant

brd - 50.72 kB - 03/09/2021 at 00:15


View all 18 files

  • 1 × ATTiny45-20MU Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × CM315D32768EZFT Frequency Control / Crystals
  • 1 × XC9140C331MR-G Power Management ICs / Battery Management ICs
  • 1 × BAT54A Discrete Semiconductors / Diodes and Rectifiers Schottky diode array
  • 1 × 10 µH inductor 1210

View all 11 components

  • Printing gears

    Nick Sayer12/15/2021 at 18:34 0 comments

    After a couple of iterations, I believe I have a pair of gears designed that work.

    Printing these is fairly difficult. As I noted originally, there's no way an FDM printer would be able to get these right. With SLA, the issue becomes how you support them. You can't tilt the gears at all, because doing so will result in the need to support the tips of the gears on one side. The problem with that is that the gear points are going to be smaller than the touchpoints. This means we have to print the gears flat. We could print them flat on the build plate with no raft at all, but then removing them without damaging the teeth is problematic. I've printed a few with carefully placed supports, and that works, but even removing supports that are kept behind the inner plane of the gearing, it's still possible to break the teeth off if you're not extremely careful.

  • Gear ratios

    Nick Sayer12/14/2021 at 20:23 0 comments

    I'm going to label these two gears of interest the "inner" and "hour hand" gear. The hour hand gear is the one with the stem riser that winds up accepting the hour hand. The inner gear meshes on its outside edge with the minute hand shaft and on the small raised inside nested gear with the hour hand's outside edge gearing.

    The outside of the inner gear is the same for both the 12 and 24 hour models. There are 45 teeth. Where things begin to differ is on the inside gear of the inner gear. For the 12 hour model, there are 12 teeth that mesh with 48 teeth on the hour hand's gear. For the 24 hour model, there are 8 teeth on the inner gear that mesh with 64 teeth on the hour hand's gear. If you do the math, you can readily see that the 24 hour gear ratio is twice that of the 12 hour model (12/48 = .25, 8/64 = .125).

    It doesn't seem like there's any optimizations to this that we can conveniently make. If we attempt to reduce the number of points on the inner gear we have to make its diameter smaller, and it's already got no room to do so given that it has to sit on a spar in the chassis that's a certain diameter itself.

  • DIY 24 Hour movements

    Nick Sayer12/14/2021 at 19:51 0 comments

    Well, I tried to ask nicely, but Primex told me to pound sand.

    So what is the difference between a 12 hour and a 24 hour clock movement anyway? Well, clearly the gear ratio between the minute and second hand is twice as slow. But what does that physically mean?

    Here's a 12 hour movement on the left, 24 hour on the right. Notice two of the gears are grey on the 24 hour movement. Those are the two gears that transmit the minute hand movement to the hour hand. Cutting to the chase, it turns out that nothing else is different, and simply moving the two grey gears over to replace their counterparts on the 12 hour movement work just fine.

    Well, can we 3D print those two grey gears?

    First, if I am even going to attempt it, let me say at the outset that I am glad I have a Form 3. I have serious doubts that any FDM printer would have any sort of shot at it. SLA may not even be good enough. I may have to get these done via SLS at Shapeways.

    But first thing's first. I have to model them in Fusion 360. I've never attempted anything this critical before.

    Time to get out the calipers...

  • Bad news - no more 24 hour movements

    Nick Sayer12/07/2021 at 03:38 0 comments

    Primex/klockit seems to have discontinued the Q-80 24 hour movements. I still have a half flat of them, but when they run out, there will only be 12 hour movements available. Sorry.

  • Smaller inductor

    Nick Sayer03/20/2017 at 00:22 0 comments

    For the life of me, I don't know why I've been using such a huge inductor all this time.

    I got a rev 2.6.1 board fab'd with an 0805 footprint for the inductor and tested it out, and it works just the same as the 2.6 version.

    My inductor choice was a Taiyo Yuden LBR2012T100K 10 µH 360 mΩ inductor. As before, the boost converter had a 10 µF input cap and a 22 µF output cap. The rest of the circuit was the same (based on the ATTiny44A).

    EDIT: Ah. Now I see. The LBC3225T100KR 1210 inductor I have been using has about half the resistance and a reel of them costs 25% less.

  • XC9142 vs XC9140

    Nick Sayer02/27/2017 at 18:57 0 comments

    Well, the XC9142 was on a par with the TI chips that I tried - and about an order of magnitude higher than the XC9140. I've reached out to Torex to ask them about the future availability of the XC9140, but I really don't see any parts out there that are any better for this application.

  • ATTiny44A and more BOM fiddling

    Nick Sayer02/24/2017 at 01:53 0 comments

    I've just had a pile of boards manufactured with QFN ATTiny45s and with the XC9140 boost converter, (they're not yet arrived, though), but also ordered some prototype boards for an ATTiny44A variant.

    After a little bit of hacking about, it works just fine. It takes maybe 10% more power, but that's really a difference between ~18 µA and ~22 µA - not really outside the margin of error anyway.

    The biggest difference is in the calibration code. The feature pin mapping is (as you'd expect) quite different on the 44 versus the 45, so the pin I was using before changed from being OC0A to OC1A. So the calibration code for the Tiny44 has to use Timer 1 instead of Timer 0. That's not really significant, since the calibration code doesn't run from a battery (or even installed in a movement).

    The only changes were in calibrate.c and base.c, and all of it got handled by using the AVR processor type macros, so as long as you set the mmcu directive on the compiler properly, you'll get functional code.

    Meanwhile, I've ordered some XC9142 chips, which appear to be an updated version of the XC9140. They at least appear to be somewhat more plentiful on DigiKey, so they may be the way to go. I'm going to try swapping some of them out on my test boards to see what the impact is on power consumption.

  • More BOM shaving

    Nick Sayer02/15/2017 at 01:34 0 comments

    Hilarity ensues.

    The ATTiny44A QFN variant, it turns out, is cheaper than the ATTiny45. Go figure. Is it volume or something? Who the heck knows?

    I'm going to try a board variant with that to see if it works. It's silly though - I only need two pins, so most of the rest will be NC.

  • Shaving BOM pennies

    Nick Sayer12/19/2016 at 04:04 0 comments

    Huh. Turns out the ATTiny45-20MU is around 30% cheaper than the ATTiny45-20XUR, depending on how many you buy. Even buying them in a tube doesn't save you the kind of scratch that the QFN package does. Even if you were to buy them a reel at a time, the QFN package is 20% cheaper (of course, then you're buying 5 or 6 thousand of them).

    Well, it's all the same to Bob, of course, so I'm going to try a board with the QFN part and see how that works out.

  • For Great Justice

    Nick Sayer12/15/2016 at 04:12 0 comments

    On a whim, I built a board with a 10 µH inductor instead of 4.7 µH, and a 22 µF output filter cap instead of 10 µF. Now the draw with the calibrate sketch is around 24 µA! Ship it!

View all 31 project logs

  • 1
    Step 1

    These instructions are for retrofitting an existing movement with the "retrofit" variant of the Crazy Clock controller board. If you don't have a movement already, then the recommendation is to simply buy a complete movement from the Crazy Clock store. These movements have had their original PCB replaced with a dedicated Crazy Clock controller board, so the result will be more reliable in the long run.

    If you have a clock that already has its own movement, and you don't want to replace it, then you'll need to retrofit that movement with these instructions.

  • 2
    Step 2

    Either obtain a pre-built Crazy Clock board from my Tindie store or assemble your own. There's no particular instructions for building the board itself beyond just the generic steps for surface mount assembly.

  • 3
    Step 3

    If you wish, you can test the board by powering it with a AA battery or other 1.5 volt power source, and connecting a bi-color LED (that is, a red and green LED in a single package connected anode-to-cathode to two common leads) to the CLOCK terminals. If you use a 5 mm through-hole LED, the leads will be spaced properly for the terminal. Don't solder the LED, just insert the leads and bend them apart to make a temporary connection. The LED should blink alternately red and green in the expected pattern for the firmware in the controller.

View all 23 instructions

Enjoy this project?



Paul Andrews wrote 04/10/2018 at 21:41 point

Hmmm. Now I want to put an ESP8285 in my clocks for time synchronization and auto DST adjustment.

  Are you sure? yes | no

Nick Sayer wrote 12/11/2019 at 21:19 point

The problem is that with true Lavet stepper movements, you have no idea where the hands are pointing. With so-called "atomic" clock movements (which are just WWVB receiver clocks), they add sensors so they can tell when the hands are in a particular position, then they just count forward to set or reset the clock.

  Are you sure? yes | no

alpha_ninja wrote 12/07/2015 at 00:40 point

Checked your design files: you seem to be missing gerber files.

  Are you sure? yes | no

alpha_ninja wrote 12/02/2015 at 00:47 point

This is your one-week reminder to upload design documents:

  Are you sure? yes | no

Voja Antonic wrote 09/28/2015 at 19:10 point

Great idea. I like the videos (the ones with action).

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates