This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using a MUX with nRF51822 ADC

Hi,

I am trying to use a mux change among 3 differential channels. The diff signal then goes through an instrumentation amplifier. The steps I'm using:

switch to ch1, read adc1, wait 3ms switch to ch2, read adc1, wait 3ms switch to ch3, read adc1, wait 3ms

            // channel 1
            mux_a0 = 0;
            mux_a1 = 0;
            resultHolder1 = adc1.read_u16();   
            readValue2[1] = (resultHolder1 >> 8) & 0xFF; // writing top 8 bits
            readValue2[0] = resultHolder1 & 0xFF; // writing bottom 8 bits 
            wait_ms(3);
            
            // channel 2
            mux_a0 = 1;
            mux_a1 = 0;
            resultHolder2 = adc1.read_u16(); 
            readValue3[1] = (resultHolder2 >> 8) & 0xFF; // writing top 8 bits
            readValue3[0] = resultHolder2 & 0xFF; // writing bottom 8 bits 
            wait_ms(3);
            
            // channel 3
            resultHolder =  adc3.read_u16();
            readValue4[1] = (resultHolder >> 8) & 0xFF; // writing top 8 bits
            readValue4[0] = resultHolder & 0xFF; // writing bottom 8 bits 

            // channel 5               
            mux_a0 = 0;
            mux_a1 = 1;
            resultHolder3 = adc1.read_u16();
            readValue5[1] = (resultHolder3 >> 8) & 0xFF; // writing top 8 bits
            readValue5[0] = resultHolder3 & 0xFF; // writing bottom 8 bits 
            wait_ms(3);

Now the problems I'm facing,

  1. All channels are showing the same value
  2. If I connect anything in the last channel all channels shows only that value.
  3. If I connect ch1 and ch2, all channels add up the values.
  4. If nothing is connected the adc seems to charge up by itself.

I checked whether the mux is working or not. So, if I use only one channel and don't switch channels the readings seem to be fine. Here's the relevant portion of the circuit:

image description

Am I missing something simple? Any help will be much appreciated.

Thanks, Yasser

Related