Analog inputs appear to switch mid operation

I am currently using two photocells to read solar data. These sensors are being fed through two transimpedance amplifiers, and the output is connected to the analog pins (A0 and A1) of an Uno. The outputs fall within the range of 0 to 5V.

What's been bugging me for some time now is after ~10 minutes the reading of first photocell will maintain its current value despite changes in light, and the second cell will begin to read values from the first cell as if the second cell was now connected to the analog pin of the first cell.

Has anyone else seen this apparent "switching of pins" and/or do you know if it's a hardware or software problem? Could it be a power problem (currently powering Uno via USB)?

Cells:
(http://ixapps.ixys.com/Datasheet/20110302-KXOB22-12X1-DATA-SHEET.pdf)

Hi,

Show Us The Code :slight_smile:

Do you have some intentional delay between reading analog values? Try delay(100);

Let us know what you find out...

There is an input capacitor in the ADC that must be charged up by the signal source, which should be low impedance.

After switching inputs, it is a good idea to discard the first reading of the ADC and take the second, or average a number of readings.

OP is using transimpedance amplifiers.
Output impedance of opamps is rather low, so there shouldn't be any A/D switchover problem.
Seems like a connection error.

If you want proper help, post pictures, a diagram with resistor values and voltages, and the code.
Are the opamps able to deliver the 2 * 44.6 (or maybe more) mA that the cells produce.
Use 1.1volt Aref, or 2.56volt Aref if you use a Mega. Default Aref could be bad for voltage measurements.
Leo..

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Are you reading the analog inputs immediately one after the other?
If so you may have a characteristic of the AtoD setup in the controller.

The controller has only one AtoD, when you do an analogRead, the input to the AtoD is switched to that input to read it.
The AtoD has a capacitor on its input which has to charge up to the new input volatge.
If you do this change in consecutive input pin readings the capacitor may not have enough time to charge to the new value, and so will give a value that appears close to the previous pin that was read.

A solution is to repeat the read statement immediately after the first to ensure that the second read will have a valid voltage.
So for example;

val1 = analogRead(A0);// this is first read of val1
val1 = analogRead(A0);// this is second read and a valid val1
val2 = analogRead(A1);//this is first read of A1
val2 = analogRead(A1);//this is second read of A1 and a valid val2

Hope it helps.. Tom.. :slight_smile:

Hi all,

Thanks for the replies. It seems like you guys have homed in on a probable issue, which is one related to the serial reading of the ADC using the internal capacitor. So I tried to solve it using what TomGeorge suggested.

TomGeorge:
A solution is to repeat the read statement immediately after the first to ensure that the second read will have a valid voltage.
So for example;

val1 = analogRead(A0);// this is first read of val1

val1 = analogRead(A0);// this is second read and a valid val1
val2 = analogRead(A1);//this is first read of A1
val2 = analogRead(A1);//this is second read of A1 and a valid val2




Hope it helps.. Tom.. :)

This wasn't able to solve my problem. I think jremington is onto something with the ADC being linked to the signal source through the internal capacitor.

jremington:
There is an input capacitor in the ADC that must be charged up by the signal source, which should be low impedance.

My circuit is attached, where the op-amp used is actually this one. This amp is only capable of supplying 1 mA (max 2.3 mA). I want to say that the input circuitry of the ADC is asking for too much current from the amp circuitry, but what are your thoughts?

The code where I read from the analog sensors is below:

  int outputSensor = A0;
  int bgSensor = A1;

  ...

  while(true){
  
    outputAvgArray[i%N] = analogRead(outputSensor);
    outputAvgArray[i%N] = analogRead(outputSensor);
    delay(10);
    bgAvgArray[i%N] = analogRead(bgSensor);
    bgAvgArray[i%N] = analogRead(bgSensor);
    delay(10);

    ...

  }

solar_amp_circuit_schem.pdf (560 KB)

That's not a transimpedance amplifier.
It's a non inverting amp that tries to measures open cell voltage.
The cell is drawn the wrong way round for this.
Leo..

A transimpedance amplifier measures solar cell current (not voltage), by drawing the same current from the cell as the cell produces, effectively shorting the cell.
The power to do so is measured as a voltage on the output of the opamp.
Leo..

You should have ~10K to GND on each analog input.

.

LarryD:
You should have ~10K to GND on each analog input.

Why?

The o/p impedance of the amp is 0 so 10K would not be needed. ???

.

Hi
OPs circuit.


Tom.... :slight_smile:

Sorry...forgot about circuit symbol conventions for a moment. This is the actual non-inverting amplifier circuit that I built, now that I'm realizing that is not equivalent to a TIA circuit.

solar_amp_circuit_schem.pdf (567 KB)

You do not need an amplifier to measure light levels with a solar cell. The current output by the cell, NOT the voltage, is proportional to the light level.

Just put a suitable resistor across the cell and measure the voltage across both, using the 1.1V internal ADC reference (assuming single junction cells with max ~ 0.6V).

A suitable resistor value would be (open circuit cell voltage)/(short circuit cell current) where the cell voltage and current is measured in full sunlight.

If you want to measure true power of a solar cell, you should measure current at a constant cell voltage of 500mV. That is more complicated than a load resistor or single opamp.
I think current is a better to compare cells than open cell voltage.
So back to the drawing board to design a transimpedance amplifier.
Leo..

Hi,
OPs new diagram

Tom... :slight_smile:

Okay, so back to the drawing board to design a TIA circuit. But regardless of what measurement I'm doing, this doesn't get at the heart of the problem, right? The analog input pins will appear to be switching mid operation regardless of whether I'm measuring current or voltage.

chadwickcasp:
Okay, so back to the drawing board to design a TIA circuit.

But regardless of what measurement I'm doing, this doesn't get at the heart of the problem, right? The analog input pins will appear to be switching mid operation regardless of whether I'm measuring current or voltage.

Cell voltage is useless for comparing cells.
A garden light cell will have the same unloaded voltage as a 6"x6" cell.

We asked for the code, pictures, and a diagram in post#1 and 3.
Leo..

Wawa:
If you want to measure true power of a solar cell, you should measure current at a constant cell voltage of 500mV. That is more complicated than a load resistor or single opamp.
I think current is a better to compare cells than open cell voltage.
So back to the drawing board to design a transimpedance amplifier.
Leo..

Did you read the OP - collecting solar data is about measuring light level using photodiodes, not
getting the most power from a PV cell. Short-circuit current is a good measure of light level in a photodiode,
although reverse bias current is probably even better.

The problem of cross talk is almost certainly nothing to do with switching ADC channels as the opamp
output impedance is very low, and everything about inadequate ground routing (failure to use
star-grounding)

The circuit needs to be changed for a current-to-voltage converter so that the photodiode
current can be directly read. The existing circuit measures open-circuit voltage which is
as much a temperature measurement as it is a light level measurement.

chadwickcasp:
Okay, so back to the drawing board to design a TIA circuit. But regardless of what measurement I'm doing, this doesn't get at the heart of the problem, right? The analog input pins will appear to be switching mid operation regardless of whether I'm measuring current or voltage.

Hi,
Lets take the circuit out of the project.
Replace the input circuit you have and use two potentiometers in place, so you can vary the input voltages manually.


Then let it sit for a while and see if problem re-occurs.
Tom.... :slight_smile: