Introduction: Laser Cut Gear Clock - With ChronoDot!

About: I am a middle school computer teacher with an EE degree. I do programming to pay for my teaching habit. I am also one of the founders of LVL1 - Louisville's Hackerspace.

This summer, my hackerspace LVL1 (in Louisville, Ky) got an awesome laser cutter http://fslaser.com/40w-deluxe-hobby-laser-engraver-and-cutter.  LVL1 is an awesome community of creative folks that like to build stuff.  You can always check out what we are up to at http://www.lvl1.org.  If you like instructables and making stuff, you should see if there is a hackerspace in your area.  Anyway...

I decided to build a gear clock after seeing something like what I made in a friends office and after playing with the gear renderer in Inkscape.  This instructable hopefully will show you how to make what I made and also teach you a little about the design process involved when working with a laser cutter.

Step 1: Gather Your Materials.

For this instructable I needed...
You will also need a computer to program your Arduino and also for designing in Inkscape.

Step 2: 1st Prototype

For the first prototype, I just wanted to see if I could get the stepper gear thing working at all.  I cut a spur gear for the stepper, a small stand with a hole in it to press fit the stepper motor and a larger gear that would be the clock mechanism.

After assembly and a quick program, I decided that the clock needed to have two gears (and thus two stepper motors) - one for hours and one for minutes.  I also discovered that the numbers needed to always be right side up as the gear traveled around.  Thus, the 6 needed to be upside down in the drawing as well as the 3 and nine needed to face outwards.

Another cool thing I discovered during my first prototype is that the Arduino has enough power to step these motors without having a driver circuit.  This makes the clock considerably easier to make!  Here are a couple of links to tell you about how to hook up the Arduino to the stepper I used...

http://ryanschenk.com/2010/03/driving-a-040-stepper-with-arduino/
http://profmason.com/?p=173

I also began to think about my gears.   In my prototype, I used a 10 tooth gear for the gear connected to the stepper and a 100 tooth gear for the ring.  100 really does not translate well into hours or seconds so what else could I use? 

My stepper gear has 10 teeth and this actually works well because the stepper I am using has 20 steps per revolution.  Thus I can step the stepper 2 times to move exactly 1 tooth.

Therefore, for my minute hand, if I use 60 teeth, then each 2 steps = 1 minute = 1 tooth of movement.

Similarly, my hour hand has 144 teeth because if we divide it by 12, each hour has 12 teeth and therefore each tooth is equal to 5 minutes!  Really, the clock does not have to have a minute ring at all.  The hour ring can tell you what time it is.

Step 3: Using Inkscape to Draw Gears.

Inkscape is a wonderful program!  It can be downloaded for free at www.inkscape.org.  Inkscape is a program that is used for vector drawing.  You can think of vectors as 'drawing lines' as opposed to bitmapped images such as digital photos.  Just like any new program, Inkscape can be difficult at first, but becomes very easy the more you work with it.

Start by opening Inkscape and creating a new document.  I like to use letter landscape as the document size.  That size fits in our laser cutter well.  File->New->Letter_landscape

From there I find it helpful to turn on a grid.  File->Document Properties Grids tab.  Set your grid to what you feel comfortable using, I like to work in inches, but others work in mm's.  It really does not matter.

Now the fun part... To put a gear on your drawing, use Extensions->Render->Gear.  When I did this clock I used a circular pitch of 10 and a pressure angle of 10.  Then I varied the number of teeth to set the gear size.  As long as I used 10 and 10 for circular pitch and pressure angle, the gears fit!  Please go ahead and try it!

Once you have drawn a gear, you will most likely need a center hole.  To get a hole centered on a gear, draw the gear and draw the circle for the hole.  Then select both the circle for the hole and the gear and go to Object->Align and distribute.  Then click the icons that say 'Center on the Horizontal Axis'  and 'Center Horizontally'.

I have attached my file for cutting the gears.  It is called ClockGear3.svg and you can download it below.   The green lines in the file are lines that I use for guides.  I do not cut anything in green.

The stand is the tall trapazoid and the two triangles.  I hot-melt glued the triangles to the back of the stand.


*** UPDATE 2/29/12 ***
If you try to download the inkscape file, it will download as something.tmp.  Just rename it to clock.svg and then you can open it in inkscape.


Step 4: Cutting the Clock File on the Laser

Using the file Gearclock3.svg and LVL1's Lasercutter, I cut the clock out of 1/8" plywood that I purchased at Michaels.  I am sure you could use other materials, and I will probably make an acrylic clock sometime.

To cut the clock on our laser, I printed to the Retina Engrave software that came with our laser.  Retina engrave allows you to control the laser based upon which colors are in your file.  For example, I set the laser to cut completely though the plywood when the color is black and engrave only a little when the color is purple.

To cut 1/8" birch plywood on our 40W laser I use a setting of 30% cut speed and 100% power.  To engrave on our laser, I use a setting of 100% cut speed and 25% power.  The order is what order the laser uses.  I engrave (purple) first, then cut the red and then cut the black.  I set the repeats to 0 for green, because I do not want to cut any green.  It really is not as difficult as it seems.

Step 5: Building the Clock

After you cut all your pieces, you will need to assemble your clock.  Start by hot-melt gluing the small triangles on the back of the stand as in the pics.  Next, take the small gears and press fit them on to the stepper motors.  You may need to ream out the hole a little with an awl or other pointy instrument.  Push the gears on in such a way that the gear bevels in toward the stepper.  When you cut something on a laser, you will notice a very slight bevel on the cut.  If that bevel is pointed in, then the outer ring gears have less of a chance to fall off.

Press the steppers into the stand.

Get some hookup wires that can go between the stepper motor and the Arduino.  It helps to use the same colors, but it is not necessary.   The wires are hooked up as follows:

Hour Stepper:
Yellow - Digital Pin 4
Red - Digital Pin 5
White/black - Digital Pin 6
Blue - Digital Pin 7

Minute Stepper:
Yellow - Digital Pin 8
Red - Digital Pin 9
White/black - Digital Pin 10
Blue - Digital Pin 11

Hook up the Arduino via a usb cable to your computer so it is ready to program.

Step 6: Programming the Arduino

I am not going to go over how to program an Arduino, there are plenty of example online.  I used the motor knob example in the Arduino IDE as the basis for driving the stepper motors.  From there I modified the code to drive the stepper motors. 

When programming a clock, you obviously want your clock to run and not loose time.  My first hack at the code, my clock lost about 15 minutes overnight.  That was not acceptable.  The algorithm for that code was to count to 60 seconds, tick the minute hand, then count to 5 minutes and tick the hour hand.  Not the most elegant of solutions.

So what i did next was to use a date/time library and keep track of the last minute, then I would check the time every 5 seconds or so and if the minute changes then I would tick the clock.  Every 5 minutes, I will tick the hour hand.  I also set the pin13 led to flash every second.  You will have to install the time library to run the pde code.  It is downloaded here http://www.arduino.cc/playground/Code/Time

Code (cut and paste) or download the PDE below:

/*
* gearclock.pde
*
* Brian Wagner
* LVL1 - Louisville's Hackerspace
* www.lvl1.org
* 9/10/11
* 9/18/11 reworked to use time_t
*/

#include <Stepper.h>
#include <Time.h>

#define STEPS 20 // The stepper has 20 steps per revolution
int ledPin = 13; // LED connected to digital pin 13
int LastMinute;
int ThisMinute;

int LastSecond;
int ThisSecond;

//for the 21-02485-03 stepper, the colors in order are yellow, red, black/white, blue

Stepper Hours(STEPS, 4, 5, 6, 7);
Stepper Minutes(STEPS, 8, 9, 10, 11);
int MinuteCount;
time_t t;

void setup()
{
pinMode(ledPin, OUTPUT);

setTime(1,1,1,1,1,1); //set the time to Jan 1, 2001
//It really does not matter what the time is set to,
//we are checking to see if a minute has passed.
t = now();
LastMinute = minute(t);
LastSecond = second(t);

//how fast is it gonna step
Minutes.setSpeed(5);
Hours.setSpeed(5);

//test the minutes and hours to make sur it is going in the correct direction
//Minutes.step(100);
//Hours.step(100);
Minutes.step(4);
Hours.step(4);

MinuteCount = 1;
}

void loop()
{

t = now();
ThisMinute = minute(t);
ThisSecond = second(t);

if ( ThisSecond != LastSecond ) {
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for 500ms
digitalWrite(ledPin, LOW); // set the LED off
LastSecond = ThisSecond;
}


if ( ThisMinute != LastMinute ) {
Minutes.step(2);
MinuteCount++;
LastMinute = ThisMinute;
}

//tick the hour ring every 5 minutes
if (MinuteCount > 5) {
Hours.step(2);
MinuteCount = 1;
}

delay(200);
}

Step 7: Hook Up a Chronodot.

Macetech has a really cool real time clock module for ~$15 that can keep perfect time!  It is called a Chronodot.  Check it out and order it here: http://macetech.com/store/index.php?main_page=product_info&cPath=5&products_id=8&zenid=3395f33814bb6d6d78fe449837b4305b

I found it really easy to program.  I just used the test program at the bottom of the documentation page as a basis. 

To hook up the chronodot, I made a couple of wires to connect to the 5v, gnd, scl and sda pins on the chronodot.  I hooked the power and gnd connectors on the chronodot to the 5V and gnd connectors on the Arduino.  The SDA pin connects to Analog pin 4 and the SCL pin goes to Analog pin 5.  Here is a resource for hooking up the Chronodot: http://www.codingcolor.com/microcontrollers/an-arduino-lcd-clock-using-a-chronodot-rtc/

Then I hacked the chronodot test code into my program and away it went!

Here is the code, or you can download below.

/*
* gearclock_Chronodot.pde
*
* Brian Wagner
* LVL1 - Louisville's Hackerspace
* www.lvl1.org
* 9/10/11
* 9/18/11 reworked to use time_t
* 9/19/11 Added Chronodot
*/

#include <Stepper.h>
#include <Wire.h>

#define STEPS 20 // The stepper has 20 steps per revolution
int ledPin = 13; // LED connected to digital pin 13
int LastMinute;
int ThisMinute;

int LastSecond;
int ThisSecond;

//for the 21-02485-03 stepper, the colors in order are yellow, red, black/white, blue

Stepper Hours(STEPS, 4, 5, 6, 7);
Stepper Minutes(STEPS, 8, 9, 10, 11);
int MinuteCount;

void setup()
{
pinMode(ledPin, OUTPUT);
//Serial.begin(9600);
Wire.begin();
// clear /EOSC bit
// Sometimes necessary to ensure that the clock
// keeps running on just battery power. Once set,
// it shouldn't need to be reset but it's a good
// idea to make sure.
Wire.beginTransmission(0x68); // address DS3231
Wire.send(0x0E); // select register
Wire.send(0b00011100); // write register bitmap, bit 7 is /EOSC
Wire.endTransmission();

LastMinute = 0;
LastSecond = 0;

//how fast is it gonna step
Minutes.setSpeed(5);
Hours.setSpeed(5);

//test the minutes and hours to make sur it is going in the correct direction
//Minutes.step(100);
//Hours.step(100);
Minutes.step(4);
Hours.step(4);

MinuteCount = 1;
}

void loop()
{
int seconds ;
int minutes ;
int hours ;

// send request to receive data starting at register 0
Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
Wire.send(0); // start at register 0
Wire.endTransmission();
Wire.requestFrom(0x68, 3); // request three bytes (seconds, minutes, hours)

while(Wire.available())
{
seconds = Wire.receive(); // get seconds
minutes = Wire.receive(); // get minutes
hours = Wire.receive(); // get hours

seconds = (((seconds & 0b11110000)>>4)*10 + (seconds & 0b00001111)); // convert BCD to decimal
minutes = (((minutes & 0b11110000)>>4)*10 + (minutes & 0b00001111)); // convert BCD to decimal
hours = (((hours & 0b00110000)>>4)*10 + (hours & 0b00001111)); // convert BCD to decimal (assume 24 hour mode)

//Serial.print(hours); Serial.print(":"); Serial.print(minutes); Serial.print(":"); Serial.println(seconds);
}

ThisMinute = minutes;
ThisSecond = seconds;

if ( ThisSecond != LastSecond ) {
digitalWrite(ledPin, HIGH); // set the LED on
delay(200); // wait for 500ms
digitalWrite(ledPin, LOW); // set the LED off
LastSecond = ThisSecond;
}


if ( ThisMinute != LastMinute ) {
Minutes.step(2);
MinuteCount++;
LastMinute = ThisMinute;
}

//tick the hour ring every 5 minutes
if (MinuteCount > 5) {
Hours.step(2);
MinuteCount = 1;
}

delay(200);
}




Step 8: Conclusion and Thoughts....

I may cut another hour ring that has numbers all the way around.  I have also toyed with making the number binary.  With this clock, there are many ways to make it neater.  Also, I wonder whether it is worth having the minute ring at all.  After all, I do not need to know exactly what time it is, close enough is good enough for me.  Please use this instructable as a basis for other clocks.  MASH IT UP! Enjoy and support your local Hackerspace!  If you are ever in Louisville be sure to visit LVL1!

Thank for reading and hack on!
Brian.

Clocks Challenge

First Prize in the
Clocks Challenge

4th Epilog Challenge

Participated in the
4th Epilog Challenge