Friday, April 11, 2008
Computer Dashboard, part 4 - D/A Conversion 2
Back to Part 3
Gee, this is getting a little epic. Keath, I'm glad you're enjoying it. Or at least reading it. So. We have a meter to swing, and a number of pins, each of which can output a set voltage. What we need to do is some binary math. For my purposes, I decided that my meters were small enough that setting them to one of 32 values was going to be enough precision. That meant I needed 5 pins to dedicate to a meter, because 2 to the 5th is 32. Got it?
No? Well, binary numbers represent numbers with just 2 values, 0 and 1. Just like in decimal numbers we have the "ones place" and the "tens place" and the "hundreds place", ie, 124 has 1 in the hundreds, 2 in the tens and 4 in the ones, binary numbers have the 1's place, the 2's place, the 4's place, the 8's place, and the 16's place, etc. So, if you are using 5 pins, you can count from 0 to 31, because 16 + 8 + 4 + 2 + 1 = 31. That gives me 32 values, so for instance, the number 10011 is 16 + 2 + 1 = 19. (n-n-n-nineteen).
Got it? Well, go google it or something. The point, is we need some way of making pin 5 "count" more than pin 1. When pin 1 changes, we only want the meter to move by 1 unit. When pin 5 changes, we want the meter to move by 16 units. The way to do this is with a resistor ladder. As shown in the picture, each of the 5 pins will connect to the network from the bottom, and there is one output, to the meter. Pin 1 will be connected furthest from the output (marked LSB on the diagram), so as the voltage from that pin makes its way across all of those resistors, it will be dropped until it contributes very little to the total at the end. Pin 5 will be connected nearest to the output (marked MSB on the diagram), so the voltage from Pin 5 only has 1 resistor in its path to the output, and will thus influence the voltage, or current, at the end, much more. (Resistors drop voltage, by the way).
That's it - that's how simple a digital-analog converter can be - a bunch of resistors. Going the other way - not so easy.