Go Down

#### kiyoshi7

##### Apr 13, 2019, 03:13 am
hi, I'm trying to read voltage with the arduino due, I have two analog pins connected to an op-amp with a known value of about 3 volts. When I have a function called volts() that returns the voltage the analog pin is reading. I'm calling this function and another similar to it with in a for loop that discards the first conversion and gets 10 sample that are later averaged. instead of getting a value of around 3 volts I am getting a value of 2.084117. I then changed the output of the opamp to be around 0.45 volts and read 0.454747 volts which is okay. Can someone tell me why I am getting this difference?

here is the part of the code I am using to read from the analog pins
Code: [Select]
`float resistor = 5;int samples = 10;int VoltMeter = A7;int AmpMeter =  A6;void setup(){ //Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } analogReadResolution(12); analogReference(AR_DEFAULT);}void loop(){ double Volts = 0; double Amps = 0; for (int j=0; j <= samples; j++) { Voltage();//cleans adc Volts += Voltage(); Current(); Amps += Current(); delay(1); } Volts = Volts/samples; Amps = Amps/samples; Serial.print(Volts,6); Serial.print(" "); Serial.println(Amps,12);}double Voltage(){ double x = analogRead(VoltMeter); x = ((x*3.3)/(4095)); return x;}double Current(){ double x = analogRead(AmpMeter); x = ((x*3.3)/(4095)); //x = x/resistor; return x;}`

#### jremington

#1
##### Apr 13, 2019, 03:50 amLast Edit: Apr 13, 2019, 03:51 am by jremington
Post a circuit diagram, with part identifications (not Fritzing).

Let me guess, though, that you are not using a rail-to-rail op amp.

#### kiyoshi7

#2
##### Apr 14, 2019, 05:20 am
Post a circuit diagram, with part identifications (not Fritzing).

Let me guess, though, that you are not using a rail-to-rail op amp.
I fixed a small problem my circuit had and now I'm being ble to read the full range. But I am still having problems with reading small analog signals and. I don't think the op-amp (OPA2180) is the problem, v+ is 5v and it shares a ground with the due. here is the schematic.

I did another test this time with a power supply and a multimeter connected directly to the analog pin A1 and found that any voltage under 10mv is not detected, though I thought that it could detect 0.8mv. for my application i need A6 to be able to read values close to 0v. I'd like to avoid putting an external ADC.

#### jremington

#3
##### Apr 14, 2019, 06:27 amLast Edit: Apr 14, 2019, 06:29 am by jremington
Please post the schematic image properly, following this guide.

The input voltage range of the OPA2180 is supposed to include the negative rail and is given as V- < Vcm < V+ - 1.5V, but performance falls off for input voltages less than V- + 0.5V.

If you want to detect 0.8 mV you will need a negative supply voltage for the op amp.

#4

#### MarkT

#5
##### Apr 14, 2019, 04:30 pm
I fixed a small problem my circuit had and now I'm being ble to read the full range. But I am still having problems with reading small analog signals and. I don't think the op-amp (OPA2180) is the problem, v+ is 5v and it shares a ground with the due. here is the schematic.

I did another test this time with a power supply and a multimeter connected directly to the analog pin A1 and found that any voltage under 10mv is not detected, though I thought that it could detect 0.8mv. for my application i need A6 to be able to read values close to 0v. I'd like to avoid putting an external ADC.
You may have an IR voltage drop across the ground wiring that is causing the ground at the opamp to be
slightly different from the Due's ground.  The Due ADC may not actually go all the way to ground,
check the datasheet carefully - I think its not a straightforward SAR ADC like in the Uno.

I suspect you will need a precision external ADC for your application, then you can use separate analog
ground and have a chance of good analog precision.  Down at the 100's of µV level you'll need to understand
sources of error in analog circuitry, things like input bias currents and offsets will matter.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### kiyoshi7

#6
##### Apr 14, 2019, 07:30 pm
Please post the schematic image properly, following this guide.

The input voltage range of the OPA2180 is supposed to include the negative rail and is given as V- < Vcm < V+ - 1.5V, but performance falls off for input voltages less than V- + 0.5V.

If you want to detect 0.8 mV you will need a negative supply voltage for the op amp.
yes but I removed the opamp to test the adc and for my application the opamp doesn't need to output 0V
for A6 the signal is 0-1.8v while for A7 I only care 1.2 - 3v.

You may have an IR voltage drop across the ground wiring that is causing the ground at the opamp to be
slightly different from the Due's ground.  The Due ADC may not actually go all the way to ground,
check the datasheet carefully - I think its not a straightforward SAR ADC like in the Uno.

I suspect you will need a precision external ADC for your application, then you can use separate analog
ground and have a chance of good analog precision.  Down at the 100's of µV level you'll need to understand
sources of error in analog circuitry, things like input bias currents and offsets will matter.
thanks,I am thinking of using a ad7794 to read this signal. What i found odd is that I applied voltage directly to the analog pin on the due's board, while measuring the voltage with a multimeter, and the due didn't read anything below 10mv.

#### ard_newbie

#7
##### Apr 14, 2019, 08:39 pm

for A6 the signal is 0-1.8v while for A7 I only care 1.2 - 3v.

Read directly from A6 and A7, remove EMI with an RC filter if necessary, make several measures and average for a better accuracy. Between 2 consecutive readings, read an analog pin connected to Gnd via a resistor. Read the errata section of the datasheet, page 1444.

#### kiyoshi7

#8
##### Apr 14, 2019, 09:08 pm
Read directly from A6 and A7, remove EMI with an RC filter if necessary, make several measures and average for a better accuracy. Between 2 consecutive readings, read an analog pin connected to Gnd via a resistor. Read the errata section of the datasheet, page 1444.