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

It turned out the battery contact had burned out. The current seemed to be significantly higher than 25A.
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.
 
The current seemed to be significantly higher than 25A.
This is quite strange. Even if for some reason you get this much current without a load, the battery protection remains. My battery can't deliver more than 40A due to hardware limitations.
 
I've added a minimum time between two clicks for the offroad code now, but I haven't tested it yet.
I hope this solves the issue with the motor stops.
Testing #2
Bafang M510 FC 3.0 | Throttle – not used. | Battery – 52v (14S).
Display - DPC245 | FW - EBiCS_for_M510_BL38_v0.0062

1) The issue with the motor suddenly stopping for a short time is not fixed. I have not found any connection between the available settings and this issue.
2) The six-magnet speed sensor is working correctly.
 
Is the "1" still shown in the display during the breaks?
It's become more difficult to detect because the display changes faster (there are 6 magnets). But the number "1" still appears. Less frequently, the number "2" appears. This happens while pedaling, without pressing any buttons.
This reminds me of the cutoff at speeds above 6 km/h in walk mode if you set the limit to "Legal"
 
Last edited:
This happens while pedaling, without pressing any buttons.
Hm, strange. I've commented out the Offroad sequence. So there should not appear a 1 or 2 in the display any longer. But I fear, this will not solve the problem. There seem to be CAN Bus misreadings sometimes, so an assist level change is detected, without having pressed any button.

Can you try this file, please? If the bug is still there, I have to add a plausibility check for the assist level change.
 

Attachments

  • EBiCS_for_M510_BL38_v0.0063.zip
    23.7 KB · Views: 10
Can you try this file, please? If the bug is still there, I have to add a plausibility check for the assist level change.
The numbers 1 and 2 disappeared from the display, but the short cutoffs remained unchanged.
I don't see any systematic pattern to these errors. They occur at different cadences and different pedaling efforts.
 
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.
Yes, without load. The screen went black and wouldn't turn on again. I replaced the motor with a spare one, but nothing changed. It turned out there was no voltage coming from the battery. I removed the battery and put it on charge separately, and it charged. The contact was burnt, so I cleaned it. I put it back, and it turned on. Perhaps the BMS had gone into protection mode.
 
Then the M560 controller hardware is different from the M510 obviously.
I've seen a few posts on related forums and Facebook groups about people replacing the M510 motor controller to an M560 controller to improve performance. This works within certain limits (the M510 motor is physically smaller, so current needs to be limited). I also have a bike with an M560 motor, and I'll be able to test the Ebics on it. But for now, I'm prioritizing the M510.
 
I also have a bike with an M560 motor, and I'll be able to test the Ebics on it.
Don't flash the M510 firmware to a M560 controller!!! It will end up in smoke obviously. The current sensing for phase- and/or battery currents are on different processor pins, otherwise @mk00 wouldn't have grilled his battery connectors. I don't know, if someone is able to check the pin connections from the four channel opamp outputs to the processor on a M560 PCB...
I don't know, if I will ever get hands on a M560 controller myself ;)

1774437552426.jpeg
1774437800784.png
1774437913994.png
 

Attachments

  • AH4IX LTC728 OpAmp.pdf
    1.3 MB · Views: 1
Don't flash the M510 firmware to a M560 controller!!! It will end up in smoke obviously. The current sensing for phase- and/or battery currents are on different processor pins,
1774451162107.png
This is a photo of the M560 controller.
 
but the short cutoffs remained unchanged
I've added a plausibility check now. The received assist level code has to be 3 times the same, before the new level is applied.
I've tested it, there are no stops of the motor assistance any more. The calories field shows the recognized level changes at the moment and you can see, that the value increases from time to time without having touched the buttons. The headlight flickers also, if this CAN misreading happens (not programmed in this way, it just happens as the light flag is in the same CAN command as the levels).
But at least the motor breaks should not happen any longer :cool:

@Avatarkhorn: If you can confirm that, I'll publish the next pre-release with this version!

This is a photo of the M560 controller.
This is the controller I'm working with.
IMG_20260325_185559_801~2.jpg

regards
stancecoke
 

Attachments

  • EBiCS_for_M510_BL38_v0.0064.zip
    27.1 KB · Views: 2
Last edited:
@Avatarkhorn: If you can confirm that, I'll publish the next pre-release with this version!
Good evening! It's too late for testing today, but I'll definitely give you feedback tomorrow. If the issue is resolved, I'll be able to spend a lot of time riding my bike with this firmware this weekend.
This is the controller I'm working with.
Here's my M560 controller. It's the same as @mk00 . I only know one revision. This controller is working properly, and I have basic multimeter skills. Later, if needed, I can connect it to the battery and screen and take simple measurements.
 

Attachments

  • 1774465346635.jpg
    1774465346635.jpg
    2.4 MB · Views: 13
  • 1774465346549.jpg
    1774465346549.jpg
    3.7 MB · Views: 14
  • 1774465346473.jpg
    1774465346473.jpg
    2.6 MB · Views: 14
If you can confirm that, I'll publish the next pre-release with this version!​
Testing #3
Bafang M510 FC 3.0 | Throttle – not used. | Battery – 52v (14S)
DPC245 Screen | FW - EBiCS_for_M510_BL38_v0.0064
1) The issue with the sudden, short motor stop has been fixed. Great job!
2) I was able to concentrate on the assist without the motor jerking:
- "Pas Ramp End" is working incorrectly for me. I can get all 1000+ watts at the start of the movement, and as I increase my cadence to maximum, it feels like I'm hitting a wall. The stronger the assist mode, the stronger this feeling. In fact, the power drops to 300-400 watts, according to the display.
- PAS timeout – the power decreases significantly longer than indicated.

The original firmware includes a feature that instantly stops the motor when pedaling in reverse. This feature improves safety for those who know how to use it. It might be worth adding it later.
You could try to follow the traces from the opamp to the processor with the multimeter
I think I can handle it. The hardest part will be removing the huge amount of varnish I covered the board with.
 

Attachments

  • Testing#4.png
    Testing#4.png
    118.9 KB · Views: 12
First: Thank you for testing!!!(y)

"Pas Ramp End" is working incorrectly for me
This parameter has no function yet. It is planned for a simple PAS mode with power levels. It is setable in the Canable tool, but it is not used for any calculation at the moment.

as I increase my cadence to maximum, it feels like I'm hitting a wall.
Hm, can you estimate the cadence where this happens? I had the same experience, but I thought, that this is the BEMF on a 36V battery. With the 52V battery this limit should be reached much later.... See #122

Does it happen at always the same speed or at always the same cadence?
 
Last edited:
This parameter has no function yet. It is planned for a simple PAS mode with power levels. It is setable in the Canable tool, but it is not used for any calculation at the moment.
Accepted. It's listed as valid in the ReadMe :)
Does it happen at always the same speed or at always the same cadence?
About the same as yours. My comfortable cadence is ~90 RPM. When accelerating at 140+ RPM, this problem becomes very serious. This effect definitely does not occur on the original firmware.
 
Hm, strange. Maybe Bafang uses field weakening. I guess, I have to do some tests with an 48V battery on the roller trainer.
I'll update my cadence information tomorrow. I found a working cadence counter on my DPC245 :)
Hm, strange.
I'm sure of it. Over 2,500 km on the Bafang M560, in the mountains and on the asphalt, I was limited only by the engine's maximum power and the 60 km/h speed limit. :)
I don't think it's fundamentally different from the M510.
 
Last edited:
I believe Innotrace M620 CAN motor controller has similar effect comparing with Innotrace X1 controller for some reason. On a 14S battery even if I lift current and power it pulls stronger than Innotrace X1 at lower cadence but not as strong at higher cadence even with higher current and wattage settings. You need higher voltage battery, maybe 16s or higher for wider cadence range support. I use 16S battery on my VESC M560 and VESC M600 controllers with the same firmware and it has very strong support at cadence even higher than I can spin the pedals.
 
Last edited:
You need higher voltage battery, maybe 16s or higher for wider cadence range support.
The Bafang controller is physically limited to 60 volts. A 14S battery is the limit. Furthermore, the M510 officially supports 120 RPM, including at 36V. I wasn't aware of any RPM limitations while riding M510 and M560 motors with a 14S battery and the original firmware. Besides checking the cadence, I'll try to compare the firmware today.
 
Hm, strange. Maybe Bafang uses field weakening. I guess, I have to do some tests with an 48V battery on the roller trainer.
Pretty sure they do have FOC. From a very crude ears only perspective when we changed the TSDZ2 engine to full FOC the electronics developed a certain sound to my ear. The Bafangs M510 & M600 have that same sound except the M820 which runs into a brick wall in cadence and power at anything over about 100 - 110rpm cadence.

I'm not sure though that brick wall is something to do with the way its programmed with the Fake Taxi project and others reporting parameter changes making changes to the way the motor responds. Its that M820 motor which I think is the most suitable and pressing need for this freeware ( on paper it has a lot attributes ). Do we have any schematics or details of that M820 controller before I pull mine to pieces to check.
 
Back
Top