Is there an on board voltage reference for A/D conversion?

I switched from the Electric Imp to the Spark and I ain’t going back. So far the only thing I miss is the ability to get the true value of the 3.3V supply for A/D conversions. Is this voltage available?

1 Like

Hmmm… I’m not sure if I got you right but the A/D reference is the same 3.3V you get from the 3.3V pin

We’re assuming 3.3V is 3.3, not 3.27 or whatever. In most cases it won’t matter, but in some it will.

Since you mentioned 3.3v TRUE VALUE, I suggested the 3.3v pin since what you read from there is indeed the true value.

You will have to add a 3.3v voltage reference to achieve a consistent voltage for your application then :slight_smile:

Correct. Unlike many micros(*), the STM32F103 doesn’t have an on-chip reference, and the package used in the :spark: doesn’t even bring the Vref+/Vref- pins out, so they are forced to VddA & VssA respectively.

Therefore, the ADC is only really accurate for ratiometric conversions based on VddA, not absolute readings based on an actual voltage (because VddA is a supply rail, not a reference voltage.

(*) Note that many micros have nearly useless on-chip references, ones that drift dreadfully with temp, time, phase of the moon, etc.

1 Like

What is *3.3v? I have analog pins to spare, do I just add a stable reference, like an AD589 to a pin and read it? Then scale the other inputs accordingly? is it that simple?

3V3* is a filtered 3.3V output which you can use to power analog sensors that will also have the same voltage powering them that is used as a reference (Vdda) to the STM32’s ADC.

You can certainly use that $4.5 voltage reference on one input and scale all readings using that gain. You can also just measure the 3V3* node and use that measurement in your code to get pretty accurate readings as well.

1 Like

3V3* would’t be a good reference would it? It would only be as accurate as the on board V reg. Andy W. says on-board references are pretty useless anyway, So if a situations calls for it, an external reference, a cheap one, is the only way to get accurate voltage conversions. Is that correct?

Using an external reference will be better, but not perfect, because 3V3* may fluctuate between reading the reference and the input pin.

1 Like

It would be fine for most applications if you measured it first and saved that value in your Spark Core. It would be as accurate as your measurement, and fluctuation over temperature range. It's a very common practice thing to do for factory calibrating a uC's ADC inputs. Not every design can afford a precision reference.

I believe he means the ones that come inside uC's, they are typically pretty bad. You are probably better off relying on your 5% 3.3V regulator which is probably +/-2% within your actual operating temperature range.

Or, as Andy says... spend money to get a 1% or better reference. Still though, if you measure that 1% reference, you can calibrate the offset out of everything and have a very accurate reading at room temperature.

Nope, not the only way, see above :wink: It really depends on how much you want to spend, and how much accuracy you really need.

1 Like

VSSA can be a negative voltage or is it the ground? I need + and - reference voltage for the ADC as my input signal can be negative and positive. if I cannot control this, then my inputs have to be positive which is cutting a lot from my signal.