Accuracy analog input. 9v batt

Hello!

In my project I have an arduino uno and a pressure sensor with a from 4 - 20 mah , I read the voltage drop throught a 200 ohm resistor (high pressicion). I wont the accuracy to be max 2-3%+- off.

What accuracy can i expect from arduino' when running with 9v power source and defult analogreferens()?

If the accuracy it to bad im thinking to use a lm4040 4,1 voltage referens shunt on AREF ! is that a good idea?
Link: Precise voltage measurement with an Arduino microcontroller

a pressure sensor with a from 4 - 20 mah

What does that mean?

AWOL:

a pressure sensor with a from 4 - 20 mah

What does that mean?

I suspect he means an industrial analog 4-20 ma current loop pressure transmitter.

http://www.bapihvac.com/content/uploads/2010/07/Understanding-4-20-mA-Current_Loops.pdf

No, that would be "4 - 20 mA"

I suspect he doesn't know the difference and meant 4-20 mA because what he said doesn't mAke sense.

The sensor range is from 4-20 mA (thanks for noticing :)) throught a 200 Ohm resistor.

What I'm wondering is how accurate the values that I am reading from 'analogRerefence()' actually are if i have a power supply that is 9 Volts

Thanks. Rock ´n roll

sebb898:
The sensor range is from 4-20 mA (thanks for noticing :)) throught a 200 Ohm resistor.

What I'm wondering is how accurate the values that I am reading from 'analogRerefence()' actually are if i have a power supply that is 9 Volts

Thanks. Rock ´n roll

Your 9 volt has no bearing on the matter of accuracy. It supplies power to the on-board +5vdc voltage regulator that powers the 328p chip and is also the voltage reference used by the ADC. Accuracy will be that stated in the AVR ATMEGA328P datasheet which most likely will meet your requirement of <2-3%..

Just be sure you wire a common ground wire between a arduino ground pin and the negative side of the loop power supply.

I presume you know that E = I *R = 0.02A * 200 ohms = 4V.
If we are to assume that your reference to a power source of 9V means you have a 9V battery (PP3) connected to Vin or the external dc voltage barrel jack, then I don't see how reading a 800mV to 4V analog value from a sensor would be a problem.
If you are not happy with the 8-bit resolution of the arduino ADC then why don't spend $15 for a 16-bit ADC ?
[ ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier [STEMMA QT / Qwiic] : ID 1085 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits ](http:// ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier [STEMMA QT / Qwiic] : ID 1085 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits)

If you do, don't forget to change this :

  // Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use thi for the 12-bit version */

to this :

Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
//  Adafruit_ADS1015 ads;     /* Use thi for the 12-bit version */

You also get programable gain with the ADS1115

   ads1015.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV (default)

// ads1015.setGain(GAIN_ONE);     // 1x gain   +/- 4.096V  1 bit = 2mV
// ads1015.setGain(GAIN_TWO);     // 2x gain   +/- 2.048V  1 bit = 1mV
// ads1015.setGain(GAIN_FOUR);    // 4x gain   +/- 1.024V  1 bit = 0.5mV
// ads1015.setGain(GAIN_EIGHT);   // 8x gain   +/- 0.512V  1 bit = 0.25mV
// ads1015.setGain(GAIN_SIXTEEN); // 16x gain  +/- 0.256V  1 bit = 0.125mV

If you are not happy with the 8-bit resolution of the arduino ADC then why don't spend $15 for a 16-bit ADC ?

You of course meant to say 10-bit resolution. :wink:

of course . (thanks for catching that)

accuracy will be good.
the 9 volt battery is controlled to 5 volt.
so the reference will be fine.

resolution is in theory 0.64 of 1023 so simple 600 points.
this is better as 0.2 % resolution

now you can calibrate your sensor, note the 2 values and make a graph or use map to get corrected values.
as the pressure sensor has an accuracy of about 2% the arduino is better and will only add another 0.5% to it. thus result is 2.5% which is for not commercial use fine.

Thanks for the info..

So the default reference voltage is good enought for an accuracy of -+ 2%?

I have read that the reference voltage (vcc) is unstable and needs some tuning to get it right. For example using a lm4040 (reference voltage diode) or using the 1.1 voltage reference to messure the vcc to get the analogread value right ( 0-5 Volt ).

Is this only the case when using unstable power supply such as usb port??

Links:

Using a lm4040 reference diode to make better accuracy;
http://hacking.majenko.co.uk/making-accurate-adc-readings-on-arduino

Using the 1.1voltage to make better accuracy:
http://hacking.majenko.co.uk/making-accurate-adc-readings-on-arduino

Edit:
Thanks for all the help. You guys are fkn awesome//

So its no idea to run the AREF with a voltage reference diode such as the lm 4040 when running on 9 volt power supply?

It doesnt work that well.

I connected a 9v battery to the power jack in the arduino and the analog readings is not accurate to the voltage.

If i have a 20 mA signal thats messeure 5 volts over the resistor 250ohm i dont get maximum value that is 1023 from the Arduino.
When i messure between the gnd and 5v pin on the arduino i have 5.17 volt.

What can i do to make the reading more accurate

sebb898:
It doesnt work that well.

I connected a 9v battery to the power jack in the arduino and the analog readings is not accurate to the voltage.

If i have a 20 mA signal thats messeure 5 volts over the resistor 250ohm i dont get maximum value that is 1023 from the Arduino.
When i messure between the gnd and 5v pin on the arduino i have 5.17 volt.

What can i do to make the reading more accurate

If you know that the on-board +5 vdc voltage regulator has an output voltage of 5.17, then use that value with the mapping function to get a correct analog voltage scaling. Best to use millivolt scaling to get better resolution.

int value = map(analogRead(A0), 0, 1023, 0, 5170); //results in millivolts

If it always is 5.17 it should work.

I just got an idea.

Example:
I use my lm4040 shunt diode on pin 1 and always have 4.1 volt there.
If i know the voltage on that pin i can calculate the k value of Y=kx+m (m=0) since the the 0-1023 value is linear and correct the value on the reading pin.

If i should use this diode i need to calculate ohm for a resistor page 25 for further information http://www.cl.cam.ac.uk/teaching/1213/P31/docs/lm4040.pdf

The problem is that i want to know the resistance on a input pin becouse i need to know the current (iL) throught the pin.

Look at this datasheet page 25 for further information http://www.cl.cam.ac.uk/teaching/1213/P31/docs/lm4040.pdf

EDIT:

I just assumed that i did not have any current throught the analog pin (iL) and then calculated the resistor to 26-500ohm. I messured the current trought the lm4040 and it was around 2 mA. The lm 4040 accept current between 60 um and 15 mA so its al good.

If you are going to discuss accuracy, it is not sufficient to simply state you setup is inaccurate. You need to present your data.
If you want to discuss your accuracy , post a list that shows voltages measured and readings acquired for at least 10 readings and post the voltage measure at 20mA. That means you need to post the exact resistance of the resistor as you measured it The voltage readings across the resistor are not accurate to calculate the current without an acurate measurement of the resistor.
If Vcc = 5V then 1 count = 5/1023= 4.8875mA. If however Vcc = 5.17V then 1 count = 5.17/1023=5.05375mA.
5/5.17=0.96711798839458413926499032882012
5V measured on a system running with a Vcc of 5.17V = 989 counts , NOT 1023.
The voltage per count is a function of Vcc. If Vcc = 4.5V , then each count = 4.39882mA.
Do the math.
If you already know your Vcc is NOT 5.00 V , why do think your measurement would be 1023 for 5V ? (which it couldn't be BTW).
There is no problem with running a system with a Vcc of 5.17 V. The problem comes when you expect it to behave the same as a system running a Vcc of 5.00 V. Your code for converting the analog counts to voltage has to be calibrated to the Vcc you are using. You need to change your code to use 5.05375 mV per count when running with a Vcc of 5.17. Then 5.00 V will read 989 counts , which is correct, not wrong. You can only read 1023 counts if you are measuring 5.17V if you are running with a Vcc of 5.17V.

What i mean is that i dont know for sure that the vcc always is 5,17V so i need a reference that i can rely on.

I need to know how many counts 5 volt is because of my 1-5V signal without having to know the vcc.

now i have a analog pin on the arduino thats always 4,1 volt with 1% accuracy from that pin i can calculate the k value of a straight line so i know how many count 5 volt is.

I have a precision resistor that i have done several test with a lab bench and a good multimeter.

From, the ATMega datasheet:

24.1 Features
• 10-bit Resolution
• 0.5 LSB Integral Non-linearity
• ± 2 LSB Absolute Accuracy
• 13 - 260?s Conversion Time
• Up to 76.9kSPS (Up to 15kSPS at Maximum Resolution)...

That's just the for ADC, it doesn't include any inaccuracy in the reference.

I have a precision resistor that i have done several test with a lab bench and a good multimeter.

Good! Any good instrument needs to be calibrated against a known-good reference. Typically, you calibrate the slope (AKA gain) and the offset (usually at zero).

With an ADC or DAC the "end points" (i.e. zero and 5V) can be "difficult" and often there is more error than intermediate measurements.

Where I work, we have some 0-10V DACs that are calibrated/corrected at 100 points (every 0.1V) in software.

In addition to constant gain & offset errors which can be calibrated-out, there is usually non-linearlty which can be corrected for to some extent as we are doing with our 100-point calibration, and short-term noise and long-term drift which cannot be calibrated-out.