Last March I was bored and decided to build a clock using analog meters. My idea was to use three analog meters with scales that went from 1-12, 0-59, and 0-59 and indicated hours, minutes, and seconds respectively. Although it’d look analog I planned to use a microcontroller to do the heavy lifting.
I wanted to use antique meters and go for a steampunk look. After cruising Ebay for a while I realized that antique meters are collectible and that they cost collectible prices. Who the fuck collects antique meters? I didn’t really feel like spending $100 on a meter I wanted and since it was unlikely I’d find them in the scales I needed, I went to plan B: buy regular meters and make them look antique.
The first step of the project was to write some software to put on the microcontroller. I had a PIC 16F84 lying around (who doesn’t?) so I decided to build my clock using it.
In order to control the output to the meters I used pulse width modulation (PWM). Since the microcontroller is digital, it can’t easily output analog amperages (meters measure amperage not voltage even if their faces say “Volts”) so if it takes 1mA to put the needle at full swing (and 0mA to put the needle at its lowest setting) I can get arbitrary points between no- and full-swing by changing the amount of time the microcontroller is outputting 1mA. For example, if the microcontroller is outputting 1mA half the time and 0mA half the time the needle should stay at around the center of the dial. If this switching is done quickly the needle should hold still and not vibrate.
[Update 20081111: As the drier winter weather started the clock started to reset and stop ticking about once a day. A little examination of the schematic reveals that I forgot to connect the /MCLR pin on the PIC to a pull-up resistor. The /MCLR pin should be connected to VDD via a 1K resistor]
Since I needed 60 discrete positions to put the needle for the minutes and seconds I needed to pulse width modulate the meters at some multiple of 60 (so to show 39 minutes I’d need to output an “on” to the meter for 39 cycles and then “off” for 21 cycles and then repeat).
I originally figured using a 60Hz duty cycle would be fast enough. I wrote my software using carefully timed assembly language so that exactly 60 pulses happened every second which, with my original clock crystal selection of 4MHz meant that each pulse of my duty cycle had to happen exactly every 16666 2/3rd instructions.
This was a giant pain in the ass. Because 60 didn’t divide one million evenly (a PIC executes an instruction on every fourth clock tick so 4Mhz = 1 million instructions per second) I had to put all sorts of complicated compensatory code into my subroutines. To make matters worse, once I built a prototype circuit on my breadboard I found that my meter needles vibrated. A 60Hz duty cycle was too slow.
After several iterations I eventually settled on running a 10MHz crystal and using a 600Hz duty cycle. Also, to make the timing less complicated I switched to using Bresenham’s Line Algorithm. This algorithm is normally used to draw lines on computer screens, but it can be applied to timing applications as well. The idea of using this algorithm is that the duty cycles don’t have to be be exactly timed and if they’re off by a microsecond here and there it doesn’t matter as long as the timing averages out correctly over time. Although any particular event might not be exactly correct there is zero culmulative error and over time everything works out correctly.
The circuit I designed had four buttons and three potentiometers: one button to force all the needles to the max setting, one button to advance the hours, one button to advance the minutes, and one button to reset the seconds. The three potentiometers were for fine tuning where the “max” setting for each needle falls.
Meanwhile, I was checking Ebay for something steampunk-ish to put my clock into. Eventually I got the idea of using an antique radio. Not exactly steampunk, but the idea of an anachronistic “clock radio” seemed pretty funny to me. I settled on a home made 1920’s radio.
The meters I had chosen still needed to be made to look antique and to have their scales altered so their units went from 1 - 12, 0-59, and 0-59. I carefully took each of the meters apart, scanned their faces into my computer and edited them using The Gimp (a freeware equivalent to Photoshop). When I was happy with the look, I laser printed them and soaked them in tea to make them look aged. I carefully cut each new meter face out and glued it over the old one and put everything back together. They looked awesome.
Finally I had to mount my meters in the radio. The front of the radio was made out of Bakelite which is super fucking brittle. I cracked the face of the radio several times trying to cut holes in it. Each time I cracked it, I had to super glue the cracks back together.
Finally everything was complete.
The clock radio now sits on a shelf in my living room and actually keeps very accurate time.







#1 - June 15, 2008 at 11:13 pm
You are a big nerd.
I love you.
#2 - June 16, 2008 at 05:18 am
Maybe you have too much time on your hands…
#3 - June 17, 2008 at 06:06 am
wow…. can i have one.
#4 - June 20, 2008 at 09:05 am
That’s pretty cool.
#5 - June 23, 2008 at 04:09 am
[...] Read more about making an Analog Chronometer [...]
#6 - June 23, 2008 at 04:45 am
I wonder if you would make the code available so that I can play about and do something similar for my self - my level of ability isn’t up to yours !!
#7 - June 23, 2008 at 11:41 am
I’d love to get a copy of the code as well if you would be willing to share. This is something I’ve looked at doing but haven’t gotten much with my progress on PIC work.
#8 - June 23, 2008 at 03:31 pm
This is one of my planned projects, thanks for the tips… Got a bunch of older meters from local University surplus store (MSU) had to take the things apart that they were in but typically $10 got 1 to 2 meters. Thank you and geeks are gods.
#9 - June 24, 2008 at 07:00 am
Looks good - Who would suspect an old radio as a clock?
One trick to get around the “divisible by 60″ problem is to use a special crystal. You would need something that is a multiple of
(60 x 60 x 12 x 4)
That’s seconds x minutes x hours x PIC outputs per clock cycle.
You might find the crystal from a digital watch will have a useable frequency and falls within the band that the PIC can use as a clock.
#10 - June 24, 2008 at 09:00 am
TK_M: I was building with the parts I had on hand. As far as I know there are no fast crystals that are multiples of 60 that are also within the specs of a PIC 16F84. Besides, solving a software problem with hardware seems like cheating to me.
By using Bresenham’s algorithm it made it extremely simple to put any crystal and into the clock and by changing a couple of constants everything worked. As an added bonus, I didn’t have to code in assembly because the instruction count of the timing function isn’t so important.
#11 - July 3, 2008 at 07:47 pm
That’s why I’m an engineer
For me, it would be so much easier to fudge the electronics - I’m not as good at coding as you!
To me it would be look up the spec sheet for the PIC and do the maths for the ideal frequency and then try and get the closest I can, perhaps even multiplying or dividing as necessary. Finally, you can use a frequency meter and a small variable (”trimmer”) capacitor to change the frequency of the clock crystal just enough to get it to work with a bit of luck.
When all you have a hammer, all problems begin to look like nails…!
I agree with it feeling like cheating though to use hardware to fix a software issue. The problem is that I see it done so often (and vice-versa of course), that I don’t question it anymore. I should really, as even at best it is a Kludge of course!
#12 - July 24, 2008 at 07:31 pm
[...] over to Chrass Landing to see what Chris was up to. Geeky Projects, [...]
#13 - June 23, 2009 at 12:07 pm
I always look for frequency meters at local sales to use on home generators to protect 60 cycle appliances. We have a lot of outages. Your meters, I thought, would “count” pulses so to speak. As I looked at your meters, I realized that yours are marked milliampres etc. To me amps are linear of sorts instead of measurable in pulses. Have I been passing on useable volt/amp meters that I could have put to use?
#14 - July 29, 2009 at 01:21 am
Brilliant, Anachronistic Clock, A great project for a dull rainy day.
PWM for the meters, I would never have thought of that.
Can you send me the hex file ?
regards Dave
#15 - November 1, 2009 at 06:29 am
This is such a sweet project, something I’d love to build and put up on the mantle piece. Is there any chance I could get the code or hex file?
Thanks
#16 - January 11, 2010 at 12:56 am
Nice looking clock. As few people are interested into building it including myself, it would be cool if you publish the hex, or at least wright you are not in the mood to share it. I don`t see much of a point publishing schematic without a code. Thank you.