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:

1 pin
On or Off
Analog Values:
0 or 1

2 pins
Pin1 ON, Pin2 ON
Pin1 ON, Pin2 OFF
Pin1 OFF, Pin2 ON
Pin1 OFF, Pin2 OFF
Analog Values:
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.

3 comments:

Keath said...

Maybe I'm just dim, but the ActiveWire board has what looks like two ports with 20 pins each. How does that result in just 16 pins to work with?

Whatever the answer, I'm eagerly looking forward to seeing dashboard gadget 2.0 in action. Have you given thought to it's container yet?

Iestyn Lewis said...

I refer you to the reference manual. Some of the pins are for input, which I did not use.

Hate to disappoint, but this is merely a writeup on dashboard gadget 1.0, which is already done (in 2005!!). I'm writing it up mostly to remember what I did, since there was some neat stuff involved (but was such a pain that I would not want to do it again).

Keath said...

You did say that in part 1. I should learn to read.

Still - good insight as to what's in the box! And USB goes both ways, huh? That seems like it should have been obvious. Thanks.