Interference between ADC inputs

Hi,

I have an arduino with two analogue inputs in use - 1 and 5 Bot inputs have AC signals, offset around 2.5v

The first is fed from the output of a MCP6S28 programmable gain amp - again with a low output impedance The second is fed from a MC33202 unity gain buffer, to provide a low output impedance input to the Arduino ADC

In my main loop, I sample both inputs consecutively(5 then 1), do some processing, wait 500mS, and repeat.

I have noticed that when the amplitude on input 1 increases, the voltage read on input 5 drops noticeably. However, using a 'scope the input to ADC 5 stays steady as a rock at all times, as does the powe supply rail to the arduino.

Can anyone suggest what might be going on? The signals are both at 50Hz, and I want to sample both inputs as close to concurrently as possible - so ideally don't want to add delays between the two reads.

The Arduino has 1 ADC which is multiplexed over the 6 lines.

A solution often mentioned is to take two samples and ignore the first. As you have a delay of 500 ms this won't be a problem with high level timing. BUt its true the samples are a bit less simultaneous.

Currently I sample pin 5 ( the problematic one), then pin 1 immediately afterwards. At the end of the loop, just before starting my 500mS delay, I read pin 5 again (but don't use it for anything). There does still seem to be some interference between the two, which I have yet to track down!

Can you post your code ?

No problem.

The work is based upon the open energy meter project here:

http://openenergymonitor.org/emon/

Rather than posting the whole code, I have been trying to replicate the problem in the simplest situation possible. Below is posted the most basic code I have that displays the problem - in an attempt to minimize the number of variables:

This function is called from the main loop repeatedly, with a delay of 500mS after each call, as well as a read of the analogue voltage pin (5)

void plot()
{
  maxI=0;
  maxV=0;

  unsigned long start = millis();
  for(int i=0;i<150;i++)
  {
    sampleV = analogRead(5);                 //Read in raw voltage signal
    sampleI = analogRead(1);                 //Read in raw current signal

    if(sampleV > maxV)
      maxV=sampleV;

    if(sampleI > maxI)
      maxI=sampleI;

    Iplot[i]=sampleI;
    Vplot[i]=sampleV;
    Serial.println( maxV);
  }
  unsigned long endTime = millis();
  plotPeriod=endTime-start;
}

When my fridge comes on, though the voltage signal on pin 5 (according to my scope) stay constant, the value read by the ADC drops from a constant 917 to 912 - and this is repeatable. Hmmm…

Do you have decoupling capacitors liberally sprinkled around the system, especially close to the two amplifiers driving the A/D inputs? That could make a difference.

-- The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

tinkered a bit to create some distance in time between the readings.

void plot()
{
  maxI = 0;
  maxV = 0;

  unsigned long start = millis();
  for(int i=0;i<150;i++)
  {
    V = analogRead(5);                 //dummy read
    V = analogRead(5);                 //Read in raw voltage signal
    if ( V > maxV ) maxV = V ;
    Vplot[i] = V;
    Serial.print("maxV: ");
    Serial.println( maxV );

    I = analogRead(1);                 // dummy read
    I = analogRead(1);                 // Read in raw current signal
    if ( I > maxI ) maxI = I ;
    Iplot[i] = I ;
    Serial.print("maxI: ");
    Serial.println( maxI );
  }
  unsigned long endTime = millis();
  plotPeriod=endTime-start;
}

Thanks - I've added 0.9uF capacitors between supply and ground on each of my ICs, as well as a larger capacitor across the supply rails at source.

I've also added the suggested double reads - the drop in voltage reading isn't massive - from it equates to a couple of volts when I have converted the ADC values to voltages - but it is also very repeatable, so whereas I would expect the two readings to be independent, somewhere within my circuit there must be a link of some kind.

Interestingly, the variation in voltage reading (from a wall wart, buffered via an opamp) does not seem to be directly related to the amplitude of the other signal - which is an amplified signal from a current clamp. Turning on a 10kW load you can see from the plot at the link below causes the read voltage to drop by about a volt. Turning off the fridge causes the voltage to rise by twice that - but all the while, as far as I can tell from the scope, the input to the voltage channel isn't actually changing.

http://energy.bbarker.co.uk

dbrb2: Currently I sample pin 5 ( the problematic one), then pin 1 immediately afterwards. At the end of the loop, just before starting my 500mS delay, I read pin 5 again (but don't use it for anything). There does still seem to be some interference between the two, which I have yet to track down!

No, sample pin 5 and ignore, sample pin 5 and record it, then sample pin 1 and ignore, sample pin 1 and record. What happens is that the input multiplexor hasn't had enough time to settle after switching and before the ADC runs. Doing two samples from the same pin in a row is the important thing. Delays don't help because they don't switch the multiplexor.

thanks Mark - actually I am now doing that. I have also added a number of decoupling caps, and have now also run my 2.5v reference - used to create an offset for my AC signals - through a buffer amp to keep it nice and constant. It hasn't really made much difference.

The volt drop is more annoying than problematic, as it is smallish, but I'm still trying to track it down :-)