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

@stancecoke,
I’ve uploaded EBiCS v0.0078 to the M560. There’s no point in writing a long manuscript — everything I previously wrote about the M510 also applies to my M560, which isn’t surprising :) The remaining issues are the “clicks” when stopping and the previously described display problems.
P.S. I couldn't plot graphs from these CSVs using your script.
I've done that now.
This is a good voltage curve. Ideally, someday we should implement a configurable zone for a gentle reduction of Imax (below 3,2 V) and a zone for a sharp reduction of Imax (below 3,0 V) — down to 1\4 of the maximum value.
Would be great to get some data which values are shown at which battery voltage with on/off button pressed and not pressed...
I will provide the data within an hour.
 

Attachments

  • M560_Test.zip
    822.7 KB · Views: 5
Last edited:
P.S. I couldn't plot graphs from these CSVs using your script.

- disable the debug messages on CAN
This can't work at the moment ;), but as the debug output is not causing the display issues obviously, we can activate it again...
Have you checked the filtering of the 6pulses per revolution already? This should be improved with v0.0079 also!

regards
stancecoke
 
Question, if the M510 and M560 controller board seem to be one and the same ? if I have both so called M510 and so called M560 boards in hand, a motor apart just about to go back together, which one should I fit ?

@Avatarkhorn you seem to be running the M510 engine with above standard amps and 52 volts. Have you ahd any over heating problems and what amps would you consider reasonably safe to use ?
 
I’ve encountered an issue regarding heat: I noticed significant heating of the device casing while it is powered on. Current consumption in Canable mode is approximately 0.20 A, while with the screen active, consumption reaches up to 12 W.

No such heating was observed when using the stock firmware.

1776105052863.jpeg
 
I noticed significant heating of the device casing while it is powered on.
Are you talking about the motor housing, or the display housing?

If it is the motor housing, can you check if you can turn the chainwheel backwards by hand easily. Maybe it's the same issue that @Avatarkhorn reported, that the motor wants to engage due to whatever. If the PWM is switched off, the chainwheel can be turned backwards easily. If you can't turn it backwards, the PWM is on, this would explain the little heating.
Have you attached a throttle?
 
No resistance is felt by hand.
OK, I'll check the current draw at standstill tomorrow, comparing the original firmware with EBiCS with and without Bootloader. You can't trust the Watts shown in the display, as the current offset is hardcoded and will differ from controller to controller. Perhaps you can check it by the Battery BMS or a simple Multimeter also?
I've checked the port states A, B and C today, but found no abnormalities. But something is switched by the bootloader that I don't understand yet :(
Have all displays 500 Ohm to ground on the orange display wire, if the on/off button is pressed? Or are there various values for the resistance?
 
Last edited:
I will provide the data within an hour.
Dealing with glitchy screens was way harder than I expected. :D
~50 Volt.
SW102: notPressed = 613-603 \Pressed = 613-603 (the value gradually decreases) (it doesn't turn off with the button)
DZ41: not "range" :D ; works fine
DPC245 (C755-0101) (2024-07-08): nP = 623; P = 611 freezing
DPC245 (C755-0101) (2024-12-09): nP = 623; P = 611 freezing
DPC245 (C755-0334) (2025-06-05): nP = 623; P = 605; works fine
Have you checked the filtering of the 6pulses per revolution already?
When I ran my test today, v0.0079 didn’t exist yet. It works pretty well, though — just need to give the wheel a bit of a spin. I’ll double‑check and get back with more details after tomorrow’s evening test.
 
Last edited:
@Avatarkhorn you seem to be running the M510 engine with above standard amps and 52 volts. Have you ahd any over heating problems and what amps would you consider reasonably safe to use ?
Yep, I’m running a 52 V battery with a 20 A current limit. No problems so far, but it’s way too early to tell — it’s spring here, which is basically like your winter. I’ll really put it to the test in the southern mountains, during long uphill climbs in the heat. And yeah, I’ve got a couple of spare PEEK gears just in case.
 
But something is switched by the bootloader that I don't understand yet
I guess the issues are related to the pin configuration and pin states of PB3, PB4 and PB6. But I see no possibility to measure the pin states on a running system, as the risk to cause a short with the probe tips on the PCB is too high.:unsure:
 
Last edited:
Perhaps you can check it by the Battery BMS or a simple Multimeter also?
Unfortunately, the BMS doesn't register such a small current, and I don't have a multimeter yet.
The current I see in the Canable is 0.18-0.22 A.

I also wanted to ask, what is the difference between these two parameters?
1776183664151.png

And also what is the maximum reasonable current that can be used?
What's the maximum voltage that can be used without damaging the controller?
For example, it's possible to use 16s with a maximum voltage of 67.2
 
Unfortunately, the BMS doesn't register such a small current, and I don't have a multimeter yet.
I've checked the current draw with the original and the EBiCS firmware. Both take about 70mA with lights off (and a powermeter and the BT-Sniffer installed). So this is very little and there is no difference between the original and the EBiCS firmware.
I hope, I have solved the display issue also. PB6 has not to be set with the bootloader. With not setting it, the raw reading of the on/off button shows values about 4095 (3.3V on the input pin) with the button released now and when the button is pressed, the value drops to about 2400. The value is in the calories field now, as the range field can't show a 4 digit number.

I've not prepared a bin file for the M510 yet. I hope someone can test it on the M560 :cool:

And I hope, I will find the trick, how to start the controller without the bootloader, as PB6 high is necessary, when I flash directly to 0x08000000 with the STLink....
 
Last edited:
What's the maximum voltage that can be used without damaging the controller?
You must not use a battery higher than 14S, as the hardware is physically limited to 63 V.

We don’t know the maximum phase current for the M510 and M560, but typically it’s 2–3 times higher than the battery current draw. I set the phase current to 60 A, and the motor is running well.
 

Attachments

  • IMG20260414201543.jpg
    IMG20260414201543.jpg
    774.6 KB · Views: 6
I set the phase current to 60 A, and the motor is running well
The phase current defines the motor torque. So at least with the PEEK gear of the M510 you should be careful not to destroy the plastic gear. The metal gears of the M560 should be more robust. The controller itself can take much more current I guess, at least for a short time. I have not looked at the datasheet of the Mosfets yet, but it is a 12 FET...
Edit: I've just looked up the datasheet, the MOSFETs are rated for 80V and 80Amps continous. So 160Amps for the 12FET...

1776189314841.png
 
Last edited:
I hope, I have solved the display issue also. PB6 has not to be set with the bootloader.
All my displays — including the SW102T — work fine, except for one quirk. The DPC245s, as usual, are acting up: when I try to open the settings menu (press “up” and “down” at the same time), the displays just shut off. The debug output matches what you’ve got.
The phase current defines the motor torque. So at least with the PEEK gear of the M510 you should be careful not to destroy the plastic gear. The metal gears of the M560 should be more robust. The controller itself can take much more current I guess, at least for a short time. I have not looked at the datasheet of the Mosfets yet, but it is a 12 FET...
I figured the controller’s DC‑DC conversion has its limits — it just can’t physically push too much phase current even with a reasonable battery current cap. Anyway, I didn’t notice any extra torque compared to the stock firmware when keeping the battery current limit the same.
 
when I try to open the settings menu (press “up” and “down” at the same time), the displays just shut off.
OK, I have to check, if the raw reading on the on/off button line changes on the other buttons press also. If so, I have to modify the threshold for shutting off.

Edit: I just checked it. The "up" button has no effect, but the "down" button lets the value drop to about 3300. So I'll set the threshold to 2800, this should work safely.

I didn’t notice any extra torque compared to the stock firmware when keeping the battery current limit the same.
In most situations, the battery current limit is kicking in first. Only at very low rpms, the phase current limit is reached. Typically at the start from standstill. This situation is stressing the gears most ;)
 
Last edited:
So I'll set the threshold to 2800, this should work safely.
Done, but I've not tested it yet. Here is the update, with the file for the M510 including ;)

The "range" field shows the BackwardsCounter now, maybe interesting for testing the Extended Boost feature with backpedaling. Values from 5 to 10 are stopping the motor.
 

Attachments

  • EBiCS_for_M510+M560_BL38_v0.0080.zip
    58.9 KB · Views: 9
Testing #9

Bafang M510 FC 3.0 | Throttle – not in use. | Battery – 52 V (14S).
Display: DPC245 | FW – EBiCS_for_M510_BL38_v0.0080.

I’ve ridden about 10 km in a flat urban area. Nothing particularly interesting from a testing perspective, but it was a good opportunity to think things over :)
For the M510 motor, EBiCS is a usable product — definitely much better than some of the less successful Bafang firmware versions. So I’ll just update the list of issues I’ve personally encountered. Almost all of them are already known.

  1. A slight motor knock when deactivating (PAS timeout).
  2. The PAS timeout setting doesn’t work or works incorrectly. Power delivery stops significantly later than the set 0.2 seconds (my configuration). This is especially noticeable in high‑power assist modes.
  3. The battery indicator works better than before. However, when using high power, the display changes quite abruptly. It might be worth enhancing the value filtering.
  4. Pressing a button too hard during power‑on causes the display to turn off.
  5. For those who haven’t followed the thread from the very beginning and are installing EBiCS, the setup can be quite a puzzle. I’ve seen this in a local chat with fellow riders.
  6. Quite often when installing EBiCS via Canable, I encounter a situation where the default «Delay» value of 300 is insufficient for a successful firmware installation. The final data packet confirmation doesn’t arrive at the end of the installation. In such cases, it’s recommended to set the «Delay» value to 400 or even 500. If the firmware upload fails, the next attempt must be made with the display power button held down.
  7. Work on configuring the throttle hasn’t even started yet. There’s no smooth or responsive operation.
  8. Walk Mode doesn’t operate very smoothly, although it does fulfill its purpose. It could probably be improved.
  9. Overrun/Extended Boost must have a power setting and the ability to be reduced to <100 % of the current assist mode. When tackling a steep climb or riding on technically challenging terrain, the rider is standing on the pedals and can generate much higher input power, which makes acceleration excessive. I encountered this when I set Overrun in «BOOST» mode.
Tomorrow I plan to ride a bike with an M560 motor.
Oh yeah, the new filter for current speed readings is working really well :)
 
So I’ll just update the list of issues
Thank you for the detailed review.
Regarding the documentation, I will setup a Wiki at GitHub, but it would be great if the community would help to maintain it. Any user with a GitHub account can edit it.

The firmware update procedure sticks sometimes at 99%, but this is not an issue of the bin file, as the update procedure is managed by the bootloader. I don't need to increase the delay time, it simply works with the next try.

I wonder again, if we should do fine-tuning for the features, or if we should try to get the M820 running on EBiCS next.
 
Last edited:
I wonder again, if we should do fine-tuning for the features, or if we should try to get the M820 running on EBiCS next
IMHO, we probably need to assess the situation with the bootloader. However, there’s no need to rush into full adaptation, since there’s Fake Taxi. According to the reviews, this firmware works well. This means it’ll be much harder to find motivated testers :)
Due to certain peculiarities of local legislation, the M820 isn’t very popular here. Off the top of my head, I can recall just two people who use it. One of them is satisfied with the existing firmware, while the other is busy searching for a nylon gear that’s nowhere to be found on the market. As far as I understand, the situation is the opposite in the EU: the M820 is quite common there.
 
So is it right, I can flash the .bin File as a normal FW via Besst to my m560 for testing? Than I can make test runs too. I am not very familiar with coding but the basics I know.

For me most Interested motors are m560/m510 and the m620 Can because I think there is a lot of potential for more Power. Also m630 but that's a rare one... But I get a test motor in some Time
 
The M820 engine has a lot of features for the gravel and road riders, weight and small format but and it is a big but, it has no internal temperature control. It looks like I have overheated mine with a controller failure. I had been working it hard in sport and boost for about 10 minutes climbing when it failed with an Err07. The bike tries to turn the motor over in a notchy way if I try and wheel it backwards. If I get time I’ll pull it apart this weekend.

Until we have everything fully controlled, documentation and user knowledge, do we just build on the two motors .
 
The M820 engine has a lot of features for the gravel and road riders, weight and small format but and it is a big but, it has no internal temperature control. It looks like I have overheated mine with a controller failure. I had been working it hard in sport and boost for about 10 minutes climbing when it failed with an Err07. The bike tries to turn the motor over in a notchy way if I try and wheel it backwards. If I get time I’ll pull it apart this weekend.

Until we have everything fully controlled, documentation and user knowledge, do we just build on the two motors .
The Bafang m820 has a single temperature sensor installed on the control board that contacts the motor housing. The software reduces motor power based on this sensor.
 
Back
Top