Bafang M500/M600 thread

It would be good to get together a set of working VESC parameters in one place for all the Bafang M-motors. How did you do your encoder? Is it producing a pulse for every motor revolution? I thought the bafang PCB picked up a magnet on the shaft, but I don't have a PCB inside the motor any more.
 
I do not know which external pins of the VESC controllers are for rotary encoder, I only know how it is connected to the MCU on the VESC based Luna controller and I just replicated it to make it works. There are different rotary encoders with different signals, resolutions and modes and VESC supports some of those encoders and some modes. Yes, Bafang controller uses rotary encoder senses the magnet attached to the end of the rotor shaft, the VESC based Luna controller uses the same rotary encoder as Bafang M560/510.

If you want to use encoder with your VESC you need to find an encoder VESC supports and figure out how to mount it inside the motor properly aligned and spaced with the motor shaft (maybe glue it or design and print a 3D printed holder for it) and route the wires from the encoder to the VESC controller. There are encoders chips mounted on small PCBs you can purchase and find out how to mount and connect.

You can use the shared CAD files to use the original Bafang PCB mounting holes as reference to align the rotary encoder with shaft

1767941114176.png
 
Last edited:
Recently rode a Giant Expression E+ that is advertised as
"SyncDrive Core 55Nm motor has Smart Assist mode, which uses sensors to constantly determine and deliver the optimal level of support by automatically adjusting power output".

The Bafang M600 has 120Nm.

Please explain why I feel exhausted riding a Bafang M600 48V canbus based bike up a hill yet when using the Giant it felt natural and easy and I wasn't exhausted on the same hill? Does the Bafang have poor sensors, bad algorithms, crap firmware?
 
Last edited:
Does the Bafang have poor sensors, bad algorithms, crap firmware?
Perhaps better marketing?! :ROFLMAO:

The torque as single value means nothing. You can have 1000Nm, with no speed it will still be zero power, as mechanical power = torque * speed (rpm)

But of course the assist factor defines the ratio of motor power to human power. It will be simply set to a higher value with the Yamaha system.

But you can set the assist factor in the assist table in the Bafang BESST (or much cheaper Canable). If your Bafang firmware version let you change them, it's a lottery if it works ;)
 
Last edited:
Recently rode a Giant Expression E+ that is advertised as
"SyncDrive Core 55Nm motor has Smart Assist mode, which uses sensors to constantly determine and deliver the optimal level of support by automatically adjusting power output".

The Bafang M600 has 120Nm.

Please explain why I feel exhausted riding a Bafang M600 48V canbus based bike up a hill yet when using the Giant it felt natural and easy and I wasn't exhausted on the same hill? Does the Bafang have poor sensors, bad algorithms, crap firmware?
The M600 motor is quite a powerful early generation motor ( it was one of the first mid Bafang motors with torque input ) and is up there with all the latest motors on a Watts's basis ( mine running on 52 volts will pull nearly 1200 W's ). However it has quite poor firmware and cannot really be custom tuned other than setting the assist levels. It does like lots of cadence and if you can run it in the 70 - 90 rpm mode it will respond quite nicely to the torque input off the pedals. Below that and it really is not a very responsive engine, more cadence based much like the old BB series.

Hopefully when Stancecoke finishes his OS for the Bafang controllers we should be able to get these very reliable and in some ways a very good engine, much more tuneable to an individual rider.

The lastest M560 engine is its replacement and can be tuned fairly well from both BESST and App.
 
Hopefully when Stancecoke finishes his OS for the Bafang controllers we should be able to get these very reliable and in some ways a very good engine, much more tuneable to an individual rider.
The firmware will not run on the old M500/M600 controllers, as they are using a NXP processor.


The code could be ported, but it seems, that would be quite an effort....
 
Last edited:
Please explain why I feel exhausted riding a Bafang M600 48V canbus based bike up a hill yet when using the Giant it felt natural and easy and I wasn't exhausted on the same hill? Does the Bafang have poor sensors, bad algorithms, crap firmware?
By any chance does one have a 15mph speed restriction and the other say 28mph, on the M600 you can run into the speed restrictions really quickly.
 
OK, now a question for those who know the analog torque/cadence sensors. I read somewhere (can't find it again, sorry) that they put out 32 pulses per crank revolution. I've gone by this when watching the SD signal, but my cadence numbers look suspiciously high. Now turning the crank very slowly and watching the revs go by - it looks like there are somewhere between 16 and 20 pulses per rev.

Does anyone know what I should expect to see, and it is different between M510 and M560? Mine is the M510. I've never pulled it apart enough to see if it's the magnetic or optical kind.
 
Does anyone know what I should expect to see
Depends on the wire, that you are looking at. There are the two quadrature PAS signals, that each have 16 pulses per revolution in both pedaling directions. On the green wire of the analogue sensor you have the processed signal with 32 pulses per revolution when pedaling forward and no pulses when pedaling backwards.
 
I believe the original M510/560 quadrature sensor is magnetic and probably different to what used in M500/600. And M510 and M560 use the same torque/cadense sensor. The new M510RS/560RS quadrature sensor is optical and have more pulses per revolution. I do not know amount of pulses for original M510/560, and I do not remember the exact numbers of pulses for M500/600 and for M510RS/560RS, but I remember the difference was not significant when I experimented with Luna firmware with VESC Tool application and did not affect anything noticeably.
 
Last edited:
Have done a rough count and the SD line on my sensor seems to show 46-48 pulses per rev. With a little smoothing (timing over several pulses) this gives believable cadence numbers.

I don't know what the quadrature lines will do but they will be either the same as the SD or half that. (I'm not using them as the SD is 3.3V logic and does everything I need)
 
Is there a pinout available for the male six pin and the female eight pin connectors of the M510? I found nothing on the internet :(

View attachment 383906
Do you use KiCAD? All the pins and much more can be found in the shared KiCAD schematics of the VESC for Bafang M600 and the Innotrace M560 controllers. M510, M560, M500 and M600 have the same pinout.


The comments "not connected on the controller board" mean those pins are not connected and not used on the VESC controllers we reversed and designed, but those might be used on Bafang controllers (I do not know if Bafang uses those or not).

1769976178285.png

1769976269872.png

1769976318577.png
 
Last edited:
If follow the Bafang numbering on your picture:

1, 16, 22 - source of +5V (connected to the 5V output low dropout regulator on the Bafang PCB)
2 - CAN Low (connected to the CAN low pin of the CAN chip on the Bafang PCB)
3 - CAN High (connected to the CAN High pin of the CAN chip on the Bafang PCB)
4, 10, 20 - Ground (connected to the battery ground)
5 - Speed hall sensor output #1
6, 7, 8, 9, 17 - I am sure those pins are not connected to anything on the Bafang PCB because of they are not connected to anything on the harness. Maybe some of them are connected to ground in the Bafang PCB.
11 - Speed hall sensor output #2 (if you combine this signal with speed hall sensor output #1 it works like rotary encoder so you can define rotation direction and probably speed once the manged passed the speed sensor without waiting full turn of the wheel)
12 - Positive terminal of the battery
13 - Signal from POWER and DOWN buttons of the display (Button POWER pressed connects this pin with 500 Ohm resistor connected to ground. Button DOWN pressed connects this pin with 1500 Ohm resistor connected to ground)
14 - Brake sensor
15 - Throttle
18 - Shift sensor
19 - Front Light
21 - Rear Light

Here is a picture DaDo sent to me, I did did not make it

1770069752121.png
 
Last edited:

Some basics about UART vs. CAN from Bafang
 
How often the position sensor has to be calibrated? I wonder if this function in the BESST tool is only for fine tuning, or if it is essential to be executed at least once, if you are installing a new controller into a motor. Any experience?
 
It’s advised to calibrate any new controller fitted. When we were all having problems with the M510 motors not starting ( it was the ribbon cable ) , a few fitted new controllers and reported they wouldn’t run until the motor had been calibrated using the BESST tool.
 
I was told a calibration is necessary with a new controller, and it proved to be so. It throws an Error 08 (from memory) until you do it. I did not get a chance as the controller failed before I could borrow a Besst. Attempts to inject a calibration packet on the CAN bus did not work either.
 
a calibration is necessary
OK, it's a little tricky, as the encoder works in A/B/Z + PWM mode. The encoder reads the mechanical position of the rotor, not the electrical, so you get a Z- pulse only every fifth electrical revolution (Five pole pairs).
The motor runs quite quick during the calibration procedure, looking at this video:


I have to try how fast the motor can spin in open loop.
 
That one spins really fast. M400 spins fast but for sure not that fast. Some others spin slow..... I saw no "torque" calibration button in the video. Anyway here from GBK you can find several video's for different motors regarding "Position" and in some they use also "torque sensor" calibration.
 
I've noticed ads for a Bosch Bluetooth Mini Remote (BRC3310) button kit for up/down and power buttons on the handlebars. Has anyone seen what its protocol might be? Being Bosch it will probably not be hacker-friendly.

Seems good for a wire-free solution if (like me) you have a BLE-speaking microcontroller + VESC down in the nether regions and no wires coming up to the cockpit.
 
Back
Top