11.04
It turns out it is very easy to add a good old fashioned analog meter to your next digital microcontroller project. Simply, drive the meter with a PWM source with proper buffering and current limiting. This post will discuss the circuit theory, resistor calculations and programming necessary to achieve this end.
By rapidly switching a voltage (a current actually, but let’s not split hairs) to a meter, it is possible to make it read wherever you like on the scale with a given fixed input. This is the very basis of Pulse Width Modulation (PWM), where a microcontroller, or dedicated chipset, can vary the duty cycle of a squarewave from 0 to 100%. PWM is also used for varying the brightness of lamps and LEDs, motor speed control and data transmission.
So, a squarewave that is on 25% of the time will read 25% of full scale, 50% duty cycle reads 50% full scale, and so on. The frequency of the squarewave, inertia of the needle and the impedance of the meter’s coil will smooth out the squarewave causing a nice steady reading with no noticable wiggle. Though it is possible to use too low a frequency squarewave causing the meter to react.
An Aduino Duemilanove was used for this project for it’s ease of programming, prototyping and built in PWM generation functions. The source code is available here. The meter chosen was originally in a Gates BC-1G AM transmitter and was conveniently laying around.
The circuit below was developed because feeding a 5V squarewave directly to a meter would simply slam the pointer against the end, meters are current driven devices and usually need very small amounts, in this case 50uA. The microcontroller pin could directly drive the meter, but I felt a bit of buffering was necessary.
The 1K ohm resistor is simply the base-emitter current limiting resistor, and any convenient value can be used here ~around 1K ohm, it is non critical. The 100K ohm pot was calculated to give current limiting at 5V of 50uA. The 50K ohm resistor is simply 1/2 of the 100K ohm pot to bring the adjustment range of the pot back around mid-range.
For your particular meter, the resistors should be calculated as follows. For the pot, R = V / I and the midranging resistor is simply R / 2. In this particular case 100,000 = 5 / 0.00005. Your meter current requirements can be determined empirically (trial and error), by starting with a large resistance pot and adjusting until you obtain a full scale reading. The meter movement will then be I = V / R, or 50uA = 5 / 100,000 (that’s what was done here).
After calibrating the meter, by zeroing the pointer at PWM = 0, and adjusting the pot for full scale = 100% at PWM = 0xFF (255 decimal), various duty cycles were fed to the meter and it read as expected.
You may have noticed that the meter doesnt quite read exactly 25%, 50% and 75%, this is due to a few things.
- The meter is older than I am.
- 0×40 hex is not exactly 25%, and so on.
- There are some possible interactions between the meter impedance and the default 800 Hz PWM frequency, this bears further study.
- No attempt was made to smooth the PWM waveform with capacitance.
A routine was written and is included in the source code to cycle the meter up and down and the following video was captured.
A Note About “Non-Linear” Meters.
Non-linear scaled meters are the same as all other meters, what you are measuring outputs a non-linear voltage or current (i.e RF power). With the non-linear power meter shown below, a lookup table was generated by trial and error to hit each major division. How to implement this lookup table or what you actually do with this is left as an exercise for the reader.











That Simpson meter may be older than you are but I want to marry it <3 (The geek behind it ain't bad either….)