BEMF detection on B-G431B-ESC

I’m working in BEMF detection for this board, I managed to get some readings that look very trapezoid-y:

image

image

The board supports pwm-on and pwm-off BEMF detection. ST says the lines take time to stabilize, at low duty cycles measurements should be taken at the end of the pwm off phase. At high duty cycles measurements should be taken at the end of the pwm on phase. It might not be possible to do off-duty BEMF detection and current sensing at the same time (needs research).

The BEMF detection circuit is shown below:
image
For on-pwm BEMF detection, GPIO_BEMF should be configured as output and driven low. The BEMF1 pin connected to the CPU can be read to obtain a measurement. How do I calculate gain from this circuit? Measurements suggest the gain should be around 40.

Is there an industry standard algorithm to detect the zero-crossings?

For interested readers, here is a reference from ST about minimizing BEMF measurement noise https://www.st.com/resource/en/application_note/cd00043112-back-emf-detection-during-pwm-on-time-by-st7mc-stmicroelectronics.pdf

Here is a paper discussing various sensorless control techniques: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3231115/

1 Like

There’s also this AN from ST:

Essentially there seem to be two major ways to go: using ADCs or using comparators. On the B-G431B-ESC it looks like the BEMF pins are all on ADC2 but not on comparators, so I guess that choice has been made for you…

Coordinating the ADC measurements to the PWM is a bit complicated, but STM32 supports it.

My readings seem to have a good amount of noise. It looks like some kind of signal filtering would be helpful, but ST doesn’t explain this. I’m looking into kalman filters to model the system, and a python tool for model verification based on captured traces. Maybe I’m thinking too hard…

It has been a rough ride…

When sampling during pwn-off, the voltage falls outside the range of the ADC. This can be ‘fixed’ with FocMotor->modulation_centered = 0, but this means pwm-off is limited to ~12% duty cycle.

When sampling during pwm-on time, the ADC’s return 0 if the power supply voltage is less than approximately 20V. The exact threshold is influenced by temperature, my board can reliably detect the temperature fluctuations from forced airflow (read: blowing on the board). This board is designed for 6-cell lipo (~22v), Apparently this means BEMF detection doesn’t work with less than 6 cells. Or more than 6.

Here are some traces (pwm-on, 100rad/s) with various operating conditions.

Cold board with slight under-voltage (21V):

image

Cold board with in-spec voltage:

image

Hot board with slight over-voltage:

image

The board works well on higher voltages, but only when cold.

The good news is that pwm-on sampling works well if an appropriate input voltage is selected, so we might not need pwm-off or expensive signal filtering.

1 Like