• 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!

BAFANG M215 (BBS01 CAN bus), M315 (BBS02 CAN bus), M510, M560, M820, CR-A101 FOC Open Source EBiCS Firmware for GD32F303 processors

Probably a dependence with one turning point
would you be happy with one parameter, that defines an exponent? You could trim the curve to a progressive or a degressive characteristic. Just one 8bit parameter would be all we need to be user defined. Orange: exponent = 0.3, green: exponent = 2
1779901333807.png
 
but have not made the exponent user settable yet.
That's done now also. The field "Speed Limit Enabled" in the canable tool is used for the exponent. The value is divided by 100 internally.
100 means 1
30 means 0.3
200 means 2

So values lower than 100 lead to a degressive curve, values higher than 100 to a progressive behaviour. See #651
It is an 8 bit value, so numbers in the range from 0 to 255 can be used.

The exponent is calculated at startup, so you have to restart the system after changing the value with the canable tool. The default value is 100, this means linear behaviour.

Not tested.

regards
stancecoke
 

Attachments

  • EBiCS_for_M560_BL38_v0.0082.zip
    30.2 KB · Views: 17
That's done now also. The field "Speed Limit Enabled" in the canable tool is used for the exponent. The value is divided by 100 internally.
100 means 1
30 means 0.3
200 means 2

So values lower than 100 lead to a degressive curve, values higher than 100 to a progressive behaviour. See #651
It is an 8 bit value, so numbers in the range from 0 to 255 can be used.

The exponent is calculated at startup, so you have to restart the system after changing the value with the canable tool. The default value is 100, this means linear behaviour.

Not tested.

regards
stancecoke
Tested. "Speed Limit Enabled" field can only be set to 0 or 1.
 
only be set to 0 or 1.
OK, then we have to ask @mdi, if he can make the field freely editable, or choose another parameter. But there are not many 8bit fields without function left...
It would be easy to build a Canable tool version, that has the EBiCS specific field descriptions, but I want to avoid two versions of the tool...
The most comfortable solution would be a switch in the tool to change from the original BESST logic to the EBiCS logic....
 
Last edited:
The most comfortable solution would be a switch in the tool to change from the original BESST logic to the EBiCS logic....
Are you now getting to the stage that the EBICS firmware is now so different to the the Bafang firmware and getting mature in development enough to just have an EBICS version of the Canable Pro with the correct naming of the parameters, it would make it a lot easier for any new users ?
 
an EBICS version of the Canable Pro with the correct naming of the parameters
I think easier would be to have double labels
Yes, it would be possible to add both descriptions, mayby two lines in different colours. As the GUI is a HTML file, you can edit it quite easily. But I don't know, if @mdi will do this service for the EBiCS project. Of course, someone else could do this scut work and submit a pull request. ;)
1780041502928.png

HTML:
<th style="display: inline-block;">
       <div style="color: black; text-align: right;">Cadence Sensor Signals/Rotation</div>
       <div style="color: blue; text-align: right;">Throttle exponent * 100</div>
</th>
 
Last edited:
  • Like
Reactions: mdi
Last edited:
Done, but not tested
Great news! The torque sensor is very sensitive at the beginning of the range. I think it can be limited even further if needed, without a noticeable reduction in sensitivity.
Recently, I’ve been riding the bike quite a lot, and at 760 mV, the torque sensor experienced thermal drift a couple of times - and the power delivery didn’t stop at all. False triggers also occurred quite often when riding over rough terrain and experiencing bumps. Fortunately, these effects were rather mild and didn’t affect safety.
 
Last edited:
Then your display is not sending the button down flag with the CAN protocol. The button down pulls down the voltage on the On/Off button pin to a certain value so this analogue voltage would have to be checked. I simply returned to the old logic, where you don't have to hold the button, but just have to switch to the walk mode level.


I guess, you didn't increased the decay parameter from the default setting? I've set the default value to 255 now and have the integral part is reset as soon as the iq setpoint is zero.


I've set the PI control parameters a little less agressive.

The attached bin file is not tested!


Yes, and you can return to the original Bafang firmware at any time.

I don't know, if someone ever tried to set the parameters with the BESST tool also. Maybe this works also even :unsure:

Edit:
I went for a test ride, I'm quite satisfied with the behaviour now :cool:
I had to set the multiplier to 20 to get sufficient assistance in sport mode, but that's just the process of fine tuning the parmeters to your personal preferences. The M820 bootloader seems to erase the whole flash memory on the firmware update, so you have to restore all your personal settings after flashing. The position sensor calibration has to be redone also. That's different to the BL3 and BL38, they don't erase the memory page of the virtual EEPROM. That's more convenient of course.
Sometimes the setpoint drops quite sharply, I don't now why, but you don't notice that during riding. Perhaps I'm really pedaling that unevenly ....

View attachment 388567
yesterday try to flash the firmware with besst tool and works, but no assist on motor. And Besst tool pro can't read the controller and off course the parameter can' be changed. So I revert back to original Bafang firmware. Wait for my canable arrive.
 
First of all, I want to say that I really appreciate the amount of work that has gone into this project. It's obvious that a lot of time and effort has been invested, and I respect that.

That said, road navigation alone is not enough for me to switch to this solution. In my opinion, there are still several important things missing or needing improvement:
  • Walk Assist (WA) is not working.
  • No range estimation. This is one of the most useful features on an e-bike and I really miss it. Combined with the inaccurate battery level estimation algorithm, the current battery information is not very useful for planning rides or judging the remaining range with confidence.
  • Cadence / PAS is not configurable. Also, the behavior and data from the M510 do not seem to match the M820, which leads to inconsistent assist behavior.
  • Safety issue: if the display gets disconnected, the motor keeps running in Walk Assist mode and the system does not shut down automatically. This should not happen.
  • Motor control needs improvement. During high power peaks the motor can feel unstable, and power engagement/disengagement is very abrupt. This creates unnecessary stress on the drivetrain and may increase wear on components.
  • Configuration is difficult. The connection through CANable is unstable, and many settings are not properly documented. It's often hard to understand what a parameter actually does and how it affects the bike.
  • No proper thermal derating. Instead of smoothly reducing power when temperatures rise, the system relies on hard limits. A gradual reduction would provide a much better riding experience.
  • No diagnostic error codes. When something goes wrong, it is difficult to identify the cause. Basic error codes and logs would make troubleshooting much easier.

Overall, I think the project has a lot of potential and I appreciate the work that has been done so far. However, before I could consider switching to it, I would like to see more focus on reliability, safety, diagnostics, motor control, and core e-bike functionality. For me, those features are much more important than navigation.

I cannot fully agree with the statement that EBiCS for Bafang is already in a mature stage. In my opinion, there are still too many missing features and unresolved issues in core functionality.
 
In my opinion, there are still several important things missing or needing improvement:
Thank you for your feedback, on which motor you did your tests? There are quite a few inconsistencies in what you've said:
Walk Assist (WA) is not working.
if the display gets disconnected, the motor keeps running in Walk Assist mode
The Walk Assist works, as long as the display is sending the walk assist level and the speed shown in the display is lower 6kph.

Cadence / PAS is not configurable.
This parameter don't has to be user settable, as there are different bin files for different motors anyway. If the cadence reading on the M820 is not correct actually, we can simply correct it with the next release.

During high power peaks the motor can feel unstable
I never "felt" something unstable, there are a lot of logs of real test rides in this thread where you can see how the motor and battery current control works.

The connection through CANable is unstable
This is not a matter of the EBiCS firmware, but a general issue with any firmware file.

Instead of smoothly reducing power when temperatures rise, the system relies on hard limits.
?! The allowed power is ramped down lineary with the temperature between 110 and 130 °C.

I cannot fully agree with the statement that EBiCS for Bafang is already in a mature stage. In my opinion, there are still too many missing features and unresolved issues in core functionality.
In EBiCS the source code is availabe freely and everyone who is interested, can read in detail how each function works and can contribute improvements.
With the Original Bafang firmware no one knows, which bin file shows which behaviour, most parameters that are available in the BESST or Canable Tool are not editable at all.
For sure, there are many features left, that can be added or improved, like coulomb counting for a range estimation or error codes or tutorials and documentations. This is simply a matter of priorities. My priority is a smooth, predictable assist behaviour and fun at riding. This challenge has already been fully met ;)
 
there are still several important things missing or needing improvement:
Hello. Please specify which motor and firmware version you are referring to. Of what you have indicated, only a couple of points are true for the M510/M560 motors:

- Difficult setup.
- The remaining range calculation feature is missing.
 
which motor you did your tests?
Only m820.

Could you please create a simple tutorial explaining how to configure the Power and Assist settings independently for each assist level Stancecoke? A step-by-step guide would be very helpful.
 
Last edited:
Could you please create a simple tutorial explaining how to configure the Power and Assist settings independently for each assist level Stancecoke?
There is a wiki page about the normal ride mode:

Every relevant parameter is explained there.
The EBiCS meaning of the fields in the Assist (Full) tab is not in the latest Canable release yet, you have to look into the EBiCS ReadMe at the moment.
The only thing I recommend to change is the multiplier, the default value is too low. I've set it to 20 for a good behaviour. The rest of the parameters can be used for fine tuning. Of course you can tune the motor and the battery current in the controller tab also. Everyone has his own preferences...

Keep in mind, that the EBiCS firmware always controlls the motor current. The battery current limit is not influenced by the enhanced parameters. It's always the one value, that is defined in the controller tab. Maybe this confuses users coming from the Power = Battery Voltage * Battery Current logic. Of course this formula is still valid.

Don't hesitate to ask for details, we can improve the documentation with user feedback only. Feel free to edit the wiki yourself, everyone with a GitHub account has write access.

The explanation of the PAS Timeout and Current Decay is still missing, we have to add it.

1780319580816.png

1780320053833.png
 
Last edited:
perhaps we should format the headers to left align
Looks much better with left align.
I have submitted a pull request for this version:

I've updated the wiki for the normal ride mode also. I hope, it is easier to understand now.

The Legal/Offroad usage was updated also:

1780511123497.png
 
Last edited:
I just did some tests on M820.

First thanks for this. A lot of great job has been done here.

Driving part is good. The wide range of adjustments allows to customize the ride nicely. Although I still need to find the right setting to prevent the motor from cutting out so often at low cadence and pedal pressure.

Stock parametres for M820 are not good, i'm sharing my - still not the best but mutch better then stock. Canable now have futere to save/load params to file so it's easy exchange them.

Walk assist part is poor, on very steep slopes motor does not have enough power to help. I would see here 2 extra params:
- Walk assist power multiplier
- Walk assist speed limit // with 1 magnet setup speed limit at 6km/h is too low because of read delay
 

Attachments

  • 2026-06-04T09-21-37_ebics_canable_backup.zip
    1.9 KB · Views: 6
Thank you for your detailed feedback!

Although I still need to find the right setting to prevent the motor from cutting out so often at low cadence and pedal pressure.
Hm, the M820 bin file has not the increased torque threshold yet to prevent the motor from running without effort from the rider when some thermal drift of the torque signal happens. So it should work with low torque on the pedal and low cadence quite good. Can you log the debug data? Then you could check, if the iq setpoint gets zero, or if the calculated setpoint is just very low. Both would need different measures to improve the behaviour.

The walk assist is tricky on a middrive indeed. As the motor doesn't know which gear is chosen, we can't use the motor speed for limiting the wheel speed. We have to rely on the external speed magnet and with only on pulse per wheel revolution, the control is very sluggish.
The iq setpoint for the walk assist is hard coded at the moment, but it's easy to make it user settable. But strength and speed will always be depending on the gear you are in...
 
Last edited:
I would encourage you to to make walk assist settable i found it very difficult to use walk assist with original bafang firmware i tried to use throttle with lowest gear with moderate result though I know that's it is complicated but i think of the situation that you could input your front/ rear cog size (you prefer to use on walk assist mode) and use throttle to fine tune walk assist speed.
I usually use walk mode on steep uphill and the gears are lowest from baseline
 
Last edited:
Back
Top