I know that having a Watts Up or Cycle Analyst bolted to the handlebars gives you loads of useful information, but most of the time I find I only want to know two things:

1. How much battery capacity do I have left?

2. How much current am I pulling?

For practical purposes you only really need to know either of these to about the same accuracy as the gauges in a car. Analogue meters are easier to read 'at a glance' than digital displays, but look clunky. You can get tiny LCD analogue meters though, that not only look neat but are also weatherproof.

As part of an update to my stealth folder (see the other thread in the ebike photos section) I decided to design, build and fit a simple fuel gauge. This is what it looks like on the handlebars:

Gauge on handlebars.JPG (186.09 KiB) Viewed 5351 times

The small switch changes the display from capacity remaining to instantaneous (well, the sum of 100 samples taken over a second) current. 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). I've left the serial programming port in place (the three pin connector in the next photo) so that I can update the code if needed. Here's a picture of the finished microcontroller module:

Microcontroller module.JPG (216.67 KiB) Viewed 5351 times

The way it works is to store the state of charge of the battery (in amp seconds) in non-volatile memory (so it remembers it when the power is off) and just subtract the Ah used as you draw current from the battery, by measuring the voltage across the controller shunt. There's a reset button on the controller that if pushed at power on resets the gauge to 'full'. The actual capacity is programmed in the code - mine is set for 10Ah. If the battery gets within 10% of being flat, then the display switches to overload mode and flashes all the pointer bars as a 'low fuel warning'. You can still switch to current mode to see how much you're drawing and eke out the last bit of capacity as a 'get you home' measure. It'd be best to always recharge before this point though and this gauge makes that pretty easy to work out.

If anyone wants it I can post the schematic and code. It's not hard to build and the code can be programmed into the chip using free software and the same 5V serial interface used to talk to the XieChang controllers.

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

;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

from 36000 (which is 10Ah in amp seconds) to the capacity of your battery. Unfortunately it's limited as it stands to a maximum of 18.2Ah (65,535 amp seconds). This could be changed by re-jigging the code to use something other than amp seconds as the measurement figure though, but would need some doctoring of multiplication and division factors elsewhere in the code.

The maximum battery voltage it will take at the moment (with the 120k/10k divider) is about 65V. You can change the resistor values to increase this, but may then need to change the value read from the voltage A/D that detect the power going off. At the moment it triggers at about 25V, which is fine. The next graph shows the decay of the +Vbatt line and the +5V line on the controller, with the module connected. It gives a good indication of how long the microcontroller has to detect a battery off event, finish what it's doing, save the current value of battery capacity in non-volatile memory and then shut down. It has ages to do this, in practice it takes only about 1mS to do the full shut down routine!

The plastic box that the meter is mounted on came from Maplin, a hobby store a bit like Tandy in the US. It's an ABS box that measures 50mm wide x 35mm deep x 17mm deep (about 2" x 1.4" x 0.7") and is Maplin part number N78BQ, manufacturers type number 1551GBK. The box is held on to the handlebars using two self adhesive cable tie pads (the ones that take tywraps), with a couple of tywraps then going around the bars. The meter is a Lascar type EMA1710 and mounts with a single 5mm hole. It only has three wires, +5V, 0V and a 0 to 1V input. I fitted a couple of resistors to the back of it to step the voltage down from the crude PWM D/A output on the controller, so that it reads maximum correctly. The meter data sheet is here: http://www.lascarelectronics.com/pdf-us ... 250942.pdf

That is exactly what I should have put on the bikes I made for my parents.

Maybe an auto-reset if it sense pack voltage at HVC for 20 minutes continously or something as an alternative to the switch for people who have extremely forgetful mothers? ( 20 min delay just so it's not activated by mistake during extended regen going down a hill or something, and not activated when the charger just hits the CV stage).

That is exactly what I should have put on the bikes I made for my parents.

Maybe an auto-reset if it sense pack voltage at HVC for 20 minutes continously or something as an alternative to the switch for people who have extremely forgetful mothers? ( 20 min delay just so it's not activated by mistake during extended regen going down a hill or something, and not activated when the charger just hits the CV stage).

That's exactly how I planned to do the reset originally, but then couldn't be bothered to run the pack down, charge it and log the voltage/time curve to work out when to accurately detect a 'full charge' condition. It's one reason the reset button simply disconnects the voltage sense line - I bodged the code to get it working by detecting 0V instead......................

If you can be pretty sure of accurately detecting the voltage rise for full charge, then just remove the push button and change the code so that the IF test in this line:

Thanks Jeremy,Another very usefull device. I have been looking for options for a realtime amp meter to mount to the bars. This is good (as was your mod for re-mote mounting of the Turnigy watt meter). Things like this are great for guys ike me on the fringe of ellectronics. It something I could actually build & use.I will attempt one of these soon & one of the servo drive switches you helped the AussieJester out with for gear changing. the more I consider it the better i like it. Very cool Thanks again. T

Pretty much any meter that will accept a voltage in the range 0 to around 3 or 4V, either directly, or with a potential divider made up from a couple of resistors, would do, so yes, the higher res version of the one I used would be OK. You could even use a clunky looking electromechanical meter if you wanted to, just by fitting a suitable series resistor. I haven't investigated them, but it might even be possible to drive an old car fuel gauge - it depends how much current they need to go full scale.

Thanks, guys. I think there is a gap in the market for something simple like this. I'm guessing that lot's of everyday ebike users, those who just want the bike to work and don't care about the details (and so probably don't frequent this forum), might find a simple capacity gauge pretty useful, in the same way as a fuel gauge in a car is useful.

It's probably not a commercially viable idea, though, as it'd cost as much to manufacture as something far more capable. If it were built in to the controller code then cost would only come down to some form of display, which might make it marketable. The cheapest display would probably be a LED bargraph, they are certainly a fair bit cheaper than the LCD meter I used (I only used that because I had a few left over from another project).

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

Hi Jeremy,Many thanks for posting this up Im just at the stage of getting the parts together myself and have been looking at using 2 of these as a display:

7ledbatmon.jpg (25.89 KiB) Viewed 5159 times

The extra one being using for a realtime battery voltage gauge as to keep a eye on how well the battery is holding up .

Edit: Ok I have just had a re-think and to keep things even more simple ( for me anyway ) is to use one of the other outputs to drive a led to monitor battery voltage ( maybe something like, led on >65% , flashing 65-20%, off <20% ).

There isnt a free output... Maybe I will just hang on till the stuff that I have ordered gets here and just have a play to see what what I can sort out.

Sorry about the lack of free outputs - it's so tight that I even had to use the serial output to kick out the timing calibration pulse. This pulse is used to fine tune the time that the code takes to execute the main loop, if you change the code the duration of the 'pauses' in the two loops may need changing (there is a 'coarse' setting using the pause in the measurement loop and a 'fine' setting in the main loop). You set the time up by making sure that the time between the calibration pulses is as close to 1 second as possible (in practice, +/- 1mS is as close as you can get).

Be very wary of using the Picaxe debug command - it massively slows down the loop and will result in very large Ah errors due to the time error it adds.

You could switch to the 14M, which would give you several more outputs. The main code would work fine on the bigger chip.

Nice to see folk having a go at building themselves one of these - watch this space as there will be another ebike related self-build project posted soon!

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

keyne wrote:Maybe this is a silly question, but how does the circuit take regen currents into account? Won't the shunt have a negative voltage across it during regen?

Not a silly question at all, you're absolutely right. It ignores regen, primarily because the very best regen system might, just possibly, manage to put perhaps 5% or so back into the battery pack. Most of the time regen will probably give less then this. The resolution of the gauge is just over 10% per segment, so regen most probably wouldn't change the indication. The geared hub motor on the bike this is fitted to can't regen, so I didn't try to cover it.

If you wanted to make it regen capable, perhaps with a higher resolution display (which is, perhaps moving away from the simple intention of this gauge), then it would be fairly straightforward to make it measure bidirectional current. Just replace the shunt amplifier with a Hall current transducer and re-jig the code to detect + and - current and add or subtract as required. The LEM LTS range is reasonably priced and works OK: http://www.lem.com/hq/en/component/opti ... antaneous/ but would make the unit too big to fit inside the controller case.

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

I think in this case, regen probably should be ignored, as even if you have it you may not gain enough from it to extend your range significantly on a typical ebike this kind of gauge would be used on, and if you *know* you are getting another 5% out of the system because of regen you can just ignore the low battery warning for that much longer if you choose.

Personally, I think if you want to monitor regen current, you'd probably be more advanced a user than what this simple project is meant to encompass. At that point, a pair of WUs or TWMs wired in mirror-series, or a single CA would be more appropriate.

AussieJester wrote:Very nice work Jeremy, are there any plans to do a small run of these for those of usthat would more than struggle to get one together and working?

KiM

I'm afraid I don't really have the time to build a few, plus there are potential problems with each one needing to be customised to some extent to match controller shunt values, battery capacity etc, that means they're really only a DIY job.

I'd love it if someone just took the basic design and came up with a product that was easier for people to just fit and use. The design changes needed to make it controller independent are simple - just fit an independent shunt, or use a DC current sensor. Making it easily settable for different battery capacities is a bit harder and would mean changing the chip to one with more input pins, so that a selector switch could be added. Pretty easy to do if someone wants to have go at it. If I get some free time I may have a go at changing it to a more universal gauge that doesn't rely on a controller shunt or need reprogramming for different battery capacities.

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

marty wrote:Cycle Analyst tells me more then I want to know. This fuel gauge has always been my dream. The GPS tells me miles per hour. Would someone please start selling a simple battery fuel gauge.

Nice job! - Jeremy

Thanks marty. I'll happily do what I can to support anyone who want to make these to sell for people. I'd love to make some up myself for folk but don't have the time right now to go into production. A production version might be better as a separate module that doesn't depend on being fitted to a particular controller type, but that isn't hard to do.

Jeremy

Please ask questions on the forum, rather than by PM, as it helps others and you'll get a better range of answers.

I have had a quick look to see what would be a suitable (cheap'ish) bargraph driver for leds and the LM3915N-1 would be suitable and very easy for the DIY'er to mount on a bit of vero board, with the addition of 10 leds and a couple of resistors.http://www.farnell.com/datasheets/9060.pdf

Jeremy, Its not your fault that there is no free outputs , I may get a couple of the larger picaxe ( more output/input ) chips to play with.