FVR 1.024 positive reference question

hax

New Member
Hi all,

The online manual for the FVR command says

"Note that the 1.024V reference may not be accurate if used as the Vref+ of the ADC (only 2.048 or 4.096 should be used for this purpose). "


Can anyone elaborate on that limitation? I don't mind if it's not accurate and I can offset the value, but I do mind if it fluctuates for some reason.


I'm trying to read a hall effect current sensor that has two output pins. One pin is 2.5V reference, and the other pin is the analog out which is + or - 600mV from the reference.... so it can read positive and negative current flow.

So I was going to set the negative reference on the picaxe as the 2.5V reference, and was going to use FVR1.024. This would give me enough resolution to use the sensor without any opamps, all be it for positive currents only.
 

hax

New Member
Oh, I just realised that I think I can't use FVR1024 as the positive reference because the analog voltage measured will be higher than 2.5v..... Initially, I thought the command added 1.024V from the negative reference.

I might still use the 2.5V sensor wire as the negative reference and use FVR4096 as the positive reference, thereby throwing away two thirds of the resolution.
 

AllyCat

Senior Member
Hi,

Which PICaxe? If you're using the Negative Reference Input then I guess it's an X2 ? We need to look at the base PIC Data Sheet, not a PICaxe User Manual. What resolution, accuracy and repeatability are you hoping to achieve?

The PIC(axe) has only one ADC with an analogue multiplexer input from a number of pins, so I would consider an alternative approach: One analogue input could measure the "signal" and a second the "2.5 volts" reference (and perhaps also measure the FVRs as an internal voltage reference). Then calculate the actual signal by simple PICaxe maths (subtraction, etc.). If you need higher resolution (than 4 mV) there are various "tricks" such as oversampling (adding multiple measurements together) or using the internal "DAC" (resistor divider chain). But I believe others have had problems applying some of these these tricks to the X2 chips.

Cheers, Alan.
 

inglewoodpete

Senior Member
Oh, I just realised that I think I can't use FVR1024 as the positive reference because the analog voltage measured will be higher than 2.5v..... Initially, I thought the command added 1.024V from the negative reference.

I might still use the 2.5V sensor wire as the negative reference and use FVR4096 as the positive reference, thereby throwing away two thirds of the resolution.
You don't mention what Vcc supply voltage you are using for the PICAXE. If it is significantly greater than 2.048 volts, then use FVR2048. With 10-bit ADC, this will give a reading on the pin in 2 millivolts per step. As 2.5v is greater than this, you will need to use a voltage divider to reduce the input to within 2048 mV.

I used the following code in an 08M2 running on a 3.2v supply to read voltages up to about 4 volts.

Initialisation (run once at startup):
Rich (BB code):
      FVRSetup FVR2048                 'FVR2048 = Fixed Voltage Reference is 2.048 Volts
      ADCConfig %011                   'VRef- = 0v; VRef+ = FVR2048 (Ie 2.048 volts)
                                       '2048mV & 10-bit ADC results in 2 millivolts per step
                                       'With external 2:1 voltage divider, gives 4 mV / step
Subroutines accessed from the main loop:
Rich (BB code):
'
' **** ReadVcc: Read the supply rail voltage
'
'  Notes:   Fixed Voltage Reference (FVR) is configured as 2048 (2048mV) (2mV/step)
'           Voltage input is through an external 2:1 voltage divider (Ie Vcc/2)
'           ADC10 full scale is 1023, so voltage value x 2 x 2 = Vsupply in millivolts
'     Exit: wRefVoltage (word)
'
ReadVcc:       ReadADC10 iPowerRail, wRefVoltage'Read power rail voltage
               wRefVoltage = wRefVoltage * 4    'wRefVoltage is in millivolts (see notes)
               Return
'
' **** ShowVcc: Log the supply rail voltage to the PE Terminal Screen
'
'  Notes:   Fixed Voltage Reference (FVR) is configured as 2048 (2048mV)
'           Voltage input is through a 2:1 voltage divider (Ie Vcc/2)
'    Entry: wRefVoltage (word) Voltage in millivolts
'     Used: (byte) bTemp, bThousands, bHundreds, bTens, bUnits
'     Exit: wRefVoltage (word) unchanged
'
ShowVcc:       BinToASCII wRefVoltage, bTemp, bThousands, bHundreds, bTens, bUnits
               SerTxd ("Supply voltage = ", bThousands, ".", bHundreds, bTens, "v", CR, LF)
               Return
 

hax

New Member
It's a 28x2.

I think I'll end up using a resistor divider across the 5v power supply.

If I have a resistor divider with 3 resistors: 1.8k,1k,1.8k, then I can connect the high part of the 1k resistor to ref+, low side to ref-, and have full 10 bit positive and negative current range within that 1.9 to 3.1v analog input. That would be pretty simple.

Sound like a plan?



In practice how many mV noise do you get with a 7805 regulator? It's just running the picaxe, nothing else.

Can you get that 4.096v reference to an output pin? If so, I can run a resistor divider from that.
 

AllyCat

Senior Member
Hi,
If I have a resistor divider with 3 resistors: 1.8k,1k,1.8k, then I can connect the high part of the 1k resistor to ref+, low side to ref-, and have full 10 bit positive and negative current range within that 1.9 to 3.1v analog input.
That's still "breaking" the Data Sheet specification which requires the minimum reference voltage to be 2 volts (Parameter A20 on page 451 of the Base PIC Data Sheet.

Base=28X2-ADC..png

But that restriction probably applies so that Microchip can make the "Note" claim at the foot of that table. Unfortunately, the data sheet doesn't appear to specify the currents that might flow into or out of the "reference" pins (which may affect your divider chain accuracy). AFAIK, the internal "DAC" is not much more than a resistor chain which "hangs" on the Reference pin(s) and/or the FVR.

It depends how you define "noise" (e.g. to include temperature and general "drift") but I would expect the 7805 high(er) frequency noise to be largely dependent on its decoupling capacitor(s). I've done a lot of work with the M2's FVR, ADC and DAC (particularly investigating the Internal Temperature Measurement hardware of M2s) and was quite surprised that the (significant) tempco of the FVR is remarkably similar to that of a 7805. The "internal temperature measuring hardware" actually proved very effective at monitoring variations of the supply rail !

However, it appears that there is significant "internal noise" on the PIC's ADC (particularly at higher supply voltage), which is not necessarily a "bad thing" because it makes "Oversampling" a useful (and maybe necessary) technique, for making high(er) resolution ADC measurements. Perhaps the best "introduction" to my measurements is in THIS SHORT THREAD, which includes links to more details if you're interested.

I don't believe there is an "intended" method to apply the FVR to an output pin, but you possibly can connect it to the "DAC" and manipulate the output from that. ;)

Cheers, Alan.
 

rq3

Senior Member
It's a 28x2.

I think I'll end up using a resistor divider across the 5v power supply.

If I have a resistor divider with 3 resistors: 1.8k,1k,1.8k, then I can connect the high part of the 1k resistor to ref+, low side to ref-, and have full 10 bit positive and negative current range within that 1.9 to 3.1v analog input. That would be pretty simple.

Sound like a plan?



In practice how many mV noise do you get with a 7805 regulator? It's just running the picaxe, nothing else.

Can you get that 4.096v reference to an output pin? If so, I can run a resistor divider from that.
I very recently went through this exercise, and as others have pointed out it is possible to use the 1.024 volt reference with no apparent problems. I never did get to the point of opening a ticket with Microchip to ask WHY they say not to use the 1.024 volt reference, especially since all of the selectable reference voltages come from the same buffer amplifier (and are actually the 1.024 volt reference multiplied by 1, 2, or 4).

The circuit I ended up using is all surface mounted on a small, double sided printed circuit board with a lot of through vias for grounding and heat dissipation. It uses a 7805 regulator driven by a 24 volt supply to run the Picaxe (an 8M2). The input to the regulator is decoupled with a 0.22 uF cap, and the output with a 1uF cap. The Picaxe has a 0.001uF cap right at the supply pin. I had no problems doing stable and repeatable 10 bit ADC reads down to 1mV using the 1.024 volt reference (1 ADC count). YMMV.
 
Top