ebike control electronics

oldswamm

100 W
Joined
Aug 21, 2010
Messages
169
Location
Bethel, Alaska
This project is for ALL ebike electronics except the controller itself. When I finish my controller project it will be both hardware and software compatible.

I've been working on this for several months, and it's quite complicated, please read or at least scan it patiently.

If anyone is interested in this project and would like to help, especially with the software, please PM me (I would like the whole project to remain open source if possible). Also if anyone is interested I can post schematics and PCB drawings. (also note that these PCB designs are for hand made boards. With plated through holes I would redesign.)

The reasons for doing this design:
Programmability!
Minimize wiring.
More sophisticated (programmable) control for multi wheel drive.
Better current monitoring with multi wheel drive.
Safer and more useful 3way switch operation.
Temperature based current limit and/or shutdown.
Speed based cruise control (could have it's own current limit).
Auto sensored/sensorless switching.
Self calibrating for the Hall and sensorless inputs.
Anti spin. Anti wheelie.
True programmable wheelie control would PROBABLY be possible.
Eventually anti skid and anti flip braking (AFB?).

Will describe each board individually. All, except the in hub units, use the same serial interface, which allows 3 wires for most of the bikes wiring, (12V, ground, and the serial line). Would put taps anywhere I think I might stick another board.

Head unit (mounted to the handlebars, or in the cowl):
display + buttons.jpg(Note, the buttons should be below.....) It also could use one LED array instead of the 2 as drawn.
Uses a PIC 18F46k22.
Head PC.jpg
I don't have a schematic for this board. A standard 5V regulator. The outputs to the display have current limiting resistors. The I/O have provision for current limiting and an optional pullup resistor. Touch buttons are direct. Here's the serial I/O. I haven't decided on the speed or current, which will determine the resistor and cap values. There's a voltage divider in the input to the CPU to set the thresholds.
View attachment 3

This boards primary purpose is to interface controls and the readout to the rest of the system, but it would probably be 'the brains' as well. As designed there are provision for up to 17 Inputs (or outputs such as an LED?), for throttle(s), 3way(s), pots, light and turn switches, key(s), or?. This doesn't include inputs from 7 capacitive touch switches, 5 buttons (esc/1, menu/2, L/3, R/4, enter/5) and a capacitive slide (up, down (will work as buttons or like a pot), the connection to an iButton socket, or the connections to an LCD or LED array (I want a 10"X2.5" red-green-orange display using 'moving sign' type segments, for better visibility under harsh conditions).
I intend to use iButtons both for keys (could use different keys for different performance limits), and also for data log transfer. Changes to the programmable parameters could be 'programed' on a PC then transferred with the iButton. Parameters could also be changed in the field with the head unit buttons. RS232 or USB could be options, if.....?
There's also a separate board on the other end of the display (not pictured), with a mosfet switch, diode isolated for 2 '12V' sources, to control power to the LED array and most other boards, and also a TO220 5V regulator for the LED array.

Controller controller:
Uses a PIC 18F26k22.
controller interface.jpg
I haven't found and transferred most of this onto the computer, but here's the phase sense input, which is most likely to draw comment. :) I can't find the pdf that I got this particular circuit for the virtual neutral point from.....
sensorless in.jpg
Outputs are current limited. The output to the throttle is double filtered (RC) PWM, then buffered. The shunt has a basic buffer.

(Can't decide what to call this board.) Mounted inside any controller. Inputs for the Hall sensors (or 3 bit parallel, auto select), the phases (for sensorless), the shunt, the serial I/O, and both the B+ and driver supply (for monitoring with ADC). Outputs for throttle, and to the Hall inputs on the controller. I also have 3 more outputs, but don't really think they will be needed (brake, 3way, reverse, lock?). There's provision for monitoring FET temps using Dallas Semi 1wire temp sensors, and a thermistor to monitor ambient/crystal temp (for a temp compensated clock, so I have accurate phase timing outputs for traction control). The phase inputs are jumper selectable for delta/wye, and a daughter board could be used for on the go selection. If none of the 3 extra outputs are used, and no 1wire, there would be connections for 6 offboard thermistors....

In motor board:
Uses a PIC 18F14k22.
View attachment 5
Didn't bother with schematics for this board, pretty simple and straight forward. Current limiting and pullups for the Halls. A single transistor 'inverter' to turn on the FET. A voltage regulator....

This board is a direct replacement for the board in newer 9C hub motors.
There are inputs for 2 'in winding' thermistors as well as one on board, for ambient temp. Obviously, inputs and power for 3 Hall sensors. There's also a TO220 mosfet to control fans or relays, with provision for current measurement, as well as 6 'tach' inputs from fans. If you wonder about the TO220, remember that this board is designed for 125C ambient. A 3 bit parallel output, which connects to the stock Hall wires. This would probably failsafe to standard Hall output. 12V would come in on the original 5V line (you might go slightly oversize on it and the ground for fans or relays).

The BMS:
Uses a PIC 18F26k22.
BMS.jpg
The schematics for the high and low boards:
BMS 2&3 sch.jpg
Changed the way the balance current optoisolators interact. (Thought putting batt V accross a 36V part might cause dependability problems.) :)
Didn't bother drawing the CPU, just labeled lines that connect to it. Most of the unlabeled resistors would probably be 10k, or haven't been determined (depend on the number of cells, etc.) I also reduced the trickle current in the LM317, but didn't relabel it (that resistor would also vary depending on the # of cells). The lines labeled 'chg control' and 'Out control' would be connected to PWM.
The Balance schematic:
BMS 1 sch.jpg
The ADC is basically a block diagram, no PS caps or current limiting resistors shown. I'm using an optoisolator to switch power to the ADC (low current and duty cycle), so don't need a seperate drive to it's CS pin.

The BMS uses 3 different boards. Designed so no one part failure can cause an over charge. (I just 'finished' this yesterday (Dec 4), so it probably has numerous mistakes (statement proven :) ).)

The board on the low side (negative) has the processor, I/O, output control, precharge resistor, current measurement, and provision for 4 (or more) thermistors. There are ADC chip selects for up to 7 balance boards (28 cell). The chip selects can be used for thermistors if you use less than 7 balance boards. With 5 balance boards there would be 6 thermistor inputs. Measurements for current, batt V, chg V, and the neg output (voltage across the precharge resistor) down to -20V. Includes the multiturn pot to adjust the peak charge voltage.

The center board in the picture is a 4 cell balance board, can use up to 7 of them. Uses a multiturn pot and an LM431 to control each cell voltage by bleeding current through a 13 Ohm resistor. When the shunt current reaches about 200mA, a second LM431 starts pulling current through an optoisolator, all of which are wired-or and used to limit the charge current and notify the CPU of the condition. There is also an optoisolated ADC which the CPU can use to monitor cell voltages.

The third board has the voltage regulator(s), a mosfet so the processor can shut off all charge current, a trickle regulator, and a crude 12V regulator for the 5V prereg, and output fet drive.

They're designed to stack above 5Ah, or larger LiPo.

Boards I haven't designed yet:
Lighting control boards, with or without LEDs. Hall interface boards for suspension and steering position. I might add a board that does nothing but traction control (distributed processing). A tilt and tip board (wheelie control)? GPS? Boards to interface with electric brakes. ETC.....


Software:
I haven't written anything yet, beyond flow charts and some thought to time constrained routines. I like to build the hardware, with provision for future software expansion, then develop the software incrementally. I can't find the software for my programmer, and am waiting for a friend who has the same programmer, but is in Mexico right now, to return.

The project is also stalled because I'm broke. I'm still more than $100 shy of having enough for parts, mostly for the BMS (which is what I really need). Won't be able to do final assy. till I sell something.....

KISS:
For you believers in the KISS principle, PLEASE DON'T MENTION IT. I personally don't APPROVE of the KISS principle. I don't do anything just because it's stupid (when I do stupid things it's at least unintentional). Also note, the main reason for this project is because the commercial electronics is TOO simple.
Actually, I insist KISS doesn't WORK. For example, connect the battery direct to the phase inputs of the motor without a controller (try different connection combinations just in case). Definitely meets the KISS principle, very simple, AND very stupid. :D

If you can suggest a simplification that doesn't lose function or dependability, go for it, but that's KISP (keep it as simple as possible).

If you have any constructive suggestions or criticisms, please post or PM. (One thing I forgot and just remembered, was I intended to provide for a capacitor paralleled with a high value resistor to provide chassis grounds, in the hubs, to the frame, and to the handlebars...... Can be incorporated in the harness....)

Thanks for reading.
Bob
 
I like the idea of the system; I had a safety/control system that I wanted to create back before I knew much of anything about ebikes that was intended to do similar things; I think there's a thread with my "requirements specifications" on it around ES somewhere if you'd like to peruse them for useful bits. But I never got anywhere on actually creating any of it, as I'm not much of an engineer (just a hack) and couldn't program to save my life.

I need to read over everything again and make specific comments on bits I have thoughts about, might take a few days as I ponder.
 
Ideas are welcome amberwolf. I guess a lot of it is safety related after I think about it. Anti skid and anti spin. Turn and brake signals. I intend to have an intermittent 40W halogen pencil beam operated by a horn button. Two modes, 'what's that?', and 'do you see me NOW?'.
The serial interface allows for expansion and diversification. If you can think of a function, I can probably design a board for it.
Bob
 
Pelle,
I'll do some editing, rearranging, and cleaning and try and post later today.
edit: maybe tomorrow. Redrawing most of them. What's clear to me probably wouldn't be to others. :)
 
I apparently never posted the project on ES, but I thought I had. I did find my posts on Adafruit forum trying to drum up an engineer and/or programmer for it, though:

http://www.adafruit.com/forums/viewtopic.php?t=7346#p36056

Unfortunately nothing ever came of it, as none of the people that said they wanted to help ever actually did (most never even replied to my acceptance of their PM'd and emailed offers of help).

Also some projects using the STM32 circle that might be useful:
http://endless-sphere.com/forums/viewtopic.php?p=338620#p338620
 
when i first became interested in this scene i followed:http://open-bldc.org/wiki/Open-BLDC but it seems to have stalled now, is it of any interest? also gas sportsbikes like bmw s1000rr are rapidly developing 2 wheel abs / traction with varyiable levels of sensitivity, might be worth researching. modern fuel injection systems have ecus firing a sort of pwm signal to activate injectors and sparks so could be more relevant than some may think? its recent tech in that field tho, so it may take a good rummage through the net to get info.
 
I stopped following that one a long time ago because when I inquired of them the possibility of much larger motor controller applications, such as those for EVs like ebikes and emotorcycles, I was brushed off with what came down to "this is for RC airplanes and helis", and there was no interest in attempting to make it for more than that. I never went back to see if it ever got more useful than that. :(
 
STM has cme up with a new eval board that might be of interest:
http://www.st.com/internet/evalboard/product/252419.jsp?wt.mc_id=enews_dec11_stm32f4discovery
 
Added some schematics. Incomplete. They don't show power supply caps, or even some of the filter caps. The thermistors are connected to CTMU inputs on the CPUs. If you're unfamiliar with this, it supplies a programmable current, then measures the voltage, ideal for thermistors (as well as touch sensors).

I didn't expect as much interest as has been shown in this project. I might improve them later. I didn't get much done on this yesterday. Some of my schematics are only on paper, an old habit from the days when computers were programed with 'punch cards', and before they were so useful in saving paper......

Took me 4hrs to get to the post office yesterday. Had to fix a flat. Then I had to change a couple mosfets in the controller, which took more time to troubleshoot than to repair. One open low side phase. Acted like a bad Hall sensor, so I eliminated them and the associated wiring before I opened the controller....

Had fun after I got out though. Riding up to 30mph (or more) on wet ice ('self drilling' screws from the inside of the tire). Slick enough so people with non studded shoes have a very hard time not falling. I enjoy showing people how the other 1/2(%) do things. :lol: My cloths are dry now, so I'll go out again soon. :wink: (no front fender) :(
Bob
 
DaveyJ (and AW),
Yea, I checked open-BLDC before I came to ES, and decided it didn't, and probably never would apply.

I haven't been back recently, but several years ago someone was working on anti spin for the Megasquirt, by killing the ignition when acceleration exceeded a set value.

I spoke to a biker friend a few weeks ago, and was surprised when he told me that abs isn't common. I would think it would be more needful on bikes than on cars/pickups.

Of course it would have to work better than the ford PU I drove a while back (in 2WD, auto transmission). Pulled up to a stop sign, slow and level or slightly up hill, stepped on the brakes, the computer decided the engine needed to speed up, so it started moving faster, stepped harder on the brakes, one front tire slid, it pushed back on the pedal and accelerated more, by then I was in traffic, so I punched it to cross the road and avoid a head on..... Even in the good old days it was a good idea to shift to neutral when you stop, but with this system it's necessity.
Bob
 
I made some minor changes to the BMS schematics. Still need to change the optoisolators on the clk line, as only one of the ones I chose could be driven direct from the processor output (a fanout of 1). :oops: Probably just replace the LTV827s with 2 more PC81510s, at least for the prototype.

I would still like to find one or more collaborators. Really the main reason I made this post.

I would think this project would be useful to others than myself. It WAS designed for me and my bike, but it would be easy to change to be useful to you more nearly normal people, if that attracted someone interested in helping.
Is there another forum where I would be able to find someone more interested in designing ebike electronics? Should I change the title?
The controller control could be added externally with only the loss of driver voltage and temperature monitoring, and the in hub unit would be optional (it should be obvious it would work with a non hub motor). But, the temp monitors are one of the main features, IMO.....
Bob
 
I'd be glad to help, but I'm nto sure how much help I can be, with only basic electronics skills (and no real programming).

I havent' had the chance to go over the schematics/etc much yet (working six days a week trying to get all the hours I can while I can during holidaze), but as soon as I can I'll post any thougths I have.
 
Yea, I'd like to find someone with pic programming experience, or a younger person who had the time, aptitude, and will to learn (and hopefully some experience).
I'm fairly sure of the hardware, although there are a couple areas I'm inexperienced with. Both microchip's touch sensing (my only experience is many decades ago using cmos flip flops), but they have some very good app notes, and the sensorless detection.
And I do keep finding silly mistakes. Most of the board designs have changed a little, since posted above. No board design survives the first prototype without minor revisions, not very often, at least in my experience.
The way the LED arrays are set up is going to take some work in the software, at least to drive it as one graphic display, they are basically 4 (or 8) separate LED arrays, in 2 rows. I'll have to build a virtual array in memory, then output the appropriate portion to each array on the board. The first prototype will use a standard 2 row by 16 or 20 character LCD (like the bulk of the parts in this project, I already have 'em).
As long as I don't fool with timing, I don't think 'automatic' setup will be much problem. (As in hook the phase wires randomly, spin the wheel when it tells you to, then ride.) If the inhub unit sent a predictable string at power up, even the binary interface could be connected randomly (the Hall wires).
Bob
 
Back
Top