Problems with using the AREF pin

Hello

I am working on a project where i am measuring multiple currents in a sequence automatically, the 10 bit ADC in the arduino mega does not have the resolution to measure my 360 mA with max 1% tolerance, so i tried lowering the measurement range from 0-5V to 0-1.1V by using the internal reference, my tolerance is much better but still not below 1%, so i tried creating my own external 0.3V and fed it to the AREF and changed the internal range to external.

Now the problem is that even at 0volts my ADC reads 1023, is 0.3V too low to feed the AREF pin or am i misunderstanding something?

Hi,
Welcome to the forum.

Can you post your code please?

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.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

My code and setup is a prototype so its all very messy right now, but this is the part of the code i use to measure between a 0-0.3V range, i'm measuring 2-5mV before a shunt resistor that i use for calculating the current so i need this low of a range to get the resolution i want.

 analogReference(EXTERNAL);
  int avgvalue1 = analogRead(A14);
  avg = (avgvalue1 * 0.3) / 1024.0;

Hi,
try;

 analogReference(EXTERNAL);
  int avgvalue1 = analogRead(A14);
  avg = ((float)avgvalue1 * 0.3) / 1024.0;

I hope you have avg declared as a float?

Tom... :slight_smile:

Yes, avg is declared as a float, it works perfectly with 1.1V aswell. It's once i change the code to EXTERNAL instead of INTERNAL1V1 the problem occurs

Hi,
Have you edited the (float)avgvalue1 in the equation?

Tom... :slight_smile:

  analogReference(EXTERNAL);
  float avgvalue1 = analogRead(A14);
  avg = (avgvalue1 * 0.3) / 1024.0;

Tried this, 0V is still 1023

Do i need to read the AREF pin?

Hi,
If you gnd the A0 pin what do you get for avgvalue1?
Thats is ensure you have 0V on the A0 analog pin?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

If your circuit is at the moment a bit messy, now might be the time to draw a proper schematic and make sure of your connections.

Tom...... :slight_smile:

Heres a picture of the circuit, the 5v to a switch is meant as a digital output from the arduino, so i can switch on the current measurement with software, my output is Source on the FET. Its active low.

I grounded A14 which is the analog pin my output is connected to and with a multimeter i see 0V, but once i start my software i get 1023 from the ADC

Udklip.PNG

Ignocia:
Hello

I am working on a project where i am measuring multiple currents in a sequence automatically, the 10 bit ADC in the arduino mega does not have the resolution to measure my 360 mA with max 1% tolerance, so i tried lowering the measurement range from 0-5V to 0-1.1V by using the internal reference, my tolerance is much better but still not below 1%, so i tried creating my own external 0.3V and fed it to the AREF and changed the internal range to external.

Now the problem is that even at 0volts my ADC reads 1023, is 0.3V too low to feed the AREF pin or am i misunderstanding something?

The ADC will not work with a reference below 1V, according to the datasheet - you certainly wouldn't
expect any more accuracy if it did, its not designed for it. I presume you want accuracy and not just resolution?

You either need a higher resolution external ADC, or an opamp to amplify the signal before sampling it.

Thanks for the reply, that makes sense.

I tried amplifying the signal by 11 times on my simulation (don't have 2 resistors to make an actual 10 times amp), would this increase my accuracy in reality if i just divide by the times i amplified in the code?

Added a picture with the amplifier

Yes that's the thing, an opamp in non-inverting mode. It needs to be one that goes down to the
negative rail on input and output.

Hi,
How many analog levels do you want to measure, 0 to 360mA?
Or do you need to just measure two levels, 0 and 360mA?

Thanks.. Tom... :slight_smile:

The OP says 360mA to a tolerance of 1% or better.

I tried the non-inverting amplifier as you suggested and it works great in my simulation, and i can see it working in my project aswell, i found a LM2903 OP-Amp and used one of the op amps in the circuit, but it won't work. I supply it with 10V and put the negative supply to ground, but i measure nothing on the output or the negative input, the only thing i can measure is the 40mV i feed the non-inverting pin.

to answer Tom's question - i have 4 current measurements, which i take sequentially, i switch between them with FETs controlled by digitalOuts from my arduino which works perfectly fine. I just need to get better accuracy on the voltage i use for calculating current in my software

Any further suggestions? Added a picture of my simulation

amp.PNG

The LM2903 is a comparator, not an opamp, it will not work as an amplifier.