Bafang M400 mid motor CAN bus hack

Disclaimer ==> The following description is solely the readers risk and responsibility to use, and is an experimental hack. Any change of an ebike speed limit might be illegal, depending on the public local traffic regulations. <==.

The hack is based on the this article:

The CAN bus has been used in cars for a few decades to provide a prioritized communication between the ECUs ( Electronic Control Units ), and has been used for Bafang ebike parts ( display, motor controller, speed sensor etc ) since 2020.Bafang provides a Besst programming tool to cope with local traffic regulations on different markets. When the Besst tool is connected to the CAN bus AND to the Bafang cloud service, it is possible to update firmware, set torque levels, speed limits, wheel sizes etc. In the article mentioned above the communication between the Besst tool and the CAN bus devices has been analyzed and the protocol for setting motor controller parameters etc has been identified.

To emulate the Bafang CAN bus protocol, 2 CAN bus extender cables (with female and male connectors) and an Innomaker USB2CAN tool is used. An example: to change the speed limit and wheel size parameters, the CAN bus connectors between the display and the motor controller is used for the connection to the USB2CAN tool:

The Innomaker USB2CAN device connects to the small interface board shown:

The USB plug connects to a Windows PC and the InnoMakerUSB2CAN application can be used to set different parameters the motor controller: