so we have been struggling with a particular issue on our Motor controllers. Before i explain the issue in detail with pictures. Let me setup the context of the hardware we are using.
Motor controller:
Custom made dual channel BLDC controller with low side shunts on ChA and ChB using DRV8302 gate driver IC's. Uses NTBGS2D5N06 Mosfets and 5mOhm sense resistors with the DRV8302 Gain set to 10 V/V.
Motor Specs:
24V 30 poles 0.560Ohm 0.850uH 200RPM with Incremental encoder (4096 PPR)
Controller Configuration:
STM32F429 with TIM1 and TIM8 being used in center-aligned mode at a switching frequency of 30Khz.
Issue:
The controller works fine in openloop configuration, where based on the set RPM the phase is incremented during each ISR routine. Below is the screen shot of the same.
Issue arises in RPM control, in which over time Vd starts decreasing from the initial value (all tests done in unloaded conditions). RPM controller is a simple PID controller with Kp = 0.004, Ki = 0.006 and Kd=0.0001.
volatile float error = static_cast<float>(set_point.targetRPM - set_point.measuredRPM);
volatile float pTerm = (error * pGain);
volatile float dTerm = (((error - prevError) * dGain )/microsPID_delta);
math::LPFast(dFiltered,dTerm,0.1f);
prevError = error;
plantOutput = pTerm + dFiltered + iTerm;
iTerm += (error * iGain * microsPID_delta);
math::truncateAbs(iTerm, 1.0f);
math::truncateAbs(plantOutput,1.0f);
plantOutput *= MOTOR_CURRENT_MAX;
If left alone to run longer eventually Vd and Vq cross-over when (vq - vd) > (Vbus/sqrt(3)). Below is the screenshot of RPM Mode
Vd starts at ~ 0V and then gradually becomes more negative. This phenomena is speed and direction dependent. As speed increases Vd's slope increases. Things we have tried to fix the issue.
change the switching frequency - tried 20Khz, 10Khz, 5Khz. Vd still falls, although much slower
Add phase shunt resistors to improve current sensing @ low currents. Doesnt fix the issue.
Check if the encoders and their code is buggy - works without issues
Change Current controller and rpm controllers PID params - doesnt effect the issue
Use higher Resistance and inductance values for cross-coupling removal to check if vq is being coupled to vd causing id to rise and eventually driving the D-axis current controller to make Vd more and more negative. Not the issue.
Make Integral term of the rpm controller zero - doesnt fix the issue.
The only hack that has stopped the Vd falling issue is when in RPM mode we dont use encoder feedback for phase rather use the openloop phase where depending on the set RPM a constant delta is added each iteration.
Since I'm not an FOC expert and dont have an indepth understanding of Motors and Field control. I'm unable to understand the problem here. Perhaps it could be a a very benign deisgn oversight from our end or could be a timing related issue between the current controller and rpm controller (current controller runs at 15Khz (dual motors hence 15Khz per motor) and rpm controller runs at 3 Khz).
Please feel free to ask questions to gain a better understanding of the situation and guide us in the right direction.
Thanks