Go Down

Topic: 48v eBike voltage display (Read 330 times)previous topic - next topic

Sven3006

Jun 14, 2018, 12:09 am
Hi all!

Lets start with the common thing.... I'm new here  I've used the search function but could not find what i wanted.

I'm working on a little project for my eBike to installe a display which will show me the battery voltage and percentage. Measuring the voltage is very accurate with only a difference of around 0.3V. Still running it on the test breadboard. Percentage is running good too but the only problem is that, lets say 54 volts ( equals 100%) and 0 volts would be 0 %. I need to have that 54V is 100% and 39V is 0%.

I'm not sure if I have worded it correctly. The coding is not perfect.

I would like to get some advice how i can make the percentage working for only the 39-54 volts. Hopefully I did post it in the right place.

Wawa

#1
Jun 14, 2018, 12:47 amLast Edit: Jun 14, 2018, 01:15 am by Wawa
Need to learn the map() and constrain() functions.

percentage = map(value, 674, 934, 0, 100); // numbers calculated for 39volt and 54volt

Note that battery voltage is a poor indicator of remaining charge.
A better (and more complicated) way is a coulomb counter.
Leo..

mauried

#2
Jun 14, 2018, 10:26 am
Ebikes mainly use Lithium Ion batteries and the voltage alone gives an extremely poor
indication of capacity left.
Coulomb counting is really the only way , and its not that great either.

Sven3006

#3
Jun 15, 2018, 04:09 pm
Need to learn the map() and constrain() functions.

percentage = map(value, 674, 934, 0, 100); // numbers calculated for 39volt and 54volt

Note that battery voltage is a poor indicator of remaining charge.
A better (and more complicated) way is a coulomb counter.
Leo..
Thank you for giving me the hint of the map function. I finally have it working. I know it will be not 100% accurate but at least I have something to go with. I will give it a couple charge and discharges to see how well it will work.

I used
Value = analogRead(A0); //collect data from pinA0
Mapped = map(Value, 398.97, 1023, 0, 100);

398,97 will be the low 39V and 1023 the 54.6. Everything has to go on a PCB board so i can get rid of voltage loss and adjust the Vin on pinA0 and Vout

Wawa

#4
Jun 16, 2018, 12:14 amLast Edit: Jun 16, 2018, 12:16 am by Wawa
Map() only works with integers, so 398,97 won't work. Use 399