So when you say that it is 'close enough' at 15V and 11V, do you mean that they are both the same side of 12V with the skew or is one more and the other less as if the value reported by the PICAXE had some sort of logarithmic relationship with the actual input? My guess is the former, in which case it would be a problem with the multiply and divide combination.Nick, here is a "checkBattery" routine that I am using. It isn't exactly linear, but I ran out of time researching the "correct" way to do this and just adjusted the numbers until I got it right at 12VDC and close enough at 15VDC and 11VDC.
Code:
checkBattery: 'Compares battery voltage at divider to fixed minimum; sets flag
batteryLow = 0
readadc10 ADCBAT, adcBatteryreading
' "40" = 4 for the voltage divider and 10 to scale the factor to an integer
' "273" = 1024 divided by 3.75 (15v / 4) rounded to scale it to an integer
batteryVoltage = adcBatteryreading * 16
if batteryVoltage < BATVOLTMIN AND batteryVoltage > 5000 then ' 5000 = 5 volts
batteryLow = batteryVoltage ' this can be used as a previous voltage value
else
batteryLow = 0
endif
return