Tuesday, April 15, 2008

Computer Dashboard, part 6 - Multiplexing



back to Part 5

I bought 4 meters and 4 LEDs and a box and came up with a layout. I figured that would be a good number of things to measure. Problem was, I didn't have enough pins on the I/O board. Each meter would need 5 pins dedicated to it, and each LED would need one, for a total of 24 pins. I only had 16 pins.

I thought about this for a while with no good ideas, and then, as is it so often does, a model railroading site came to the rescue. It seems to be dead now, but here's a cached copy. They had the same problem of wanting to control a bunch of stuff from a parallel port, with not enough pins, so they designed a parallel port expander using a gizmo called an octal latch.

An octal latch is kind of like a very small memory chip. It's called octal because it can store up to 8 bits of data. The way it works is, you signal the chip and say, "hey, I've got some data for you - here's 8 bits." The latch takes those 8 bits and outputs those 8 bits until you come back with some more data for it, at which point it forgets the previous 8 bits and starts outputting the new 8 bits.

So how does this help? Well, if we give each meter one of these latches, then we can run from latch to latch, setting values for each meter. In effect, we can use the same 5 pins on the I/O board to set each meter - we just activate one of the latches, send our 5 bits, the 5 bits get converted to a current, the meter displays that current. The 5 bits are held for that meter until we come back around to that meter and give it a new value.

Because we can cycle around many times a second, all of the meters appear to be moving simultaneously and independently, when in fact they are being set separately, one right after another. So now we can use 13 pins to set all of our meters and LEDs:

1 - activate latch 1
2 - activate latch 2
3 - activate latch 3
4 - activate latch 4
5 - 9 - 5 bits of meter output
10 - 13 - 4 LED outputs

Whew. Well, that covers all the "hardware" stuff. The latches, R/C networks and resistor networks were all placed on one breadboard, with a LOT of soldering. Because I hated to waste 3 bits on each latch, I decided to add a red and a yellow LED inside each meter to indicate some condition (medium value or high value), and piggybacked those onto each latch - so I actually ended up using 7 bits for each meter, 5 for the value and 2 for the LEDs. I put the LEDs inside the meter cases, and they glow from behind the meter scale.

No comments: