Hello All,
Well I have read several threads on the subject and get the idea you cannot read a battery supply voltage with the Picaxe because the supply is the ADC reference. Well I refuse to give up so easily. I hope I can explain my idea well enough to get help with the math, the part that is not working.
The power supply is (3) 1.5 VDC "C" cells or a base voltage of 4.5 VDC and will run the design to 3.0 VDC. I have added a 2.5 VDC reference to the circuit, attached to AD 2. I have also attached a single cell (of the three) to AD 1.
The 2.5 VDC reference should not change it's output as the cells decay. The plan was this read the 2.5 volt reference the result was 144 bits, then read the single cell 1.5 volts result was 87 bits. So the math looks like this 2.5 / 144 = 0.01736111 * 87 = 1.5104. If we assume the cells will all decay evenly the result could be multiplied by the number of cells, three in my example.
As the supply voltage sags the result for the 2.5 volt reference will increase and so will the results for the "nominal 1.5 VDC" cell. The end result should be the ability to check the supply source with the on board ADC(s).
Now we all know the math above will not work as typed on the Picaxe. I have tried this:
Test_Batteries:
b1 = 0 'Clear Variables
b2 = 0
w5 = 0
readadc 2,b1 'Test Battery needs a AD2 is 2.5 volts
readadc 1,b2 'Single Cell Read
pause 1000
sertxd ("2.5 volt regulator is ",#b1,ret,lfeed)
sertxd ("single cell voltage is ",#b2,ret,lfeed)
W5 = b1 * 10 'keep all references in same power
b3 = 25 // w5 'use 25 for 2.5 as decimal values do not work return the remainder
b3 = b3 * 100 ' get some decimal places
sertxd ("Volts per bit is ",#b3,ret,lfeed)
w6 = b3 * b2 'multiply decimal volts per bit * number of bits of one cell
sertxd ("W6 is ",#w6,ret,lfeed)
I hope this idea may help others with a battery supply that needs to be monitored as well as get some help with my wayward math.
Thanks in advance for any help.
PFM
Well I have read several threads on the subject and get the idea you cannot read a battery supply voltage with the Picaxe because the supply is the ADC reference. Well I refuse to give up so easily. I hope I can explain my idea well enough to get help with the math, the part that is not working.
The power supply is (3) 1.5 VDC "C" cells or a base voltage of 4.5 VDC and will run the design to 3.0 VDC. I have added a 2.5 VDC reference to the circuit, attached to AD 2. I have also attached a single cell (of the three) to AD 1.
The 2.5 VDC reference should not change it's output as the cells decay. The plan was this read the 2.5 volt reference the result was 144 bits, then read the single cell 1.5 volts result was 87 bits. So the math looks like this 2.5 / 144 = 0.01736111 * 87 = 1.5104. If we assume the cells will all decay evenly the result could be multiplied by the number of cells, three in my example.
As the supply voltage sags the result for the 2.5 volt reference will increase and so will the results for the "nominal 1.5 VDC" cell. The end result should be the ability to check the supply source with the on board ADC(s).
Now we all know the math above will not work as typed on the Picaxe. I have tried this:
Test_Batteries:
b1 = 0 'Clear Variables
b2 = 0
w5 = 0
readadc 2,b1 'Test Battery needs a AD2 is 2.5 volts
readadc 1,b2 'Single Cell Read
pause 1000
sertxd ("2.5 volt regulator is ",#b1,ret,lfeed)
sertxd ("single cell voltage is ",#b2,ret,lfeed)
W5 = b1 * 10 'keep all references in same power
b3 = 25 // w5 'use 25 for 2.5 as decimal values do not work return the remainder
b3 = b3 * 100 ' get some decimal places
sertxd ("Volts per bit is ",#b3,ret,lfeed)
w6 = b3 * b2 'multiply decimal volts per bit * number of bits of one cell
sertxd ("W6 is ",#w6,ret,lfeed)
I hope this idea may help others with a battery supply that needs to be monitored as well as get some help with my wayward math.
Thanks in advance for any help.
PFM