# How to use a MUX DEMUX to communicate two circuits?

I'm trying to reduce two circuits with 14 connections to only 3. I was googling for hours and I read a lot about multiplexor and demultiplexor. But as is my first investigation in electronics (I'm a really noob) I can't found a solution to this.
My near aproximation to resolve this problem is the following one (is a concept/analogy, not the real circuit).

Any help or comment will be preciated as any answer! Thanks in advance

As long as you allow ground as an uncounted line, you can do it a bit more simply than Asmyldof suggests. Not only that, you can do it for as many channels as you like.

simulate this circuit – Schematic created using CircuitLab

The counters are synchronous reset, and the carry is active when the counter is at max carry. The polarities of the carry and reset must be the same. 74HC163 is a type IC, except that the carry and reset are of opposite polarities, so an inverter must be used.

There are only 3 signals required: clock, reset and data.

The counter size can be more or less indefinitely extended.

• wow! thanks a lot for your time @WhatRoughBeast. I'll check this right now! Actually I found I could improve my design with 9 wires/connections and ground. Jun 29, 2015 at 1:20
• Now I've time to probe it, I'm wondering about some things so, please sorry for my ignorance. What micros are registers and counters? Thanks in advance for your patience. Jun 29, 2015 at 3:40
• Any, actually, it's just that you have to do it in software. Jun 29, 2015 at 3:49

First about your picture, even though it's a rough draft, I need to point out that you put two 3 to 8 decoders, one used as a 8 to 3 priority encoder (I think), and hooked them up with a single wire on their Z. The idea of the decoder, of course, is having 3 inputs A, B and C, and the binary code will determine which output is enabled. As such the priority encoder turns 8 inputs into 3 wires, A, B and C.

Unfortunately you cannot encode 14 channels into 3 wires.

3 bits allow the numbers:

• 000
• 001
• 010
• 011
• 100
• 101
• 110
• 111

That's 0 through 7 in binary code. That's only 8 options.

If you want to transmit 14 options over 3 or fewer wires you will need to implement a serial communications protocol, or have multiple levels on a single wire, such as 0V, -5V and +5V. With three distinctive states per wire you can encode 3*3*3 = 27 different states on a 3 wire system. There are, to my knowledge, no standard chips that can do that easily for you. (Tri-state is something completely different, before you ask, since your decoders seem to have that, Tri-state just means you can disable the outputs so they don't interfere with other things when you don't want them to).

With 3 wires you can use different serial protocols. If the system has one common ground, you can use the three wires to use any of the following protocols:

• SPI
• I2C / SMBus
• RS232 or RS232-TTL

There are more, but these are the most useable with tutorials from the internet. But you will need intelligence that you program to take your 14 inputs and encode them into a datastream, then on the other side decodes them and makes them into outputs as you desire. Doing that will be a whole big step further than you are at this point.

If there is only 3 wires in total, you need to carry the ground over one, and you will not be able to use SPI. If you go a long distance, I2C is probably not a great option, for reasons better explained if you get to that.

One other option, is to multiplex two encoders over 3 wires, but you'll need a protocol around it with some form of synchronisation, to determine when you send the first 3 bits and when the second 3 bits, and that will again require some pre-programmed intelligence.

• Your answer rocks @Asmyldof, thanks a lot. I can see now that I'm trying to do a very complex procedure. I'll read more about RS232, I think it could be more easy or familiar to understand to me. Thanks a lot! Jun 29, 2015 at 0:16