• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

BBS-FW: Open Source Firmware for BBSHD/BBS02 Controller

It seems everything is working properly, but the motor stutters and doesn't want to give me full power.
Seems like it does spin the motor properly until full power kicks in, and then limits itself to about 100W.

I will play around with settings and hopefully find a way to omit this issue, otherwise I might have to give in and buy a new controller sadly enough.
 
I suspect it has something to do with with the current ramp setting - does anyone have any information as to what they configured this setting to succesfully with a BBS02B?
Changing current ramp from 10 to 15 makes the behaviour worse, from what I could find 15 is supposed to be the default setting.

Both PAS and throttle give little jitters. Occassionally the throttle does go up to 600 something what, the expected power the motor is supposed to put out.
 
I suspect it has something to do with with the current ramp setting - does anyone have any information as to what they configured this setting to succesfully with a BBS02B?
Changing current ramp from 10 to 15 makes the behaviour worse, from what I could find 15 is supposed to be the default setting.

Both PAS and throttle give little jitters. Occassionally the throttle does go up to 600 something what, the expected power the motor is supposed to put out.
I run a BBS02B (12s, 44v) with this fw and don't have any of the issues you mention. Current ramp set to 10, max current 25A. Your issues are not any way 'known' which makes me suspect your problem probably lays somewhere other than the fw. Maybe battery sagging badly (under min voltage..) or a bms or controller glitch - or maybe just a connection issue somewhere. Just guessing really so probably not much help, but good luck with it...:)
 
I run a BBS02B (12s, 44v) with this fw and don't have any of the issues you mention. Current ramp set to 10, max current 25A. Your issues are not any way 'known' which makes me suspect your problem probably lays somewhere other than the fw. Maybe battery sagging badly (under min voltage..) or a bms or controller glitch - or maybe just a connection issue somewhere. Just guessing really so probably not much help, but good luck with it...:)
I have two 24AH 48V packs that are still good on my 1000W hub motor pulling 2.5KW peaks so it for sure isn't the battery, I can confirm its not the current ramp setting, I tried disabling the thermal sensor but it didn't change anything meaningfull.
Note that on my original firmware my controller was limiting to about 350 watt due to the thermal sensor being faulty, but other than that, the controller had no problem albeit power limited.


I was a fool not to back up my original firmware sadly enough.
 
Sorry for the updates in rapid fashion but I thought I would share my process.

I ended up re-flashing the custom firmware a few times after I have tried to restore a firmware supposedly for the BBS02B I found on this very same forum.
That firmware gave me error 30 and did not work.

Upon returning to the custom config tool I noticed that the tool said;
"Failed to read status from motor controller"

I spammed restore a few times and kept having it write to the controller until I did not see this error.
I then disabled the speed sensor, shift sensor and the temp sensors after which to my pleasant surprise - the motor now seems to deliver full power again. With the wheel against the wall it did not stutter and I've seen an output of around 900W on throttle before obviously stopping.

Tomorrow I'll once again come back to update and troubleshoot a bit further to see if I can narrow down what my problem was after testing if it actually does ride at full power again now in real world riding conditions.
 
Sorry for the updates in rapid fashion but I thought I would share my process.

I ended up re-flashing the custom firmware a few times after I have tried to restore a firmware supposedly for the BBS02B I found on this very same forum.
That firmware gave me error 30 and did not work.

Upon returning to the custom config tool I noticed that the tool said;
"Failed to read status from motor controller"

I spammed restore a few times and kept having it write to the controller until I did not see this error.
I then disabled the speed sensor, shift sensor and the temp sensors after which to my pleasant surprise - the motor now seems to deliver full power again. With the wheel against the wall it did not stutter and I've seen an output of around 900W on throttle before obviously stopping.

Tomorrow I'll once again come back to update and troubleshoot a bit further to see if I can narrow down what my problem was after testing if it actually does ride at full power again now in real world riding conditions.

Everything seems to be working flawlessly again.
I've turned the speed sensor option back on without any error to the functionality of the motor.
My conclusion is that the shift sensor option ticked on caused the stuttering / janky throttle & PAS.
Turning the shift sensor option back on reintroduces the problem.
It almost feels and sounds like when the phase wires on a hub motor are shorted out and you put throttle on.

I've solved the issue of the disabled shift sensor by putting it on a brake switch connector.

A bit of troubleshooting and Nils's firmware is working a treat.
I have two profiles set up for both road and offroad profiles, switching is easy via the light button.

Only time will tell how long my controller will last, but atleast its back from the dead and fully functional again, plus extra's to play around with.

Some info about my motor and controller:

BBS02B bought 2023 via AliExpress.
750W controller 48V, MCU; STC15F2K60S2

TLDR: Users flashing this firmware and experiencing throttle / pas problems should try disabling the shift sensor option, in my case, it solved my issue.
 
Everything seems to be working flawlessly again.
I've turned the speed sensor option back on without any error to the functionality of the motor.
My conclusion is that the shift sensor option ticked on caused the stuttering / janky throttle & PAS.
Turning the shift sensor option back on reintroduces the problem.
It almost feels and sounds like when the phase wires on a hub motor are shorted out and you put throttle on.

I've solved the issue of the disabled shift sensor by putting it on a brake switch connector.

A bit of troubleshooting and Nils's firmware is working a treat.
I have two profiles set up for both road and offroad profiles, switching is easy via the light button.

Only time will tell how long my controller will last, but atleast its back from the dead and fully functional again, plus extra's to play around with.

Some info about my motor and controller:

BBS02B bought 2023 via AliExpress.
750W controller 48V, MCU; STC15F2K60S2

TLDR: Users flashing this firmware and experiencing throttle / pas problems should try disabling the shift sensor option, in my case, it solved my issue.
Well done, thanks for posting a conclusion to your issue, that way we all learn something..:)
Just wondering if a triggering shift sensor shows up in the Event Log, if so maybe there was an early clue there....
 
Well done, thanks for posting a conclusion to your issue, that way we all learn something..:)
Just wondering if a triggering shift sensor shows up in the Event Log, if so maybe there was an early clue there....
I did not see anything in the log concerning a shift sensor, or a shift sensor error.
I'm also not sure why the motor behaved the way it did with the shift sensor on, but it would not power up the motor under load, and not properly under freespin no load either; it felt like the motor was "knocking"

All I can say is I have been following this project for a very long time, from the first versions until now, very happy to have my motor back up and running.
I'll eventually order a new controller just to have one as a back up but very sweet to be able to switch profiles etc.
 
Is it possible to use bbs-fw on a CANbus version of the BBS02?
As far as I know this is for UART based controllers only, the firmware and protocol for CANbus controllers, displays and such are alot different from UART.
Correct me if I'm wrong though, anyone.

I have seen someone buy a UART controller and swap his CANbus based BBS02 out to UART with only a little bit of modification of the connectors on the motor side of the controller housing.
 
Is there a way to add a base current injection into the motor that's always on? 5-10w to keep driveline slack tight so no freewheel clunk when using throttle. Kind of like grin phaserunner simulated freewheel setting
 
Is there a way to add a base current injection into the motor that's always on? 5-10w to keep driveline slack tight so no freewheel clunk when using throttle. Kind of like grin phaserunner simulated freewheel setting
I think something like that was already introduced here:

And, if you look at the screenshot at the base of that repo, you'll see there's option for pretension*.

*) as is atm., might require building from source - idk., as i don't use that config tool, nor released
binarys from there anyway.
 
I think something like that was already introduced here:

And, if you look at the screenshot at the base of that repo, you'll see there's option for pretension*.

*) as is atm., might require building from source - idk., as i don't use that config tool, nor released
binarys from there anyway.
Nice. But ya I'm not sure how all this stuff works. But is it implemented in the newest release? I know it wasn't added to the notes that I saw at least
 
But is it implemented in the newest release? I know it wasn't added to the notes that I saw at least
Nope. Will be in the next release, but i have no idea when that will be.
 
Can throttle start current be set to 0.5%? The throttle wasn't jerky at 1% when using battery with 73 mili ohm internal resistance but it started to get jerky again after upgrading the battery to 34 mili ohm internal resistance.
 
With this firmware my throttle is super easy to modulate. Like I can even walk next to the bike and do a little throttle to function as a "walking mode". Or I can cruise anywhere from almost standstill (0 - 5kmph) to max speed and anything inbetween with just throttle.


Check the settings, I think it might be:

Start Current
Minimum power to apply for lowest throttle input. Setting this to 10% will map throttle range to 10-100% power output.

Default: 1
Can throttle start current be set to 0.5%? The throttle wasn't jerky at 1% when using battery with 73 mili ohm internal resistance but it started to get jerky again after upgrading the battery to 34 mili ohm internal resistance.
Or should I change the throttle mapping by tweaking the voltage to get smoother response?
 
I wanted to edit/reprogram the FW 1.5.0 from Daniel (only some small changes because I use the lighter BBS02 with the more powerful BBSHD controller). Therefore I wanted to learn to compile the .hex file.
My problem is that even without changes of Daniels source code the .hex file gets too big (about 130kb instead of about 23kb).
So I can't flash the .hex without problems (.hex has to be smaller than about max. 60kb because otherwise it would be too big for the memory of the controller).

Any ideas where I made the mistake (I am very new to SDCC - Small Device C Compiler)?
See attachments.

Thanks!
 

Attachments

  • Compiling of .ihx and .hex sucessful, but files too big.PNG
    Compiling of .ihx and .hex sucessful, but files too big.PNG
    112.1 KB · Views: 6
  • hex too big in size (133kb).PNG
    hex too big in size (133kb).PNG
    44 KB · Views: 5
I wanted to edit/reprogram the FW 1.5.0 from Daniel (only some small changes because I use the lighter BBS02 with the more powerful BBSHD controller). Therefore I wanted to learn to compile the .hex file.
My problem is that even without changes of Daniels source code the .hex file gets too big (about 130kb instead of about 23kb).
So I can't flash the .hex without problems (.hex has to be smaller than about max. 60kb because otherwise it would be too big for the memory of the controller).

Any ideas where I made the mistake (I am very new to SDCC - Small Device C Compiler)?
See attachments.

Thanks!
I'll say right away that I'm no coder, but I usually manage to blunder my way through this process, so take anything I say as possible nonsense.
Your procedure looks the same as mine but I end up with a .hex file of 62kb. Just wondering which version of SDCC you're using, I'm using an older SDCC4.2 version, not sure if that will make any difference..:unsure:
 
Thanks guys, I managed to compile and test my own firmware for my BBS02 with BBSHD controller today.

Works now fine for me (also for trail riding).
I am a bit proud because this is the first created firmware in my life and it is a joy to ride.

I enjoyed to process to build, test, program and now ride this old ~4kg mid-drive with huge 1800W peak power (15s battery and 33A controller) smoothly with very good software and without spending too much money (motor still looks neat, not like a DIY-solution.).

My main change in the app.c:
  • Smoother change/ramp up of PAS-current without overshoots (only for this motor+controller combination a big improvement) in the app.c:


Change to more conservative ramp-down at high temp-values in the fwconfig.h to avoid too much stress of the nylon gear at higher temps (because this is of course a weak point of the highly tuned BBS02 because the nylon gets soft at higher temps):
60°C controller temp: 33A
65°C = 23A
70°C = 10A
(The BBS02 has no motor-temp-sensor, so it ramps down only based on the controller-temp. I think with this software I will have a good reliability as long as I am aware that the actual nylon-temp might be much higher than the controller-temp when riding with very low cadence and high torque / when the motor is in an inefficient state).

My three needed powershell-commands for creating the .hex firmware (I use Powerhell instead of CMD and Win10/Win11):
  1. make clean
  2. make all TARGET_CONTROLLER=BBSHD
  3. cmd /c """C:\Users\correctusername\scoop\apps\sdcc\4.2.0\bin\packihx.exe"" bbs-fw.ihx > bbs-fw.hex"
To clarify my confusion from my post above:
By default Powershell (but not CMD) saves the compiled .hex in the UTF-16 character encoding.
But by using my third (3.) powershell-command not powershell itself but CMD is used for the .ihx > .hex converesion step - and CMD uses UTF-8.
UTF-8 needs only have the size of UTF-16 (.hex has now 67kb instead of ~130kb).
The binary of the .hex has only ~23kb, see explanation attached.

My slightly changed firmware based on Daniels 1.5.0 is attached if anyone wants to combine the power of a up to 33A BBSHD-controller with the weight of the BBS02b (use at own risk).
 

Attachments

  • grok explanation of 67kb to 23kb binary and flash size of bbshd.PNG
    grok explanation of 67kb to 23kb binary and flash size of bbshd.PNG
    52.5 KB · Views: 7
  • Powershell commands.PNG
    Powershell commands.PNG
    127 KB · Views: 6
  • bbs-fw BBS02 motor with BBSHD controller 2026-04-18.zip
    21.8 KB · Views: 7
After the update of my BBS02B I can't connect with the BBS-FW Tool I get the message "a device connected to the system is not functioning" when I try to connect. T reid to do an update again and this was no problem. any suggestions?

Thanks.
 
I have a BBS02 500w made in 2018 - there is a warning about instability for older BBS02 so a few quick questions:

-could i revert back to stock FW if it doesn't work/is not stable?
-are the default settings going to be better than the stock FW or do I need to fiddle with them using the config flie?
-anyone using an older BBS02 and have no stability issues?

Thanks :)
 
Back
Top