Skip to main content
SRedd.5
Senior III
October 22, 2023
Solved

STC_CalcTorqueReference function

  • October 22, 2023
  • 1 reply
  • 2192 views

In the __weak int16_t STC_CalcTorqueReference(SpeednTorqCtrl_Handle_t *pHandle) function 

The original ST code contains the below line code.

hMeasuredSpeed = SPD_GetAvrgMecSpeedUnit(pHandle->SPD);
hError = hTargetSpeed - hMeasuredSpeed;
hTorqueReference = PI_Controller(pHandle->PISpeed, (int32_t)hError);

I modified the first line of code to

hMeasuredSpeed = -SPD_GetAvrgMecSpeedUnit(pHandle->SPD); i put a negative sign before the function.

This i have done since the error was never going to 0. Is it correct or i need to remove the negative sign? I have start up issues is it because of this?

 

 

    This topic has been closed for replies.
    Best answer by SRedd.5

    I changed the sign and tested the issue remained same, the issue resolved by changing the HALL_PHASE_SHIFT

    to different angle. I have a real challenging understanding this. The way i have found this issue is with HALL_PHASE_SHIFT set with original value, it was jerking in the forward direction and not jerking in the reverse direction and i changed the sign of the HALL_PHASE_SHIFT and it is not jerking in either forward or reverse direction, slight jerk is still there some times i need to resolve that as well. Do i have a mechanism from which i can confirm if my Hall_phase_shift is correct. By reading one of the posts in these forums i understood that the raising edge of Hall1 signal shall match with zero point of U phase current. Is it correct?  

    1 reply

    FouadB
    ST Employee
    October 23, 2023

    Hello,

    The speed parameter returned by the SPD_GetAvrgMecSpeedUnit function contains the direction of rotation. Reversing the sign of the estimated speed value, as you have done, will reverse the speed at the input of the speed regulator. This explains the startup issue reported, as your control will never converge during the startup phase.

    Best regards

    If you agree with my answer, please accept it by clicking on 'Accept as solution'.""
    SRedd.5
    SRedd.5Author
    Senior III
    October 23, 2023

    Thank you for the reply, i will remove the negative sign and verify if the startup issue is resolved and update.