In practical terms 1,000,000 seems very ambitious to "maintain the required fractional precision" given the lack of precision of the ADC in the first place..
J-M-L:
In practical terms 1,000,000 seems very ambitious to "maintain the required fractional precision" given the lack of precision of the ADC in the first place..
The value of the variable safely remains within 32-bit (10000000x0000 to 10000000x03FF = 0x00000000 to 0x3CF9BDC0). We sometimes employ this trick to display load temperature signal of LM35/DS18B20 on UNO based on 6-digit 7-segment display unit of precision weighing scale of Gold Shop where client wants 4-digit precision. (Edit)
I get this is safe for a uint32_t. that's not my point.
We sometimes employ this trick to display temperature signal of LM35/DS18B20 on UNO based 6-digit 7-segment display unit where client wants 4-digit precision
Geee, I'm speechless... a DS18B20's precision is ± 0,5 ℃ and LM35 has ±0.5°C Ensured Accuracy (at 25°C)
The point is that you do a lot of 32 bit math operations on a 8 bit microprocessor when the sensor data fits on 10 bits.. an error of ±1 in the reading of the ADC gives you almost ±5mV error...
And if you are on an arduino UNO where the 5V reference can vary, your ADC will be very far from giving you 4 digits precision nor stability between two consecutive reads.
So There is no scientific truth in 4 digit precision there... you could (almost) display random numbers after the decimal point...
J-M-L:
Geee, I'm speechless... a DS18B20's precision is ± 0,5 ℃ and LM35 has ±0.5°C Ensured Accuracy (at 25°C)
Sorry, for the blunder mistake; it was actually for precision weighing scale of Gold Shop.
That reminds me of a guy I was at school with in the early 70s, before scientific handheld calcs, whose Dad bought him a fancy calculator that scrolled 20 or so decimal places.
So he typed in 22/7 and scrolled to 20 or whatever decimals, very proud of the fact that he had pi to 20 places.
He was mightily pissed-off when I pointed out that 22/7 was an approximation for pi and was already wrong at 3.142.
(Although still closer than Indiana's attempt at 3.2)
the Joy of PI!
![]()
J-M-L:
So There is no scientific truth in 4 digit precision there... you could (almost) display random numbers after the decimal point...
There is a 3.4736 volt point while going from 3.4V to 3.5V. Now, the query is: Can I build a DVM using ATmega328P of UNO that can register this voltage (4-digit after decimal point)? If not, how much voltage the UNO DVM can register authentically? Is it 3.473 or 3.470 and the remaining digits (if included) are meaningless as they have been produced by the abstract mathematics.
With 5V full scale for the above 10-bit ADC, the error is 1 +/- 1 count (though data sheet says 2 counts) which is: 5000 mV/1023 ~= 5 mV which @J-M-L has already showed. That means that a change of 5 mV quanta at the input of a channel will be seen by the ADC. If the input is 3.4736 volt, the DVM will show 3.470 volt; if the input is 3.4756 volt, the DVM will show 3.475; if the input is 3.4789 volt, the DVM will show 3.475; so on.
The above quote stands solid (+1k).
J-M-L:
In practical terms 1,000,000 seems very ambitious to "maintain the required fractional precision" given the lack of precision of the ADC in the first place..
I am lucky that I have not said 4-digit precision -- the UNO based DVM can at best maintain 3-digit precision with a discrete value of 0 or 5 for the LS-digit.
sayHovis:
He was mightily pissed-off when I pointed out that 22/7 was an approximation for pi [...].
I heard in trigonometry school back in 1968 that pi (
) is the symbolic name for the constant 22/7 which is the measure of the angle (in radian) bounded by the semi-circle over the diameter. I had a long query to know how did they come to this constant.
![]()
Dear Golam Mostafa,
It is nice code and short, thanks.
GolamMostafa:
A brief version of your codes (semi-tested in NANO) which occupies 3280/266 instead of 3804/302 space.float sensorValueFloat[6] = {0};
void setup()
{
Serial.begin(9600);
}
void loop()
{
for(byte i=14, j=0; i<20; i++, j++)//A0 to A5 = 14 to 19
{
sensorValueFloat[j] = (float)analogRead(i)*(5.0/1023.0);
Serial.print("Sensor-"); Serial.print(j); Serial.print(" Value: ");
Serial.print(sensorValueFloat[j], 2);
Serial.println();
}
Serial.print("=========================");
Serial.println();
delay(3000);
}
Dear all,
I want to make
same as attached meter but with high accuracy and for industrial use.
Please find attached pictures of meter.
Regards,
Imran
GolamMostafa:
I am lucky that I have not said 4-digit precision -- the UNO based DVM can at best maintain 3-digit precision with a discrete value of 0 or 5 for the LS-digit.
the challenge with some Arduinos is the 5V is not super stable when powered through USB and thus your ref voltage is approximative too... using the INTERNAL reference should lead to better results
J-M-L:
the challenge with some Arduinos is the 5V is not super stable when powered through USB and thus your ref voltage is approximative too... using the INTERNAL reference should lead to better results
Now, the precision is still 3-digit; however, the LS-digit will be changing by 0, 1, 2, 3, .., 9 (1100/1023 ~= 1 mV); but, it is at the cost of full scale which is now only 1.1V.
What is about external voltage applying at AREF-pin? Can we apply less that 1.1V at this point while invoking the command: analogReference (EXTERNAL)?
GolamMostafa:
Now, the precision is still 3-digit; however, the LS-digit will be changing by 0, 1, 2, 3, .., 9 (1100/1023 ~= 1 mV); but, it is at the cost of full scale which is now only 1.1V.
Yes - this is to address also the instability of the 5V reference that can be significant (although in some arduino the 1.1V internal reference is also super sensitive to temperature, so if you use your arduino outside you might get challenged there).
GolamMostafa:
What is about external voltage applying at AREF-pin? Can we apply less that 1.1V at this point while invoking the command: analogReference (EXTERNAL)?
kind of... but you don't have much to play with. The spec states that
- AVcc absolute min and max are 1.8V and 5.5V.
- the reference Voltage for the ADC needs to be within 1V and AVcc
- the Internal Voltage Reference of the 328P needs to be within 1.0V and 1.2V with a typical value at 1.1V
So I'd say that you could go as low as 1.0V using EXTERNAL but that would be playing with fire... (within the 10% approximation of Internal Voltage Reference). Ideally I don't think you should go under the Internal Voltage Reference.
To be able to obtain good accuracy with the ADC, get a very stable reference and use a decoupling capacitor (typical value for the capacitor is 100nF) between AREF and the GND pin — as close as possible. (that's why you have a GND pin next to the AREF socket on your arduino)
J-M-L:
To be able to obtain good accuracy with the ADC, get a very stable reference and use a decoupling capacitor (typical value for the capacitor is 100nF) between AREF and the GND pin — as close as possible. (that's why you have a GND pin next to the AREF socket on your arduino)
It appears from the schematic of UNO that the 100 nF decoupling capa is there on the UNO board. Do we still need to install another one?


Depends what board you buy ![]()
J-M-L:
Depends what board you buy
So, not all Arduino boards have this built-in filter capa.
By-the-by:
For ATmega32A, they recommend to connect a ferrite (Fig-1) to form LC filter for better stability of the VREF voltage. Why don't we see such recommendation in ATmega328P?

Figure-1:

Figure 24-9. ADC Power Connections of the 328P data sheet,
2018 Microchip Technology Inc. Data Sheet Complete DS40002061A-page 254
shows the same connections.
CrossRoads:
Figure 24-9. ADC Power Connections of the 328P data sheet,
2018 Microchip Technology Inc. Data Sheet Complete DS40002061A-page 254
shows the same connections.
Thank you. I have found it in the 2018 data sheets as you have referred.
Please find the attached pictures I want to make this.
Imranahmed:
Please find the attached pictures I want to make this.
@Imranahmed - there is nothing attached. read how to use the forum.