Internal 1.1V voltage varying significantly

Hi all,

I'm trying to measure a voltage between 0.4 and 0.7V with the internal voltage reference. The problem is, that when I measure the voltage between the AREF pin and GND, I get 1.03V when no input is given to the analog input, but I get 0.848V when a voltage input is given to the analog input pin. I am using a relay to switch between both situations, and a multimeter between the AREF pin and GND pin.

In this thread it seems to be shown that the internal voltage is stable over time; how can it be that my internal voltage varies?

Also, how can I read the internal voltage directly from the Arduino without the need of a multimeter? I ask this because I am having significant differences between the measurements I'm doing with the multimeter and measurements from Arduino inputs (but this depends on the internal voltage, which is why I'm investigating this parameter...).

I would greatly appreciate some help!!

Cheers

Nongsai:
I am using a relay to switch between both situations...

You are doing what?

@Coding Badly: Sorry, that was probably unclear. I have to situations: one in which 0V is fed into the analog input, and one in which a voltage of around 0.5V is fed to the analog input. I am using a relay to switch between these 2 situations. When I measure the AREF voltage with respect to GND in situation one, I read around 1.03V. When I am feeding a voltage to the analog input, the internal voltage drops. The higher the voltage fed, the lower the internal reference voltage drops. When I feed only a tiny voltage, the reference voltage approaches the full 1.03V again.

I should mention that when I use an external voltage reference of 1.0V and change my sketch accordingly, I get pretty accurate voltage measurements. However, since I need to bring the system into the field, I cannot bring my voltage source with me. For this reason I wanted to use the internal reference voltage.

There are four possibilities...

• There is problem with your circuit. For example, a short-circuit through the processor may cause the problem you describe.

• There is problem with your code. In order for the bandgap voltage to be present on the AREF pin you have to enable the internal reference.

• The processor you are using does not support an external bypass capacitor when using the internal reference.

• The processor you are using is faulty.

You have been here long enough that you can very likely guess the next three steps. (If not, ask.)

Thank you for your reply! I am using an Arduino MEGA ADK.

  • All other sensors work fine, and the measurements are accurate when using an external reference, so I doubt that there is a short-circuit through the processor or that the processor is faulty.

  • I activated the internal reference in the code and am making some dummy readings before starting the actual measurements.

  • I don't know what you mean by the processor not supporting an external capacitor when using the internal reference. I'll look it up.

What do you mean by the next three steps? Thank you!

Nongsai:
What do you mean by the next three steps?

Post your code. Please use
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags.

Post your circuit. Please post a schematic.

Nongsai:

  • I don't know what you mean by the processor not supporting an external capacitor when using the internal reference. I'll look it up.

Most AVR processors have the AREF pin connected to the internal voltage reference when it is enabled to allow an external bypass capacitor to be included in the circuit. That's why the internal voltage reference is present on the AREF pin.

Some AVR processors do not have this feature. I believe the ATtiny85 is an example.

I believe all the ATmega family does have this feature.

Hi, since my post has been moved it deleted my reply and I can't attach the same file again (the diagram) because the server seems to find a copy somewhere. I'll at least rewrite the answer, without the diagram attachment:

The extra components in my diagram (which I hope I can attach soon!) are 2 Arducams, a couple of temperature sensors, an SD shield and 3 buttons. The second circuit with relays is where the current sources (solar cells) are placed, and the problem I was describing is when reading the voltage drop over the shunt resistor, which is called V_AMP in the diagram. This voltage reading is not correct when using the internal voltage reference, because the internal reference changes in function of the input voltage V_AMP which is read by my pin A15.

My code is long and exceeds the allowed characters, so I'll paste the snippet where I take the measurement I'm talking about. I always find it hard to make snippets, but I'll try:

int shunt_input = A15;
float shunt_analogamount_array[10]; //to make 10 fast readings which will be averaged
float shunt_voltageamount_array[10]; //to calculate 10 shunt voltage drops which will be averaged
float shunt_analogamount_sum[4]; //to store the sums of the analogamounts
float shunt_voltage_sum[4]; //to store the sums of the calculated voltage drops
float shunt_voltage_sqDevSum[4]; //to store the sum of the squares of the differences from the mean
float shunt_voltage_stDev[4]; //to store the standard deviation of the series of fast voltage drop measurements
float cell_current_sqDevSum[4]; //to store the sum of the squares of the differences from the mean
float cell_current_stDev[4]; //to store the standard deviation of the series of Isc measurements
float shunt_analogamount[] = {0, 0, 0, 0};
float shunt_voltage[] = {0, 0, 0, 0};
float cell_current[] = {0, 0, 0, 0};
float Rshunt = 0.120; //Calculated from tests (cf excel). resistance must be calibrated/measured
const byte RelayPin[] = {33, 31, 29, 27}; //Cell1 to 33, Cell2 to 31, Cell3 to 29, Cell4 to 27
float AREF_voltage = 1.03; //actual measured internal voltage(measured with DMM)
CellN=4;
SAMPLES=10;

//in setup
for (int thisPin = 0; thisPin < CellN; thisPin++) {   //transistor pins: for the 4 relays
    pinMode(RelayPin[thisPin], OUTPUT);
    digitalWrite(RelayPin[thisPin], LOW); //Set to low, just in case this is not default: we don't want the cells to be shorted now.
  }
  pinMode(shunt_input, INPUT);

//in loop
//thisCell is incremented under certain conditions and tells which relay to close

 //Measure Isc

          digitalWrite(RelayPin[thisCell], HIGH); //Send input to the transistor which shorts the circuit of actual cell
          Serial.print("Circuit Shorted for Isc measurement for pin: ");
          Serial.println(RelayPin[thisCell]);
          delay(20);
          if(thisCell==3)delay(5000); //just to calibrate and have the time to read value
          for (int i = 0; i < SAMPLES; i++) { //make average of 10 fast readings
            if (i == 0) { //set sums to 0 before starting
              shunt_voltage_sum[thisCell] = 0;
            }
            shunt_analogamount_array[i] = analogRead(shunt_input);
            shunt_voltageamount_array[i] = shunt_analogamount_array[i] * AREF_voltage / 1023.0; // in volts
            Serial.print(shunt_voltageamount_array[i]);
            Serial.print(" --- ");
            Serial.println(shunt_analogamount_array[i]);
            shunt_analogamount_sum[thisCell] +=  shunt_analogamount_array[i];
            shunt_voltage_sum[thisCell] +=  shunt_voltageamount_array[i];
            Serial.print("shunt_voltage_sum[thisCell] =");
            Serial.println(shunt_voltage_sum[thisCell]);
            Serial.print("AREF=");
            Serial.println(analogRead(A0));
          };


          shunt_analogamount[thisCell] =  shunt_analogamount_sum[thisCell] / float(SAMPLES); //calculate average analog amount and store in analog amount array
          shunt_voltage[thisCell] = shunt_voltage_sum[thisCell] / float(SAMPLES); //calculate average voltage drop and store in analog amount array
          cell_current[thisCell] = shunt_voltage[thisCell] / Rshunt; //Convert with Ohm Law Isc=Vshunt/Rshunt (Rshunt determined experimentally by comparing input (Isc) and output (Vamp) (slope))


          // Calculate Standard Deviation for voltage drop over shunt (Vamp) and Isc
          // STEP 1, Find the mean. (We Just did)
          // STEP 2, Sum the squares of the differences from the mean
          for (int i = 0; i < SAMPLES; i++) {
            // pow(x, 2) = x^2
            shunt_voltage_sqDevSum[thisCell] += pow((shunt_voltage[thisCell] - shunt_voltageamount_array[i]), 2);
            cell_current_sqDevSum[thisCell] += pow((cell_current[thisCell] - shunt_voltageamount_array[i] / Rshunt), 2);
          }
          // STEP 3, Take the square root of the mean of that
          shunt_voltage_stDev[thisCell] = sqrt(shunt_voltage_sqDevSum[thisCell] / float(SAMPLES));
          cell_current_stDev[thisCell] = sqrt(cell_current_sqDevSum[thisCell] / float(SAMPLES));


          Serial.print("Averaged analogread for shunt: ");
          Serial.print(shunt_analogamount[thisCell]);
          Serial.print("Averaged Vamp=");
          Serial.println(shunt_voltage[thisCell]);
          Serial.print("Standard deviation for Vamp=");
          Serial.println(shunt_voltage_stDev[thisCell]);
          Serial.print("Averaged Isc=");
          Serial.println(cell_current[thisCell]);
          Serial.print("Standard deviation for Isc=");
          Serial.println(cell_current_stDev[thisCell]);
          delay(20);

          digitalWrite(RelayPin[thisCell], LOW);//Close relay[thisCell] again
          Serial.println("Circuit Closed again.");

What readings do you get during the time the relays are switching and bouncing?

Paul

Hi Paul,

As you can see I leave a 20ms delay between switching the relay and taking the measurement. Do you mean I should quit this delay and check which readings I'm getting during the transition?

Nongsai:
Hi Paul,

As you can see I leave a 20ms delay between switching the relay and taking the measurement. Do you mean I should quit this delay and check which readings I'm getting during the transition?

no, I didn't look at your code, only your description of what you were doing and the results you were seeing.

Paul

To any modertor: I'm receiving the following message while trying to post the diagram:

The message has the following error or errors that must be corrected before continuing:
The following attachments were found which you had previously attached to another post but not posted. It is advisable that you do not upload any more attachments until these are removed or that post has been submitted.
Click here to remove these attachments.

Any way to solve this issue? I believe it is because the thread has been moved.

Is Diagram-PhaseII.png the name of the attachment you are trying to upload?

Is this what you are trying to upload...

Nongsai:
I believe it is because the thread has been moved.

It is not.

Hi,

Yes this is the diagram I wanted to upload.

My internal reference is not stable, and this seems weird to me. It shouldn't change depending on the input applied to the A pins. I guess I'll need to use an external reference.