lowest value on readADC?

Hi all, it's the idiot child again.....
If i reduce the supply voltage to 3vlts ( therefore the reference voltage?) what's the lowest voltage I can measure on ADC, please?
I'm using an OM2 chip and would like to measure down to millivolts if that's possible.
thanks in anticipation :unsure:
 

Engle

Member
Hi, OM2 chip?? With a 3.00V supply a readadc10 on my 20M2 read a 1 when the input reached about 300uV and a 1023 when it reached 2.990V. Hope that helps.
 

AllyCat

Senior Member
Hi,
.... my 20M2 read a 1 when the input reached about 300uV and a 1023 when it reached 2.990V.
? ...The "Lowest" voltage a PICaxe can measure is zero volts, giving an ADC output value of 0 ! If you mean the Lowest (or Best) "Resolution" (which is NOT the same as "Accuracy") then with a 3 volt Reference, the nominal Resolution with READADC10 would be 3000 / 1024 or just under 3 mV per step. Perhaps the output jump from 0 to 1 will occur at around 1.5 mV, but that's being rather optimistic.

The 08M2 can work down to a supply rail of typically 2.3 volts and a 20M2 to 1.8 volts (up to 16 MHz clock frequency), but we can do better. The PICaxe can use an internal Reference called the FVR or "Fixed Voltage Reference" (using the ADCCONFIG and FVRSETUP commands) with 3 levels of nominally 1.024 , 2.048 and 4.096 volts. "Officially" the ADC is only approved for Reference voltages above 1.8 volts (i.e. "FVR_2048"), but it does work from FVR_1024 giving a nominal Resolution of 1.0 mV.

And perhaps we can do a little better, rather surprisingly at a higher supply voltage of around 5 volts. In my experience the PIC{axe} generates more internal "Noise" at 5 volts, so if you add together a sequence of READADC10 measurements (perhaps 4 or 10) with a FVR Reference and take an average, then you might get a better Resolution.

Also, HERE is a recent thread attempting to improve the ADC resolution.

Cheers, Alan.
 

Engle

Member
Hi Alan, thanks for the fuller description. You're right to call out the low reading I had, it's probably misleading.

Personally, I'm always dubious about rail-to-rail claims and I had an M2 setup so did a quick check for the 1st and last step. I think that's prudent, but I've found the PICAXE to be quite good in the past, so I was a little surprised too. The 1 reading is probably something to do with my test setup, or a tolerance or spec issue on something. I was using a linear supply and bench multimeter but I've seen a lot of noise at low voltages so I'm happy to put it down to that or the test setup.

I found ADC values jumping around a little was interesting in the past, so I dabbled with averaging too. I guess it’s safe to assume the chips are fairly good but I haven’t seen a complete test to know if the average is homing in on accurate values. My go to supply voltage is 5V, so it’s very useful to know that’s the noisiest, thanks.

In my case I was using Vref readings to do integer maths and get Vdd, then use that to scale the ADC input on a 20X2. Perhaps that's not the best method? I’d be interested to know if there’s any electronics recommendations to smooth out the ADC readings like input resistors and capacitor values etc.

For the wider audience, one interesting thing I found was switching off a circuit failed when an ADC was connected to a Li-ion cell 😊. It seems like the diode protection on the ADC input tries to power up your circuitry! I guess you run the risk of blowing the chip if the current is too large, but I was fortunate.

Any comments or improvements to the code below are welcome (_VoltageDebug is just an alias for sertxd):
Code:
#macro GetVdd
    _VoltageDebug("@GetVdd")
    calibadc10 _VoltageADCval                                    'Read reference 1.024v (Value = 1023 * 1.024V / Vdd)
    Voltage_Vdd = 10450 / _VoltageADCval * 100      'Obtain first 2 digits, nnxx. Max=5200(5211), Min=1800(1803)
    _VoltageModulus = 10450 // _VoltageADCval       'Find remainder. Max=580, Min=0
    Voltage_Vdd = 100 * _VoltageModulus / _VoltageADCval + Voltage_Vdd  'Obtain last 2 digits, xxnn. Max=99(=100*580/581), Min=0
    _VoltageDebug("  (Ref_1.024V=",#_VoltageADCval,",  Vdd=",#Voltage_Vdd," mV)",cr,lf)
#endmacro

#macro SetVdd(VoltsW)
    _VoltageDebug("@SetVdd")
    Voltage_Vdd = VoltsW
#endmacro

#macro VoltsByVdd(VoltsW, Channel)
    'The measured voltage is Vdd(1800 mV to 5200 mV) * ADC_Reading(0 to 1023) / 1023(ADC_Range).  NB: ADC range is approximately 1024
    _VoltageDebug("@VoltsByVdd")
    readadc10 Channel, _VoltageADCval                  'Read ADC Channel, the range is 0 to 1023 from Gnd to Vdd.
    VoltsW = Voltage_Vdd */ _VoltageADCval          'Get the middle word of Vdd * ADC10, so the result is divided by 256.
    VoltsW = VoltsW / 4                                            'Then divide by 4, now we have approximately Vdd * ADC_Reading / 1023.
    _VoltageDebug("  (ADC",#Channel,"=",#_VoltageADCval,",  Voltage=",#VoltsW," mV)",cr,lf)
#endmacro
Regards, Alan
 

AllyCat

Senior Member
Hi,
..... switching off a circuit failed when an ADC was connected to a Li-ion cell 😊. It seems like the diode protection on the ADC input tries to power up your circuitry!
Yes, "Phantom Powering" is a gotcha for ALL pins on a PIC(axe), so you also need to be careful with Serial Communications, etc.. The only exception is the Programming/MR "Input Only" pin (which may have its own issues). The "Electrostatic Protection" diodes (rated up to 20 mA) connect each pin to supply or ground if the pin is above the (actual) Vdd or below the Vss rails. As the PICaxe power drain can be so low (<<1mA) , it may be necessary to connect around 10k in series with the pin. This is the largest recommended value for accurate ADC readings, but a "higher" (unspecified) series resistance can be used if a capacitor (of some nF) is also connected directly between the ADC input Pin and Ground (because the ADC uses a dynamic "capacitive" reference/divider, not resistive). These details come from the ADC/FVR/Electrical Specifications etc. sections of the relevant Base PIC Data Sheet ("Advanced Technical Details" link).

I've posted several Code Snippets (around pages 4 and 5) for improving the accuracy (strictly the resolution) of "CALIBADC" measurements, from 20 mV down to around 1 mV. However, most use the internal "DAC" which doesn't work (in the same way?) in X2 devices, that I see you're mainly using. Also try following the links through from my post #3 above. There are also Snippets for higher accuracy division routines (31 - 32 bits numerators), etc..

Cheers, Alan.
 

Engle

Member
Hi Allycat, thanks for the extra info. Those code snippets with large numerators seem very useful too. Fortunately, with my phantom powering issue there was only 1 ADC to worry about, a mid point between 2 cells in series, so I was able to use a dual pole power switch to cut the ADC completely, although for protection I also added a 1K resistance.
 
Top