Introduction: Laser Cut Gear Clock - With ChronoDot!
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.
- 2 small stepper motors. I used Symbol 21-02485-03 steppers that I bought from electronics goldmine. Unfortunately they no longer sell them. http://www.goldmine-elec-products.com/prodinfo.asp?number=G14197 I will keep looking for another source.
- 1 Arduino (actually, I used a Freeduino - http://store.nkcelectronics.com/freeduino-arduino-diecimila-compatible-board-complete-kit.html)
- 1/8" birch plywood (You can buy this at Michaels or Hobby Lobby) it cuts really nicely.
- Inkscape (http://www.inkscape.org)
- Laser Cutter
- Optional Chronodot from Macetech (http://macetech.com/store/index.php?main_page=product_info&cPath=5&products_id=8&zenid=f63efb4e6b02850ef3da2f48cf86d70e)
Step 2: 1st Prototype
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.
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.
Attachments
Step 4: Cutting the Clock File on the Laser
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
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);
}
Attachments
Step 7: Hook Up a Chronodot.
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);
}
Attachments
Step 8: Conclusion and Thoughts....
Thank for reading and hack on!
Brian.