E-Bike Conversion – Software

e-bike_conversion(pic21)

It’s been a while since I wrote the posts about my electric bicycle conversion project. The bicycle runs fine so far and I finally finished rewriting the software that configures its controller.

I will not make a long post for this so you won’t get bored. Basically I took the original software which also included all required source files and made it look better, fixed many bugs, improved its operation and added a small help file. Now you don’t need administrative rights under windows 8 and 10 to be able to see the available COM ports. The interface looks more tidy and well aligned and also uses better English. Numerous bugs were fixed, regarding error messages and error checking, communication, parameter limits and so on. I found this program as an open source (including all source files) I am providing it the same way.

Be advised! Doing any changes to your controller might lead to damage. I won’t be held responsible for any kind of damage you might induce to your controller, motor, gears, bicycle or yourself. Do what you like at your own risk! Cycle safe and take care of others on the road!

You can download the program HERE. The file keeps getting reported for violation, so it might get blocked again. I just reuploaded it again. I have no idea who and why is doing this. It can’t be shared on WordPress directly, so I might have to look for new sharing service again.

Latest version uploaded on 16.05.2017 with a few updates. Assist level labels now say Assist, not Assit 😀 The current limit is not active when bike is not connected. This allows you to work with your saved profiles even if you haven’t connected your bike.

Compatibility with BBS##B drives has been confirmed by many users now. Luckily for all, Bafang hasn’t changed the communication protocol.

375 thoughts on “E-Bike Conversion – Software

    1. I don’t have Linux and no such version as I can’t test it. You are welcome to port it to Linux. Source code is in the zip file. It is Delphi 7 (Pascal).

  1. I DONT FIND A PORT IF I START UP THE PROGRAM?CAN YOU EXPLAIN WHATS THE ISSUE?THANX

    1. No need to shout (CAPS LOCK). If there is no port found, try refresh. If there is still nothing, you have issues with the driver for your USB to serial adapter.

  2. Hey Penoff, Thanks for your effort to rewrite the configuration tool prog!
    question:
    Just downloaded and installed the tool, but the tool does not show full view, the right hand and bottom section is not visible and no slider is showing for this too. Can you give me a hint what to do to solve this?

    greetings from Holland, Rene

    1. The issue is most likely your system font, which has been changed. Possible other reason is Windows scaling.

  3. Thx´s for your support, fyi no answer from controller with 9600Baud, no changes.

    1. Read is also a command sent to the motor to tell it to return something. 🙂

  4. …ok. Software-environments isn´t realy my buisiness. Seen in main.pas at line 211 1200Baud.
    Would you please compile and provide a 9600Baud variant?

    Regards, Walter

    1. I can do it when I have time, but I doubt that will solve your problem. Provide it where? It would be best if you send an email for that, so I could reply with the executable attached. And also I must say that I am not taking any responsibility if something goes wrong with your motor after this experiment.

  5. Hello Stefan,

    thanks for providing this project and the software. I´ve got a Hub Bike with C965 LCD. Checked the communication Tx / Rx with a scope and found a higher Baudrate (Frame to Display is about 10ms long, repeated every 100ms, BitTime about 100us. Can send Tx signals via your software USB2RS232 but no reaction. See there a BitTime of 1ms.
    Would there be a possibility for changing the Baudrate?

    Regards, Walter

    1. I haven’t looked into the LCD real time communication. It should be the same baud rate though. You can change the baud rate in the source code if you want, but I can’t say if that will work. Not sure if hub motors use the same protocol.

  6. Thank you, I saved more than 100 eur for deleted speed limit on bafang m400 mid drive, program work well,thank you very match

  7. Hello,
    Please tell me if it is possible by programming the controller, to limit the throttle speed to 6 km/hour with big power in any PAS mode, in accordance with UE regulation .
    Thank you,
    Silviu

    1. You can’t limit it that low for all PAS levels. It is mostly useles with such speed limit anyway. Instead you could just not install the throttle at all. Everything else will work just fine.

  8. Hello, do you think I can use this mid drive to steering wheel in tractor, similar to this https://www.youtube.com/watch?v=cWFfW7f8y7Y , I am planning to put encoder to know the position of the shaft, Does this have protocol that I can control with m own device to control direction of rotation and rpm

    1. Bafangs motor has entirely different purpose and I don’t see a way it can be used for what you show in the video.

  9. Hello Stefan, thanks a lot for this work. You are so kind because you didnt choose to earn money with this work. Thank you.

    If you didnt stop this project, i have a question. in the throttle section, the highest value of speed limit is 40km/h. But my mid drive can make higher than 50km/s. What can i do now?

    1. I jave wondered about that setting as well. Mine is set to use the limit set by the display, which is 99km/h and I have used the motor at speeds above 50. I don’t know why it is like that. If I set some value higher than 40 I just get error from the controller. That is why I left the control in the software with limit of 40 like the original software.

  10. Hi Penoff,
    Great work with your website.
    As an electronics engineer I am very interested to know what protocol Bafang uses for the controller to display can bus and if there is any software available for a DPC-14/850C Display please? Maybe just to re-initialise the display.

    1. Hi! Thanks!
      They use a simple serial protocol with modulo 256 error check. It is the same for changing motor settings and reading status information for the LCD. If you look into the source code you will see how it works. I don’t have the commands for requesting current speed, power and so on. You can just monitor the communication and you will find them fairly easy.

  11. Hi Awesome job on the config sw! I’m trying to make my BBSHD appear street legal in Norway. To do this, it would be awesome to have the ability to set the throttle speed limit to 6kmh. Is that supported in this sw? The lowest I was able to set from the drop down menu was 15km/h..

    1. I don’t think the controller accepts any value lower than 15 even if you send one to it. To be street legal, you are not allowed to have throttle. The 6km/h is for walk assist and you have that when you press and hold the “-” button. You can disconnect the throttle. The system will operate just fine. Also street legal should be limited to 250W and 25km/h. You can limit those as well, but then it is really waste of a great motor. 🙂

    2. I found a way to do this. I locked the throttle mode to assist level 1 and configure this mode for only 6kmh (walk assist). This way the throttle has a function and is less suspicious. I’m working on an arduino device that will legalize the BBSHD by the press of a button in case I’m stopped. I can then ride it with all power (and throttle) available until I press the button. Thanks to your program, I don’t have to dive into the protocol, I can only copy the data sent by your program 🙂

    3. That seems like working solution for the throttle. You can do the Arduino hack as well. You just need DC-DC converter for low voltage. I am not sure how many write cycles the memory supports on the motor controller so don’t use it too often to rewrite settings. Should be good for at least 10000, but you never know with unknown brand microcontrollers.

  12. Thanks for the gift to Bafang users Stefan! Your version is very nice to use.
    I am just adding this comment to say that everything is working fine with a brand new 750W BBS02.

  13. Hi and thanks for your works, few month later do you know if it works with BBS01B

    1. I am not sure. I haven’t searched the forums for information. I guess it works, but it will be nice if people who tried, share their experience here.

  14. Hi
    The installation of the drivers por the bbs02 controller doesn’t work.
    It appears ”Unknow device error 43”, and I didn’t get any solution yet.
    Any suggestion?

    1. Do you mean the USB to Serial cable drivers? My program doesn’t have anything to do with that. Maybe it is a defective USB adapter. Try it on another computer. If it show same error, get new adapter.

  15. Hi Penoff, Some (or maybe all?) BBS02 and BBSHD motors manufactured in 2017 seem to have a software issue where when you pedal (in any PAS %) and twist the throttle any amount, the motor is very jerky … constantly cycling between full power and low power. So users are having to decide between using only PAS or only throttle (by snipping a PAS wire). I’m just using PAS and not touching my throttle.

    Luna doesn’t have a solution. I’m not sure if Bafang is ever going to address the issue. I doubt they would issue a service fix for motors already sold.

    Is there any chance you can look into this issue and see if there is a setting you can add to your program to solve it? Or is this more of a deep down firmware issue that you can’t access? Thanks!

    Some threads on the topic:
    https://endless-sphere.com/forums/viewtopic.php?f=28&t=89554
    https://endless-sphere.com/forums/viewtopic.php?f=28&t=91306

    1. I’ve heard about it. My program is revision of the original Bafang program. I can’t add any configuration parameters which are not already available in the firmware.
      The problem is most probably a firmware issue. I can have a look at the forums, but I doubt I could help much unfortunately.

  16. hello!
    i’m trying to configure my BBSHD i install your software and it still ask me for a password to get in to …

    can you help me abaut this ?

    best regards

    1. When are you asked for a password? There is no password in my program.

Your comment:

This site uses Akismet to reduce spam. Learn how your comment data is processed.