Very poor current measurement when not sampling mid-PWM period
- February 24, 2022
- 16 replies
- 9627 views
STM32F405
MCSDK = V5.4.5
f_pwm = 10kHz
High frequency task = 10kHz
Medium frequency task = 1kHz
Position and speed = Hall (main) & STO+PLL (auxiliary)
Current sensing = 3 x 3mOhm shunts
I am having a problem with very poor Id and Iq measurements when the motor hits a certain critical speed, around 650rpm mechanical with no load.
Fig1 shows plots of Iq, Id, RPM, Electrical angle (hall and sensorless) and BEMF generated by printf-ing out the values in the Medium frequency task using Segger RTT. Fig2 is the same plot but zoomed in on the "good" region. Fig3 is zoomed in on the "bad" region.
I have traced the transition between "good" and "bad" to when the R3_2_SetADCSampPointSectX() function in r3_2_f4xx_pwm.c stops sampling in the middle of the PWM period and uses one of the alternative schemes. Here are some of the defines that I believe are of interest here:
#define TNOISE_NS 1000
#define TRISE_NS 1000
#define MAX_TNTR_NS TRISE_NS
#define LOW_SIDE_SIGNALS_ENABLING LS_PWM_TIMER
#define SW_DEADTIME_NS 120
#define PWM_FREQUENCY 10000
#define PWM_FREQ_SCALING 1
I've also run a test with exactly the same motor and setup but with an alternative non-MCSDK based motor controller and this is shown in Fig4. This test does not exhibit the same problem and runs fine at over 700rpm with a much smaller variance in Iq and Id. I think this means we can rule out any issue with the motor or Hall effect sensors.
Can anyone point me to what might be the problem here?
Why might the alternative current sampling techniques be so much worse?
Is it expected that the variation in Iq and Id measurements be so large (+/-2.5A)?
EDIT:
I'm adding a link to this question (not answered yet unfortunately) which seems to describe the same problem:
