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

Bafang M500/M600 thread

If money not an issue this is an aftermarket controller for m560 you might want to try. And if this is from the creators of Innotrace controller you probably gonna love it despite the Innotrace drama because they certainly know the technical stuff, way better than VESC. You probably will not obtain the full control over the controller (basing on the Innotrace history), but as long you ask them to set the maximum power to your preferences you will probably just love it.


If you decided to purchase it please post your feedback. It looks like there is no real feedback about those controllers yet. I am interested how they work and how they look like other than what posted on their website.

If you do not have motor it looks like they also sell motor+controller option.
Interesting though I ain't rich! Mainly looking for an open source option for the CLWB ebike I designed and built. I would rather go with a vesc and tweak the options to adapt it to a specific motor.
 
TSDZ2_wireless_board_small-12.jpg

I decided to update my Opensource DIY EBike, mainly because I am using a better display now, a monochromatic instead of an OLED. This new one is much better to see on outdoors as also is bigger - I am being using this display and firmware on my Fiido Q1S scooter, since one year ago.

A bit more details of the project: EBike Bafang M500 mide drive motor: VESC + DIY ESP32 board running Pyhton firmware | VESC Project

I am sharing the OpenSource schematics for this DIY EBike / ESCooter electronics and software, here on github: GitHub - OpenSourceEBike/EBike_EScooter_modular_DIY: EBike / EScooter app developed in CircuitPython, to control a motor by sending commands to VESC motor controller

I had to open the motor plastic 3D printed enclosure to have access to the VESC motor controller + ESP32 board. The plastic glue I used was great, no signs of water inside!!
1743777508768.png


I had to update the firmware, as for this new display communications I am using ESP32Now wireless instead of the previous UART wired communication. And while I was doing that, I also updated the VESC firmware and run again the motor parameters detection - everything went great!!
On the display, I am only showing 3 variables: Battery voltage (to mentally compute the battery SOC); Assist level and Motor Power.
I have configured the system to use max of 15 battery amps, so with my 48V battery, it is about max of 750W!!
1743777686563.png


Pictures of the old display, working perfectly, no water inside although with a lot of rust on the metallic screws:
1743777944712.png

1743778024578.png

1743778048879.png

1743778091149.png


On the new display I also now use the ESP32-C3 instead of ESP32-S2, because C3 uses about half the power which is important due to the nature of this DIY boards. Also this ESP32-C3 board is smaller:
1743778192274.png


The new display is bigger although uses the same 128x64 pixels, so I had nothing to change on the firmware:
1743778232281.png



I updated my seated scooter display firmware, I will probably follow the same design and improve for my EBike.
The current design of the main screen. Big numbers for the current wheel speed!! A graph bar to represent the current motor power, between 0 and 2000 watts. With smaller numbers, the current time. And I need to work the battery SOC value.

1744250433826.png
hey casainho I want to work on my own Bafang ebike with the vesc controller do you know since your version of the M500 which uses UART for control protocols, if its possible to use the newer M600 that has the canbus display protocol and whether it might still work on your code is the canbus feature an issue when your bypassing it with your own controller? if anyone has an answer to this question would love to know.
 
hey casainho I want to work on my own Bafang ebike with the vesc controller do you know since your version of the M500 which uses UART for control protocols, if its possible to use the newer M600 that has the canbus display protocol and whether it might still work on your code is the canbus feature an issue when your bypassing it with your own controller? if anyone has an answer to this question would love to know.
Remove the original motor controller and display, and just use VESC + you own basic display!! I am doing just that both for my EBike and for my EScooter.
 
The nearest I can tell, they are JVT PHB Series connectors (or I think a newer designation might be JVT2041). At least it looks to be as close as I can see without actually getting one to plug in! Somewhat rare to have the indexing slots on the short sides of the shroud, as most JST / molex type connectors seem to have the slots/tabs on the long sides.

These JVT connectors seem to be a good match, even down to the tiny 45° chamfer in the corners of the shroud on the latching side of the connector.


If you can not find a part in regular places like Digikey then it is most likely Chinese brand and you can try to find it on LCSC.com .

I found those connectors can not be found withing the western distributors. You can find them on Alibaba but if you want more quality and certainty you better search and purchase such stuff on LCSC.com .

These are 2x11 positions 2mm pitch options with highest temperature and flame retardant rating Bafang controllers probably use



These are 2x3 positions 2mm pitch options with highest temperature and flame retardant rating Bafang controllers probably use


 
Not sure if this is of any use to anyone, but I had some time over lunch, so I digitized the controller board outline and key components in the layout. The mosfets obviously need to sit above the thermal pads on the cover and the magnetic sensor is relatively critical to have centered and properly offset above the magnet. Also I located the pin headers for convenience. Ultimately, my goal would be to get a VESC style controller in this format, so we'd have full control over the operating parameters. It's just a multi-horse race to see if this project ever comes to pass, we actually 'crack' the CAN code / firmware and get that functionality, Luna ultimately releases the V2 controller for retrofit, or something else entirely!

I'll add dxf files, though if someone takes a crack at this and those don't work we can possibly try some other way to communicate between CAD software!
How accurate this CAD model of the board is? How did you outline it? Do you know if this shape is the same for M560 motor?
 
Nice to see the display coming along! Appreciate the video to show more detail.

I've been playing around with getting some of the VESC components laid out on the 500/600 shaped board. Would have some way to go to have something functioning, but at least things generally fit!
Have you finished that VESC controller? If so where I can I find the files?

It looks like the EX-FORCE controller for Bafang m560 does not follow that heat pads area. They allocated the MOSFETs on the opposite side of the board crossing that embossed/debossed pattern.

They also use only 6 MOSFETs with tiny traced to the phase wires, so I am not sure how much juice they can squeeze out if such layout. Maybe they use high current MOSFETs with heavy copper PCB which is quite expensive.

1756437556364.png

1756437640703.png

1756437698386.png

1756437969313.png
 
Last edited:
How accurate this CAD model of the board is? How did you outline it? Do you know if this shape is the same for M560 motor?
It should be 'damn accurate'- I used a vision analysis measurement system. The overall system is calibrated and certified to +/- 0.000002 inches, I believe. Now, I didn't push it that hard for the board, but it should pretty easily be +/- 0.002" - of the board I have. Component placement is also accurate - based on the board I have. But keep in mind, all this is just 'one board' - so if it was a bit off in its manufacturing - I don't know. But the ultimate goal was that the scan would be 'accurate enough for all practical purposes'.

Sorry, I don't know if this would fit the 560 or not. At a glance, the M560/M600 cases seem to be the same, so I suspect it's likely.
 
Have you finished that VESC controller? If so where I can I find the files?

It looks like the EX-FORCE controller for Bafang m560 does not follow that heat pads area. They allocated the MOSFETs on the opposite side of the board crossing that embossed/debossed pattern.

They also use only 6 MOSFETs with tiny traced to the phase wires, so I am not sure how much juice they can squeeze out if such layout. Maybe they use high current MOSFETs with heavy copper PCB which is quite expensive.

View attachment 376406

View attachment 376407

View attachment 376408

View attachment 376409
Unfortunately, no. I was getting a very rudimentary start on this project, then Luna opened sales of the V2 controller to people who had previously purchased a bike - so I was able to pick up an 'unlocked' controller there. ...and I sort of dropped efforts to create this open controller after that.

I must say, though - you've come in and tacked the project with amazing drive, determination and knowledge. First class all the way and light years ahead of my efforts! If there are any scraps of my project that can help, just let me know. Happy to support where I can.
 
Cool - thanks a lot for taking the time to try it out! I don't have an m560 so I can't test it for your using a mockup like you did but I don't think you're reverse engineered controller will work out of the box on the smaller motor. Sadly no time to dig deep into it myself, but thanks for all the good work so far!
We might have an opportunity to 3D scan M560RS (internals specifically) a few weeks with a new Keyence a CMM machine. I do not know how good the 3D scan is going to be, this is just new CMM machine promotion marketing campaign Keyence offered 3D scan for free. But if we will obtain a good 3D scan and If you are willing to figure out the Luna firmware we can design a new controller for M560RS based on the Luna M600 controller. We need someone who knows VESC firmware to get rid of some components (like the Bluetooth and USB) and make this thing works with VESC Express instead. So if you are interested in VESC for M560 controller and know the VESC programming thing we might be able to make it happens.
 
We might have an opportunity to 3D scan M560RS (internals specifically) a few weeks with a new Keyence a CMM machine. I do not know how good the 3D scan is going to be, this is just new CMM machine promotion marketing campaign Keyence offered 3D scan for free. But if we will obtain a good 3D scan and If you are willing to figure out the Luna firmware we can design a new controller for M560RS based on the Luna M600 controller. We need someone who knows VESC firmware to get rid of some components (like the Bluetooth and USB) and make this thing works with VESC Express instead. So if you are interested in VESC for M560 controller and know the VESC programming thing we might be able to make it happens.
cool - keep me posted!

EDIT: It's actually pretty easy to tailor the vesc firmware to your needs. All you have to do is configure a custom hwconf file; the compiler will than include all the files you need and leave out those you don't.
 
Last edited:
cool - keep me posted!

EDIT: It's actually pretty easy to tailor the vesc firmware to your needs. All you have to do is configure a custom hwconf file; the compiler will than include all the files you need and leave out those you don't.

Yeah, this is what we probably will need to do.


I just got off from conversation with Marcos (I believe he is one of the Luna M600 controller developers) and Lunacycles trying to figure out how to connect VESC Express and it turned out Marcos is not going to help us because of I asked mxlemming to ask him to share the Luna Ludicrous V2 M600 schematics through him (maybe Marcos is pissed off because of we tried to extract the information from him the sneaky way even it is clear there is no other way to obtain it).

Basically what Marcos told me is that it is easy to connect VESC Express to any Luna controller and said that I should ask Lunacycles about it. I contacted Lunacycles and asked the same and initially they told me they were not even aware that it is even possible to connect VESC Express and told me to contact Marcos again. Then they said that they do not disclose any information other than what is posted on their website and they did not give me any reason for such refuse. Then Marcos told me that the controller I have is a knock off and because of it is knock off I am not a Luna customer and therefore he is not going to help me to connect VESC Express. I have no idea why it is knock off, maybe he is just lying. The controller I got has different shape comparing with what posted on the Luna website, but it has the same black color and the same Luna logo, so I believe this can not be knock off and it is just different revision and they just changed the shape.

Regarding Lunacycles it looks like they even have no idea what they have and how it works and could not care less to bother the developers with customers questions. It looks like Marcos and whoever else Luna outsourced this controller from are the only ones who know about how the controller works but are not interested to provide support (I guess simply because of they get not paid for it and are not quite involved or interested in electric bicycles community).

Maybe we can find another Luna M600 controller owner and ask that person to ask Marcos about how to connect VESC Express. I do not believe Marcos or Lunacycles are willing to help us but wort a try.
 
Last edited:
Yeah, this is what we probably will need to do.


I just got off from conversation with Marcos (I believe he is one of the Luna M600 controller developers) and Lunacycles trying to figure out how to connect VESC Express and it turned out Marcos is not going to help us because of I asked mxlemming to ask him to share the Luna Ludicrous V2 M600 schematics through him (maybe Marcos is pissed off because of we tried to extract the information from him the sneaky way even it is clear there is no other way to obtain it).

Basically what Marcos told me is that it is easy to connect VESC Express to any Luna controller and said that I should ask Lunacycles about it. I contacted Lunacycles and asked the same and initially they told me they were not even aware that it is even possible to connect VESC Express and told me to contact Marcos again. Then they said that they do not disclose any information other than what is posted on their website and they did not give me any reason for such refuse. Then Marcos told me that the controller I have is a knock off and because of it is knock off I am not a Luna customer and therefore he is not going to help me to connect VESC Express. I have no idea why it is knock off, maybe he is just lying. The controller I got has different shape comparing with what posted on the Luna website, but it has the same black color and the same Luna logo, so I believe this can not be knock off and it is just different revision and they just changed the shape.

Regarding Lunacycles it looks like they even have no idea what they have and how it works and could not care less to bother the developers with customers questions. It looks like Marcos and whoever else Luna outsourced this controller from are the only ones who know about how the controller works but are not interested to provide support (I guess simply because of they get not paid for it and are not quite involved or interested in electric bicycles community).

Maybe we can find another Luna M600 controller owner and ask that person to ask Marcos about how to connect VESC Express. I do not believe Marcos or Lunacycles are willing to help us but wort a try.

I mean.... wouldn't it connect like every other VESC compatible controller? over CAN-bus?
 
I mean.... wouldn't it connect like every other VESC compatible controller? over CAN-bus?
This is what I tried to do. No dice. Maybe Luna locked it just like Innotrace did.

 
Sounds quite convoluted for from actually basic problems. What's your goal ? What do you need the vesc-express for ? If you want to connect a display, you're better off using a lisp script compatible with one of the existing displays (bafang, kt...) or programming directly an esp32 based display like I did. Vesc-express is really only useful in my opinion if you want to log stuff, or add a wifi/ble functionality to a vesc that has no nrf header or in built chip.
 
Sounds quite convoluted for from actually basic problems. What's your goal ? What do you need the vesc-express for ? If you want to connect a display, you're better off using a lisp script compatible with one of the existing displays (bafang, kt...) or programming directly an esp32 based display like I did. Vesc-express is really only useful in my opinion if you want to log stuff, or add a wifi/ble functionality to a vesc that has no nrf header or in built chip.
We need VESC Express primary for wireless connection and USB connection to setup the motor (rotary encoder calibration, torque sensor calibration, changing all the settings including power, battery etc), to get rid of the integrated Bluetooth module (it is obsolete and hard to find part and it might be useless on M560 motor with completely enclosed aluminum case) and to get rid of USB on the board (it is useless inside the motor). This will allow us to free quite some space on the PCB, make it cheaper, use the extra space for better routes, maybe it will allow us to make it 4 layers PCB instead of 6 layers which will make it cheaper too.

Because of the Bafang M560 motor has connectors on the housing with CANL and CANH pins (and also +5V and GND pins) it should be very convenient just to connect VESC Express dongle to the brakes connector for instance (which is usually not used) and use it to setup the motor.

I am no familiar with VESC stuff but as I understand VESC Express allows to use all the VESC Tools functions through it like you connected the controller through integrated Bluetooth and USB.

I do not know if the Can Transceiver chip and VESC firmware can work with display and VESC Express connected parallel at the same time though. If not maybe this is why it did not work for me. If it should work with display and VESC Express at the same time then we need to figure out how to make it happens.

AI says it should work no problem, but it does not see the Luna controller through the VESC Express

1759430220194.png

All Canbus Bafang displays already work great with Luna firmware and Luna M600 controller out of the box, no changes here. It shows speed, changes assist levels, shows torque level you apply on the pedals, activates walk mode, turns the power ON and OFF, shows the battery charge percentage - basically all Bafang displays functions work with Luna controller out of the box.
 
Last edited:
We need VESC Express primary for wireless connection and USB connection to setup the motor (rotary encoder calibration, torque sensor calibration, changing all the settings including power, battery etc), to get rid of the integrated Bluetooth module (it is obsolete and hard to find part and it might be useless on M560 motor with completely enclosed aluminum case) and to get rid of USB on the board (it is useless inside the motor). This will allow us to free quite some space on the PCB, make it cheaper, use the extra space for better routes, maybe it will allow us to make it 4 layers PCB instead of 6 layers which will make it cheaper too.

Because of the Bafang M560 motor has connectors on the housing with CANL and CANH pins (and also +5V and GND pins) it should be very convenient just to connect VESC Express dongle to the brakes connector for instance (which is usually not used) and use it to setup the motor.

I am no familiar with VESC stuff but as I understand VESC Express allows to use all the VESC Tools functions through it like you connected the controller through integrated Bluetooth and USB.

I do not know if the Can Transceiver chip and VESC firmware can work with display and VESC Express connected parallel at the same time though. If not maybe this is why it did not work for me. If it should work with display and VESC Express at the same time then we need to figure out how to make it happens.

AI says it should work no problem, but it does not see the Luna controller through the VESC Express

View attachment 378479

All Canbus Bafang displays already work great with Luna firmware and Luna M600 controller out of the box, no changes here. It shows speed, changes assist levels, shows torque level you apply on the pedals, activates walk mode, turns the power ON and OFF, shows the battery charge percentage - basically all Bafang displays functions work with Luna controller out of the box.
Thank you for your explanations. In that case, I really see no issue at all:
1. You can plug many different devices in parallel on the same CANbus. That's the whole point of canbus vs serial connection. Without going too much into details: each can frame is sent with a unique identifier (SID or EDI) which you set and which is than used to address it on the bus. The receiver runs a code filtering frames for the one it needs. In cars signal crowding can be an issue, but not in ebikes, especially at relatively low baud rates. I've programmed my own canbus for vesc in C and lisp, and am quite confident about it...

2. Vesc-express works plug-and-play with vesc to do exactly what you want: wifi & usb connection for a controller vesc. Just connect it to the vesc via canbus and plug a pc onto the usb port. Than launch vesc-tool to configure wifi and use detect all vesc on canbus. You can even run light lisp scripts on it to preset a config, if you want to

3. My point of view: on an ebike, wireless connection is unnecessary. Since all peripherals need power, you have wires running all over the place anyway so it's easy to add 2 lines for a much more reliable canbus connection, and to configure the motor, a usb connector on the controller housing is really all you need. If you are running out of space, you can always use an usb extension cable and mount the plug somewhere else. Still better than a wireless connection that can fail and be a security issue. If you really need wifi, I'd add a power switch to the vesc-express to switch it off when not needed.
 
Last edited:
I do not know if the Can Transceiver chip and VESC firmware can work with display and VESC Express connected parallel at the same time though. If not maybe this is why it did not work for me. If it should work with display and VESC Express at the same time then we need to figure out how to make it happens.
Did you measure if perhaps both* are trying to terminate the bus? If you have 60ohm between
can hi & lo, it is terminated(has 120ohm resistors between them) correctly. I suppose controller
does terminate one end, and so only one device(at the other end) of the bus should "terminate",
unless it is in the wiring harness.

*) display + that VESC Express.
 
Did you measure if perhaps both* are trying to terminate the bus? If you have 60ohm between
can hi & lo, it is terminated(has 120ohm resistors between them) correctly. I suppose controller
does terminate one end, and so only one device(at the other end) of the bus should "terminate",
unless it is in the wiring harness.

*) display + that VESC Express.
Here is how is it connected.

This is the CAN transceiver circuit on the Luna controller PCB

1759681249386.png

Here is CANL and CANH in the torque sensor connector in the Luna PCB and those are connected to the torque sensor

1759681725182.png

Here is the connector on the Luna PCB with CANL and CANH pins from the CAN transceiver which is connected to Display and where I also connect VESC Express

1759681505822.png



If we skip all the wiring and connectors here is how the Torque Sensor, Display and VESC Express are connected. There are only wires between the controller and the units connectors.

1759682221247.png
 
Unusual switch-on problem.
1. My M510/DPC245 display will try to turn on immediately the battery switch is pressed (it doesn't wait for the power button on the button pad).
2. Battery icon flashes a couple of times, then it throws error 30.
3. Once this is cleared the display appears to work normally (shows correct battery %, responds to buttons)
4. Motor gives no power, and display turns itself off, and sequence repeats.
5. Turning off battery switch is the only way to shut it down.

It feels like a sticky power button on the button pad - and I know I have had this problem and have to pop out the little button after pressing. But I tried unplugging the button pad and the problem still occurs. All cables checked as usual for Error 30.

Any ideas? Display? BMS? Controller? Reflashable or fried?
 
It can be a problem inside the cable you can not see outside, or in a connector, or in the display, or in the controller. Probably the easiest and fastest way to check it is to connect the motor to another wiring harness or to another display or both and see if the problem still exists.
 
Last edited:
cool - keep me posted!

EDIT: It's actually pretty easy to tailor the vesc firmware to your needs. All you have to do is configure a custom hwconf file; the compiler will than include all the files you need and leave out those you don't.
The Markhor M560RS motor halves have been precisely 3D scanned inside and outside with the CMM machine. Now we need to process the data and we can start designing the VESC controller for Bafang M560 motor.

I did a few more attempts to contact Marcos and Luna and tried to motivate them to help the electric bicycles community to solve the issue with the VESC Express with Luna M600 controller and offered them they can use freely the VESC M560 controller and other files we will generate in exchange to their assist but they do not respond anymore. So it looks like nobody from the VESC Labs Team is going to help the electric bicycles community or willing to collaborate and at this point we can only rely on ourselves.

1759859726589.png

1759859802996.png

1759859854523.png

1759859900382.png

1759859949188.png

1759859978798.png
 
Last edited:
Unusual switch-on problem.
1. My M510/DPC245 display will try to turn on immediately
Looks like it might be this problem. But I will have to pull the motor apart to see. The motor on its own (no display connected) is pulling Vbat up to 48V, which it should not do until switched on by the button pad. Curious that it only happened after charging to 100% (54.something volts). If controller itself is fried then it might be time to move on to a VESC!
 
Check for some corrosion from water ingress around connector on your motor pcb. I just had something similar but for me it was in a DPC080 display. PCB had fretting and green junk between components from water ingress. Without touching a button it still pulled the motor on.
 
Back
Top