Project BlogsCorsair
12345
Rated: 100% (2 votes)
Loading ... Loading ...

Simple Analogue Meter Control

plingboot

Posted in retro cool on April 15, 2008 at 6:45 pm

Originally intended for the Neverending Slug project as a retro way to show network stats. I thought it might look nice on my desktop PC too, so here’s a quick write up on how I rigged up a couple of old analogue meters to my PC.

Quick update - changed the links to some slightly improved software.

There’s a Custom PC guide somewhere on how to connect a meter to a hard drive activity LED. It connects easily enough with a resistor but is only ever going to flick the needle between two positions. What I want is to be able to control the needle to point to pretty much any place on the scale.

There are guides around the web that show you how to do this properly. They use pulse width modulation (PWM), PIC micro controllers and various other gubbins connected up to some kind of custom USB - Yikes! Maplin make it a bit easier, they sell a USB interface card which even offers some PWM output but this still requires some electronics & programming know how - and presumably knowing what the hell this PWM is all about too. All a bit too complicated then not to mention expensive.

I thought I’d try and avoid all the snazzy electronics and keep it simple by using plain audio-out to drive the meter. After all, those old style vu meters do just this don’t they? All I’ll need to do then is write some software to make a noise and then increase / decrease the volume of noise to move the meter’s needle around. Sounds simple enough, right?

 

1. Adding an additional audio device

Okay, just a couple of problems. First, the Slug (that’s my original target machine) doesn’t even have audio out and… Second, if you’re connecting this up to a desktop machine you probably want to keep your audio out for other stuff, you know, like being listened to. A silent home server could probably get away with it but with these other cases an extra audio device is needed.


Tada! The World’s worst cheapest sound card

 

I found a tiny USB sound ‘card’ for 4 quid on ebay. It works a treat with the Slug and shows up as an additional sound device on my desktop machine in both Linux and XP.

 

2. Connecting the Meter
Wiring up audio out to an old meter isn’t as straight forward as some might think. After some bamboozling research into things like bridge rectifiers & op amps and making various circuits - and then realising that this thing didn’t have to be all that accurate really and ditching it - I tried this simple little circuit.

Parts List

a diode (1N914)
a resistor (value ??)
a capacitor (electrolyte capacitor 10µF ?)
some wire
an audio out jack
a dusty old analog meter
an unused audio source

Which, when connected together looks a bit like this…

Not a lot to see there is there? In fact there’s so little, it can be built into the jack!

and on the other end of the wire…

…a dirty old voltmeter. Connected with a resistor of your choice on the positive line.

A quick test then, playing a constant tone and then manually increasing and decreasing the volume. The meter should max at 100% volume, be somewhere in the middle at 50% volume and er, 0 at silence. The component values affect the result and depend on the meter, so lots of trial and error picking out the values that worked - that is unless you know clever eletro-maths. I just guessed until it kinda worked.

 

3. The Software

With the new audio card’s volume controlling the meter, the next step is to get it all to work automatically. My plan was to use this to show network down speed on the little Linux home server and CPU load on my mighty Windows desktop PC.

 

Windows

The main problem here is targeting the additional audio device. Luckily the DirectSound API lets you do this. I wrote a quick and dirty VB.Net app to play a sound and alter its volume depending on the value of the CPU load. Check out my little app here, source included. It’s a bit rough and ready, and it would be nice for future versions to minimse to the sys tray, but it will do for now.


VB app alters USB audio volume based on CPU load

Linux

Targeting specific sound cards here is much easier. After setting up XMMS to use the new sound device in the prefs. A quick test :

xmms tone://440hz

plays the constant tone. Or, A wav of the tone can be generated and then something like mplayer used to play that :

mplayer -ao alsa:device=hw=1.0 440hz.wav -loop 0

the ‘-ao alsa:device=hw=1.0′ here uses the 2nd audio card to as output.

To change the volume I used the alsamixer :

amixer -c1 set PCM,0 50%,50%

Here it’s the ‘-c1′ that targets the new card. I wrote a little C program to grab the network download speed from /proc/net/dev and then call amixer with a vol value. Here’s the C code. I then threw this along with the mplayer line into a BASH script and ran it. Eventually this will be made to start on boot.

A quick demo of it in action displaying the network download speed : http://uk.youtube.com/watch?v=FOLht3QFwPw

 

4. Final Touch

All that’s left to do then is to break open the meter and replace that scale with something more appropriate… for my desktop I’m going with CPU Load…

Next, I decided to add a second meter. There might be a nice way of doing this using the left and right audio channels to control two separate meters - the code to do this is trivial, but unfortunately my useless (vintage CDT, C pass) electronics skillz failed me. A quick rewire didn’t work, with each channel influencing the other - rubbish. I gave up and I cheated, using another el cheapo USB audio card instead.


Just begging to be mounted in an empty drive bay

Now where to mount these? Oh yeah. Connecting the audio device to an internal USB socket I bunged these in an empty drive bay.

For my Slug server I’m looking at something a little more retro and interesting. The case has still yet to be found but something along the lines of that bleak cold war look would be nice with the meter shown at the top of the page. I might get round to finishing it one day.


 

7 Comments

You pwn!!! This has got to be the coolest project I’ve seen here so far.

Comment by conholster - April 15, 2008 @ 9:19 pm

 

Cool project. sorry - that should be ‘another cool project’

Very neat soldering, im impressed by how you got the rectifier into the jack plug. Bit of a coincidence realy - i just covered half/full wave rectifires in my electronics lesson today - come back and read about it here…

keep up the good modding :)

Comment by gryphon - April 16, 2008 @ 9:27 pm

 

Thanks! :) Not sure why I put it in the plug to be honest, bit unnecessary as everything could’ve been mounted on the meter’s end much easier but I thought it looked pretty neat.

Still experimenting with all this rectifier stuff, would be nice to drive two meters from a single stereo output. Must be possible somehow.

Comment by plingboot - April 16, 2008 @ 11:32 pm

 

don’t have visual basic. is this possible without the vbnet? how about connecting thru serial and usng lcd smarty??

Comment by gatesy - April 17, 2008 @ 7:45 am

 

gatesy, since mplayer is cross platform you could probably use that in windows with the directsound driver to send the tone to the additional card : mplayer -ao dsound:device=1 (maybe) but then you’ll still have to script the rest, you could turn on windows logging and then manually parse the generated text file but not sure how you’d alter volume or what scripting you’d use, but it might be doable.

as for using serial to drive the meter… here’s a site that shows how to do what you want : http://www.diylife.com/2008/02/02/show-pc-stats-on-analog-gauges/ - as you an see it gets complicated! The point of this mod was to bodge it a bit and try and do it really simply. Still, it might be possible to write an lcdsmarty plugin for my mod

Comment by plingboot - April 17, 2008 @ 8:06 am

 

gatesy, just remembered. VB express is a free download http://www.microsoft.com/express/vb/default.aspx

I compiled mine with visual studio 2003 (with the directx sdk) but should work with VB express 2008 I should think.

Comment by plingboot - April 17, 2008 @ 8:30 am

 

Hey plingboot, that’s a very nice analogue meter. Do you fancy doing a guide on making one for the mag? Drop me a line at ben@custompc.co.uk and hopefully we can work something out!

Comment by Ben Hardwidge - May 6, 2008 @ 12:10 pm

 

Make a comment
  • * required
  • * required

Click to manage your blog

Advertisement
Most commented posts
Highest Rated Blog Posts