Tuesday, April 08, 2008
Computer Dashboard, part 3 - D/A Conversion 1
back to Part 2
Meters work by swinging a needle in response to an electrical current. No matter what the scale on the meter says, "Degrees C", "Fuel Level", "Houseguests Offended", the meter only cares about one thing- when you feed it no current, the meter goes to (usually) the left, or Empty, or 0, and when you feed it the maximum amount of current, the meter goes to Full, or 100, or "That's a paddlin'", or whatever. So the meter needs to be fed a variable amount of current, in response to whatever you're measuring.
Now the ActiveWire USB board doesn't have the ability to output a variable amount of current. It has 16 pins, each of which can either output a voltage (5V, I think), or no voltage. So somehow, we need to take a number of those pins, and change various digital combinations of "off" or "on" into analog values, varying between 0 (no current) and 1 (the maximum amount of current).
Such a thing is called a digital-to-analog converter, and it's amazingly simple. This is the same way your CD player or mp3 player works (more or less). What happens is that you assign a number of pins to represent a voltage (which is then converted to current). The more pins you assign, the more precisely you can specify the voltage. Let's say you assign 1 pin:
On or Off
0 or 1
Pin1 ON, Pin2 ON
Pin1 ON, Pin2 OFF
Pin1 OFF, Pin2 ON
Pin1 OFF, Pin2 OFF
0, 0.33, 0.66, 1
The more pins you assign, the more precision you get in the analog signal. CDs use 16 "pins", or bits, and all they do is read 16-bit sequences from the disk, many times a second, and simply send that voltage level, or current, to the speakers, which results in a waveform, which is converted to sound.