Electronic – Connect 16 outputs to as few pins as possible on a microcontroller

latchmultiplexeroutput

I would like to control 48 outputs from a microcontroller, with individual access to each of them.

But let's focus on 16 outputs.

My initial solution involved a 1:16 demultiplexer and 16 (actually 8 dual) D-type Flip-Flops (DFFs). 4 pins would be used to set the address on the demux, 1 pin would be connected to the input of the demux and outputs would connected to the "clock" signal of the DFFs. Finally, one pin would be connected to the Data input of each DFF. That means in total 9 chips and 6 pins.

Thanks to a comment here a few days ago, I have now a new solution that involves 2x 8-bit addressable latches and a 1:2 demux i.e. 3 chips. I've looked for a 16-bit addressable latch but couldn't find one.

To control 48 outputs, I essentially triple the circuit, but also in the first case, I have 3 clock pins. So I can set the target address, set my "value" pin, then send a clock edge only to the right target.

Would anyone have a better option? Ideally, keeping direct access to any output. I'm having a look at things like shift registers though.

Anything I²C, SPI or any other bus is out of question.

Speed-wise, 100 Hz is the target (per output).

Best Answer

Well, if you do not want any bus like I²C, SPI

and as little Pins as possible, simple shift registers are what you need. only two Pins needed at best. You just need to figure out which chips are in your voltage range and can be cascaseded.

e.g. Ti still offers a good range:

https://www.ti.com/logic-circuit/flip-flop-latch-register/shift-register/products.html#sort=p848;desc