retepsnikrep
Senior Member
I have read with interest Jeremy's 32 bit maths routine, but maths is not my strong point, and I can't understand what i need to do to utilise it.
Basically my problem is this
I have a state of charge indicator which goes from 0-100%.
I am using the number 10,000 to represent the value 100 with two pseudo decimal places.
Now I also have a curent sensor which gives a reading every second between 0-100A. This current reading is used to calculate the Soc on a second by second basis.
I'm happy with the formula. The following discharge rates per second mean I need to deduct the following amounts from my 10,000 value to get the remaining Soc for my 40ah battery.
`1A discharge from 40ah cell = 0.07 per second when 100% (40ah) = 10,000
`40A discharge from 40ah cell = 2.78 per second when 100% (40ah) = 10,000
`50A discharge from 40ah cell = 3.50 per second when 100% (40ah) = 10,000
`100A discharge from 40ah cell = 7.00 per second when 100% (40ah) = 10,000
For example if the battery is discharging at 40A then it should last 1hr before it is exhausted (ignore any puekert stuff here) so 2.78 x 3600 (seconds/1hr) = 10008 near enough to 10,000 or 100%
The problem is of course I can't work with 2.78 or the other decimal values, and if I multiply both sides of the formula then I quickly exceed the 16 bit integer limit.
It seems an ideal candidate for the 32 bit maths unless anyone else has any ideas? I have previously used the average current per minute which worked but I want to update the soc every second so need much bigger integer numbers.
Jeremy can you guide me a bit as to how to use your routines?
If I could multiply both sides by 1000 then the problem is solved.
So my starting Soc would be 1000000 and 40A discharge would be 278
1000000 - 278 would give me the soc after one seconds discharge at 40ah.
Grateful as ever for ideas/help.
Basically my problem is this
I have a state of charge indicator which goes from 0-100%.
I am using the number 10,000 to represent the value 100 with two pseudo decimal places.
Now I also have a curent sensor which gives a reading every second between 0-100A. This current reading is used to calculate the Soc on a second by second basis.
I'm happy with the formula. The following discharge rates per second mean I need to deduct the following amounts from my 10,000 value to get the remaining Soc for my 40ah battery.
`1A discharge from 40ah cell = 0.07 per second when 100% (40ah) = 10,000
`40A discharge from 40ah cell = 2.78 per second when 100% (40ah) = 10,000
`50A discharge from 40ah cell = 3.50 per second when 100% (40ah) = 10,000
`100A discharge from 40ah cell = 7.00 per second when 100% (40ah) = 10,000
For example if the battery is discharging at 40A then it should last 1hr before it is exhausted (ignore any puekert stuff here) so 2.78 x 3600 (seconds/1hr) = 10008 near enough to 10,000 or 100%
The problem is of course I can't work with 2.78 or the other decimal values, and if I multiply both sides of the formula then I quickly exceed the 16 bit integer limit.
It seems an ideal candidate for the 32 bit maths unless anyone else has any ideas? I have previously used the average current per minute which worked but I want to update the soc every second so need much bigger integer numbers.
Jeremy can you guide me a bit as to how to use your routines?
If I could multiply both sides by 1000 then the problem is solved.
So my starting Soc would be 1000000 and 40A discharge would be 278
1000000 - 278 would give me the soc after one seconds discharge at 40ah.
Grateful as ever for ideas/help.
Last edited: