Introduction: Planetary Gear Clock

(Old) mechanical clockworks are incredibly interesting and pleasing to watch, but are unfortunately almost impossible to build yourself. Mechanical clocks also lack the carelessness of the precise digital technology available today. This Instructable shows you a way to combine the best of both worlds; by driving mechanical clock hands through a planetary gearbox with a stepper motor and an Arduino!


General components:

  • 5mm wood and acrylic sheet
  • M5 bolts (countersunk), washers and nuts
  • PCB standoffs
  • M3 screws for the stepper motor

Electrical components:

  • Stepper driver (i used the L293d)
  • Any type of Arduino
  • Real Time Clock (i used the DS3231)
  • Hall effect sensor (i used the A3144)
  • 5mm Neodium magnet
  • Buttons for user input
  • 10K resistor
  • 100uf 25V capacitor
  • DC jack
  • 5V 2A DC power supply
  • Battery for the RTC (cr2032 in my case)

Mechanical components:

  • Any type of 1.8 degree/step stepper motor with 5mm axle
  • GT2 400mm timing belt
  • GT2 60 tooth 5mm axle pulley
  • GT2 20 tooth 5mm axle pulley
  • 5x16x5 mm bearing (3x)
  • 5x16x5 mm flanged bearing (2x)
  • M5x50 threaded rod

Step 1: Designing and Making the Gears

One of the goals of this project was to have one motor that drives the complete clock, similar to a real mechanical clock where one escape mechanism drives the complete clock. The minute hand however needs to make 12 rotations in the time the hour hand makes 1 rotation. This means a 1:12 reduction gearbox is needed to drive both hands with one motor. I decided to do this with a planetary gearbox, the included video beautifully explains how this type of gearbox works.

The next step for me was to determine the tooth count for the different gears to create a ratio of 1:12. This website was very helpful and contains all the needed formula's. I attached the sun gear to the minute hand and the planet carrier to the hour hand, leaving the ring gear stationary. Let's do a little bit of math!

  • S = number of teeth on the sun gear
  • R = number of teeth on the ring gear
  • P = number of teeth on the planet gear

The gear ratio (i) is determined by:

i = S/R+S

Note that the number of teeth on the planet gear doesn't matter for the gear ratio in this case, however we do need to respect the general constraint:

P = (R - S)/2

After some puzzling i ended up using the following numbers: S = 10; R = 110; P = 50; They seem to be on the edge of what is possible since there is very little clearance between the planet gears, but it works!

You can draw the gears in your favourite CAD program, most of them have special gear plugins. You can also just use the files attached to this Instructable. of course. Note that all gears, although differing in sizes, have the same tooth pitch.

I thought it would be awesome to make these gears from 5mm aluminium and contacted a local shop with a waterjet if they could cut these gears for me. Normally you would never make gears with water cutters, but these are very low performance gears. Surprisingly they agreed to try, but this plan failed horribly. The parts were simply to small for the waterjet and started to move around while it was cutting.

This setback meant it was time for plan B, so i bought some 5mm smoke black acrylic and found a place with a laser cutter, which had no problem cutting my gears. If you do not have a laser cutter available you can probably also use a 3D-printer for these gears, i included the STL files (the ring gear might need to be split into 3 parts).

After cutting i press fitted bearings into the planet gears. To get the fit right i made a test piece of acrylic with several holes which each had a slightly larger diameter (0.05 mm steps). After finding the setting with the correct fit i changed the hole size in the planet gears to this setting. This is something that differs with material and type of machine so you should always do this yourself.

Step 2: Assembly of the Gear System

To assemble the gears, the frame of the clock is needed. Now this is the part where you can let your creativity go wild since the shape of the frame is relatively unimportant as long as all the bolt holes are in the right place. I Chose to make a lot of holes in the dial plate and back plate to emphasize the gear mechanism. This is also the reason the planet carriers and minute hand are kind of see-through, but it also just looks cool!

I once again used the laser cutter to make these parts, and since the acrylic parts were 5mm thick i also made the wooden parts 5mm thick. All holes in the dial plate and planet carrier were countersunk to accommodate matching bolts.

The central axle of the clock runs in two bearings inside the planet carriers. Since i made this axle from 5mm bar stock it has a really tight fit inside the bearings and i was not able to disassemble these components anymore. It would be a lot easier to just use a piece of M5 thread since you also would not have to cut your own thread anymore (if only i realized beforehand.....). To stop the sun gear from rotating around the axle it has a D-shaped hole, so the axle also needs to be filed into this D-shape. When the sun gear fits around the axle you can assemble the axle, don't forget the planet carriers if you use flanged bearings! Check out the exploded view for assembly instructions.

When the central axis is mounted, its time for the planet gears. These also need the small washers, just like the central axle, to make sure the gears run smoothly. Once everything is mounted to the planet carriers, check if the planet gears and sun gear run smoothly.

The central part can now be mounted into the clock frame. This is a tedious job, but sticking the bolts through the front plate and taping them in place helps a lot. It can also be useful to raise the front plate to create room for the minute hand. The photos show that i placed six small pieces of paper between the gear ring and back plate to give a little bit of clearance for the gears. When inserting the planet carrier make sure the dials are pointing at a sensible location (if jour minute hand points at 12, the hour hand should not be in-between two hours of example)

Step 3: Connecting the Stepper and Sensor

Now that we have a gear mechanism that drives the hands correctly, we still need to drive the gear mechanism correctly. Various types of electric motors could be used, I chose a stepper motor since it can make precise movements without constant angular feedback sensors. A stepper motor can also make a real "Click" sound, which is great for the semi-mechanical clock!

A regular stepper motor can make 200 steps per revolution, which translates to 200 steps per hour if we connect it to the minute hand. This would mean an interval of 18 seconds per step, which does not yet sound like a ticking clock. Therefore i used an 1:3 transmission between the stepper motor and the minute hands so the stepper motor needs to make 600 steps per hour. Using the half step mode this can be increased to 1200 steps per hour, which equals one step per 3 seconds. Sounds better!

One problem with stepper motors it that you never know where they are when you power up your Arduino. This is why all 3D printers have end-stops, so you can move your printer to a known position and then continue from that point. This is also needed for the clock, only an end stop will not work since a clock should make continuous rotations. To realize this position sensing i used an A3144 Hall-effect sensor that senses a magnet (check the polarity! ....) attached to the planet carrier. This is used to move the hands to a specific position on start-up, after which they can move to the needed time.

Assembly is very simple; Attach the stepper motor to the back plate, leaving the screws slightly loose. Then you can mount the small pulley on the stepper motor axle and check if the timing belt runs straight. Now you can slide the stepper motor to adjust the tension on the timing belt. The timing belt needs a tiny bit of play to make sure you are not putting any stress on the gears. Play around with this setting until you are satisfied, then tighten the screws of the stepper motor completely.

The hall-effect sensor is glued in place. Its best to solder three wires to the sensor first, making sure to put heat shrink around each leg of the sensor so they cannot short each other out. After soldering the sensor can be glued into place. It does not really matter which side is up, as long as you have not attached the magnet yet. After you have glued the sensor in place, connect it to an Arduino or a small LED circuit to test if its working. (NOTE: the hall effect sensor only works if the magnetic field lines go in the correct direction). Using this test circuit, verify how the magnet should be glued. Once you are absolutely sure which side of your magnet should face the sensor, glue the magnet in place.

Step 4: The Electronics That Make the Clock Tick

You could use a very simple Arduino code which makes a half step with the motor and then takes a 3000 millisecond delay until the next step. This would work but it's not very precise since the internal Arduino clock is not ultra accurate. Secondly the Arduino would forget the time every time it loses power.

To keep track of the time its therefore best to use a real-time clock. These things are specially designed chips with a back-up battery that accurately keep track of the time. For this project i chose the DS3231 RTC which can communicate with an Arduino via i2c, making wiring easy. Once you set the time correctly on his chip it will never forget what time it is (as long as the cr2032 battery has some juice left). Check out this website for all the details about this module.

Driving the stepper motor is done with an L293d motor driver. Some more advanced stepper motor drivers use a PWM signal for micro-stepping and current limitation. This PWM signal can make the annoying peep noise every maker is familiar with(especially if you own a 3D printer). Since this clock is supposed to become part of your interior, nasty noises are not desired. Therefore i decided to use the low-tech l293d motor driver to make sure my clock is silent (besides the stepping every 3 sec, but that's actually enjoyable!). Check out this website for a detailed description of the l293d chip. Note that i run my stepper motor at 5V which lowers the power consumption and temperature of the stepper motor.

As mentioned earlier, i use an Hall-effect sensor to detect a magnet glued to the planet carrier. The operation principle of the sensor is very simple, it changes state when a magnet is close enough. This way your Arduino can detect a digital high or low and therefore detect if a magnet is close. Check out this website which shows how to connect the sensor and shows the simple code used for magnet detection.

Last but not least, I added 4 buttons for user input to the PCB. They use the Arduino internal pull-up resistors to simplify the wiring. My PCB also has headers in an Uno configuration so i could add Arduino shields for possible expansions (i have not done this so far).

I first tested everything on my breadboard and then I designed and ordered a custom PCB for this project, since it looks awesome! You could also mount the PCB on the back of your clock if you don't want to look at it.

The Gerber files for the PCB can be downloaded from my drive, Instructables does not let me upload them for some reason. Use this link to my google drive.

Step 5: Programming the Arduino

The basic code for the Arduino is actually very simple. I attached a scheme that visualises what happens inside the Arduino and how the Arduino interfaces with the other devices. I used several library’s to simplify the coding.

  • Accelstepper -> handles the stepping sequence of the stepper motor, lets you give intuitive commands like: Stepper.runSpeed(), or Stepper.move() which let you move at a certain speed or to a certain position respectively.
  • Wire -> this is needed for i2c communication, even when using the RTClib
  • RTClib -> handles the communication between Arduino and RTC, lets you give intuitive commands like which returns the current time.
  • OneButton -> Handles the button input, detects presses and then runs a pre-specified void to do something. Can detect single, double or long presses.

When writing code for a clock it is very important to avoid having variables that keep on increasing. Since the Arduino code will be running 24/7 these variables will quickly get bigger and bigger and will eventually cause an overflow. The stepper motor for example is never commanded to go to a certain position, since this position would only increase over time. Instead the stepper motor is commanded to move a certain number of steps in a certain direction. This way there is no position variable that increases over time.

The first time you connect the RTC you need to set the time of the chip, there is a piece of code you can uncomment that sets the RTC time equal to you computer time (the time at the moment you compile the code). Note that when you leave this uncommented the RTC time will be reset to the time at which you compiled your code every time. So uncomment this, run it once and then comment it again.

I attached my code to this Instructable, i commented it thoroughly. You could upload it without any changes or check it out and see what you think!

Step 6: Enjoy the Sound of Your Clock Ticking for the First Time!

After connecting all electronics and uploading the code, this is the result!

The basic design of this clock is very simple and it could be made in many different shapes and sizes. Since there is an Arduino on board you can also easily add extra features. Setting an alarm, have the clock turn on you coffee machine at a set time, internet connectivity, cool demo modes that highlight the mechanical movement to show of your design to others and much more!

As you might have noticed throughout this Instructable, i had to take my clock apart for the sake of writing this Instructable. Although unfortunate for this Instructable i can at least guarantee the design performs very well in the long term, since this clock has been ticking away for more than 3 years in my living room without any problems!

Please let me know in the comments if you liked this Instructable, its the first time i write one. Also if you have any tips or questions, just send me a message. And hope i inspired someone to also build a semi-mechanical clock one day!

Clocks Contest

First Prize in the
Clocks Contest