FOC Open Source Firmware for Bafang CAN bus controllers with GD32F303 processor

As a request, we need to be able to read the temperature of the motor on the display to check on over amps and poor efficiency, is this possible.?

Great news on getting the first Beta available. Unfortunately I’m out of the U.K. at the moment and can’t help on testing. Will be back in a few weeks.
 
we need to be able to read the temperature of the motor on the display to check on over amps and poor efficiency, is this possible
No problem in principle, if the M510 has an NTC on the motor windings. But I have to identify the ADC input pin for that. Any idea which pin carries the NTC information on the PCB connector? I guesss this is the right one, but which of the six pins? :unsure:
IMG_20260205_183956_643~2.jpg
 
Last edited:
It looks like Bafang changed numbering of those pins or maybe flipped the connector on PCB. On M560RS the numbering is different. I do not know if the connector on your picture is flipped or if they just changed the numbering.

1770315585932.png

Regarding the connector locking tab orientating here are the pins for the 20K NTC Thermistor. The pins on the thermistor leads connector should be the same for all the motors in regard of the locking tab location. You have to check where the tab is to find out the pins (but if you have the motor just see where the leads are connected).

1770315918450.png

By the way, for same reason Bafang uses wrong numbering for the pins. The 1st pins is indicated on the connector with an arrow and correct numbering order described in the connector manufacturer documentation (and they follow the common numbering order for such connectors), but Bafang numbered those pins differently on the PCB for some reason.
 
Last edited:
You have to check where the tab is
This is really strange. There are only 3 pins connected on my PCB. GND, +5V and one signal. Three pads (1,2+4) have no traces on the PCB.

1770320547867.png
1770320615912.png
1770320685180.png

I followed the trace via some ferrite balls and resistors to pin PC4, which is ADC channel 14. So I can implement the temperature reading now.

1770322721073.png
 
Last edited:
I do not know which pin is for signal and which pin is for ground on the Bafang PCB. I only know which pins are for the thermistor. There are only 2 wires connected to 2 pins on that connector. 5V pin is not used, it is there for nothing (or maybe to trigger an error in case of user connected PAS sensor to the temperature sensor receptacle). Just signal and GND are used on that temperature sensor connector.

On the LUNA controller the pin #3 (from you picture) is connected to 3.3V voltage divider circuit (the thermistor is part of the voltage divider circuit) and to MCU through some resistors. The pin #5 (from you picture) connected to GND. On the Bafang controller it might be swapped and operate with different voltage, but I do not know details about it.

1770332829908.png
 
Last edited:
I followed the trace via some ferrite balls and resistors to pin PC4, which is ADC channel 14.
Hm, strange. The voltage on this pin does't change with the temperature. The pin PA4 changes. But that pin is also the one that reads the on/off button. So it has a dual function?! I can't really believe it, because the measured value also changes slightly with the battery voltage, so it's actually unsuitable for temperature measurement?! Maybe it is just a temperature drift of the resistors on PA4? :unsure:
Or this is a dual safety function, the controller switches off on low battery and on overheat?!

ProcessorPinoutM510.PNG
 
Last edited:
Correct me if I’m wrong here. The on off button pulls down to only 1/2 voltage to signify the on call from the button on the M510. When connected to say BESST it pulls that line fully to ground to signify BESST is connected. Is this the dual function you are talking about ?
 
I looked at a not so good picture (grabbed from a GBK video) from a M510 board and it seems you have located the ground and signal wire from the 2 wire temp sensor at the correct pins in the 6 pin connector. Maybe by trying to follow the signal trace via some components you ended up on the wrong pin on the processor?
M510 temp sensor 2 wires.png
 
Maybe by trying to follow the signal trace via some components you ended up on the wrong pin on the processor?
Yes, I had more than one error in it :)
First, the trace ends in PB0, not in PC4.
Second, I've configured PB0 as digital output, so the processor pulled it to Gnd by default.
Now I have to find the right linearization for the temperature signal....
 
Last edited:
Back
Top