Shop OBEX P1 Docs P2 Docs Learn Events
Multiplexers/demultiplexers, what's the big deal? — Parallax Forums

Multiplexers/demultiplexers, what's the big deal?

Velvet LeopardVelvet Leopard Posts: 47
edited 2004-08-31 08:15 in General Discussion
Hewwo, all.· I have heard a bit about multiplexers/demultiplexers and was thinking about learning more about them.· I have heard they can be used to increase I/O capabilities of controllers and switches.· I tried to look through google to find out more, but all I found was sites about networks and security camera setups.· How do multiplexers/demultiplexers work and would they be useful in small apps like a BS2 app?· Is it true that they can increase I/O capabilities?· And if they are major network compnents, then can they be used to create a kind of "hardwired" intelligence?· Thanks for the info.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-14 19:22
    If you're simply looking at increasing IO capbilities, have a look at a couple SHIFT REGISTERS that are very easy to use: 74HC595 (used for expanding outputs) and its compliment, the 74HC165 (used for increasing inputs).· Each normally takes three lines, but the clock can be shared bringing the host (e.g. BASIC Stamp) IO requirement down to five pins.· You can find connections and code examples in StampWorks:

    ···· http://www.parallax.com/detail.asp?product_id=27220


    Also, you might consider downloading our "Elements of Digital Logic" book:

    ···· http://www.parallax.com/detail.asp?product_id=70008

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Dwayne ReidDwayne Reid Posts: 5
    edited 2004-08-14 20:07
    Shift Registers are a good choice. I use both 74hc595 as well as TPIC6595 versions for outputs and 4021 for inputs. But the 74hc165 Jon mentioned works equally well.

    However, you can get the total I/O requirement down to 3 pins very easily - all you need to do is add a single resistor between the input SR's data out pin and the pin used for data on the stamp. In other words, connect all the "clk" pins together and to a pin designated as "clk" on the stamp, then connect all the "latch" and "p/s" pins together and to a pin designated as "latch" on the stamp.

    The data line is a bit harder to describe in words but here goes: You have 2 serial chains: one chain for the input SRs, one chain for the output SRs.

    The input chain consists of one or more parallel to serial shift registers - 75hc165, 4021, whatever. The data IN of the first SR is grounded. The data out of the first SR (often referred to as "Q8") is connected to the data IN of the next SR. And so on.

    The data OUT of the last SR connects to the pin designated as "data" on the stamp via a 4k7 resistor.

    The output chain is similar. The data IN of the first SR connects directly to the pin on the stamp designated as "data" - no resistor needed. The "QS" pin on that SR connects to the data IN pin of the next SR. And so on.

    Changing from sending data to reading data is as simple as changing the "data" pin on the stamp from input to output.

    In practice, its a tiny bit more complicated. First I init the output SRs by sending as many bytes of "0" as needed. This is usually done only once, right at the start of the program. Then pulse the "latch" line high, then low. That loads the data you sent previously into the output SRs *and* simultaneously latches new data into the input SRs.

    Turn the "data" pin into an input and shift in as many bytes of data as you have input shift registers. Now turn the data pin into an output and shift out as many bytes of data as you have output shift registers. Once both of these operations are complete, pulse the "latch" line.

    Most of my controllers do this with 4 bytes of input data and 4 bytes of output data. In other words, I get 32 bits each input and output using only 3 lines to the processor.

    dwayne
  • Mag748Mag748 Posts: 263
    edited 2004-08-31 06:20
    the multiplexer included with the stampworks board can control up to 64 individual LEDs, to display bargraphs, 7-segment displays (8 digits), or a dot matrix led display. all using 2 or 3 pins i think.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • GadgetmanGadgetman Posts: 2,436
    edited 2004-08-31 08:15
    Multiplexers and demultiplexers...

    Fun topic...

    As long as they work...

    Basically, a multiplexer takes several inputs(relatively low-speed), combine them and sends them as a single stream on an output.

    The demultiplexer takes that single stream and separates it into it's original multiple signals.

    One common application was to use it to let several Terminals share one dedicated 9600bps line.
    You could easily have 8 terminals on a 9600 line without the users complaining too much. (We used 'statistical' multiplexers which allocated bandwidth based on traffic, and those allowed us to use up to 16 terminals on a single 9600 line)

    We also ran printers through them, but we made certain that those were set to use 1200bps instead of 9600 as a user would rather have slow prints than a lagging terminal...
    (It was mostly specialty printers for Vehicle registration and drivers licenses, and they don't have much text anyhow, so it wasn't as bad as it sounds)

    The problem with them is keeping them synchronized.

    So...

    Multiplexers/demultiplexers aren't made to give a CPU more IO, but to send data through a 'narrower' channel than would othervise be needed.

    As for expanding IO on the BS2, shift registers works OK, but...
    Linking them together will mean having to clock a whole lot of data through a long chain.
    A 74HC138 though, have 3 inputs which are decoded into 8 outputs and can be used as 'Chip-select' for 8 chips.
Sign In or Register to comment.