Beware: "Problems" with FVR1024 (primarily M2s)

AllyCat

Senior Member
Hi,

This thread is not a plea for help as such, but I will be interested to hear if anybody can confirm (or dispute) my observations. It's not likely to be relevant to typical PICaxe applications, but members who frequent the "Finished Projects / Code Snippetts" section of the forum may be aware that I have been attempting to devise some "Higher Resolution" methods for the PICaxe to measure its own supply rail. This data can be useful in its own right, but is essential to get any "worthwhile" results from my new "ReadInternalTemperature" code. The methods have been generally very successful, with the exception that several times I have been "stung" by unexpected behaviour when attempting to use the FVR1024 Fixed Voltage Reference.

There are two basic reasons why one might want to use FVR1024: 1. To obtain a higher resolution from the on-chip DAC or ADC (e.g. 1 mV resolution steps) or 2. to work with a supply rail near to or below 2 volts. So far, I have not found any issues when using FVR1024 with the ADC or DAC at a supply voltage above 3 volts, and that includes using it as the ADC reference (which is advised against by PIC and PICaxe data sheets). The problems are mainly concerned with using FVR1024 as the reference for the DAC at lower supply voltages. All my observations have been with M2s; the commands for X2s are different or unavailable (and unsuccessful operation was reported in the forum thread below).

It's worth mentioning here that FVR1024 is the chip's "raw" reference voltage and FVR2048 and FVR4096 are outputs from associated rail-to-rail Op-Amps with nominal gains of 2 and 4. Thus the higher references have a slightly worse tolerance (accuracy) than FVR1024 (which might be another reason for using it), but they do remain stable right down to within ~100 mV "headroom" to the Vdd supply. However, the 14/20M2s are specified to work down to 1.8 volts (and typically 1.5 volts with the Brownout Detector disabled), so FVR1024 is the only available reference if one wishes to develop a "full voltage range" application.

The first "issue" I observed was with my "CALIBADC13" code snippet, which used FVR1024 with the aim of working down to the minimum possible supply voltage. However, I discovered that it lost all useful accuracy below about 2.8 volts, because the DAC output started to "sag" significantly. Therefore FVR1024 offered no benefit (in fact a major flaw) compared with using FVR2048. See the pale blue line in the second graph (and associated text) in post #24 of this forum thread.

More recently, I have been trying to devise a "better" READINTERNALTEMP algorithm, for which a highly accurate supply voltage measurement is required. My "CALIBADC15" routine has proved very staisfactory but works only down to 2.1 volts because it uses FV2048. So I devised an alternative method (still to be documented) which uses FVR1024 as the ADC reference voltage. Again, this appeared to work well at higher voltages but went "wild" below 2.1 volts. However, this is actually an interesting observation because it shows that the internal "temperature-sensing" hardware can be an excellent indicator of power rail stability over the short-term (i.e. whilst the temperature does not change).

Here are two graphs that I've plotted using the method and hardware described in this finished project. The "zoomed" graph around 2000 mV, compares three methods of the PICaxe measuring its own supply against a horizontal axis of time. The "CAL 11" line (Blue) uses a slightly improved version of CALIBADC10 + PICaxe division to give "10 mV resolution" "steps" which are clear in the graph. The "CAL 15" line (Red) uses my CALIBADC15 code which can give excellent (~1 mV) resolution, but only down to 2.1 volts where the FVR2048 drops out. The third line (Yellow) measures the (exponentially falling) supply rail using the ADC referenced by FVR1024. The "error" is quite small (up to about 30 mV) but has a rather disasterous effect on the temperature calculation (Yellow) shown in the second graph.

NewCAL2000.png TempAsVddMonitor.png

The second graph shows the same supply voltage measurements applied to my improved READINTERNALTEMP routine, which shows that temperature measurements (vertical axis) with around 1 degree C resolution are practical. In fact above about 3 volts it seems possible to achieve around 0.2 degree C resolution, but numerous problems, such as outlined here, arise at lower supply voltages. As previously observed, the Yelllow line (using FVR1024) starts to droop from about 2.8 volts and exhibits strange "ripples" below 2 volts.

To give an indication of the "sensitivity" of these measurements, the temperature line calculated from CALBADC15 has only been limited to zero (i.e. negative values set as 0), so the "cliff edge" fall really is the point at which FVR2048 stops regulating (and follows Vdd). This graph is an X-Y plot (Vdd across the X axis) so the apparently higher level of "noise" at the lower voltages is actually due to the greater number of points plotted (because the voltage is falling more slowly).

Cheers, Alan.
 

hippy

Technical Support
Staff member
The "zoomed" graph around 2000 mV, compares three methods of the PICaxe measuring its own supply against a horizontal axis of time.
I have to admit that I am not sure on what that means or what the graph is consequently showing.

I would be expecting to see something which shows FVR readings against supply voltage, and perhaps another which shows actual supply voltage against calculated supply voltage at various FVR settings. I am not sure how time comes into it.
 

AllyCat

Senior Member
Hi,

Thanks for your interest. The graphs can contain literally thousands of points, so I use an "automated" method with the hardware described in the link above. The Vdd ramps down slowly whilst the PICaxe reports measured values via SERTXD, separated by commas and with a "newline" after each PAUSE of a few seconds. After a full "sweep" (which can be from 5 minutes up to more than a hour) the .csv data file is transferred to a spreadsheet such as Excel, so that columns contain the various test measurements to be compared and the rows follow progressing time.

Normally, the first column would contain a "measured" reference supply voltage and the spreadsheet is selected to plot an X-Y graph (X is the first column), so the supply voltage would be the horizontal axis (as in the second graph). The problem with my first graph is that I have no "known" accurate calibrated supply voltage at this zoom level and Vdd, because all three have "defects" so cannot be used as a "reference" for the X-Axis:

The line based on CALIBADC10 has "steps" of at least 10 mV in magnitude, which if used as the X-Axis would show the other values as short vertical lines. The "CALIBADC15" subroutine values descend smoothly (within about 1 mV) until the point where FVR2048 drops out and then the ADC "reference" falls at the same rate as the "measured" Vdd. This produces a horizontal line, or a vertical line if used as the X-Axis.

The third line was a "candidate" to use as a "perfect" reference for the X-Axis of other plots (i.e. a smooth line down to the point where the PICaxe stopped working at ~ 1.5v). Sadly, it too is "defective" because it "wanders away" from the CALIBADC-derived line, which does show the expected average gradient (slightly exponential because the test rig uses just a simple C-R discharge network).

Therefore , I plotted this particular graph against row number (along the X-Axis), which corresponds to "time" (not the PICaxe's value, but it could be) that can be reasonably assumed to correlate with the falling Vdd, at least over the "zoomed" period (where the exponential curvature is fairly small).

Cheers, Alan.
 

hippy

Technical Support
Staff member
I think I understand, or at least the gist of it.

What intrigues me is that, when I've calibrated the FVR's they all seem usable to calculate the Vpsu to within a few mV of what it actually is across their entire range I have spot measured. Admittedly I have not using calibrated equipment and I haven't tested a sweep so don't have any details of linearity.

The way I did it was to set Vpsu to 5V, measure each FVR 64 times, then calculate the Vref mV reference voltage from -

Vref = ( Nref * Vpsu ) / 1023
Vref = ( (Ntotal/64) * Vpsu ) / 1023
Vref = ( (Ntotal/64) * 5000 ) / 1023
Vref = ( Ntotal * 5000 ) / ( 1023 * 64 )
Vref = ( Ntotal * 625 ) / ( 1023 * 8 )

Then, to determine the actual Vpsu later, read the Vref with Vref set as ADC Vref 64 times ( though I'll admit that doesn't sound quite right ! I would have to check ) and calculate -

Vpsu = ( Vref * 1023 ) / Nref
Vpsu = ( Vref * 1023 ) / ( Ntotal / 64 )
Vpsu = ( Vref * 1023 * 64 ) / Ntotal

Maths done using 32-bit divided by 16-bit. It probably doesn't make much difference if using 1023 or 1024 in the calculations.
 

AllyCat

Senior Member
Hi,

It depends if there is any "noise" present. If we first assume that there is no noise, then 64 measurements should produce exactly the same value. If the voltage is slowly changed then (theoretically) at some point all 64 values suddenly change by one diigit to produce a step 64 units higher or lower. Thus the calculated result still jumps in steps of about 20 mV (which is rather unsatisfactory when the chip temperature sensor changes by only 2.5 mV/C).

In practice there is some (maybe lots of) noise, which is a known method to increase ADC resolution. The problem is that it's not "guaranteed" or specified, and appears to be significantly less at lower supply voltages. A lot of this was discussed from post #11 in this thread (also referenced above).

IMHO, the dark green line (marks code) in the second plot of post #24 is rather revealing. It's calculated from an average of about 25 CALIBADC10 values at relatively low voltage. The internal noise is sufficient to "soften" the transitions between the integer levels, but the deviation from the "ideal" diagonal line is clear. My light green (CALIBADC15 subroutine) is far more satisfactory, but unfortunately stops at 2.1 volts. :(

Again, that graph uses data-row numbers as the X-Axis, which correlate to elaspsed time and thus (decreasing) supply voltage. The vertical axis is measured+calculated mV.

Cheers, Alan.
 
Top