ANALOG AMP METER CLOCK- An Elegant timepiece marks the hours with needle meters – By Gene Scogin…

Several years ago I had the idea of making an analog clock that used voltmeter-style needle gauges rather than a standard dial. A few weeks ago I finally made one, using an Arduino board and 3 current meters from a local electronics store. I built it up in stages, starting out with a single meter that displayed just seconds, then adding hour and minute meters, adding buttons and programming to make the time settable, and finally building it into a nice box. Here’s how I did it.

### Feeding the Meter

The Arduino board has 6 outputs that can drive analog values using pulse width modulation (PWM). This means they simulate output voltages lying in between binary high and low (0V and 5V) by cycling rapidly between the two for varying time ratios; for example, a 2.5V output would be simulated by being on for exactly half the time. I found that the Arduino’s pulse frequency was fast enough (490Hz) and my meters were slow enough that you could drive them directly from the board’s outputs without the needles vibrating; you don’t need a capacitor to smooth out the signal.

I was only able to find ammeters and not voltmeters, so I needed to put a resistor in series with the meter to limit the current. Ohm’s law states that to get 1mA of current with a voltage of 5V, you need 5,000Ω of resistance. To allow for normal variations in components, I assembled this resistance by putting a 4,750Ω resistor in series with a 0Ω to 500Ω potentiometer. To set the range for each meter, you first zero it with the adjustment screw on the meter itself, then adjust the pot to set its high point.

#### MATERIALS

Arduino microcontroller board I used an Arduino Diecimila I bought at Maker Faire. You can order one from store.makezine.com.

1mA current meters (3) Make sure your board delivers enough current to drive the meter’s needle over its whole range; I originally tried a 50mA meter, but that wasn’t scaled right for the Arduino.

4,750Ω resistors (3)

500Ω potentiometers (3) aka variable resistors

Button switches, momentary SPST (3)

Computer with printer and paper

Nice wooden box and paint

The microcontroller output pin runs through adjustable resistance and then to the seconds meter.

### Making It Tick

Once we have our meter hooked up, we can write a simple C program to make it count 60 seconds over its full range every minute. The analog Write() function takes a value between 0 and 255 and the index of an output pin, and sets the output for the specified pin to a PWM value between 0V and 5V.

To track the seconds, the program runs a continuous loop that calls millis(), a built-in Arduino function that returns the number of milliseconds since the board was last powered up. The value returned is compared with the millis() value from the previous loop, and the difference is added to the running total of seconds, which in turn updates the display.

The breadboard carries 3 identical circuits running in parallel, for the hours, minutes, and seconds meters.

When the seconds wrap around, the code resets the running total to 0 and adds the remainder. The code also handles another special case, when the value returned by millis() itself rolls over, after about every 9 hours of uptime.

I used the Arduino’s pin 11 to drive my newly programmed seconds meter. Then I went on to programming and driving the hours and minutes meters in a similar fashion, using pins 9 and 10. The wiring for each meter is exactly the same: the microcontroller output pin connects to the potentiometer in series with the resistor, which then leads to the meter. All the code for this project, along with wiring diagrams, is available at makezine.com/13/diycircuits_clock.

Original ammeters showed a scale between 0 and 1 milliamps.

### Setting the Time

To make our clock useful, we need a way to set the time after we power it up. To do this I used 3 switches. One cycles the clock through its 4 modes (normal, set, all-low, and all-high — explained later), one increments the hours, and one increments the minutes. To get a proper reading from digital inputs, we need a pull-up resistor between each input pin and +5V. The Arduino’s microprocessor has these conveniently built in, but you need to explicitly activate them by declaring the pin as input with

`pinMode(b1pin,INPUT)`

and then calling

`digitalWrite(pin,HIGH)`

Because the program runs through its main loop many times each second, we assume that a single push of the button will be read multiple times. To handle this, I have a variable for each button that keeps track of its state. Also, when the program first detects that a button’s state has changed, it delays for 20 milliseconds to wait out any signal bounce from the switch.

The mode switch moves the clock between 4 modes: normal, set time, all meters low, and all meters high. Normal mode shows the time, set mode lets you change it, and the all-low and all-high modes set the 3 output pins to 0V and 5V, respectively, for calibrating the meters. The code continues to keep track of the current time in all modes, unless it’s reset. I am considering adding additional modes to the clock, such as alarm, stopwatch, and timer.

### Making the Scales

The scales on the meters as purchased read from 0mA to 1mA, but for the clock to be readable, we need scales that go from 0 to 24 for the hours and 0 to 60 for the minutes and seconds. Doing this ended up being one of the hardest parts of the project.

I started by disassembling one of the meters and scanning the printed panel with the scale. Then I used the measuring tools in the Unix drawing program Xfig (xfig.org) to measure the image’s distances and angles. One complication was that the scale isn’t based on a simple circle arc; it’s compressed vertically so that the ends of the scale lie farther away from the needle’s pivot point than the middle.

To generate the new scales, I wrote a program in Tcl (tcl.tk) that takes a set of distances and angles that describe a scale, calculates its component lines and curves, and outputs an image file in Xfig’s native format. I read this file into Xfig and used it to generate a printable PostScript file.

Fig. A: The seconds meter scale displays 60 with an input of 1 milliamp.

The only problem was that the finest line that Xfig could draw was thicker than I wanted, so I edited the PostScript by hand to make the line thinner before printing it. Once I printed out the new scales, I cut them out and used spray adhesive to stick them on the plates (Figure A).

To help line up the scales on the plates, I printed extra marks where the screw holes were. And so that the original scales would not show through the paper, I put the new scales on the backs of the plates, which were blank (and symmetrical).

### Boxing It Up

This is the type of project that needs a good box, to display the meters and conceal the wires and such. My wife suggested that a nice wooden box would look good on the mantle, and we chose one at a local craft store.

Fig. B: Paper template for cutting holes in the box.

Fig. C: Holes in the box, with some holes sawed out into slots to fit screws.

Fig. D: The meters with their new scales fit into the box.

Mounting the meters meant drilling a wide central hole for the back of the meter itself, surrounded evenly by 4 small holes for the mounting screws. I made a paper template as a guide (Figure B, previous page) and drilled accordingly, but it was hard to get the mounting holes accurate enough, so I used a larger bit and a keyhole saw to clear out enough space for them to fit (Figure C). The meters all fit tightly in the central holes, so I didn’t bother putting nuts and washers on the mounting screws (Figure D).

For the power source, I considered putting batteries in the box, but the Arduino pulls 20mA–30mA, so even with D cells, they would need to be changed about every 5 weeks. Instead I decided to use a wall wart and ran the cord through a hole in the back of the box. The buttons for setting the clock and changing modes I left on the breadboard inside.

Fig. E: Red paint undercoat.

Fig. F: Black paint partially rubbed away along the edges, exposing the red undercoat for an antique effect.

Finally, I wanted the box to be an aged black, to match our furniture. I accomplished this effect by first putting down a coat of red paint and allowing it to dry (Figure E). I then followed it with black and lightly wiped the wet paint off the edges, exposing small amounts of red underneath (Figure F).

The end result is a unique clock and a great conversation starter that can be displayed prominently in my home, and now in yours, too!

Fig. G: Finished amp meter clock with the lid open to show the circuitry.

Fig. H: Clock displaying the analog to a blinking 12:00.

Gene Scogin is a computer programmer who enjoys a variety of hands-on projects.

#### References:

http://store.makezine.com

http://www.makezine.com/13/diycircuits_clock

http://xfig.org

http://tcl.tk

From MAKE 13 – Page 165. To get MAKE, subscribe or purchase single volumes.