In McDrv_pwm3ph_ftm.c in bldc_ref_sol, there is a MCDRV_FtmSetDutyCycle function, which I'm not sure about the duty cycle Settings.
i16Duty = MLIB_Mul_F16((i16InpDuty), (this->ui16PwmModulo) / 4);
i16FirstEdge = -(this->ui16PwmModulo) / 4 - i16Duty;
i16SecondEdge = (this->ui16PwmModulo) / 4 + i16Duty;
I think the PWM waveform generated by this setting is shown in the figure below.So the final duty cycle is not consistent with the duty cycle of the input function.I want to know where did I get it wrong?
Solved! Go to Solution.
Hello 相国 尹,
As the function mention, the input duty cycle is an escalated frac number so the -1 = 0% and +1 = 100%. So the value need it for the 20% is FRAC(-0.6).
Best Regards,
Alexis Andalon
Hello,
The description of the API is the following one:
MCDRV_FtmSetDutyCycle – updates duty cycle generated with PWM module. In variable f16DutyCycle there is stored new value of duty cycle in the fractional number representation. Fractional number value in range <-1; +1) is then processed and scaled in appropriate PWM driver function to fit the actual PWM module configuration.
So in the dutyCyle variable previously the value is escalated to match the wanted duty cycle.
Best Regards,
Alexis Andalon
Dear Alexis Andalon,
I don't think you understand my question.
I mean I drew the PWM waveform according to the program statement, but the duty ratio of this PWM is not consistent with the duty cycle of the function input. I want to know what the problem is.
Hello 相国 尹,
What did you draw is correct, by default, but as the description mention the i16InpDuty should be a fractional number between -1 and 1, and the multiplication function will escalate the value to match the appropriate module. So if the value if -1 the PWM duty will be 0% and if the value is 1 will be 100%.
Best Regards,
Alexis Andalon
I know that i16InpDuty is a fraction and a numerical match.Did you notice that the duty cycle of PWM wave I drew is different from the duty cycle of function input?For example, the duty cycle of the function input is 20%, but the duty cycle of the PWM wave I have drawn is 60%
Hello 相国 尹,
In this case that you want the 20% duty cycle, what is the value that you put in the i16InpDuty that corresponds to 20%?
Best Regards,
Alexis Andalon
Hello Alexis Andalon,
The value is FRAC(0.2) in the i16IputDuty.
Best Regards,
xiangguo
Hello 相国 尹,
Try with FRAC(-0.4).
Best Regards,
Alexis Andalon
Hello,Alexis Andalon
if I use the FRAC(-0.4),the final duty cycle is 30%. As the function,the duty cycle of input should be the final duty cycle of PWM.
Best Regards,
xiangguoyin
Hello 相国 尹,
As the function mention, the input duty cycle is an escalated frac number so the -1 = 0% and +1 = 100%. So the value need it for the 20% is FRAC(-0.6).
Best Regards,
Alexis Andalon