This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello TI,
I tried to use the torque mode in lab11e, I changed these two variables:
bool gHall_Flag_CurrentCtrl = true;
gIdq_ref_pu.value[1]= Iq_Ref_pu;
But when I increased gIdq_ref_pu.value[1] nothing happened.
I recognized that gHall_PwmDuty was always at zero.
I found this in the code:
if(gHall_Flag_CurrentCtrl == true) // Torque Control Mode
{
gHall_BLDC_Is_fdb_pu = gAdcData.I.value[gHall_BLDC_Flag_Is_fdb];
gHall_BLDC_Is_ref_pu = speed_pid_out;
// BLDC current loop
PID_run(pidHandle[3],gHall_BLDC_Is_ref_pu,gHall_BLDC_Is_fdb_pu,&gHall_PwmDuty);
HALLBLDC_Ctrl_PwmSet(gHall_PwmState, gHall_PwmDuty);
}
else // Speed Control Mode
{
gHall_PwmDuty = speed_pid_out;
HALLBLDC_Ctrl_PwmSet(gHall_PwmState, gHall_PwmDuty);
}
Then I put the gHall_PwmDuty in the torque control like this:
if(gHall_Flag_CurrentCtrl == true) // Torque Control Mode
{
gHall_BLDC_Is_fdb_pu = gAdcData.I.value[gHall_BLDC_Flag_Is_fdb];
gHall_BLDC_Is_ref_pu = speed_pid_out;
// BLDC current loop
PID_run(pidHandle[3],gHall_BLDC_Is_ref_pu,gHall_BLDC_Is_fdb_pu,&gHall_PwmDuty);
gHall_PwmDuty = Iq_Ref_pu;
HALLBLDC_Ctrl_PwmSet(gHall_PwmState, gHall_PwmDuty);
}
else // Speed Control Mode
{
gHall_PwmDuty = speed_pid_out;
HALLBLDC_Ctrl_PwmSet(gHall_PwmState, gHall_PwmDuty);
}
After this change the motor started moving, but it only runs smoothly at very low speeds, at higher speeds it begins to oscillate and sound badly and I’m thinking it’s not changing to FAST.
I think I did something wrong in the code, because the current control works in the other labs and speed mode of lab11e works as well.
I’m not sure what I have to change to use the torque mode. Please Help.
And only out of curiosity if I want to add the hall start-up in lab5a or 10a would this be easy?
Because I saw some differences in the mainISR and I don’t know how to handle that.
thanks in advance
Yes, I want to implement torque control with full speed range, BLDC and FAST.
Thank you for the code Yanming. Now it’s a bit clearer to me.
I tried the changes, but it did not work. gHall_PwmDuty is still at zero.
Here is a picture of the watch window:
Another thing I found I out, if I set outMin to 0.1 the motor begins to spin and Ui goes from zero to the value of outMin.
Here is a picture of the watch window where outMin is set to 0.1 .
I think Ui is the cause. Is there something else to change?
thanks
It seems the outMax and outMin of pid[3] is not right. Did you have below code to initialize the PID controller pid[3] as other pid[0/1/2].
PID_setGains(pidHandle[3],Kp_Iq,Ki_Iq,_IQ(0.0));
PID_setMinMax(pidHandle[3],-maxVoltage_pu,maxVoltage_pu);
PID_setUi(pidHandle[3],_IQ(0.0));