Bafang M500/M600 thread

casainho said:
Lid magnet

What is that for inside the motor??

Custom OpenSource firmware

Does anyone at least were able to connect JTAG and flash firmware on the FS32K142 microcontroller??

I believe we discussed this previously and I bought a couple of the recommended dongles/connector to try it, but then wound up putting my bike back together to ride! Then life got crazy, and here we are months later!

I will take a look over the weekend and see what I can get set up. You were originally looking for a download of the existing firmware (though again, I caution that I have the 'lousy' version, not the better version installed.) is that still the case?

It seems almost that the ultimate solution is to build a VESC controller into a package / shape which will fit in the original M500/600 slot? ...essentially an open source Luna V2 controller? This would avoid the complicated firmware of bafang and instead use the open firmware of VESC, and if the board was DIY or open source, would also avoid the Luna 'embargo' on selling aftermarket V2 controllers?
 
Not specifically sure on that. I thought bafang might have started open source, but they took that as a base and locked the firmware into a 'corporate' version? But either way, but the end result is the same, no? ...we're sort of stuck trying to back-engineer a medeocre grade controller and hack a few settings here and there, whereas a VESC based controller (Luna V2 analog) would give much more control, bluetooth interface, field weakening, and a host of other goodies.

(As a note, I don't mean this to be derogatory to any of the work anyone is doing in getting more access to the Bafang controller and hope we can keep up that great work, too!!)
 
4πr^2 said:
casainho said:
CiDi said:
Animalector said:
Has anyone described the process to actually calibrate the torque sensor (like hang a 1kg mass from the pedal?)

The torque sensor calibration must be done empty, without any weight.
So it is probably just for system to record the offset value it has as 0kg force.

I believe the sensor may be 'calibrated' (to 'zero') every time the controller is powered on. On a few occasions, I have powered the bike on while pedaling, or with my foot resting on the pedal. It led to some 'wild' actions...no assist when I first pushed on the pedals... continued assist long after I stopped pedaling.... assist which wasn't in proportion to the pedal effort, etc.

The solution was to power off, keep my feet off the pedals and power on again. This seemed to reset the torque sensor to 'zero' and it performed as normal... which still isn't great, but better than being shot off a cliff by a phantom power surge!
That is exactly what we do on our TSDZ2 firmware, but we alert the user, on the display, to leave pedals free for 1 second at startup.

But on TSDZ2 torque sensor, we really need to define a curve because torque sensor is far from linear!! All of them measure very different values!!
 
4πr^2 said:
casainho said:
Lid magnet

What is that for inside the motor??

Custom OpenSource firmware

Does anyone at least were able to connect JTAG and flash firmware on the FS32K142 microcontroller??

I believe we discussed this previously and I bought a couple of the recommended dongles/connector to try it, but then wound up putting my bike back together to ride! Then life got crazy, and here we are months later!

I will take a look over the weekend and see what I can get set up. You were originally looking for a download of the existing firmware (though again, I caution that I have the 'lousy' version, not the better version installed.) is that still the case?

It seems almost that the ultimate solution is to build a VESC controller into a package / shape which will fit in the original M500/600 slot? ...essentially an open source Luna V2 controller? This would avoid the complicated firmware of bafang and instead use the open firmware of VESC, and if the board was DIY or open source, would also avoid the Luna 'embargo' on selling aftermarket V2 controllers?
There are some possible paths:
1. Develop firmware for original controller: we already have the datasheets so next step would be to see with a multimeter where each pin of the microcontroller connects on the board.
Then next step would be to run the motor in openloop mode, for that we would only need to control the mosfets drivers correctly - no need to measure the currents yet, just simple slow rotation to validate we control the motor. This would run on lab power supply to protect against any error and burn the controller.

On this option, we would need to keep investing in buying this expensive motor controllers, like 150€ each one (shipping and taxes included).

And the controller hardware seems relatively simple. On the other side, that one shunt only to measure the current, would mean we would be forced to use the NXP motor development tools... This microcontroller is a ARM Cortex M4, it is good for this task.

2. Design our won board based on VESC or other EBike motor controllers.
I can't do it, but if someone would like to do it, maybe is not so much difficult. There are OpenSource motor controllers on this forum, there are a lot of knowledge on this forum and github.

3. Use an already existing motor controller hardware and try to adapt to the case of M500/M600.

Seems there may be little space to grow to outside, as will touch on the rotating crank arms! Still I may start to explore this path, using our OpenSource Easy DIY motor controller. And I do not have much experience with sensorless, so there is a long way....
 
casainho said:
CiDi said:
Animalector said:
Has anyone described the process to actually calibrate the torque sensor (like hang a 1kg mass from the pedal?)

The torque sensor calibration must be done empty, without any weight.


@CiDi I think you were the guy you documented more the CAN commands. Do you think would be possible to develop our own display and have all the information the original display shows as also add configurations menu to send the commands for configurations as the max speed as also the torque sensor calibration?

My idea would be to adapt this display firmware, to show the Bafang M500/M600 data as also add the configurations. This display has Bluetooth, meaning we could even make an app to flash the Bafang M500/M600 firmware using our phones.
Also supports the ANT+ LEV EBike wireless profile, so we could send all the Bafang M500/M600 data to our GPS units on the handle bar or to our watches.


We all know the Can commands to read data from the controller and to change speed and wheel diameter, so if the display can read and write Can commands, it is possible to do everything, in theory even loading the firmware.
A button can be set to change top speed from road at off-road.
 
CiDi said:
casainho said:
CiDi said:
Animalector said:
Has anyone described the process to actually calibrate the torque sensor (like hang a 1kg mass from the pedal?)

The torque sensor calibration must be done empty, without any weight.


@CiDi I think you were the guy you documented more the CAN commands. Do you think would be possible to develop our own display and have all the information the original display shows as also add configurations menu to send the commands for configurations as the max speed as also the torque sensor calibration?

My idea would be to adapt this display firmware, to show the Bafang M500/M600 data as also add the configurations. This display has Bluetooth, meaning we could even make an app to flash the Bafang M500/M600 firmware using our phones.
Also supports the ANT+ LEV EBike wireless profile, so we could send all the Bafang M500/M600 data to our GPS units on the handle bar or to our watches.

We all know the Can commands to read data from the controller and to change speed and wheel diameter, so if the display can read and write Can commands, it is possible to do everything, in theory even loading the firmware.
A button can be set to change top speed from road at off-road.
Ok, great!! And I checked the datasheet of the display DP C240 and it has 3 buttons, the same as our DIY display.

We use buttons UP + DOWN long press to enter in configuration menu. To disable / enable offroad mode (in this motors would be to increase the speed over 25 km/h) would be only the buttons UP + DOWN press and an indication on the display.

Does anyone know what are each pin function for the display connector?? I understand the GND, 5V and CAN H, CAN L but I need to know how to enable / turn on_off the motor controller:

 
To not forget the idea of developing our own DIY OpenSource display for Bafang M500/M600 motors, I wrote the main idea on the github repository -- while I do not have free time currently, I can help any developer want to do it, as I was the developer of this display, I can quick guide anyone. See more here: https://github.com/OpenSourceEBike/Bafang_M500_M600

 
Guys, try not to reinvent the wheel too much please, the motor is good, there's more than enough power with the current board with reliability, who needs too much more ( OK field weakening would be good but are you sure Bafang are not already doing this, mine easily will pull into the 120's cadence ), stick with what you have and with just abit of fettling you could have a good system and get to ride your bike more.

Try not to go down the DP C240 route, its been replaced with the DP C241 which has bluetooth on board. Its actually a very good display readible in virtually all light and quite discrete, but Bafang for some reason have made the real things we are interested in such as Watts, cadence, battery levels are all only available on the very small lower row, which for 90 % of users are too small to be readable. If only all the fields were able to be diplayed in the large centre part of the display, it would be pretty darn good.

On /Off is via the +- switch, theres an extra button there which controls the display and also with a long press switches the motor on and off.
 
Waynemarlow said:
Guys, try not to reinvent the wheel too much please, the motor is good, there's more than enough power with the current board with reliability, who needs too much more ( OK field weakening would be good but are you sure Bafang are not already doing this, mine easily will pull into the 120's cadence ), stick with what you have and with just abit of fettling you could have a good system and get to ride your bike more.

Try not to go down the DP C240 route, its been replaced with the DP C241 which has bluetooth on board. Its actually a very good display readible in virtually all light and quite discrete, but Bafang for some reason have made the real things we are interested in such as Watts, cadence, battery levels are all only available on the very small lower row, which for 90 % of users are too small to be readable. If only all the fields were able to be diplayed in the large centre part of the display, it would be pretty darn good.

On /Off is via the +- switch, theres an extra button there which controls the display and also with a long press switches the motor on and off.
What I really value on TSDZ2 and that I am looking at Bafang M500, my next motor, is fine control of assist levels, motor current and motor current ramp, that way I can optimize my range / battery size / weight, as I wish to have a low weight battery and do long days riding on the mountains. Also that will let me optimize my workouts / my fitness / health, as I can reduce the motor assistance to a minimum that is of my interest for my workout.

I expect the original motor control to be good but I wish to have that fine control of the motor, like even control the amount of field weakening to save battery.

And battery advanced configurations as we do on TSDZ2, automatic calculating the battery resistance and having a good SOC estimation, including being able to deep discharging the battery to increase the SOC on that long rides!!

As you say, "try not to reinvent the wheel too much" make me think that is a good idea and why doing everything from scratch again since we already have advanced motor controllers as VESC and displays? For instance, much cheaper to use the standard 48V EBike batteries than the specific 43V Bafang batteries. Much better to reuse the already existing EBike motor controllers, displays, batteries e softwares!!

About the display, for me will be much better and quicker to reuse this OpenSource DIY display I already developed for TSDZ2, that also has Bluetooth and ANT to connect wirelessly to the cycling GPS displays, that way I will not be reinventing the wheel and I will have full control of it. And they are cheap, even because I will reuse the ones I am using on my current EBikes with TSDZ2.

Not reinventing the wheel is using the EBike wireless standard ANT+ LEV and that way we can use software already developed by others, like this one for the Garmin Edge cycling GPS:





 
another example with estimated range in km or miles…
10pk.jpg
 
SUPERJC said:
another example with estimated range in km or miles…
10pk.jpg
Can you explain which motor are you using? and which technology to implement the ANT+ LEV wireless?
 
Anyone knows what are that 2 missing components on the motor controller board? could it be 2 power resistors to measure the motor phase current?

image.png
 
CiDi said:
The Bafang M series due to the closed firmware, allows very limited settings, maximum speed, wheel circumference, wheel diameter and calibration of the torque and motor speed sensor.
You can use BESST or CAN interface, but the parameters that you can set are the same.
In the case of the torque sensor you can only do an empty calibration and it is only needed in case of sensor or controller replacement.


gm1970 said:
CiDi said:
To configure the Bafang M500 / M600 motor without using the BESST programmer, you can use this interface.

Link interface USB to CAN on Amazon:
https://www.amazon.co.uk/USB-Converter-Module-Raspberry-Zero/dp/B07Q812QK8/ref=sr_1_2?dchild=1&keywords=usb+to+can+innomaker&qid=1604409709&sr=8-2

Link cables Bafang HMI M500/M600 on e-bike-technologies:
https://www.e-bike-technologies.de/index.php/en/connectors/connectors-signal/connectors-higo-mini-f-series/higo-b5-f-detail
https://www.e-bike-technologies.de/index.php/en/connectors/connectors-signal/connectors-higo-mini-f-series/higo-s5-f-detail

Below are the software and the instructions for configuration and use.


Hi
Let me know what is the actual recommended M600 longdistance modified firmware for motor with steel gearing⚙️?
Thank you!
 

Attachments

  • Aversus_Bikes_Peccatore3.png
    Aversus_Bikes_Peccatore3.png
    501.4 KB · Views: 659
casainho said:
SUPERJC said:
another example with estimated range in km or miles…
10pk.jpg
Can you explain which motor are you using? and which technology to implement the ANT+ LEV wireless?
If know protocol (CAN or UART)
making a DIY display is advantageous for all the reasons you said
I like all your work to advance knowledge on the subject
But I don't know the use of NRF with technology ANT+ device profile LEV
for your questions:
The motor -> simply BBS01 UART but the new ones risk being CAN
Technology communication to the Garmin use ESP32 bluetooth smart (BLE)
the picture TTGO ESP32 display is here:
https://endless-sphere.com/forums/viewtopic.php?f=7&t=113971&start=49
 
SUPERJC said:
casainho said:
SUPERJC said:
another example with estimated range in km or miles…
10pk.jpg
Can you explain which motor are you using? and which technology to implement the ANT+ LEV wireless?
If know protocol (CAN or UART)
making a DIY display is advantageous for all the reasons you said
I like all your work to advance knowledge on the subject
But I don't know the use of NRF with technology ANT+ device profile LEV
for your questions:
The motor -> simply BBS01 UART but the new ones risk being CAN
Technology communication to the Garmin use ESP32 bluetooth smart (BLE)
the picture TTGO ESP32 display is here:
https://endless-sphere.com/forums/viewtopic.php?f=7&t=113971&start=49
Thanks for the explanation.
I will keep using the NRF52840, as it have Bluetooth and ANT simultaneous.
 
About FOC implementation on the M500/M600 motor controllers, that has only one shunt resistor - an experienced FOC developer says. So maybe there is something to win to use a good motor controller as VESC, mainly energy efficiency, some more battery range. That may not be of interest of users that have big batteries like 800Wh and uses M600 as almost a motorcycle motor, but it is for me that I want to stay 10 hours pedaling on the mountains with a 500Wh battery.



 
Since I have a big focus on the battery, I need to have a good range battery. On my knowledge, there are 2 characteristics important for me over time that will reduce with usage: battery capacity and battery resistance.

To measure the battery capacity, we need to fully discharge it while measuring and summing all the instantaneous power, then we will have the battery capacity in Wh.

The battery resistance is important because it will grow as the battery ages, the higher the resistance, the less power it will provide to the motor (and we feel it!!) as also the faster it will discharge. It is very easy to measure it in real time and our DIY display does it: R = battery delta voltage / battery current.

Here the example of my 500Wh battery pack with 0.3ohms. If I pull 10 amps, the power loss on the battery will be P = 0.3 * 10 * 10 = 30W. If the battery ages and get 2.5x more resistance, then the power loss will be 75w. 75W is about 1/3 of the 250W motor power, so it is quite noticeable!!

For the display to be able to calculate and show to user the battery resistance, it needs the motor controller to send the battery voltage and battery current values.
 
The thing that M500/M510/M600 need is the button to offroad mode that by one tap could remove speed limit and enable/disable throttle.
That could send speedlimit set command and have the plug for throttle (no throttle command but have separated plug).

With current known firmwares the power is not an issue. All of three above are great.

The issue is to have turn on/off offroad mode easily and quickly, with disability the throttle and set 25 or 32 kmh (eu/usa switch?) on each power up.

So what could be awesome to have it as external module with a button that would play the man in the middle role between throttle, display and engine.

that shall be much easier than developing the controller and software for it.

If someone would could lead such project then i would be more than happy to help, i am not an expert on that but with someone experienced leading that could happen.
 
casainho said:
Since I have a big focus on the battery, I need to have a good range battery. On my knowledge, there are 2 characteristics important for me over time that will reduce with usage: battery capacity and battery resistance.

To measure the battery capacity, we need to fully discharge it while measuring and summing all the instantaneous power, then we will have the battery capacity in Wh.

The battery resistance is important because it will grow as the battery ages, the higher the resistance, the less power it will provide to the motor (and we feel it!!) as also the faster it will discharge. It is very easy to measure it in real time and our DIY display does it: R = battery delta voltage / battery current.

Here the example of my 500Wh battery pack with 0.3ohms. If I pull 10 amps, the power loss on the battery will be P = 0.3 * 10 * 10 = 30W. If the battery ages and get 2.5x more resistance, then the power loss will be 75w. 75W is about 1/3 of the 250W motor power, so it is quite noticeable!!

For the display to be able to calculate and show to user the battery resistance, it needs the motor controller to send the battery voltage and battery current values.
I think the best way is BMS connect with your wireless display
BMS has already the data (Ah, A, V, …)
my battery has this -> Xiaoxiang Smart Bluetooth BMS
Look at the end of this link (Third Party Software / API / Technical Information)
https://wnsnty.xyz/entry/jbd-xiaoyang-smart-bluetooth-bms-information#wiring
 
SUPERJC said:
I think the best way is BMS connect with your wireless display
BMS has already the data (Ah, A, V, …)
my battery has this -> Xiaoxiang Smart Bluetooth BMS
Look at the end of this link (Third Party Software / API / Technical Information)
https://wnsnty.xyz/entry/jbd-xiaoyang-smart-bluetooth-bms-information#wiring
I also use that BMS on my battery packs, and that way is an option.

This Bafang motors are ready to connect a battery, on the CANBUS, that will provide that data. On the M365 EScooter is the same, but is not CANBUS but UART from BMS to motor controller. Then other UART from motor controller to the display. And there is an OpenSource firmware to that Xiaoxiang BMS that implements the M365 EScooter protocol, meaning you can build your battery, flash that firmware on the BMS and the battery will work as a original one -- the same could be done here, adapt that firmware for the Bafang battery protocol and add a CANBUS adapter. Still I would prefer to make that calculations on the display side.
 
Kyokushin said:
So what could be awesome to have it as external module with a button that would play the man in the middle role between throttle, display and engine.

that shall be much easier than developing the controller and software for it.

If someone would could lead such project then i would be more than happy to help, i am not an expert on that but with someone experienced leading that could happen.
I think with CANBUS, it is not even men in the middle, you just connect another device to the CANBUS and send and receive the data you want.

You can use Arduino to make what you want!! Just go and search Arduino examples for CANBUS!!
 
SUPERJC said:
another example with estimated range in km or miles…
10pk.jpg
SuperJC, can you clarify where you got this from, Garmin have Apps you can import into their displays and this one seems just about all I want. But who is the author and where do I find it or is it just for the earlier UART motors and not CanBus ?

If you look at the Bafang Go App, the ability to change the percentage of effort to each level is there in one of the back level screens, just you are not able to implement it. Are we sure that Bafang have not already built this into the latest firmwares and not yet activated it for some reason ?
 
Waynemarlow said:
SUPERJC said:
another example with estimated range in km or miles…
10pk.jpg
SuperJC, can you clarify where you got this from, Garmin have Apps you can import into their displays and this one seems just about all I want. But who is the author and where do I find it or is it just for the earlier UART motors and not CanBus ?

If you look at the Bafang Go App, the ability to change the percentage of effort to each level is there in one of the back level screens, just you are not able to implement it. Are we sure that Bafang have not already built this into the latest firmwares and not yet activated it for some reason ?

SUPERJC said:
The motor -> simply BBS01 UART but the new ones risk being CAN
Technology communication to the Garmin use ESP32 bluetooth smart (BLE)
the picture TTGO ESP32 display is here:
https://endless-sphere.com/forums/viewtopic.php?f=7&t=113971&start=49

For the answer on SUPERJC, I think is like this:
- the motor used is a BBS01, UART communication with the display
- SUPERJC developed his own display and that is based on ESP32 module (see next picture)
- the ESP32 send the motor data by Bluetooth to the Garmin Edge GPS display
- the app on Garmin Edge GPS display was probably developed by SUPERJC (since it probably does not follow any standard)
- processing of motor data, like range estimation, can be done on the display side or on the GPS display, but I would say it is probably done on ESP32

6nrs.jpg


The only thing I would do differently was using the ANT+ EBike wireless standard. Well known brands like Specialized EBikes uses the ANT+ EBike wireless standard.

We already implemented ANT+ EBike wireless standard on our DIY display, then the GPS display supports nativelly the motor data, without the need to install any app (although they are available) -- here a picture of my GPS display while I was riding my EBike with TSDZ2 motor:



See this video: https://www.youtube.com/watch?v=F43oqj1Zlww
 
The ESP32 calculate the Wh with current and volt
these values (V and A) can be retrieved by any protocol (Uart, Can, ADC, other…)
On the Uart Bafang BBS protocol we only have steps current of about 0.25A or 0.5A
On the canbus M600-500 -> I dont know what are the steps of the current?
For me it's read by ESP32 with ADS1115 (for precision)
ESP32 send only Wh to Garmin wirelessly (BLE)
The Garmin having the km and the elevation can calculate Wh/km and the estimates itself
you can do your data field and your calculation by Garmin itself
app for that already exists -> Garmin IQ AppBuilder 5+
https://apps.garmin.com/en-US/apps/394941a6-4e73-4843-820b-fdcfbc877f3a
yw71.jpg


…and if you have memory
you can recording
qs63.jpg
 
Back
Top