tonymillar
New Member
Hi. I have a strange problem with ADC. I have spend many hours trawling thru the forum & have implemented a number of various suggestions, however the anomaly remains. I am trying to monitor the battery voltage of a 12V SLA battery connected to a solar charging panel. The solar panel is diode connected to the battery. The output of the battery is directly connected to the voltage monitoring divider and an LM7805 regulator. The divider is currently 3k & 500 (exactly) ohms, with there having been many iteration of larger values. Up to 100K & 5K. The 08M2 runs from the 5V output of the regulator and is heavily decoupled. The divider tap is connected to C.4. I have tried decoupling the the ADC input with a number of different caps - .001uF to 100uF and combinations of those (currently .02 & 10uF). The ripple on the divider tap is less than 0.1mV on my scope. The battery voltage is stable at 12.57V & the voltage divider tap point is stable at 1.78V on my Fluke multimeter. Total current draw from the battery is 97mA and stable. The ripple on the 5V rail @ the 08M2 is less then 10mV. Code follows:-
#picaxe 08m2
#no_data
FVRSETUP FVR2048
ADCCONFIG %011
init:
symbol voltin = C.4
symbol voltsraw = b1
symbol voltscaled = b2
symbol hunvolts = b3
symbol tensvolts = b4
symbol onesvolts = b5
symbol tenthvolts = b6
serout C.1, N2400,(254,1)
serout C.1, N2400,(254,128)
main:
FVRSETUP FVR2048
ADCCONFIG %011
readadc10 voltin,voltsraw
voltscaled = voltsraw * 14/10
gosub voltlog
debug
pause 2000
goto main
voltlog:
bintoascii voltscaled,b4,b5,b6
serout C.1, N2400,(254,1)
serout C.1, N2400,(254,128)
serout C.1,N2400,("Volts ",b4,b5,".",b6," ")
return
Debug shows the raw ADC value in C.4 fluctuating between 63 and 144 - a huge swing. I have tried using an accumulator and averaging over a few minutes, but it is the huge fluctuation in the raw input that has me flummoxed. Thoughts please. Thanks.
Tony
#picaxe 08m2
#no_data
FVRSETUP FVR2048
ADCCONFIG %011
init:
symbol voltin = C.4
symbol voltsraw = b1
symbol voltscaled = b2
symbol hunvolts = b3
symbol tensvolts = b4
symbol onesvolts = b5
symbol tenthvolts = b6
serout C.1, N2400,(254,1)
serout C.1, N2400,(254,128)
main:
FVRSETUP FVR2048
ADCCONFIG %011
readadc10 voltin,voltsraw
voltscaled = voltsraw * 14/10
gosub voltlog
debug
pause 2000
goto main
voltlog:
bintoascii voltscaled,b4,b5,b6
serout C.1, N2400,(254,1)
serout C.1, N2400,(254,128)
serout C.1,N2400,("Volts ",b4,b5,".",b6," ")
return
Debug shows the raw ADC value in C.4 fluctuating between 63 and 144 - a huge swing. I have tried using an accumulator and averaging over a few minutes, but it is the huge fluctuation in the raw input that has me flummoxed. Thoughts please. Thanks.
Tony