NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Power supply reference voltage

March 18, 2010
by Ralphxyz
Ralphxyz's Avatar

I have seen a couple of discussions on how to get the actual power supply voltage. There were a number of steps that seemed to me to be to complicated. Why can not I just connect PC5 or any of the ADC pins to the + voltage rail?

For the Temperture Sensor project 5000mv is assumed:

double sampleToFahrenheit(uint16_t sample) 
{
  // conversion ratio in DEGREES/STEP:
  // (5000 mV / 1024 steps) * (1 degree / 10mV)
  //    ^^^^^^^^^^^      ^^^^^^^^^^
  //     from ADC         from LM34
  return sample * (5000.0 / 1024.0 / 10.0);  
}

Why could I not make the 5000.0 a variable referencing a ADC pin? I assume have the true power supply voltage would make for more accurate calculations and using a variable it would allways be accurate even if the power supply was drainnig down as from a battery.

Thanks for the help, again.

Ralph

March 18, 2010
by bretm
bretm's Avatar

The ADC doesn't measure the input voltage, it measures the ratio between the input voltage and the reference voltage, Vin/Vref. If AREF and PC5 are both connected to VCC, the ratio will always be 1.0 and the ADC will always return 1023 (maybe minus noise).

March 18, 2010
by Ralphxyz
Ralphxyz's Avatar

I was thinking of using the Temperature Sensor code.

With the ADC pin connected to the + rail I currently get 499.51⁰F. Which has decreased with battery usage. It had been at 500 with a fresh battery.

I just measured the rail voltage and got 4.95v so they are not in sync or my meter is not sensitive enough. Seems like I could figure out a scale to be able to use this.

Of course my imediate project does not require great accuracy, so it was just a thought.

Thanks for the knowledgable reply it all ways helps. Ralph

March 18, 2010
by mongo
mongo's Avatar

Something maybe worth looking into...

Back in the day, I used a chip similar, (maybe even the same) from Analog Devices. It was the AD580 2.5V precision reference.

If you use it for VREF (not ground), it shifts your scale to a point where negative temps can be read without going with a negative power source. Of course, it means changing a few numbers in the program but that should not be too hard...

I think there is another thread on this but I can't find it.

March 19, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi all,

Check out this thread. There's a voltage reference built into the chip that you can use, along with an external resistor divider (of a known ratio), to measure the power supply voltage.

Let me note that 499.51 degrees F (for an LM34) represents a voltage or 4.9951 volts... and that 5.0*(1023/1024) = 4.9951! Coincidence? I think not :-) As bretm points out, the ADC is reporting the highest reading it's capable of (binary 1023).

Mike

Post a Reply

Please log in to post a reply.

Did you know that interrupts can be used to trigger pieces of code when events happen? Learn more...