lbenson
Senior Member
I've often used this code to calculate voltage times 10:
calibadc b4
b4 = 2611 / b4 ' 1.024 * 255 * 10 / calibADC value: V*10
I have a design which needs to run at 32mHz and 3V to accomodate a Nokia 5110 LCD, but have found that CALIBADC doesn't return the right value for this calculation, whereas it is correct for 4mHz, 8mHz, and 16mHz.
Here's my test code. I first display the calculated voltage at 4mHz, and then again after SETFREQ M32.
Powering with 2 AAs I get a DVM reading of 3.16
With DVM reading of 4.48, the following:
As mentioned, with SETFREQ M8 and SETFREQ M16 I get correct answers.
(I tried switching to SETFREQ M4 to do the voltage calculation, but that causes the LCD to clear.)
calibadc b4
b4 = 2611 / b4 ' 1.024 * 255 * 10 / calibADC value: V*10
I have a design which needs to run at 32mHz and 3V to accomodate a Nokia 5110 LCD, but have found that CALIBADC doesn't return the right value for this calculation, whereas it is correct for 4mHz, 8mHz, and 16mHz.
Here's my test code. I first display the calculated voltage at 4mHz, and then again after SETFREQ M32.
Code:
' 20calibadc ' trys to calculate voltage @ 4mHz & 32mHz
#picaxe 20M2
#terminal 4800
pause 2000
calibadc b4
sertxd("calib: ",#b4," ")
b4 = 2611 / b4 ' 1.024 * 255 * 10 / calibADC value: V*10
sertxd(#b4,cr,lf)
b5 = b4 // 10
b4 = b4 / 10
sertxd("Supply Voltage @ 4mHz = ",#b4,".",#b5,cr,lf)
pause 1000
setFreq M32
pause 16000
calibadc b4
b6 = b4
b4 = 2611 / b4 ' 1.024 * 255 * 10 / calibADC value: V*10
b7 = b4
b5 = b4 // 10
b4 = b4 / 10
pause 16000
setFreq M4
pause 2000
sertxd("calib: ",#b6," ")
sertxd(#b7,cr,lf)
sertxd("Supply Voltage @ 32mHz = ",#b4,".",#b5,cr,lf)
pause 2000
Code:
calib: 83 31
Supply Voltage @ 4mHz = 3.1
calib: 99 26
Supply Voltage @ 32mHz = 2.6
Code:
calib: 58 45
Supply Voltage @ 4mHz = 4.5
calib: 86 30
Supply Voltage @ 32mHz = 3.0
(I tried switching to SETFREQ M4 to do the voltage calculation, but that causes the LCD to clear.)