Author Topic: Measuring Internal Voltage Reference  (Read 2503 times)

digi_guy

  • Jr. Member
  • **
  • Posts: 87
Measuring Internal Voltage Reference
« on: April 17, 2016, 02:11:29 pm »
My current project involves measuring temperature using a K-type thermocouple and an amplifier from Adafruit
(https://www.adafruit.com/products/1778) reading on the analog pin 10.

The problem I'm running into is that I need to convert the reading into a relative voltage, and then translate that into a temperature, ie

 Temperature = (Vout - 1.25) / 0.005 V.

Vout is supposed to be
Vout = (analog reading) * 3.3 / 1024
where that 3.3 should be the internal voltage reference.

What I've noticed is that it's not 3.3, and it changes depending on the power source. When powered from my laptop USB I'm measuring a reference closer to 3.19, and when plugged into a USB adapter I get 3.17.

Right now a voltmeter is measuring
4.9V on Vin
0.0V on Gnd
3.29V on Vcc


My attempt at setting up a scientific process has my thermometer in an ice bath that should be a 0C and that is supposed to produce a voltage of 1.25, but instead I'm getting 1.238V

I know there was a thread about this with the Digispark Pro but I'm not sure if that was every resolved. Any thoughts?






PeterF

  • Hero Member
  • *****
  • Posts: 881
Re: Measuring Internal Voltage Reference
« Reply #1 on: April 20, 2016, 02:49:59 am »
All of these micros will vary slightly dependent on input voltage. Arduino Uno/Mega were more prone to it as they run from 5v, so when you plug into the computer, they get anything from 4.5 to 5.1v, which then throws all your readings one way, and then nearly 5v when you plug in a power supply into the barrel jack.

Unfortunately, I don't think you can use the technique used there of using the atmega's internal 1.1v reference voltage as a calibration source, and then offset the readings as necessary as the input voltage changed. You can read the supply voltage via the ESP.getVcc() command, but since you have to also give the ADC_MODE(ADC_VCC); command outside of any functions (not even in setup or loop), it doesn't look like you can switch between the analogue pin and the ADC_CC as the device to read. And another trick of using a voltage reference is won't help as the ESP8266 only has one analog pin!!!

I think unless someone else comes up with a bright idea, you'll just have to live with the inaccuracy of the analogue input...

Pete

emardee

  • Full Member
  • ***
  • Posts: 135
Re: Measuring Internal Voltage Reference
« Reply #2 on: April 20, 2016, 04:24:52 am »
Will the final implementation be on just one power source? Or will you keeping running it off different power sources?

If it will only be used on one power supply in the end, I'm presuming you can implement a "fudge-factor" into your maths to get it accurate.

It has been 20 years since I did such things, so it is REALLY hazy in my mind, but pretty sure you can conduct some sort of experiments to confirm the multipliers used, and the offsets needed to make it always right on that power supply. That way you get to tune the readings to match real life.

(Visually you might find it helpful to picture that the multiplier is adjusting the slope of the line of a graph of Temp vs Voltage, and the offset is tweaking for where it crosses the Y axis - which might help you work it out.... which means you can use geometry and other tricks to help you work it out along with suitable experiments.... 0c for offset, and other known temp for multiplier).

If you need this to work on multiple power supplies, it gets trickier, which is where you need to be able to have some feedback of chip voltage to be able to get the formula to fix it for you in every case.

You might already know all this of course... in which case, I wish you luck in working it out.