Simple ebike 'fuel gauge'

kvoldulfur said:
Cheap and small 5v power supplies : A friend has just loaned me a controller with a cycle analyst plug built in (6 pin connector) which has made me rethink my power options.

For PIC and little associated logic circuit supply I use a drop resistor, zener BZX-C5V1 and ceramic 100nF 50V cap. as a filter. This gives me 5.1V and does not have to be too precise. For 12V I use 2k2 resistor. The PIC is quite happy, and I drive 741 and gate of a MOSFET switch with it.
Cheap and cheerfull, tried and tested on 10-16V.

otto
 
Jeremy Harris said:
otas said:
Exactly, but I wanted to KISS - keep it simple s... LED's will start dropping off after approx 70% remaining power, which I think is acceptable. For me at least...

I'm not sure that this will really be the case. I did something similar to lower the trigger voltage of the LEDs on my throttle (I just used a series resistor, as it turns out that the current variation as the LEDs turns on isn't that great) but found that the indication wasn't that reliable. I was running on a pack of Headway LiFePO4 cells at the time, that tended to sag a bit more then LiPo under load, but one thing I noticed was that the LEDs tended to drop as the power came on then recover back at lower power settings. Leaving the bike off for a few minutes would restore the "full power" indication as the cell terminal voltage recovered, even when I knew that the battery pack had to be close to being fully discharged. Trying to interpret the voltage drop under load with the battery charge state was difficult, which is why I opted to build this meter instead.

Jeremy

Jeremy, I agree, this is far from your elegant and precise power meter, I have tried the same, first the drop resistor, which I found not very good, than voltage divider, which had to have relatively small resistances to have the output suitable for 5k ohm "LED voltmeter/indicator". I did not want to waste precious energy on the voltmeter. Therefore my low impedance emitter output with voltage divider in the base. I have just rode the bike and my Zippy's do recover very slightly after a load, but as an indicator of battery voltage it works fine. It shows pretty well the near full, middle and near end of the charge.

otto
 
otas said:
Jeremy Harris said:
otas said:
Exactly, but I wanted to KISS - keep it simple s... LED's will start dropping off after approx 70% remaining power, which I think is acceptable. For me at least...

I'm not sure that this will really be the case. I did something similar to lower the trigger voltage of the LEDs on my throttle (I just used a series resistor, as it turns out that the current variation as the LEDs turns on isn't that great) but found that the indication wasn't that reliable. I was running on a pack of Headway LiFePO4 cells at the time, that tended to sag a bit more then LiPo under load, but one thing I noticed was that the LEDs tended to drop as the power came on then recover back at lower power settings. Leaving the bike off for a few minutes would restore the "full power" indication as the cell terminal voltage recovered, even when I knew that the battery pack had to be close to being fully discharged. Trying to interpret the voltage drop under load with the battery charge state was difficult, which is why I opted to build this meter instead.

Jeremy

Jeremy, I agree, this is far from your elegant and precise power meter, I have tried the same, first the drop resistor, which I found not very good, than voltage divider, which had to have relatively small resistances to have the output suitable for 5k ohm "LED voltmeter/indicator". I did not want to waste precious energy on the voltmeter. Therefore my low impedance emitter output with voltage divider in the base. I have just rode the bike and my Zippy's do recover very slightly after a load, but as an indicator of battery voltage it works fine. It shows pretty well the near full, middle and near end of the charge.

otto

What about using a little picaxe to drive the leds on the throttle ?. That way it could be made precise to drive all 3 (?) leds.
 
gwhy! said:
What about using a little picaxe to drive the leds on the throttle ?. That way it could be made precise to drive all 3 (?) leds.

Gwhy, there is perhaps a little misunderstanding. The modified throttle indicator works fine with all 4 LEDs working as they should in the max-min-empty display. It has got the usual limitation of estimating the power left by measuring voltage across cells as any voltmeter would have. Slight drawback is, that it still shows HI - as in 100%, when the voltage difference between 4.2V and 3.2V is down to 80%. The middle, low and empty at 32V for 10S 40V pack is shown correctly from this point on.
otto
 
otas said:
gwhy! said:
What about using a little picaxe to drive the leds on the throttle ?. That way it could be made precise to drive all 3 (?) leds.

Gwhy, there is perhaps a little misunderstanding. The modified throttle indicator works fine with all 4 LEDs working as they should in the max-min-empty display. It has got the usual limitation of estimating the power left by measuring voltage across cells as any voltmeter would have. Slight drawback is, that it still shows HI - as in 100%, when the voltage difference between 4.2V and 3.2V is down to 80%. The middle, low and empty at 32V for 10S 40V pack is shown correctly from this point on.
otto


Yes ok I see what you mean now. I am not driving the led battery gauge on the throttle myself, but drive 2 leds ( 4 levels )from the picaxe to indicate the drop between 4.2 and 3.2 but now rethinking about using the throttle leds my not be possible because how they are configured.
 
amberwolf said:
What, no pics of the sacrificial victims, showing their cratered epoxy housings? ;)

There was no excitement, no magic smoke, just wouldn't download once I got it on the right voltage.

I got no change in the fuel level and no current reading on my first ride. I'll switch the shunt leads and see if that's the problem.
 
Well I got my software all figured out and the board into a box. My setup is self contained from the controller and would be mounted on the handle bars and just tied to battery voltage and my current hall sensor. The final specs around 30 - 110v, 200a, with a 30ah maximum. Here are a couple photos of the almost finished case, I really wish I would have waited to just make the slot on the mill but I wanted it working NOW :p

Ps that is a watts up with my current sensor on the line for testing.

meter3.jpg


meter2.jpg


meter1.jpg
 
Hi Magudaman, nice job, shame about the slot. What about drilling individual holes, if no mill is at hand?

otto
 
A technique I've used to make waterproof "windows" for displays, and cover up mishapen cut outs, is to draw a front panel in black with a drawing or CAD programme, leave a white bloc the exact shape you want for a display window, then print it on to a bit of ordinary paper. Next, trim the paper to size and cut out the white block with a very sharp craft knife. Finally, laminate the cut out bit of paper usign a cheap plastic film laminator. This gives you a front panel with a clear window in it that you can just glue on to the box.

Jeremy
 
I swapped the shunt wires and I see the meter move. Yay! I just finished mounting my new MAC hub. Looked over and saw my rim liners setting there. Oops, crap. Oh, well. Too late now. Hope the rhyno rim is smooth enough to not matter.

Off for a test ride.

Thanks for the design, Jeremy!
 
Just saw one of these at the LBS. I think it was $6, aluminum, intended to mount a standard drink "bottle cage" onto the handlebars. One thing I like about it, is that it can be attached without removing the grips or any other thing from the handlebars. If its too tall, you can easily cut off one of its ears (I dub thee, the "Van Gogh" mount), $4 plus tax & shipping:

http://yhst-84224226242177.stores.yahoo.net/vohatowaboca.html

handlebar_to_water_bottle_cage_mount.jpg


bt-0002_1.jpg
 
All this crappy weather lately has brought me indoors as well as the need to finish 2 scooters I had promised my nieces. I really like the simple meter Jeremy had found and decided that was the perfect meter for the razor e300 scooters. I wanted something simple enough for them to follow without numbers. I decided to use pics, since I have a whole development platform for it. I will use a smaller pic for the final layout as well as incorporate a low voltage cutoff circuit.

Currently it’s working fine on my desk, just working out features to add. This meter worked out well for this project.
 

Attachments

  • lab work.jpg
    lab work.jpg
    70.1 KB · Views: 3,647
  • Meter.jpg
    Meter.jpg
    55.7 KB · Views: 3,646
Jeremy,

I love your "fuel gauge" it is exactly what I was looking for. Do you sell these at all? I have tried to search online in the forums but have not been able to find one. Please let me know what the cost is and I could send you payment via PayPal.

Thanks,

Doug
 
Doug,
Jeremy took some time off from bicycle stuff so he could have move time to build a new house for him self. His last post was Sun Dec 25, 2011

Why don't you build a Simple ebike 'fuel gauge' ? and I will buy one from you.
 
Thanks for the info Marty, where are you from in Buffalo? I live in FL now but grew up In Alden
 
I know this is old, but is anyone still watching? I am going to try and build this. Where would I hook into my ebike system. I have a Prodeco Phantom X.
 
Same place as a Watts Up or Cycle Analyst (as mentioned in the first post) would go: between the battery and the controller.
 
Ok, now I'm going to sound really stupid! On my phantom-X, I don't know where the controller is and I can't find any diagrams anywhere... I suspect it is in the plastic housing on the battery rack, just forward of the battery. See attached image. Battery slides into contacts which are presented here. Or could the controller be built in to the removeable battery? Sorry if this all sounds like simple stuff.

On another note, what would the pro's and con's be between Jeremy's gage and the Watts up?

Thanks!
 

Attachments

  • phantomx controller.jpg
    phantomx controller.jpg
    14.4 KB · Views: 1,020
Still tinkering and trying to build this with very little electrical background, so hope these aren't dumb questions.

From early in this post:
There's nothing in the little handlebar box except the meter and display, the stuff that drives it sits inside the controller case. The controller already has a shunt for measuring current, which is easy to tap into, so this is what I used. The controller circuit is a tiny module about 1.5" x 1", covered in heatshrink, that just stuffs inside the controller case. A thin four core cable runs up to the display on the handlebars. The module is powered by the 5V supply on the controller (it only draws a couple of mA or so).
*****
1) "The controller already has a shunt for measuring current,"... is this the ebike controller? If so, how can I find the shunt to tap into on my controller?
2) "The controller circuit is a tiny module about 1.5" x 1", covered in heatshrink, that just stuffs inside the controller case."....Does this tiny module covered in heat shrink have the reset switch on it?
3) "The module is powered by the 5V supply on the controller"...is this the ebike controller? If so, how can I find this on mine to tap into?

Other questions:
4) What switches would you recommend for the reset and mode switches
5) When you switch to current mode vs soc mode, what does the display look like?

Any remedial help appreciated!
 
Me again. Still haven't given up. Have all the parts. Now trying to put together on a breadboard. Here is a picture of the Phantom X controller. I see the shunt but not sure how to locate the 5V supply
 

Attachments

  • phantomx controller med.jpg
    phantomx controller med.jpg
    51.1 KB · Views: 2,470
It is just voltmeter - very inaccurate indication of SOC of Lithium battery.
For Lead Acid can be more useful.
BUT cheap.
There is no way around it - real gauge must measure real Ahours/Aminutes/Aseconds going out of battery and compare it with stored Ahours of fully charged battery/100% SOC/
I love my CAnalist , need real Ah displayed, no bars, bars are always more or less approximation.
 
Jeremy Harris said:
And here's the code:

Code:
;Simple 'fuel gauge'


main:

	SYMBOL Capacity = w0					;Capacity holds battery capacity remaining in amp seconds (18.2 Ah max, due to 16 bit 

limit)
	SYMBOL Current = w1
	SYMBOL Voltage = w2
	SYMBOL DisplayCapacity = w3
	SYMBOL DisplayCurrent = w4
	SYMBOL Averagecurrent = w5
	SYMBOL loopcounter = b12

startup:

	;read value of Capacity stored in non-volatile memory
	READ 0, WORD Capacity
	
	
	;Read supply voltage (assumes divider of 120K and 10K, giving 1023 = 65V)
	READADC10 1, Voltage
	
		
	;Reset capacity to 10Ah (36,000 amp seconds) if reset button (which disconnects the voltage sense) is pressed at power on
	IF Voltage < 50 THEN LET Capacity = 36000
	ENDIF
	
	;check for capacity over-range from misreading
	IF Capacity >36000 THEN LET Capacity = 36000
	ENDIF
		
	;Wait for power to settle on power up for more accurate ADC readings and allow time for reset button to be released, 5 second delay
	PAUSE 5000
	
		
mainloop:

	;setloop time calibration output pulse high (use serial out pin for calibration pulse)
	HIGH 0

	;reset averagecurrent drawn over last second to zero
	Averagecurrent = 0
	
measurementloop:

	;take 100 measurements and sum the results to give amp seconds (mainloop time is 1 second)
	FOR loopcounter = 1 TO 100
	
	;Check for battery voltage below about 25V (indicating power going off) and not in reset mode, every 1/100 second
	READADC10 1, Voltage
	IF Voltage < 400 AND Voltage > 50 THEN GOTO poweroff
		
	;Take current reading using voltage across controller shunt. A/D current reading is 321 for 50mV across 5mOhm shunt = 10 amps (~ 31mA 

resolution)
	READADC10 4, Current					
	;At this point Current can be any value between 0 and 1023 (~31.87A)
	
	;divide current by 2 to remain within 16 bit limit during summation
	Current = Current / 2
	;At this point Current can be any value between 0 and 511 (for 0 to 31.87A)
	
	;add current to averagecurrent over one second
	Averagecurrent = Averagecurrent + Current
	
	;Add loop delay time to make main loop execution 1 second	
	PAUSE 4
	
	NEXT loopcounter
		
	;At this point Averagecurrent can be any value between 0 and 51,100 (~31.87A)	
	
	
backtomainloop:
	
	;set loop time calibration output pulse low
	LOW 0
	
	;Add loop delay time to make main loop execution 1 second	
	PAUSE 70
	
	;Divide Averagecurrent by 146 to convert to ~ 330 = 30A ~ full scale for Displaycurrent to drive current display mode
	DisplayCurrent = Averagecurrent / 146
		
	;Convert Averagecurrent to amp seconds, based on 1 second main loop time
	Averagecurrent = Averagecurrent / 1603
	;At this point Averagecurrent can be any value between 0 and 31
	 	
	;Averagecurrent is in amp seconds and loop time is 1 sec, so each time around loop current x amp seconds are subtracted from capacity
	Capacity = Capacity - Averagecurrent				
	
	;DisplayCapacity is used by PWM command in remaining capacity mode, where 330 equals full scale of 10Ah (36000 / 330 = 109)
	DisplayCapacity = Capacity / 109			
	
	;Check for less than 10% battery capacity remaining and exit to low battery warning routine
	IF Capacity < 3600 THEN GOTO batterylow
	IF Capacity >=3600 THEN GOTO display
		
		
display:

	;Mode switch takes pin 3 high or low, low = capacity remaining display, high = average current over last second display
	;99 sets 10kHz on timer, max duty cycle range on PWM is 0 to 330 for 0 to 100% full scale on meter (400 gives overload indication)
	;Check mode switch and output appropriate PWM stream to simple D/A that drives meter
	IF PIN3 = 0 THEN PWMOUT 2, 99, DisplayCapacity ELSE PWMOUT 2, 99, DisplayCurrent
	ENDIF
	
	GOTO mainloop
	
	
batterylow:

	;Set meter to overload display as a low battery warning (all bars flashing) when in capacity mode
	IF PIN3 = 0 THEN PWMOUT 2, 99, 400 ELSE PWMOUT 2, 99, Displaycurrent
	ENDIF
	
	GOTO mainloop
	
poweroff:

	;save value of Capacity in non-volatile storage for use on next power up
	WRITE 0, WORD Capacity
	END

Hopefully this should be fairly easy to work through. If you want to change the battery capacity then you need to change the value that the variable Capacity is reset to in this line:

Code:
;Reset capacity to 10Ah (36,000 amp seconds) if reset button (which disconnects the voltage sense) is pressed at power on
	IF Voltage < 50 THEN LET Capacity = 36000
	ENDIF


Is that assembly? I've never seen code like that other than what I did in my architecture course. Why did you choose to write it like that?
 
Back
Top