Specialized Demo 9 + BBSHD with VESC

amund7

1 W
Joined
Sep 6, 2015
Messages
54
Location
Oslo, Norway
I never liked uphills much.

My first ebike:

Specialized Demo 9, Magic Pie 4 at 30A 1600W

Experimenting with several batteries, main battery & least problems = 48v 13ah 'fits bafang' bottle.
Lots of headache but light & small = 2x 6s 10ah multistar lipo.
 
1KW said:
what range with 10ah?

After calibrating my BMS's voltage measurements I was up to 12 km, mostly uphill. Turns out, a BMS that measures correctly, gives me a fuel gauge AND has a proper low voltage cutoff per each cell is really valuable.

Will rework the packaging, I think I will build 2 equial boxes, each containing 2x paralell 10Ah lipos and a BMS + arduino with wifi for logging and monitoring. That way I can quickly swap battery packs, charge one while using the other, or for longer trips: one extra pack in the backpack which is already proving to be the best fuel gauge ever:
1. Bike away from home until bike stops
2. Swap batteries and be guaranteed to reach back home (since I live at sea level in a hilly city)

The arduino is proving kinda cool, it streams to my home wifi so I can graph all cells while charging, also have a phone app that will show all cellls + amps while biking. Maybe the phone app could have logging as well, if I find the inspiration one day.


Finding code and/or programming explanations for the OZ890 BMS proved a lot harder than I expected, so I will share my projects in case anyone's interested:

https://github.com/amund7

It's far frome done, but it's updated now and then, and it's a few steps further along than the TWO other pieces of code that exists on the entire internet, which my code builds on.
 
oh and please don't read the cell voltages in this picture, this was before I got the calibration tool to work. Now they're calibrated, and my cells look pretty nicely balanced.

DSC00612.JPG
 
Ditched the Pie, got the BBSHD instead.

DSC00879.JPG

Bought some bigger gears from Ebay. BBSHD 1 - gear 0



Anyways - suspension works again, bike climbs like a goat, lots of fun.
 
Nice !!!

What kind of gearing are you running to pop those wheelie's so easy?
 
cal3thousand said:
Nice !!!

What kind of gearing are you running to pop those wheelie's so easy?

That video was the original gears, 32 in the back and 42 front

New gears are 36 on the cassette + 40 black alu gear that broke. But the 36 (now 2nd gear) is still pretty awesome, a lot better than the 32.
 
[youtube]Ho_Yz-qZ-Ik[/youtube]

Couldn't find a lightswitch that did the job, so I built one!

Arduino Nano
Bafang switch
Takes up to 100v, feeds the same voltage through to the lights.
PWM dimming, software adjustable frequency
Turns on/off with bike
Adjustable brightness for low beam. Stores that brightness, and also the on/off state


Source code here: https://github.com/amund7/EBikeLight
 
BBSHD controller died after exactly 1 year! Turns out it only had a 3 month warranty. That is BS for such an expensive item.

It's not short circuited when I ohm the battery wires, but it welded my XT90 plug when I plugged the battery in. Luckily the BMS cut off (but not quickly enough), because the plugs were actually welded together, I spent a while breaking them apart.

So I ordered a VESC. From vesc.co.uk. And it's been almost 2 weeks since they said they shipped it, no tracking number, no reply to my e-mails about a tracking number. Hope it arrives soon.


I realized I will need a display. There is an Android app called Vesc monitor, but I don't want to have to use the phone every time, I am now very spoiled with the Bafang color display hard mounted. My experience is LCDs for Arduinos are not usable in sunlight, and I also never found a waterproof case for it. Actually the bafang display is so good that I broke it apart to see if I could control it from an Arduino or Raspberry pi. And I found a number on the display driver, and it IS supported by one of the LCD libraries for Arduino.

But I decided to go another route. Arduinos are easy to get started with simple programs, but it gets difficult when you want graphics, comms, files. I have an Android app that reads and decodes canbus packets off Teslas (https://play.google.com/store/apps/details?id=com.emon.canbus.tesla, and I realized that I could use that UI, logging and most of it, and just plug a VESC decoder in it. That way, much of the development time will benefit both apps, and I'd have twice the motivation to create cool gauges, customizations and other stuff. It already has customizable tabs and CSV logging.

Already ran the app on a Raspberry Pi 3 with Arduino Things. So the hardware will run on a RPI with alu casing and 3.5 inch LCD:
https://www.banggood.com/3_5-Inch-H...-Pi-3B-2B-B-Zero-p-1093111.html?rmmds=myorder
 
First VESC test passed!

https://goo.gl/photos/xSbyqmWuEZ9TW4Zk6

Running in FOC mode, sensorless. Currently hunting for the right connectors, funnily enough I can't find the type of sockets on the vesc listed anywhere. If my measurements are correct, the BBSHD needs a 6 pin JST XH (2.5mm pitch) male plug, and the VESC 6 pin JST PH 2.0mm pitch. Will need some crimping tools as well...
 
I'm surprised that this thread is so quiet, but you're doing some really cool things in here.

Question about your light setup (totally awesome, BTW): I understand that it is mostly controlled by Arduino and that you have included the code in Github (thanks for that), but I don't see how it hooks up to the Bafang display and switch. Would you mind sharing the details of that part too?
 
cal3thousand said:
I'm surprised that this thread is so quiet, but you're doing some really cool things in here.

Question about your light setup (totally awesome, BTW): I understand that it is mostly controlled by Arduino and that you have included the code in Github (thanks for that), but I don't see how it hooks up to the Bafang display and switch. Would you mind sharing the details of that part too?

Thanks for the interest! Check the Wiki page in github, I added some pictures of the wiring. I just used an extra bafang switch I had, the wires are soldered directly to the arduino, each button has a DI pin (I forget the pin numbers, but should be obvious in the arduino program).

The display, I used the display USB charge port to power the arduino, a little strike of genious there if I dare to say it, makes the lights turn on and off with the bike :)
Funny lesson though, without a noise killer / ferrous core thingy around the usb wire, the bike would throttle itself when I turned the lights on! :shock:
 
First VESC died in less than 24 hours! For others to learn from my mistake, my mistake was to order a VESC without battery side external capacitors, and running a burned / poor connection XT90. XT90 lost contact while it was auto-detecting FOC parameters - there were welding sounds - and magic smoke. DRV chip has 2 big holes in it! Crash analysis is no caps - lost battery in the middle of a very oscillating cycle - voltage ripples over 60V which is the max for the DRV chip.
*Edit* I have later read that you should not do FOC detection with 12S battery, it is too close to the max limits of the chip, use a power supply with a lower voltage. (I tried that, bench power made some weird sounds and actually turned itself off! But that was without any battery side capacitors)

VESC 1 ran quite good the first day. 3,5 km uphill to work, full throttle the whole way, no sweat. Ran in sensorless FOC mode (because I didn't have the right connectors to hook up the halls). It did have startup issues though, half the starts would stutter and stop. But once it got running it ran strong.

VESC 1 from vesc.co.uk (which is in Vilnius)
VESC 2 from Ebay / Maytech (Hong Kong)

Vesc 2 does not like FOC mode at all! It would run (now I am in Hall sensor mode), but it would cut off at full throttle, throwing an ABS_OVER_CURRENT error. Every time, also, same error randomly at spin-up.
I should probably go back and test sensorless FOC to see if that makes any difference ?

Finally switched it to sensored BLDC mode, and it seems perfect. But maybe, a bit weak on very steep hills and standing starts, will test more.
I also noticed that after commuting to work, taking a horrably steep uphill (VESC went up to 90 C and was downramping), motor is not even body temperature! Feels ice cold! I am pretty sure I would burn my fingers on the motor if this was with the BBSHD controller.
So the good thing is that the BBSHD motor seems to have a lot of headroom. Bad news is that the VESC needs better cooling. And this morning was around 15 C outside, it will only get worse.

Picking inspiration from a raspberry pi aluminium cover that uses the whole cover as a heatsink, maybe I can glue/cooling-paste the FETs directly to the bike frame, to have the whole frame as a heatsink :) That would be awesome, but probably impossible because cables and plugs are on the same side. Anyone know a way to waterproof AND cool the vesc at the same time?

I also noticed, watching the VESC Monitor Android app, which is awesome, that battery amps very rarely reaches my limit of 30 amps, but quickly goes down as the rpms goes up. This probably makes sense, but the old Bafang display reported 30A all the time, as long as I was on the throttle, even at the RPM limit. That was probably not right though, probably just a stupid interpolation of throttle input and not a real measurement. I just never realized that the bike should be quite economical.

Finally, here is my REAL motivation to run a VESC, the data and the logs!
 
After some strange behaviour I discovered that my RX & TX for the bluetooth were partially connected or just interfering with the analog input from the throttle. This led to all kinds of weird stuff I tried to tune away... firstly, the motor and chain would give a loud bang as it tightened, when I throttled up and the bike was already rolling. So I de-tuned some gain parameters etc to get a smoother engagement. Also the vesc would overheat quickly, quicker than my earlier tests, almost to the point of it not being usable.

Fixed the throttle/uart wiring, and tuned back a lot of the parameters. Now it's quite awesome, only thing missing is steep hill starts, if I stop on a steep hill I can't get going again, the motor is super weak, and I can't pedal hard enough.

I had been wondering what the 'min rpm' setting really did. After all this time I haven't found any good explanations about the different vesc parameters, so I decided to check the VESC source code. And lo and behold, it very clearly shows (in the ADC app file, current mode) that it regulates current DOWN when you go below the min RPM. Don't know why some would want that, maybe it makes sense in a skateboard, but not in my bike for sure.
 
This is awesome. I just got a Vesc 6.0 and am thinking of trying it with BBSHD. Glad to see it's working out so well. I'm thinking of building a fat commuter.
 
206monkey32 said:
Glad to see it's working out so well.

Not really sure what you're referring to? The first VESC that exploded, or the second that will not do FOC mode or pull steep hills? :wink: If you are looking at the videos they are old, and with the stock BBSHD controller. VESC still has a lot of tuning to do, but now I have a raspberry pi logging data at 50 Hz, so I can get some good graphs of what's going on.

I still have a bit of way to go before I'm at the same spot as the stock BBSHD controller. Currently, only missing cooling and hill start torque. Will get there soon. And then I can start increasing the amps, I am thinking 40 battery amps to compete with my friend's Cyclone.
 
Back
Top