E-bike control system w/BMS, lights, controllers, chgr, etc.

oldswamm

100 W
Joined
Aug 21, 2010
Messages
169
Location
Bethel, Alaska
What I’ve been working on for the last 3 or 4 months is a whole bicycle control system. I’m concentrating on circuit/board design, as I intend to order boards out of China in mid Oct, so I’ll have time to get started on the programming while I wait on them (I think I have a pretty good idea for most of the routines). Anybody have experience with dirtypcbs.com?

Other than batt+ to the controllers, and the phase wires, the only wiring on most of my bike will be a 3 wire harness. +12 volts, G (not really ground, but labeled so), and a serial LAN.
Beyond simplified wiring, my goals are better control and integration for multiple motors, improved (safer) 3 way, improved cruise control, good voltage based regen control (Lebowski did the work for me there), antispin/traction control. I’ll elaborate more toward the end of this post. I’ll also put a zip at the very end of this post with gerbers, renders, schematics, etc.:

I (mostly) have boards designed for the following:

A handlebar display, which would also be the master controller, and would serve ALL handlebar electrics, with inputs for 4 buttons, 4 throttles, a 3way, and turn signals, and outputs for 2 separate displays.

Motor controllers using Lebowski’s controller chips.https://endless-sphere.com/forums/viewtopic.php?f=30&t=72728&p=1098267

A BMS.

A battery charger.

Turn signals, head, and tail lights. I just narrowed this one, so it still needs major work. No schematics or pcb drawings yet (soon), but there’s an image with the current LED layouts.
A board for in the motors, which will put hall and temperature data on the LAN, and will also be capable of controlling fans (or a relay). I just finished the first version of this one since realizing that it couldn’t be done in through hole (to thick), and it’s probably functional, but a messy looking pc board. ;)

Since the system is basically open, almost anything could be added, such as GPS, compass, anemometer, camera control, even an integrated motion alarm and audio.

The boards are designed for everything solid state to be through hole (other than a few diodes, and the board in the motor), and most of the caps and resistors to be surface mount.

Following are a few details on individual modules:

The handlebar unit uses a 40 pin PIC16F1719 (tentatively). There is provision for a temperature compensated real time clock, as well as battery backup to keep it current. There is a circuit to switch the power to throttles and other current drains, as well as another transistor to switch an external 5 volt source for higher current loads such as displays (I would like an LED display (for cold), and would use a separate 5v DC-DC in the battery box), and yet another one to switch the LCD’s LED power. There are pilot holes and space so I could easily drill holes to match a large number of displays, from 122mm to 185mm (outputs for 2 separate displays). I have provision for an iButton interface on this board, which I intend to use both for a key, and for data retrieval. I also made provision for a sparkfun BlueSmirf, so maybe I can interface to a cell phone’s Bluetooth, and hopefully control music and phone functions, and possibly even use it for a display (I know little about Bluetooth, and less about what it would take to write the app(s).

The BMS uses a separate processor for each cell, in a chain of attached boards, which can be ‘broken’ into blocks to match the balance connectors. The processors only draw around 25uA in sleep mode, which is how they will spend virtually all their time, so current draw is miniscule. They communicate daisy chain from one to the next, simply adding data to the end of the received data string, the first word of which would be the command, followed by a ‘cell count’ byte, and sending it on (with a new CRC). The negative end processor is the master and communicates with the bikes LAN and/or the charger. Each cell’s processor takes an ADC measurement of a 2.5v voltage reference, using the cell voltage as the ADC reference (actual cell voltage has to be calculated). I would also measure the cell voltage (Vdd) using the internal reference, mostly for a check. Both ADC results, as well as a temperature measurement, and of course the cell # and a CRC, would compromise one packet of data sent out on the LAN. By breaking it up, into packets, I can help avoid collisions, and easily control the data flow. These processors would expect a cell with 4.200V (or as close as I can get) connected to them on first power up, or after getting a ‘recalibrate on next power up’ command. There’s no provision for current control other than communication with the bikes processor. Oh yea, they can discharge up to 35mA for balancing (if 35mA, (up to24hr a day), isn’t enough, you need a new battery…). The processor, transistor, and references are mounted from below, so they will provide a relatively smooth surface against the battery, and the processor’s temp sensor will give a good approximation of cell temps. Any differences in temp would indicate trouble, and it might be interesting to see how cold the battery actually gets, and how much performance actually suffers.

The battery charger has its own serial interface and power supply, so can function with the battery on or off the bike. It has triacs to control up to 3 AC sources, for automatic current selection. There’s provision to measure the charge current (10A max as drawn), and of course battery voltage. Since each BMS is uniquely serial numbered, the charger (or bike) can recognize which battery is connected, and also retrieve charge/discharge-rate/limit data which would be stored in the BMS master.

The In Motor board has inputs for the 3 halls and 2 thermistors. The hall data would be given priority on the LAN, but with Lebowski controllers, I would probably only use hall info for tire speed, for slippage detection, and possibly for a speed control mode in the controller. There’s also a mosfet to control fans (or a relay), and a shunt to measure the fan current.

The light board consist of 16 LEDs arranged as an arrow on each side and 21 LEDs in an array for a head light with white LEDs, or the tail/stop light with red LEDs. There’s also provision for side markers with 4 or 8 LEDs which can be separately controlled so they can flash out of sync with the arrows. I put a current shunt on the LEDs, so they could maybe be programmed for current, rather than just pulse width, for more voltage independence.

I also have a couple boards partly designed to switch current via a mosfet, to use as high power switch, for a headlight for example, and for a low voltage cutout on the 12v backup battery which also has provision for a simple on/off charge control for the 12v batt.

Each board in the system will have a unique serial #, or address, which will also indicate its general function.

What do I hope to accomplish with this system?

Good control of 2 (or more) motors for off road use.

Programmability. If I want something to function differently I can change it later on.
For example, it should ‘learn’ the throttle, then allow full throw less a programmable dead band.

For the 3 way, I think shifting to a less aggressive throttle curve should be immediate, but to a more aggressive curve should require the throttle to be backed off till it matches the new setting (back off till you feel a slight reduction in power, then you can go for it). Or it could be programmed how you think it should work, if you have a better idea.

The cruise control should control the bikes speed, period (unless you hit a current limit of course). A single click slows N mph (N being programmable) and a dbl click increases a like amount.

I’ve included a button specifically for limit override. I’ve too many times gone for an opening in traffic, only to remember to late that I had a speed or current limit set. The limit override would make full power available no matter what.

I want to be able to control everything from limits and other setup parameters, to what music I’m listening to without taking my hands off the handlebars. I not only have single and dbl clicks available on my 4 buttons, but I can also use the long hold and even triple clicks for alternate functions.

One operating mode I want to include, as well as ‘legal’, ‘economy road’, ‘HP road’, and a couple off road modes, would be a speed controlled mode. Set the throttle to 5mph and that’s the speed it goes, uphill or down, through mud, snow, or on packed ground, over obstacles or through depressions. No coming up against an obstruction, stopping and having to power/push/lift over from a dead stop, especially when I’m ‘walking’ the bike through the rough. If traction control is off, and the bike did stop moving, the tires would continue to grind away at the set speed.

For traction control, I was thinking I would set up maximum acceleration tables for several different currents (I can extrapolate for others), and if either wheel accelerated faster than that, it’s spinning. I can also compare the 2 motor speeds, but that would have limitations too. My tentative plan, at least for one traction control mode, when spinning is detected, would be to send a command to the relevant motor controller, telling it to go to a specific speed, or to resume the stored speed from a specified number of milliseconds ago, then, when spinning stops, go back to a fraction (all such parameters are programmable) of the previous current, then gradually ramp it back up.
When accelerating or climbing, where the front wheel has minimum ground pressure, its speed could be limited to say, 103% of the rear. Feedback from the front suspension sensor could also be used to sense when the front wheel was nearly off the ground and limit the rear wheel torque (anti flip/anti wheelie, selectable of course). If either wheel leaves the ground, the speed should be maintained till contact is resumed.

If I get a one wheel trailer, it would have its own motor, fully integrated into the system. I think an AWD 3 wheeled bicycle (or is it an inline tricycle?) would be great in the snow, as long as things were kept under control (wouldn’t want the trailer pushing you too much).

I would like to have a sophisticated ‘fuel gauge’, that would be capable of estimating, and implementing the current and speed limits necessary to get home on a remaining charge, based on stored and realtime GPS data including altitude changes, and possibly wind speed from a simple propeller type anemometer (and readjusted based on actual current draw, after starting back up the hill against the wind toward home). It would also give me a low battery warning with more charge left, the farther I am from home. I said 'like', not necessarily 'will'.

I don’t need the serial interface on the bike to be very fast. It’s my intention to write the program so it tests the speed to every board at startup, and occasionally during operation, then operate at maybe 10% of the slowest. Also, if the test speeds drop, it’s an indication that something’s wrong (possibly just external noise, but a record of its effect would be interesting for the prototype).

Sorry again for being long winded, but I still didn’t include a tenth (or even 1/100) of what I could have… ;)
View attachment gerbers etc.zip
 
Sounds like you're actually building what I once tried to work out the design for. :)

But it seemed a bit more familiar than just that--is it the same system as this one?

https://endless-sphere.com/forums/viewtopic.php?f=2&t=34422

I was disappointed when you never came back to that thread...had been hoping to see and help with it's evolution. :(

Hopefully there will be more of it in this thread (or if they are the same system, maybe merge the two?).
 
I pretty much abandoned that project when I broke my hip in the spring of 2012, and have hardly been on ES since. I was actually without a bike for a while (sold almost everything just to survive).

It's hardly the same as the earlier effort, but still uses the same serial interface, and is an extension of that idea. I've done a little learning and a lot of thinking in the mean time. I would still like to use the LED array I bought at that time, but the older I get, the less riding I do at sub zero temps anyway.

As for merging the two, the other posting is obsolete is why I decided to start a new thread rather than going back to that one. As far as I'm concerned it could be taken down. The biggest change is actually my decision to have boards made rather than making them myself, which is what I've been doing for the last 45 years. I would say the controller portion would be almost impossible with my homemade boards.

Aw, Amberwolf, this is the first I knew of your fire. I noticed your avatar, but didn't realize what it meant. I've been reading your 'fire blog' and crying for the last several hours. Most people don't realize how close those of us who live alone with our animals get to them. When I had cats, fire was one of my worst fears (wouldn't have mattered that they would probably be the cause of it). My dog is seldom left in the house when I'm not home, so at least that's not such a worry for me. I'm glad you have the support to help you get through it.

Bob
 
oldswamm said:
I pretty much abandoned that project when I broke my hip in the spring of 2012, and have hardly been on ES since. I was actually without a bike for a while (sold almost everything just to survive).
Ouch...I'm sorry you went thru that. I fractured an ankle around the same time you broke your hip (or was it the year before?), and it was bad enough for me; I can't imagine how bad it was for you. :(




As for merging the two, the other posting is obsolete is why I decided to start a new thread rather than going back to that one.
Ah, ok. There's times people have a project hiatus or even simply stop posting to ES during development, then come back and make a new thread (or several) about the same project, having forgotten that they even ever posted about it before. ;)

So if I happen to see that, I'll put a reminder in the new thread for them, in case they want to use the old thread.



Aw, Amberwolf, this is the first I knew of your fire. I noticed your avatar, but didn't realize what it meant. I've been reading your 'fire blog' and crying for the last several hours. Most people don't realize how close those of us who live alone with our animals get to them. When I had cats, fire was one of my worst fears (wouldn't have mattered that they would probably be the cause of it). My dog is seldom left in the house when I'm not home, so at least that's not such a worry for me.
The two I have now, Tiny and Yogi, have full access to outside, and generally run outside whenever the smoke alarm goes off (like when I'm cooking; the alarms are overlly sensitive), but I am still always worried when I am not here that something will happen and they won't go outside. It's too hot to keep them out there, and other bad things could happen even there. Paranoia, I'm sure, but I can't help it.

Might be adding a third one, Bernie, sometime soon, depending on how Tiny and Yogi react to him, and he to them. Don't know anything about him yet other than he's 9 years old, and freshly neutered.

I'm glad you have the support to help you get through it.

I still haven't really gotten over it, though I'm considerably more functional than I had been, and most of the nightmares are gone (there are still some now and then). I've changed, inside, in a few ways I know of and others I probably don't. Some good, some maybe not. But here on ES, a few on another forum, and a few local people, have helped me more than I could have imagined, and I doubt I would have made it without the help.
 
Very interesting. I was just thinking on this subject for next build, as my off the shelf 3 LED fuel gauge was very useless.

I was wondering how good a "sense resistor" would be if it was just the wire which connects the batteries to the controller? If that wire was 12 inches of 10 gauge wire it would be about a 1mΩ resistor.

Your thoughts?
 
Sorry to have taken so long to post an update, and reply to speaker guy.

Speaker guy, this goes WAY beyond a fuel gauge or even the CA, which I still recommend heartily. :D Actually one of my very first posts on ES suggested the idea of using the copper wires to measure the current, but it's not a good idea, primarily because of copper's large resistive temperature coefficient. I'm convinced the hall sensor type are the best, even though they are expensive.

I have all the parts to build the system with 3 controllers, one with IRFB4115s, one with FDH055N15As, and the third will depend on the tests with the aforementioned FETs.

But, I decided the project needed a 3d printer to complete like I want to (as well numerous other projects, both bike and non-bike). I ordered a kit in Sept, and STILL don't have a 3d printer operational due to what is often referred to as a 'comedy of errors' (although this one has stretched my sense of humor), my mistakes were mostly in my choice of who to do business with.... But, all my money and spare time have been going into project 3d printer (While waiting on kits, and parts, I've designed my own, which I will build as soon as I get the one I (almost) have now, operational, so I can print it), and I no longer have the money to order the PC boards made for this project. I DO have most of the parts to build 3+ 3d printers though. LOL

On top of which I hurt myself in early Oct, and have only ridden once since (that one time hurt), so the bicycle has gotten lower priority of late. Also, since 2 or 3 of my worst injuries have been the result of bicycle accidents, I'm a little paranoid.

I still plan to finish the project, it's just gotten back burnered. Assuming I live out the winter, I'll finish it. ;)

Bob
 
Back
Top