MCP3208 VS MUX

Is there any advantages using a MCP3208 VS a MUX to get more analog inputs ?
Can you share an example circuit / code how to do this ?

Thanks

(Assuming you are talking about analog mux obviously)
The advantages/disadvantages depends on your application. Still few differences between the two:
For analog mux you would need extra control lines, which would increase delay if you want to switch channels continuously, comparing that with MCP3208, it runs with spi, so if the controller you are using has hardware support for spi then there will be negligible delays changing channels continously.
The default sampling rate for arduino is 9615sps, which can be increased to ~76.9ksps(might work with maximum resolution, but not to rely on 'might') with some extra programming, the sampling rate for MCP3208 can go till 100ksps at 5v with no resolution compromise which is 12bit.
Using the arduino default adcs without a low pass filter(like cap) and external power at aref can result in a lot of noise(like i said again, depends on your application, if you want a coarse value this won't affect you), whereas MCP3208 will be a bit detached from the controller noise.

Also making a conversion take time. Having 2 ADCs enables to make conversion from 2 different sources at the same time. I would say MCP3208 is better than using MUX but on the other side using Pentium is better than Arduino for computation. Yet power/complexity/cost considerations may lead you to use the MUX/Arduino.

Also a small advantage of MUX - since it is bidirectional you can use some of its pins as outputs. But only one at a time and when you are not using it for ADC.

I want to build a midi controller and needs to access all the pots and switches simultaneously , so I can turn any pot or press any switch ...

Using an analog MUX like the CD74HC4051M96 , how do I have access to any switch or pot simultaneously since the MUX can only access 1 pot or switch @ a time like a rotary switch ? ?

Thanks

You cannot have simultaneous acces. But you cannot sample more than one channel with one ADC either.
For digital inputs (switches, buttons) you may use shift register or with some advantages a port expander (to get interrupt when input is changed).

izhmel:
I want to build a midi controller and needs to access all the pots and switches simultaneously , so I can turn any pot or press any switch ...

Using an analog MUX like the CD74HC4051M96 , how do I have access to any switch or pot simultaneously since the MUX can only access 1 pot or switch @ a time like a rotary switch ? ?

Thanks

Well, you do not exactly need to have access to all the pots and switches simultaneously man. What you can do is sample all of them, one at a time and depending on their values decide what you want to do further. Since we all are humans here few ms difference won't be a matter for us when you change the switch or pot.
Let me do some calculations for you:

  1. Whatever functions you need to perform after simultaneous/gradually obtaining the values of the pots/switches will take the same time.
  2. if using mux:
    Default sampling rate from arduino ide-9615 => 1 sample time=1/9615=104us
    Assuming parallel port access to the control of mux, 1 clock cycle(Load Immediate instruction) should be
    taken for changing the input(unless the mux is slower), but lets again assume that it takes 10x more and
    running the uc with default clock at 1mhz, so 10 cycles=> 10/1000000=10us.
    So, for 10 different sampled inputs from mux it should take (104+10)*10=1.14ms.

Now, for taking all your knob values one by one it took 1.14ms(goes down to 230us if used at full speed) instead of 104us(assuming whichever simultaneous adc you find takes the values at same sampling rate) and that 104us doesnt include the time taken to get the data to arduino/atmega.

Does 1.14ms really look a lot? whatever action you perform on it will probably take more time than this to complete :stuck_out_tongue:

What i would say is go for the mux or the adc whichever is cheaper and also that you don't need to go for simultaneous sampling unless every microsecond is important for you(in which case 76ksps will be a slow down in itself).

Since the MUX is only 1 of 8 like a rotary switch , pot 1 set to A0 ,and pot 2 set to A1 , the MUX wiper arm is set to A0 pot1 based on the address setting of the MUX, when you move pot 1 and 2 at the same time , how dose the address of the MUX change back and fort to read the 2 analog voltages from pot 1 and 2 , can you give an example circuit ?

The application I want to use it in is a midi controller

Thanks

izhmel:
Since the MUX is only 1 of 8 like a rotary switch , pot 1 set to A0 ,and pot 2 set to A1 , the MUX wiper arm is set to A0 pot1 based on the address setting of the MUX, when you move pot 1 and 2 at the same time , how dose the address of the MUX change back and fort to read the 2 analog voltages from pot 1 and 2 , can you give an example circuit ?

The application I want to use it in is a midi controller

Thanks

I understand what "MUX" you are talking about now -_-. You are thinking about analog rotary switch, it would be pointless to use that here. I was talking about "Analog Multiplexer" it is controlled digitally, you set the address and chip select or other control pins and that particular input is shown at the output. Google analog multiplexer.