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

FOC Open Source Firmware for Bafang CAN bus controllers with GD32F303 processor

With the DPC245 motor runs in walk level on display without any buttons pressed.
That's the same with my display. As said, from other non Bafang system displays the behaviour is different. There in no assist level called "Walk" at all. The push assistance simply starts with a long press on the down button and stops with releasing the button, even if you are in the highest assist level 🤷‍♂️
 
2. When switching to walk mode, the motor immediately starts spinning, which is dangerous
I also thought it was a crappy implementation, but in practice it works really well. Of course, ideally we could make the startup smoother.

This is a strange behaviour of the display firmware
My DPC245 works like this too:

First press — exit to “0” mode.

Second press — WalkMode starts right away, no need to hold the button.

Honestly, I figured it was a feature, not a bug — it’s pretty handy. But then, after a few seconds, it randomly shuts down, and that’s annoying.

The button‑hold method only works on my SW102T display — but that one’s always a little weird.
 
The walk assist mode should engage instantly and smoothly. The original configuration, which requires holding the button, is highly inconvenient and makes the feature practically unusable for me.

On tough terrain where you have to push the bike uphill, holding the button down is next to impossible
 
I use the throttle instead of walk mode. But a couple of times I accidentally switched to walk mode instead of O mode by pressing the down one extra time. I used the O mode in particular to measure the throttle trigger voltage.
 
but backpedaling should still interrupt the Extended Boost safely.
Obvoiusly I forgot to commit the latest change before compiling, here is the update. Backpedaling shoud interrupt the Extended Boost now....

I'm just starting with the M820. I found some slight differenced already...
 

Attachments

  • EBiCS_for_M510+M560_BL38_v0.0072.zip
    60.1 KB · Views: 15
bvoiusly I forgot to commit the latest change before compiling, here is the update.
I’ve finally managed to test it, and it even lifted my mood =)
Herr @stancecoke has repeatedly told me that most people want a smooth ride, but he designed the throttle for off‑road enthusiasts — i.e., it’s quite responsive/aggressive :D. If I were using this, I’d actually want something like that.
I also figured out the hype around power levels in local chats: for throttle lovers, 1–1,3 kW is indeed a bit too low.

The PAS timeout seems to work as intended. I’m not entirely happy with everything, but I’ve found the optimal setting for myself. The decay works exactly as a decay, not as a second PAS timeout. There’s only one issue left: jerking at cadence <10 RPM.

It seems that Ext. Boost has stopped choking during intense pedalling and is working fine now. I even got the urge to master this feature. I’ll need to pick a good, fairly high activation threshold. Make the operating time longer. Then I’ll need to make using the reverse rotation interruption second nature.
 

Bosch copies the EBiCS feature now :ROFLMAO:
Extended Boost
Now it’s possible to adjust the level of Extended Boost using the Flow app. You can dial it up to a maximum of 10, or turn it off completely by adjusting the slider down to 0.
Another new feature: pre tensioning the chain by a backpedal impulse to avoid hard punches on the drive train. Would be easy to implement.

Drivetrain Tensioner
The final motor update incorporates a new function called ‘Drivetrain Tensioner’. This is designed to remove any lag when you go to step on the pedals, improving power response while also reducing noise.
 
Last edited:
I’m not super familiar with EU laws, but all these motor upgrades since the Avinox came out totally look like fiddling with the numbers! ’Cause anyone who’s ever tuned a Bafang motor knows what kind of currents and power you need to get that kind of torque. I just can’t wrap my head around how they get away with calling it 250 W. :D
Another new feature: pre tensioning the chain by a backpedal impulse to avoid hard punches on the drive train. Would be easy to implement.
I’m curious how much extra energy this’ll draw. I personally go for Cues cassettes — those things just shrug off impacts. Regular cassettes, on the other hand, really do get their tooth profiles squashed under sudden loads. Weird that nobody figured this out sooner!
 
Bosch have a problem with their motors rattling like Maracas on the downhill sections, Avinox overcame the same problem with making the gear interfaces much tighter tolerances but created quite draggy engines when peddling with low support, have Bosch decided it’s better to waste a bit of battery with pretensioning the gears to avoid the “Bosch rattle “ than to spend large redesigning the gear train and with the increased production costs of future engines to get those better machine tolerances ?

Be interesting to see just how much energy that system would absorb ?
 
Bafang M560
I have tested your Ebics v.0.0079, and the overall feel, smoothness, and assistance are now indeed as good as in systems from Bosch, Yamaha, etc.

However, I have encountered one major issue. Initially, the assistance works very well, but after about 3 hours of riding, the power delivery starts to weaken across all modes. It eventually reaches a point where the Boost mode feels even weaker than Eco.
I don’t think this is related to the motor overheating, as the assistance remained very weak even after a long descent when the motor had completely cooled down. It was only after returning home and leaving the bike for a few hours that everything started working correctly again.
This problem seems to be strictly related to the torque sensor. Full power remains consistently available via the throttle at all times.
 

Attachments

  • Screenshot_2026-05-03-12-12-25-346_com.miui.gallery-edit.jpg
    Screenshot_2026-05-03-12-12-25-346_com.miui.gallery-edit.jpg
    229.6 KB · Views: 7
Bafang M560
I have tested your Ebics v.0.0079, and the overall feel, smoothness, and assistance are now indeed as good as in systems from Bosch, Yamaha, etc.

However, I have encountered one major issue. Initially, the assistance works very well, but after about 3 hours of riding, the power delivery starts to weaken across all modes. It eventually reaches a point where the Boost mode feels even weaker than Eco.
I don’t think this is related to the motor overheating, as the assistance remained very weak even after a long descent when the motor had completely cooled down. It was only after returning home and leaving the bike for a few hours that everything started working correctly again.
This problem seems to be strictly related to the torque sensor. Full power remains consistently available via the throttle at all times.
Did you check the battery voltage, 3 hours is pushing into lower voltages ?
 
battery voltage was still high. 4.0v for cells.

Could this torque sensor behavior be related to damage? A while ago, I hit the crank arm exceptionally hard and ended up bending the whole thing.

What are the differences between the different versions of ebics? I see that at least two users are submitting their versions with slightly different numbering.

I’m currently testing the version from user stancecoke. However, I noticed that the 'legal flag' option is missing, and the engine temperature isn't displaying either (even though that feature was supposedly added).
I have a dcp080 display
 
What are the differences between the different versions of ebics? I see that at least two users are submitting their versions with slightly different numbering
Hm, as far as I know, I'm the only one who is providing ready to use bin files at the moment. There are the releases at GitHub with the v0.00x nomenclature and here in the forum there are attachments with v0.00xx. I'm not really consequent with the xx, so it might give two different files with the same name. It would be much better to publish at GitHub with a strict version tracking.

Concerning the torquesensor, difficult to analyze from the distance. I could send the actual torque value to the calories field, then you can see the state in the display, without having to attach the laptop to read the live data by the Canable.
 
If it were possible to display the torque sensor readings on the screen, it would be an excellent diagnostic tool. Right now, I'm a bit stuck, so I’m considering buying a newer version of the M560—apparently, it features an optical torque sensor.
 
Concerning the torquesensor, difficult to analyze from the distance. I could send the actual torque value to the calories field, then you can see the state in the display, without having to attach the laptop to read the live data by the Canable.
That would be so helpful for diagnosis of faults.
 
If it were possible to display the torque sensor readings on the screen, it would be an excellent diagnostic tool.
Done. I've just released v0.008 at GitHub:


The calories field shows the actual torque signal now. Right after switching on, it should show about 740mV without load on the pedal. With high force on the pedal it will show up to 3300mV. Would be interesting, if the value drifts with time and/or temperature...

it features an optical torque sensor.
The optical part is only the PAS signal, not the torque signal, so I guess this will make no difference...


regards
stancecoke
 
I tested v0.008 today.
The torque sensor seems to be reading correctly, showing values from approximately 740 to 3200 (there was one instance where the range shifted to 400–2800, but the correct values returned after a restart).

1. I notice that in this version, the ramp up/down values are now set to 0.7s and 0.9s. If we want the motor to cut off quickly after stopping pedaling and to react instantly to pedal pressure, should both of these values be set to 0.1s?

2. What should the "current limit phase" value be if I set the "current limit battery" to 30A on the M560? (I want to test the motor performance at around 1700W). After setting only the "current limit battery" function, I have the impression that it is very difficult to reach a current higher than about 20-25A (I am monitoring this via Smart BMS).

3. I noticed significant issues with the "legal flag" function. Toggling this function via the button combination works. However, in my case, the speed is not restricted to 25 km/h at all. The throttle itself is limited to a maximum of 6 km/h, but pressing it causes a very violent power surge. Also, if I pedal and press the throttle at the same time, the 6 km/h throttle limit is completely bypassed. With the legal flag enabled, I observed other strange bugs—the motor can even provide power without any pedaling.

4. I would also suggest, if possible, displaying the motor/controller temperature directly on the display in another, less essential field.
 
With the legal flag enabled,
Have you used the field "Coaster Brake Support?"
Last time I've tested this feature it worked as expected.
In combination with pedaling the use of the throttle is legal. Only if the pedals are not turning, the throttle is limited to 6kph.
And of course you can give maximum motor torque with the throttle.

 
Last edited:
The torque sensor seems to be reading correctly, showing values from approximately 740 to 3200 (there was one instance where the range shifted to 400–2800, but the correct values returned after a restart).
I wonder why this kind of mix‑up only happens with the M560?
(I want to test the motor performance at around 1700W)
Be prepared to replace the overrunning clutch HFL1426 or the gear assembly. With this power output, mine lasted 2 500 km before failing. The issue is that the gear assembly isn’t always available for order. Our local riders replace it with a higher‑quality equivalent, and sometimes even bore out the gear to fit a larger clutch. Both options work quite well.
 

Attachments

  • 2023-12-09-12-48-55-396.jpg
    2023-12-09-12-48-55-396.jpg
    1.5 MB · Views: 15
Have you used the field "Coaster Brake Support?"
Last time I've tested this feature it worked as expected.
In combination with pedaling the use of the throttle is legal. Only if the pedals are not turning, the throttle is limited to 6kph.
And of course you can give maximum motor torque with the throttle.

I have tested the legal flag mode in versions v0.0079 and v0.008. It toggles on and off correctly, and the display properly shows the digit 8 or 9.

However, in my case, the speed is not being limited to 25 km/h at all (m560). While the throttle is restricted to 6 km/h, it would be ideal if the throttle in "legal mode" provided a gradual power increase, similar to how the "walk assist" function operates.
I also believe it would be better if the throttle were deactivated during pedaling. Having the throttle provide full power while pedaling might be frowned upon during a roadside inspection.

I solved the low power issue by increasing the "current limit phase" parameter to 50A. Previously, I wasn't sure what this function did, but I’ve just learned that it should be roughly twice the expected power (current).
 
I have tested the legal flag mode in versions v0.0079 and v0.008. It toggles on and off correctly, and the display properly shows the digit 8 or 9.
This is the off-road mode, not the legal flag.
The speed limitation works only, if the legal flag is set (Coaster Brake Support set to "yes") and the Off-road mode is disabled.
 
Last edited:
Back
Top