6
\$\begingroup\$

What is Vref in microcontrollers? For instance an Arduino has a +5V, +3.3V, and Vref pin. If I wanted to use the Arduino as a voltage source providing 3.3V to my circuit, I would use the +3.3V pin. What is the purpose of Vref in this context?

Additionally, what is Vref in ADCs? I see that ADCs have a Vdd pin and a Vref pin. If I were to power the ADC using say 5V DC, I would connect to the Vdd pin. However, what is the purpose of Vref in this context?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ It's the same on both MCUs and ADCs, because the Vref pin on an MCU is used for its built-in ADC. MCUs that don't have ADCs won't have a Vref pin, and some cheap or low-pin-count MCUs that do have ADCs will also not have a Vref pin, and just use the supply voltage as a reference, which negatively impacts accuracy, but that probably isn't a primary concern if you're using a cheap or low-pin-count MCU. \$\endgroup\$
    – Hearth
    Commented Oct 9, 2021 at 18:40
  • 2
    \$\begingroup\$ Does this answer your question? What is "Vref" of ADC in a microcontroller datasheet? Or perhaps What is the function of AVDD,AVSS and Vref of ADC in Microcontoller? \$\endgroup\$
    – Cody Gray
    Commented Oct 10, 2021 at 5:00
  • \$\begingroup\$ I would close the other question as a duplicate of this one, as this one is more generic. \$\endgroup\$
    – Null
    Commented Oct 14, 2021 at 11:51

3 Answers 3

14
\$\begingroup\$

what is Vref in ADCs?

Vref is the reference voltage by which the ADC computes digital values. Of course, on many ADCs you can use chip voltage supply as your reference voltage but, it would be noisy and not very consistent or accurate and drift over time.

So, if you are looking for very accurate results from your ADC, then you use a very stable voltage reference that has an initial accuracy that is very close to what is stated on the tin (and very low drift with temperature and time).

If you are not bothered about those things then use Vcc as the reference voltage.

\$\endgroup\$
3
  • \$\begingroup\$ for example, a 16-bit measurement of 0x8000 means the input value is approximately half of Vref. A measurement of 0xFFFE means the input value is only slightly less than Vref. \$\endgroup\$
    – user20574
    Commented Oct 11, 2021 at 8:27
  • 1
    \$\begingroup\$ There are instances where using the chip supply as a reference can help: for example when reading a pot, or a divider (e.g. with an NTC) which are powered by the same supply. The reading will be independent of the actual supply value. (the supply still needs to be clean though) \$\endgroup\$
    – Redy000
    Commented Oct 11, 2021 at 9:19
  • \$\begingroup\$ @Redy000 correct - it's called a ratiometric measurement. \$\endgroup\$
    – Andy aka
    Commented Oct 11, 2021 at 9:29
12
\$\begingroup\$

Vref is the reference voltage -- ADCs work by determining the ratio between an input voltage and their reference voltage (DACs work in reverse, giving a voltage that's the ratio between the reference and the input number -- or in older DACs, giving a current that's proportional to a reference current).

If you're going to use an ADC, or the ADC function of a microcontroller, you need to study the data sheet carefully and understand what that part's Vref does. Different parts have different ranges of what's acceptable input to Vref, and the relationship between Vref and their outputs. A few ADCs and quite a few microprocessors will drive a voltage out of their Vref pins, or can be programmed to do so.

\$\endgroup\$
2
\$\begingroup\$

To elaborate a little on the other answers, Vref may be an input or an output (depending on the device). If it's an input, then it's a way to supply an exact 5.000V supply to sensitive parts of the chip. If it's an output, then it's telling you what the chip's internal power supply is providing (which you might need for other parts of your circuit). Chips like the Arduino Atmels have it as a programmable input - that is, it's defaulted to using the 5V from Vin unless you flip a switch with the code you run to specifically use the Vref pin instead.

The reason this matters (particularly with ADCs) is that when they convert an analogue voltage to a digital one, they'll use voltage reference to do it. Let's say that a particular ADC says it can convert any voltage from 0.0 to 5.0V into 0-1024. If you imagine putting in 2.5V, you'd expect to get a reading of 512 from the ADC (mathematically: 2.5/5.0 * 1024). However, if the ADC were using Vdd as the reference, and maybe the power supply was a bit high at that moment, so was supplying 5.2V. That would mean that the 2.5V input would return 492 (ie. 2.5/5.2 * 1024). Because of that low reading, the circuit around it turns something on, which draws some additional power supply current, so the supplied voltage goes down to 4.9V... and now the 2.5V reading becomes 522.

To avoid this obvious problem, the ADC compares the input to a high-precision voltage source. Chips like the Arduino can use their own, internal precision power supply for this, or you can use an external chip to provide the precision voltage that the ADC will use in its comparisons.

As the old saying goes "you get what you pay for". The Arduino built in voltage source is pretty good - and suffices for nearly all the sorts of things Arduinos really get used for. However, if you were doing some sort of super-precision analogue measurements, then you may want to spend a few extra quid on a precision voltage source, and then connect that to the Vref pin so that the ADC gets a super-constant, super-accurate 5.0V reference all of the time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.