0
\$\begingroup\$

If you have 8 analog input sensors (or 2 or 9 or 738479) is there a chip / is it possible with microprocessor programming to actively monitor all of the channels? Say you had 8 rotary potentiometers attached to each i/o pin on the mux, would you have to change the selection inputs every time you wanted to use a different potentiometer? It seems like this would make a mux much less useful than I thought it was. So if I wanted to use the pot on i/o pin 1 and then the pot on i/o pin 8 immediately following the first, I would have to tell the microcontroller / processor to change to reading pin 8 before I could use the peripheral attached to it? Or is there a way to make it monitor all of the i/o pins at once so that I could use the peripheral on pin 1 then on pin 7 then on pin 2 without having to do anything at all regarding changing the io pin being read, so long as I only use one at a time?

CD74HC4051MM96EP is the mux I already have tons of, and I'm using teensyduino (arduino code library) / teensy 3.1 to send midi messages. I'd like to read all kinds of different input sensors.

\$\endgroup\$
1
  • \$\begingroup\$ How fast do you want to turn the potentiometers? Reading them sequentially should be fine, as long as that *duino software doesn't slow it down too much. \$\endgroup\$ – starblue Dec 10 '13 at 22:12
3
\$\begingroup\$

The idea behind using a multiplexer is that you would read all of the inputs in a sequence very quickly and then loop around and do it again. It's a trade-off of bandwidth and latency vs. port count. It lets you divide the available bandwidth and required port count down by the same factor. If you have an ADC that can sample at 10 KSps and an 8 port mux, then with 1 input you can sample at 10 KSps on that input, with 2 inputs you can sample at 5 KSps on both inputs, with 4 inputs you can sample at 2.5 KSps on each input, etc. One side-effect is that the samples are interleaved in time as you can't look at all of the inputs at exactly the same time. With 2 inputs, there will be an offset of 1 sample period between readings on alternate channels where the first sample from input 1 will occur at 'T=0', the second sample will come from input 2 and will occur at T=100us, the third sample will come from input 1 and will occur at T=200us, etc.

If you're just trying to read from POTs, you should be fine as the signals coming out of them will change very slowly. All you need to do is write a for loop that will cycle through all of the mux settings and read in the corresponding analog value.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the detailed explanation, I had thought about something similar to this but didn't realize that adc's were capable of sampling that fast or the relevant search term to google how fast they're capable of reading signals (which I now know is ksps / sps / msps) \$\endgroup\$ – Rumbleklub Dec 11 '13 at 21:28
2
\$\begingroup\$

Say you had 8 rotary potentiometers attached to each i/o pin on the mux, would you have to change the selection inputs every time you wanted to use a different potentiometer?

Yes, if you want to change which input is connected to the output of a mux, you have to change the inputs to the select signals.

Or is there a way to make it monitor all of the i/o pins at once so that I could use the peripheral on pin 1 then on pin 7 then on pin 2 without having to do anything at all regarding changing the io pin being read, so long as I only use one at a time?

You could use 8 different monitor circuits (ADC inputs?) and no mux at all.

Or you could make a circuit to sum the 8 inputs and monitor the sum signal. That might be helpful if you want to avoid polling to see whether there is any activity at all on your inputs. But if two inputs are active at the same time you would not be able to distinguish which one was active.

You could use a counter to make a continuously incrementing digital bus to be applied to the MUX select pins, avoiding having the uC use instructions to change those signals. But you'd probably want to syncronize your "monitoring" activity with the counter so that you don't accidentally make a measurement while the mux is switching.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ "You could use 8 different monitor circuits (ADC inputs?) and no mux at all." But note that a microprocessor with 8 ADC inputs is actually one ADC with an internal mux to 8 pins. \$\endgroup\$ – markrages Dec 10 '13 at 22:14
  • \$\begingroup\$ @markrages, that's probably true, but 1. We don't even know for sure that the "monitor" circuit is in fact a uC ADC input. and 2. It may require fewer instructions to switch the internal mux than to switch the control pins for the external mux. \$\endgroup\$ – The Photon Dec 10 '13 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.