Thank you very much for your video and your code. After searching and trying for hours to get something working with my OLED Voltmeter code yours worked right away and now I can see the voltage of my LiPo battery.
At 11:00 you explain how to measure ARef. ARef varies with VCC. Here are my measurements for ARef taken for a range of VCC values on an Arduino Nano (ATMega 328P). I bypassed the regulator putting VCC straight to the VCC pin; VCC ARef 6.0 1.030 5.5 1.043 5.0 1.054 4.5 1.067 4.0 1.073 3.5 1.081 3.0 1.085 This represents a 5.1% variation. I want to use a battery, but get the maximum use from a single charge so bypass the regulator to avoid regulator drop-out. I deduce that we should use the ARef when VCC is in the mid-range of what is to be measured. In my case I am putting an unregulated 18650 cell directly to VCC. The 18650 range is 4.0 to 3.0 V so I'm taking the mid-range value of ARef at 3.5V of 1.081 for maximum accuracy at the mid-point of the 18650 discharge curve. If I want end state accuracy I would use the value at 3.0V of 1.085. Comments?
@@bob-ny6kn Bob, I can barely remember what I was doing at the time 4 years ago 💁♂️ I do not know why there was an inverse relationship ... but those were the values I recorded at the time, presume the same now if you want to try it?
I have notice for slide (5:24). External AREF pin not go down to 0V. Datasheet says (for each chip may be different) bottom/minimal value, but not 0V. eg.m328 1.0V-AVcc, ATtiny44A 2.0V-AVcc ranges
your question is very good. unfortunately, it does not have a simple answer (I've been struggling with it for years). this topic on the arduino forum illustrates what I mean: forum.arduino.cc/index.php?topic=303189.0
hi, i want find out my arduino internal reference voltage. i did the same you said. i put my DMM GND to Arduino GND and DMM PLUS to ARDUINO AREF. and ran the code but nothing happened. i mean it was still zero.
That should work, make sure you have the internal reference selected and then just loop in your code ADC measurements and the internal reference voltage will be at the AREF pin. Another way to calculate it would be to use a known VCC value (measure it) divided down with a voltage divider. Then measure that known value with the internal reference. Any error in the measurement will be due to your internal reference not being exactly 1.1V and you can derive a correction factor from that.
Thank you for good illustration. I have a 50Hz sine wave and I want to sample it at 120Hz using Arduino Uno but l found that it's slow: I try only at sampling frequncy fs=50Hz. How l can increase the speed of ADC? I am looking forward to hearing from you. Thanks
You have to use the 328p datasheet to reduce the measurement time of ADC by setting the proper registers. These settings are done behind scene by Arduino
The internal reference for the ADC is suppose to be 1.1V, but it is not perfect so the datasheet says it can be off plus or minus 10%. If you assume that it is 1.1V and it is actually 1.07 than all your ADC measurements will be off 30mV. If you measure the internal reference from the AREF pin to find out its actual value you can use that as a calibration factor in your code to have more accurate ADC measurements
Sorry for responding to such an old video but I have a question that I can't seem to find the answer to on the Arduino Forum or Stack Exchange, I think I already know the answer but maybe you can confirm what I'm thinking. I have one analog input that is 1.8V max and it's certainly easy enough to use a resistor voltage divider scheme to scale that down to just under 1.1V max (or just under whatever the voltage reference actually is). The problem is that I have three other analog inputs with voltages ranging from 0 to 4.6V, when I activate the internal 1.1V reference, it seemed to effect all of the analog inputs. Is there a way to use the internal 1.1V reference for just one analog input, then use the default reference for the other three analog inputs? It would be great if I could use the internal 1.1V reference for just one analog input because that specific input needs to be as accurate as possible. I'm guessing that the best way to handle this is to use an external voltage reference at the AREF pin at the 328P-AU chip, I could remove the 0.1uf SMD CAP and attach the external reference voltage to the pad where the CAP was removed. I'm think about using the TL431 Adjustable Shunt Voltage Reference Device for that purpose. I read on the Arduino website that I can use an external reference at the AREF pin with a 5k resistor in series so I could switch between the internal and external references. Unfortunately There were no code examples to demonstrate how to switch between the two. I realize that using an external reference requires that I call for the external reference in the code to prevent a dead short internally but I'm not sure how to switch between them or even for sure if what I read is what I am after. Great videos!! All are very helpful!! Thank you!! Joe
Most microcontrollers, including the ones used by Arduino, only have one internal ADC. They may have multiple ADC inputs but a multiplexing switch feeds those multiple ADC inputs to the single internal ADC therefore you can only use one voltage reference at a time. I would consult the microcontrollers datasheet for things to watch out for when switching voltage references during operation
@@ForceTronics I checked the datasheet for the 328P-AU and it indicates that I can switch between references but one small mistake in code for the reference portion could easily render the chip useless due to an internal short. So, I plan to use the TL431 Adjustable Shunt Reference at the AREF pin (then of course make sure the external reference is called in the sketch), I will buy a different version of the INA250 current sense/amplifier that will output a higher voltage per amp, basically, I can just increase the max output from 1.8V (500mV per amp output) to 7V (2 volts per amp output), then use a resistor voltage divider to scale that down to about 4.5V for the max input at the analog pin I'm using. Keep it as simple as possible, right? :-) For those not familiar with the INA250 series current sense/amplifier device, it has the current sense resistors, output buffers and an op amp style amplifier all built into one chip, they are designed to have extremely low output errors. The resistors are about 6 milliohms each but there are three of them for a total of 2 milliohms since they are in parallel (and Kelvin connected) and since the resistance is so small, that very small device can handle up to 15 amps of current flowing through as long as the PCB traces are done right (usually best done with dedicated polygons for separate copper pours). Thank you so much for your quick response! All the best and I hope you have a great day!! Joe
Thank you very much for your video and your code. After searching and trying for hours to get something working with my OLED Voltmeter code yours worked right away and now I can see the voltage of my LiPo battery.
You are the man! This video helped me so much to understand the internal reference voltage.
Awesome! Been looking for some way to measure the Li-Ion Battery status on the MKR1000... looks like this technique is the way forward. Many thanks.
Nice stuff!
This is what i wanted. Thank you
At 11:00 you explain how to measure ARef. ARef varies with VCC. Here are my measurements for ARef taken for a range of VCC values on an Arduino Nano (ATMega 328P). I bypassed the regulator putting VCC straight to the VCC pin;
VCC ARef
6.0 1.030
5.5 1.043
5.0 1.054
4.5 1.067
4.0 1.073
3.5 1.081
3.0 1.085
This represents a 5.1% variation.
I want to use a battery, but get the maximum use from a single charge so bypass the regulator to avoid regulator drop-out.
I deduce that we should use the ARef when VCC is in the mid-range of what is to be measured. In my case I am putting an unregulated 18650 cell directly to VCC. The 18650 range is 4.0 to 3.0 V so I'm taking the mid-range value of ARef at 3.5V of 1.081 for maximum accuracy at the mid-point of the 18650 discharge curve. If I want end state accuracy I would use the value at 3.0V of 1.085.
Comments?
Why does Aref decrease as Vcc increases?
@@bob-ny6kn Bob, I can barely remember what I was doing at the time 4 years ago 💁♂️
I do not know why there was an inverse relationship ... but those were the values I recorded at the time, presume the same now if you want to try it?
Working perfect!!!
This was something I was really looking for...
Thank you so much!!
Divide by 1024 (steps), not 1023 (largest number).
I have notice for slide (5:24). External AREF pin not go down to 0V. Datasheet says (for each chip may be different) bottom/minimal value, but not 0V. eg.m328 1.0V-AVcc, ATtiny44A 2.0V-AVcc ranges
Really thank you so much for sharing
Voltage = (iRef/result)*1024 ;
Is that equation right for calculating adc voltage?
Is it not this:
Voltage = (iref/1023)*result;
???
your question is very good. unfortunately, it does not have a simple answer (I've been struggling with it for years). this topic on the arduino forum illustrates what I mean:
forum.arduino.cc/index.php?topic=303189.0
Thank you for the video, it helps me alot!
At 1:45 you say 10 bit is "10 to the 2", I think you meant to say "2 to the 10th power".
+Charles Marsh Thanks for pointing out that error, I will add a note.
This is great Video!! thank you so much for the wonderful explanation!!! :)
Very good tutorial!! :)
Thank you!
This is realy helpful.
At 11:00 can I use any analog pins for this (for reading the analog value in the loop)?
hi, i want find out my arduino internal reference voltage. i did the same you said. i put my DMM GND to Arduino GND and DMM PLUS to ARDUINO AREF. and ran the code but nothing happened. i mean it was still zero.
That should work, make sure you have the internal reference selected and then just loop in your code ADC measurements and the internal reference voltage will be at the AREF pin. Another way to calculate it would be to use a known VCC value (measure it) divided down with a voltage divider. Then measure that known value with the internal reference. Any error in the measurement will be due to your internal reference not being exactly 1.1V and you can derive a correction factor from that.
Thank you for good illustration.
I have a 50Hz sine wave and I want to sample it at 120Hz using Arduino Uno but l found that it's slow: I try only at sampling frequncy fs=50Hz. How l can increase the speed of ADC?
I am looking forward to hearing from you.
Thanks
You have to use the 328p datasheet to reduce the measurement time of ADC by setting the proper registers. These settings are done behind scene by Arduino
What is the 1.08 internal reference cal factor? And where do I get mine? :)
The internal reference for the ADC is suppose to be 1.1V, but it is not perfect so the datasheet says it can be off plus or minus 10%. If you assume that it is 1.1V and it is actually 1.07 than all your ADC measurements will be off 30mV. If you measure the internal reference from the AREF pin to find out its actual value you can use that as a calibration factor in your code to have more accurate ADC measurements
arduino raw
Sorry for responding to such an old video but I have a question that I can't seem to find the answer to on the Arduino Forum or Stack Exchange, I think I already know the answer but maybe you can confirm what I'm thinking.
I have one analog input that is 1.8V max and it's certainly easy enough to use a resistor voltage divider scheme to scale that down to just under 1.1V max (or just under whatever the voltage reference actually is).
The problem is that I have three other analog inputs with voltages ranging from 0 to 4.6V, when I activate the internal 1.1V reference, it seemed to effect all of the analog inputs.
Is there a way to use the internal 1.1V reference for just one analog input, then use the default reference for the other three analog inputs?
It would be great if I could use the internal 1.1V reference for just one analog input because that specific input needs to be as accurate as possible.
I'm guessing that the best way to handle this is to use an external voltage reference at the AREF pin at the 328P-AU chip, I could remove the 0.1uf SMD CAP and attach the external reference voltage to the pad where the CAP was removed.
I'm think about using the TL431 Adjustable Shunt Voltage Reference Device for that purpose.
I read on the Arduino website that I can use an external reference at the AREF pin with a 5k resistor in series so I could switch between the internal and external references. Unfortunately There were no code examples to demonstrate how to switch between the two. I realize that using an external reference requires that I call for the external reference in the code to prevent a dead short internally but I'm not sure how to switch between them or even for sure if what I read is what I am after.
Great videos!! All are very helpful!!
Thank you!!
Joe
Most microcontrollers, including the ones used by Arduino, only have one internal ADC. They may have multiple ADC inputs but a multiplexing switch feeds those multiple ADC inputs to the single internal ADC therefore you can only use one voltage reference at a time. I would consult the microcontrollers datasheet for things to watch out for when switching voltage references during operation
@@ForceTronics
I checked the datasheet for the 328P-AU and it indicates that I can switch between references but one small mistake in code for the reference portion could easily render the chip useless due to an internal short.
So, I plan to use the TL431 Adjustable Shunt Reference at the AREF pin (then of course make sure the external reference is called in the sketch), I will buy a different version of the INA250 current sense/amplifier that will output a higher voltage per amp, basically, I can just increase the max output from 1.8V (500mV per amp output) to 7V (2 volts per amp output), then use a resistor voltage divider to scale that down to about 4.5V for the max input at the analog pin I'm using.
Keep it as simple as possible, right? :-)
For those not familiar with the INA250 series current sense/amplifier device, it has the current sense resistors, output buffers and an op amp style amplifier all built into one chip, they are designed to have extremely low output errors. The resistors are about 6 milliohms each but there are three of them for a total of 2 milliohms since they are in parallel (and Kelvin connected) and since the resistance is so small, that very small device can handle up to 15 amps of current flowing through as long as the PCB traces are done right (usually best done with dedicated polygons for separate copper pours).
Thank you so much for your quick response!
All the best and I hope you have a great day!!
Joe