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

I can make a bin file for the M560 this evening.
Today I'll make an adapter with an easy-to-replace fuse. I'll be able to test the M560 on Thursday.

What is missing most? If it is fast to implement, I can do it in parallel of course...
This information will appear gradually. My testing, at the moment, is an endless "assault" on the same bridge near the house :).
Now I will be able to make full-fledged trips in flat terrain. Closer to May, in places with a small difference in altitude. In June, I will be able to visit the mountainous terrain.
1) "Pas timeout", "Pas Ramp End";
2) Algorithm for turning off the engine when reverse pedaling is detected;
3) Smoother "Walk Mode";
4) Configurable "Overrun" function linked to the riding mode; - this would be total domination over the original firmware. In some versions it is available, in some not, it cannot be configured :D. Perhaps even instead of "Torque Override" since I have never heard of anyone using it;
5) For those who use the throttle handle - responsive and customizable control;
6) Filter for current speed readings. When using a large number of magnets (more than three), the display does not keep up with the changing speed readings and the readings are difficult to read.
 
1) "Pas timeout", "Pas Ramp End";
timeout is used already, Ramp End is only useful for simple power levels like the old BBSxx had. Is someone keen to use that mode?!

2) Algorithm for turning off the engine when reverse pedaling is detected;
Would be quite easy to implement. But would be useful only for a few milliseconds until PAS timeout kicks in anyway...

4) Configurable "Overrun" function linked to the riding mode; - this would be total domination over the original firmware. In some versions it is available, in some not, it cannot be configured :D. Perhaps even instead of "Torque Override" since I have never heard of anyone using it;
you have to explain, what this "overrun" should do. I have no idea :)
In the Lishui project, users asked very often for the torque override function 🤷‍♂️
6) Filter for current speed readings. When using a large number of magnets (more than three), the display does not keep up with the changing speed readings and the readings are difficult to read.
That's very easy to implement (if the filter has not to be user settable)
 
Last edited:
Would be quite easy to implement. But would be useful only for a few milliseconds until PAS timeout kicks in anyway...
This increases driving safety for the "Overrun" function and long "PAS Timeout".

you have to explain, what this "overrun" should do
This is what Bosch does in its off-road systems. It will be clearer if I ask the English-language AI.

"The term overrun (also known as Extended Boost in Bosch systems) is a software feature of an e-bike motor that allows it to continue providing power for a brief moment (typically up to 2 meters of distance) after you have stopped pedaling.
What is it for?
This feature is specifically designed for technical e-MTB riding to help navigate difficult sections:
Clearing obstacles: On steep climbs with rocks or roots, riders often need to pause pedaling for a split second to avoid "pedal strikes" (hitting an obstacle with the crank). Overrun provides an "extra push" that carries the bike over the obstacle while the pedals are held level.
Smoothing "dead zones": During slow uphill pedaling, the motor helps compensate for moments when the pedals are in a vertical position and leg power is at its lowest.
Maneuvering: It makes it easier to lift the front wheel at low speeds to clear ledges or steps.
How it works in practice
Systems: This feature is most prominent in Bosch's eMTB or the newer eMTB+ modes (especially on the Performance Line CX Gen 5), as well as in the latest firmware for the Shimano EP801.
Customization: In apps like Bosch eBike Flow, you can adjust the intensity and duration of this "extra boost."
Learning curve: It takes time to get used to. If set too high, the bike might "lurch" forward in a tight turn or on a narrow trail if you don't cover you
r brakes."
 
continue providing power for a brief moment (typically up to 2 meters of distance) after you have stopped pedaling.
is it triggered somehow, or just always active?! I woud say such a behaviour is more dangerous than helpful, but I'm not a mountain biker. :ROFLMAO:
We could combine it with the torque override function, if you give an impulse with the pedal, this boost is kept for xxx (milli-)seconds. What should be user settable? The torque? The duration?
 
In the Lishui project, users asked very often for the torque override function
I first heard about this feature in this thread. Perhaps it's somehow related to the specific torque sensors of individual motors? I could simply load the torque sensor to 3300 mV in the appropriate mode. I can hardly imagine a situation where I suddenly need to enter Earth orbit from "ECO" mode.
What should be user settable? The torque? The duration?
Both time and power. Let's say "Boost" mode is used for climbing difficult slopes. The user then adjusts the time and power to suit their needs and to avoid being thrown backwards. This is actually a fairly high level of skill for e-bikers. Not everyone uses it. Some simply use the throttle. Therefore, implementing this feature is desirable, but not urgent.
 
is it triggered somehow, or just always active?! I woud say such a behaviour is more dangerous than helpful, but I'm not a mountain biker. :ROFLMAO:
We could combine it with the torque override function, if you give an impulse with the pedal, this boost is kept for xxx (milli-)seconds. What should be user settable? The torque? The duration?
I personally highly prefer less overrun als possible, the first m620 UART I have has High overrun and I was quite happy when my m620 with X1 motor doesn't have it anymore 😅 If I need that assistance I give a little bit of throttle..

So for m560 testing I have besst tool here but not sure if it's safe as I also read that advise to not flash the 510fw to m560.
 
I first heard about this feature in this thread.
Yamaha drives have this behaviour.

With the PW-ST motor, as soon as you put your foot on the pedal, even the slightest pressure is enough to get the motor to start moving. That’s not the case with the Bosch motor. With that one, you can just leave your foot on the pedal.
Some love it, some hate it, as always. Therefore I have made it user settable...
is it triggered somehow, or just always active?!
Do you have experience if the overrun is active always, once configured?
I would prefer to trigger it by the override detection and even define the strengh by the kick on the pedal. Otherwise this boost would be uncontrollable, once triggered...
 
Yamaha drives have this behaviour.
Obviously, I had no experience with Yamaha.
Do you have experience if the overrun is active always, once configured?
Most Bafang users have this experience (especially in powerful assist modes). It's not always a good one, though, because it's not configurable. :D
The motor simply continues to run for about a second, depending on the power output when the pedals stop. Yes, this wasn't always a positive experience, but it was also impossible to configure with the stock firmware. In certain situations, overrun is better than hitting rocks and stumps with the pedals.
 
The overrun feature of all EMTB motors is very “ marmite”. Riders who generally are more skilled and more adventurous desire it, road and gravel riders hate it, it would be a great + feature to be able to tune that power and length of that Boost to the riders skill and preference.

As Bafang has it at the moment it is always there, becoming more powerful as each higher power level is engaged. Length of time seems pretty consistent across all user levels. Bafang as soon the pedals are rotated in reverse cadence, cuts all power to the motor. Not everyone can do all things climbing technical off-road and pedal in reverse, it’s a difficult skill to learn.

My recommendation if you plan to incorporate this feature would be to have a fixed time but a power level for each assist level. Quite often in technical uphill I have to back off the assist level as the overrun is just too much and yet I need the full boost. The new EMtb phenomenon seems to be that EMtb riders have finally worked out ( I’ve been advocating this a decade and more ) that it’s as much fun riding uphill as the sheer adrenaline junkie downhill blast of the analogue bikes. Much of my riding time is now going up the downhill tracks.
 
Torque over ride I thought was that you could manually input the high and low figures of the torque sensor to ensure you get a full spread of the torque sensor. Not all sensors have the same “span” of output.
 
My recommendation if you plan to incorporate this feature would be to have a fixed time but a power level for each assist level.
As written before, I would let the strength of the last stroke define the power for the overrun. This should be quite intuitive. First I will use one fixed duration for all levels. If really someone asks for individual durations or fixed strength per level, we have to find a way how to define them, as no level dependent fields are left in the Canable tool. 🤷‍♂️
But you can define the threshold for the override for each level already, so you can scale the power with this parameter already.

It will be available in Off-road mode only, as it does not meet the requirements of DIN EN 15194.
 
Last edited:
This happend without load?! Then the M560 controller hardware is different from the M510 obviously. And of course it is always recommended to do such trials with a Lab power supply or at least with a properly rated fuse.
A theory emerged that when I pressed the throttle without a chain, the controller encountered an error due to a lack of speed readings and couldn't display it correctly. After removing the battery, the controller rebooted.
 
As written before, I would let the strength of the last stroke define the power for the overrun. This should be quite intuitive. First I will use one fixed duration for all levels.
Done. But the duration is hardcoded to 2 seconds at the moment. But I wonder, who will like this behaviour?! It's totally weird...
(but it's the way @TPEHAK has implemented it in the VESC by default ;))
The maximum torque of a stroke is taken for the strength of the overrun and this value is simply freezed for the defined duration of the overrun. Absolute nonsense for my way to ride a bike :ROFLMAO:
The threshold is set to a torque signal of 1500mV in this test.

1775667583243.png
 
Last edited:
But the duration is hardcoded to 2 seconds at the moment
I've made it settable by the parameter "Start Current" in the controller tab. It's defined in hundredths of a second, so a value of 200 means 2 seconds. As it's an 8 bit field, 255 is the maximum value, that can be set, so 2.55 seconds.
In this test ride (on the roller trainer) I've set the threshold to 2200mV and the duration to 0.5 seconds: With this threshold, you can ride quite normal and the override only kicks in, if you push the pedal really hard...

1775674157355.png
If you want to use the "normal" torque override function, just set the override duration to zero.

There are two files in the zip-file, one for the M510 and one for the M560, wich is the same binary, just with a different header. So be really careful to test it on a M560, I have no idea, if it works on the M560 controller!

regards
stancecoke
 

Attachments

  • EBiCS_for_M510+M560_BL38_v0.0074.zip
    54.5 KB · Views: 5
So be really careful to test it on a M560, I have no idea, if it works on the M560 controller!
It doesn't work and shouldn't, because the M560 doesn't have a 38 bootloader. You did BL_3 on M560 before.
In any case, I had to restore the original firmware via BESST
 
Last edited:
Ah, OK. This can't work of course, wrong start address. Here are the bin files for BL3!
[Concerns M560]
It's strange, but I'm getting reversible bricking of the controller. Both through Canable and BESST. Moreover, the firmware download isn't working properly—the controller isn't responding.
 

Attachments

  • M560_BL3.png
    M560_BL3.png
    31.9 KB · Views: 14
Your bin file shows BL38, so the first binary should work.
I'll try again this evening. But it seems there were no errors. Interestingly, @mk00 was already flashing EBiCS on the M560 when something went wrong. Nevertheless, the flashing process was success.
#183
#200
We have the same controllers for the M560. There are no others for this engine. Perhaps only the "RS" version.
 
Last edited:
We have the same controllers for the M560.
Is it known how many pole pairs the M560 has?
If it is different from 5, the M510 firmware can't work, as we get a different encoder count per electrical revolution. This would explain, why the open loop control worked, but the closed loop control failed.
It is very easy to adapt the code for different pole pairs.
 
Back
Top