Bosch mid drive with vesc controller

mechhead

10 W
Joined
Mar 10, 2017
Messages
90
Location
adelaide south australia
Hi All, new project time.

Bike: Corratech e-power e28 hybrid, bosch mid drive, alfine igh and hydraulic rim brakes.
problem: controller is bricked by wrong one time initialisation code, now gives error 500
slution: gut controller and install enerton vesc foc box controller.

I will start by disconnecting the phase wires from the motor and installing a temp sensor and new phase plug, add a vesc and bypass the bms for a direct feed.

It will hopefully run sensorless as the bosch uses a single hall sensor and a magnetic code wheel on the shaft end that ill bet does not have the same pole number as the motor and is therefore junk. ill try leaving the factory controller intact without phase connections so the lighting circuit may still work. the pack is 4p10s LG MG1 2900mah 10a cells so ill try for 800 watts to start with to keep it under half the c rate of the cells.
Tomorrow illl get the vesc and battery conections soldered up and have a play with the start up boost settings until it hopefully works and post some photos. if anyone else has tried an alternative controller on a bosch let me know how it went.
 
Hi Mechhead,
Sounds an interesting project! I had often wondered about using different controllers on the "packaged" mid-drives, so I will be keen to see what results you have.
Are you planning to run it throttle-only, or are you going to try and use the torque sensor signal? I would expect the throttle-only option to be fairly easy, but integrating the torque sensor would be more challenging.
Good luck with the project.
Dave
 
Hi Drum , it will be throttle only but i plan to leave the bosch controller in the motor to preserve the function of headlights battery guage and indicators if it works the accessories with the phase wires disconnected

details of the actual motor are :
18pole stator 16pole rotor

magnets are 90 degrees to rotor airgap with 0.5mm lams in both rotor and stator rotor segments, is this like some kind of halbach array? , the rotor segments have the magnets sandwiched between them with the wide dimension of the magnets radial to the shaft presumably with their poles facing nnssnnss and the outer face of the triangular segments of the rotor core are barrel faced with a smaller radius than the rotor, (for extra sinusoidal commutation perhaps?) this means the air gap varies from closest in the middle of each segment tooth and lager at the leading and trailing edge of the rotor tooth segments, i suspect they engineered it to fly apart if over volted and run at excessive rpm and made it so its also easy to cook at excessive rpm due to eddy currents. The stator is made from individual segments, one per winding, windings are single strand of thick copper 1mm dia, the segmented stator is then assembled and windings spot welded to copper busbars that connect them in series groups, bus bars are 1mm by 2mm minimum copper bar stamped from sheet, this would be really good for avoiding end turn losses and make machine winding and assembly really easy.

this means low eddy current losses in cores up to 400hz or 3000rpm in the motor but means adding more rpm to get more power without overloading the plastic gears may run into eddy current core losses that are excessive and cook up the motor, also the lams apear to be un coated steel sheet, very unimpressive considering bosch are always touting them selves as state of the art gear.

16t motor gear to 47t idler to 18t on the idler shaft and final drive cog 77t there fore motor to idler ratio is 2.9375:1 and idler to final drive is 4.277... for total reduction of 12.565 ish, i may have counted the teeth wrong but not by much as keeping track of position when conting lots of small teeth is not always easy. next up connection of vesc and testing

dont know if speed limit is by voltage to back emf balance or software limit, i suspect software limit as this would allow better torque all the way to rpm limit and consistant top speed regardless of pack volts/sag etc.
 
It Works,

Except for the crappy hall throttle i have that gives a stable rise in volts until about 3.1 then goes all over the shop, it is a quarter twist hall throttle but it is crap as only half the rotational travel is usable. zero to full throttle in 22 degrees, need a better hall throttle for the left grip any recomendations ?

The vesc runs the motor fine in BLDC mode but not in FOC mode it detects fine and spins up the motor during the foc test but fails to make it turn with the throttle later.

I'm at a loss, i have never had a vesc fail to work in FOC before Anyone have any ideas ??
 
update: system works in foc i had not set the right minimum battery voltages and the vesc thought the battery was flat.

major problem is the lack of a pedal freewheel system, it drives the pedals with the motor and nothing i can see can be done about that

In summary the bosch pedal assist is never going to be more than that, a pissweak pedal assist unit with the usual problems of a propriatry system the bafang wins every time. probably wont continue this thread.
 
Ok, seems like a dead end for that particular system using throttle. That's a shame.
Did you get any feel for the power the motor / controller combination could produce without overheating etc?

Any chance of picking up the torque sensor output and using that as a "throttle" signal into the ESC? In other words, keep it as a torque sensing PAS / not throttle system, just a bit more powerful and maybe quieter / more efficient?
I actually enjoy riding the torque sensing mid-drive mountain bikes on singletrack.. it feels so natural as well as so much less effort, so for me it would be worth chasing that torque sensor signal and seeing if it could be used or modified for use.. even if it had to be put through a Cycle Analyst or a special signal conditioner.
Of course, the ESC would have to be happy to drive the motor in "Torque mode" not "speed mode".

However, that's my ideas.. it is your bike and project, and you know what type of riding you were planning to do, so my idea might not suit your situation.
Dave
 
Hi Drum,

I haven't analysed the signal from the torque sensor, I suspect its a kind of strain gauge as it has no moving parts and apears to measure deflecion of the pedal power to output shaft transfer gear under human power. i would think from the look of the motor that 500 to 700 watts is doable with out straining the plastic gears too much and the stator appears to have a good thermal path to the casing which is large so it should not overheat easily but i would fit a temperature sensor for protection if i was going to persue the project further, for now it looks like it will get a cheap 250w sensorless cadence sensing controller to make it go, as the vesc is rather wasted on such a small motor. this will be done so the bike is functional and can be sold as a legal bike for street use. the motor spun up nicely with foc mode once i cleaned the swarf out of the hall throttle that was causing it to function poorly and set the proper LVC thresholds, it would not go in FOC mode before because the vesc thought the battery was flat, I was testing it off a 12v PB battery to minimise the risk of cooking the controller during testing. i set it up to manage throttle with current/torque mode as this allows variable power levels at any speed it will do and it worked fine during bench testing. I to like the natural feel of pedal assist vs throttle control as its one less thing to think about and bikes set up with pedal sensing of some kind are more intuitive to use and very nice for the single tracks as it allows intuitive gear changes and power when your legs ask for it and takes less room on crowded handle bars.
 
If you are looking for a mid drive motor, that is good comparing that the motor runs silent with "hardcoded FOC", has a good torque sensors, parts for repairing, runs with 7S up to 14S at 16 amps, available online in many shops and with OpenSource firmware being developed, go with TSDZ2!!

Here a video of me showing torque sensor working. Right now the hardest part of the project is to implement "hardcoded FOC", that is pure math but I will do it anyway:

[youtube]1xiMbCerRKw[/youtube]
 
I am not an expert in this, but I know that some strain gauges and Hall sensors output voltages between 1 & 4 volts through their range, and this matches Hall effect throttles, so it is at least possible that the torque sensor output is already usable, at least for a controller where you can select throttle start voltage and end voltage.
 
Drum, thanks for the tip, There is hope for it, I have made a small amount of progress with the strain gauge.

Powering up the bosch controller that does not function because of lock out, shows it supplies the strain sensor with 4.95v and the other terminal reads 2.49v above the common ground for the three wire torque strain sensor, if i force the sensor by hand I get it to swing up to 2.54 or down to 2.45 by pushing it in both directions, the rise is given by force in the direction of strain imposed by pedal torque. I suspect the pedals place a much larger force on it than i can deliver by fingers so should give a larger voltage curve to work the throttle input with. The next step is to attach it to the vesc and give it 5v, ground and an adc port for the signal and use the throttle deadband adjustment and min, max v setting to see if i can use it, this would be a breakthrough if it works as it would be rather annoying to ride with a throttle because of the lack of a pedal freewheel. On the other hand if I can get its original torque sensor to work as a throttle input then it would be ridable as a pedal assist as it was originally designed and should work well. Because it is such a low power capable device I think a fairly coarse torque sensing ability would be fine and definately better than any other simple cadence sensors out there i have ridden. i cant use a cadence sensor controller because there is no way to make it stop because as soon as you start to pedal the sensor goes round and the motor activates and continues to drive the pedals and cadence sensor which can not be stopped because the motor is self sustaining in this scenario. it could be annoying approaching an intersection because it would not want to stop. The bike has no brake sensors as in the original configuration they are not needed because it is normal to stop applying pedal force when slowing down.

the other way this could be done is with a cycle analyst to interpret the wierd torque sensor signal curve 2.49v to 5v and map it into a normal hall throttle curve to feed a cheap sensorless controller. this would also give a nice stats display and odometer.
 
It sounds like you need an amplifier for the torque sensor that will scale the signal to the right range for a throttle input. This is a fairly simple circuit but may take a little tuning to get the right range.
 
mechhead said:
Hi fechter, it reads like you posted a circuit but there is nothing there ?

Correct. If you give me a while, I could probably draw one up. I would need to know the real input range. There would also need to be some kind of adjustment for gain to vary how hard you need to pedal to get full throttle. The stock controller does this with the level setting. This could be analog, but some kind of microprocessor might make things easier.
 
Hi Fechter, if I go with a cheap sensorless controller I may need some kind of torque sensor signal interpreter circuit like you suggest, iIneed to gather more data about the actual torque output as read by the sensor and how this corresponds to real world pedaling effort I will probably put it on a trainer roller drag device to test it and use the vesc software and a laptop to look at the actual signal produced by the sensor while riding it on the trainer.

It should be realtively easy to set up the vesc to give the desired ratio of motor power to torque sensor reading because the min and max throttle voltages are adjustable in 0.01v increments and it seems to have a very accurate ADC for the sensor signal and some adjustable noise level filtering that can be played for starters I can set the zero throttle point to 2.52v 0.01v above the resting state of the sensor which seems to produce a very stable signal with no fluctuations from anything other than the torque variation, the signal quality is excellent from the bosch sensor, much more precise than a hall throttle signal. I have not pushed the sensor very hard yet to see how high it goes so I don't know the upper limit of the signal. Only testing will tell this. Levering the mechanism with a screw driver I got it up to 3.55v from rest of 2.49v (readings are from a quality fluke multi meter with 10 mv resolution in the range used)

A hall throttle signal is noisey as in comparison dancing around within a 60 mv error bracket. The bosch sensor seems to have some kind of internal noise reduction hysteresis or signal conditioning as the signal does not rise and fall rapidly with changes in loading, this may be to help with the minute vibration/ torque fluctuation from the helical gears on the idler shaft cogging past each other even though they are very smooth . I suspect slowly decreasing the maximum throttle voltage in the vesc from 5v downward will give a zero to full power torque based demand throttle that works very nicely once the desired level of pedal effort is assigned to full power which will after all not be so huge (600 to 800w ) as the motor runs out of rpm on 36v at about 80 pedal rpm on this bike this equates to about 38 kmh in top gear overall they have engineered the system well for the low power device that it is, supposed to be 350 watts max 25kmh limit . There will be no limit with the vesc except max motor rpm.

i could also increase the dead band to above 2.50v to allow some room for pedal only power in the low torque/effort zone this would allow the power assist to only come on when a significant and adjustable amount of human power is applied.

for a good interpreter circuit it would need an adjustable deadband for some human power only head room under the threshold for motor power demand for cruising on foot paths and slow navigation riding, because I dislike sudden bursts of power as are given by simple cadence sensing setups ( these suck IMO), an adjustable maximum power assist level that can be adapted to user prefered human torque level ( lazy or fit ) and instant power cut off with lack of pedal force, this simplifies everything and no brake switches or gear sensors are needed keeping the system ultimately simple, this is prity much how bosch designed it to work in the first place but they have the handy five levels of assist torque response in the user interface.

Ill have to read the cycle analyst manual for implementing torque based assist but I suspect it is also programable enough to replace the vesc and use a cheap sensorless controller and let a CA do the torque sensor interpretation and it allows other useful functions like range odo and the many other feautres it has. At the moment I have a vesc that belongs to the shop to use and no CA and I like them so thats what I'm working with. I work at Mycycles ebike shop in adelaide south australia. and we are going to use the vesc to start with for data gathering and later possibly adapt a CA and cheap sensorless controller to the task. I put this build up on ES because i dont think anyone else has published a hack for the bosch mid drive which is small low powered and weak but well designed for what it is. they are very quiet at least which I like.

The vesc is really limited on this set up, some would say wasted but it is the only controller i know of that is so versatile as far a programability goes, the other bike I'm slowly building is a mongoose wingcomp pro FS with a Crossbreak style middrive using a 6t 0.27mm lam mack reconfigured for shaft output, this should be able to eat the vesc's full output of 80a at 44v nom from a pair of 6s 20ah multistar packs for 3500w ish but that is another build ...
 
mechhead said:
Levering the mechanism with a screw driver I got it up to 3.55v from rest of 2.49v (readings are from a quality fluke multi meter with 10 mv resolution in the range used)

for a good interpreter circuit it would need an adjustable deadband for some human power only head room under the threshold for motor power demand for cruising on foot paths and slow navigation riding, because I dislike sudden bursts of power as are given by simple cadence sensing setups ( these suck IMO), an adjustable maximum power assist level that can be adapted to user prefered human torque level ( lazy or fit ) and instant power cut off with lack of pedal force

Sounds like their sensor already has some kind of amplifier in it and the signal could interface directly with the A/D input on a microcontroller.

To re-map a signal that goes 2.5v-4v to one that matches a typical motor controller (1v -4v) would be pretty easy.
 
I finally got it running with the torque sensor, just need to finish wiring details, close up the motor case and put it back on the bike, then a test ride and a bit more tweaking and its ready to roll . Sensor outputs 2.49v (fluke) 2.51v (vesc adc port) at rest and 3.3v is maximum out put of sensor. By setting the throttle range on the vesc to the above values it seems to give nice proportional control. also beefed up the battery case internal cell group link wires to 25a heavier cable as they were rather thin for the hoped for 800 watts. Feed bypasses the bms and the setup leaves the original controller intact and it still functions as a battery gauge and speedo odometer but will not turn on the lights. the bms is still present and used as the charger balancer.

Will see how it rides soon ...
 
Great news! I'm glad it has worked out.
That's a fairly narrow voltage range for zero to full throttle, but as long as it is stable and repeatable you should be able to work with it.
Hope it rides great and can handle a bit more power than originally without overheating too much!
Dave
 
Hi all,

success after much fiddling with controller parameters it rides, and bosh built it right after all then crippled it terribly in the name of 25kmh speed limits and 250w legal limitations im feeding it 20 battery amps and 30 phase amps, more hase amps and it does not sound sustainable and happy i would worry about the strength of the plastic gears it matches a nice pedal cadence with the available rev band not too much torque at low motor speeds but this would kill the plastic gears. secret is use the gears and keep the pedaling cadence up and there is plenty of power there on command from the legs in the 60 to 75 pedal rpm range, top gear i have had it up to 65kmh and the motor does not run out of volts yet but does not have the power to maintain this speed except on flats or down hill. With the back wheel lifted the motor powers all the way to 75kmh in top gear, wow this alfine hub is tall in top gear in a 700c wheel.

there were some problems encountered when it fitted to the bike first i got the torque sensor values backward and it has a resting voltage of 2.51 and the voltage decreases with increasing pedal torque after finally working out how to reverse the throttle v curve in the controller it works wonderfully and by playing with the minimum throttle voltage i can set the throttle ramp end to match a particular torque, I have it set to 1.75v and this means i can get full power with my sustainable all day effort level , If you wanted more of a work out or to save full power for emergencies you could lower it to 1.50v or 1.3 if your a serious athlete. there were some other problems with the torque signal sampling rate, this is defaulted to 500hz in the controller and set like this it gives great big gobs of torque exactly matching your own legs and total loss of torque at pedal rollover every 180 degrees, I didnt like this so i tried 1hz sampling rate then it would keep pedlaing for me for a whole second after i stopped applying effort (very annoying ) testing continues but now i have it set at 14hz sampling and it only releases torque on rollover at very slow pedaling speeds and only drives the pedals for a brief instant after you stop applying effort, the rest of the time at cadences above about 45 prm torque is smooth and responsive without the annoying dropouts on rollover. i will probably increase the sampling to 16 or 18hz to further minimise the delay between stopping leg torque and motor torque ending as the pedals and motor are incurably linked in the bosch design

In all im highly impressed it goes like a rocket and my prediction of 600 to 800 w was correct as the gears sound nasty at 1000w and i only pushed it that hard for a few seconds before backing down the current, the same bad noise happens at low speed if the phase amps are set much above 30a. secret of gettin max power through weak gears is to spin them fast hence the low phase amp to battery amp ratio ideal is probably 1:1 so only at max rpm is max power availble when the pissy plastic gears can take it .

I did not believe this thing would ever go as high as 60 kmh but it has long legs and the hub shifts fine if you gentle it and simply wont shift to the next gear if it is under too much load silent and smooth...

so far i have only been hotrodding up and down my street and motor does not even get warm yet , tomorrow i will go for a decent ride if the weather is good and take some photos
 
Great result!
As the bike has a top speed much higher with the wheel in the air then riding it you could replace the sprocket on the Alfine for a 2 to 3 tooth larger one. That would relief some stress on the drive train and keep the same (or slightly higher) top speed with even better acceleration.
 
hi SlowCo, I like the suggestion do they use a standard three dog sprocket like the nexus? It definitely needs it to be a capable hill climber and it would put less strain on the igh at top speed
 
Great work. Thanks for posting the pictures. I like how you put the VESC inside an aluminum box so it can dissipate heat and still be protected from rain, dirt, etc. Too bad it won't fit inside the motor.
 
mechhead said:
hi SlowCo, I like the suggestion do they use a standard three dog sprocket like the nexus? It definitely needs it to be a capable hill climber and it would put less strain on the igh at top speed

If I google for Alfine and Nexus sprockets they look to be the same. But they might use slightly different dimensions. Do you have a Nexus sprocket you could trial fit? I can't find a definitive answer online if they're the same.
 
Awesome work. Just out of interest what parts would normally fail on the bosch cx and can you get spare parts for a descent price?
 
Hi jabalat, no idea on the price or availability of parts, i would think the small plastic gear would get mashed first if the motor was allowed to run at excessive temperature, with the bosch controller at 250 to 350w this will never happen but with the vesc pushing 800+w it would be easy to cook it on a long hill climb, 3 km of 8% grade in first gear and the motor was too hot to touch on a cold day. if you want reliability and more power and cheap easy to get spares get a bafang mid drive.
 
Back
Top