dillond666 wrote:
Hi folks,
Peter, could you possibly explain in simple terms, the following bit of the slave code as mathmatical operations have never been my strong point.
`Add cell voltage inverting and conditioning
`routine here to make cell V value
`*25/25 to improve integer math accuracy +- 0.02 RESULT is * 1000
CellVoltage = RefVADC *25 /RefADC * 100 /25
I have bought the picaxe 8m and 18x project boards and the green book thingy. Thanks for bringing the picaxe to my attention, it is a fascinating bit of kit, my imagination is doing overtime!
Ahh Got me

, I had to get some help on this as well from the excellent Picaxe forum.
http://www.picaxeforum.co.uk/showthread.php?t=8624
The Picaxe Basic is limited to integer only arithmetic with a max 16 bit value of 65356 or something. So all arithmetic has to take this into account and result must fit into a 16bit word.
The Picaxe 08M adc10 input has 10 bits of resolution that's 1024bits or 0-1023.
My Picaxe 08M is measuring the 1.25v ref voltage. That's the only stable voltage!
The result of this reading of the static ref V will change as the pic supply (cell voltage) changes. So you have work out the result.
So Imagine the cell voltage is 4V that would give an adc10 result for the 1.25v ref of 319
1023/4*1.25=319
If the cell Voltage is 2V that would give an adc10 result for the 1.25v ref of 639
1023/2*1.25=639
The equation (CellVoltage = RefVADC *25 /RefADC * 100 /25) basically scales the result up to make maximum use of the full 16 bit integer maths available to reduce errors and convert result.
Picaxe basic maths is strictly left to right so discarding any decimal places along the way the equation with a 4v supply is below.
1279 * 25 = (31975) / 319 = (100) * 100 = (10000) / 25 = 400 (4.00v)
Try it for 2V (639) and see what you get.
I still don't fully understand all of it but it works so that's fine by me.
