2023-04-15
09:37 PM
- last edited on
2023-12-06
04:47 AM
by
Laurids_PETERSE
There is mistake in either the documentation or the source code, which one is correct please advise.
__weak uint16_t PWMC_SetPhaseVoltage(PWMC_Handle_t *pHandle, alphabeta_t Valfa_beta)
{
wUAlpha = Valfa_beta.alpha * (int32_t)pHandle->hT_Sqrt3;
wUBeta = -(Valfa_beta.beta * ((int32_t)pHandle->PWMperiod)) * 2;
}
But if you compare with the documentation
In the alpha code the PWM period (T) is missing.
In the beta code additional 2 is found.
Why there is a difference? Please help.
Solved! Go to Solution.
2023-08-14 03:51 AM
for someone with the same question, in mc_config.c -> PWMC_R3_2_Handle_t PWM_Handle_M1,
there is .hT_Sqrt3 = (PWM_PERIOD_CYCLES*SQRT3FACTOR)/16384u
PWM_PERIOD_CYCLES is in tick (clock freq / pwm freq), and SQRT3FACTOR is 16384 * sqrt(3) * 2
so there's 2 also in Ualpha, so Ualpha and Ubeta is doubled in code
2023-04-18 03:18 AM
Any help on this?
2023-08-14 03:51 AM
for someone with the same question, in mc_config.c -> PWMC_R3_2_Handle_t PWM_Handle_M1,
there is .hT_Sqrt3 = (PWM_PERIOD_CYCLES*SQRT3FACTOR)/16384u
PWM_PERIOD_CYCLES is in tick (clock freq / pwm freq), and SQRT3FACTOR is 16384 * sqrt(3) * 2
so there's 2 also in Ualpha, so Ualpha and Ubeta is doubled in code