- Home
- :
- General Purpose Microcontrollers
- :
- Motor Control and Smart Energy
- :
- Set the duty cycle

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

SOLVED

07-25-2020
07:04 AM

300 Views

xgy_upc

Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.

1 Solution

08-12-2020
08:14 AM

177 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

9 Replies

07-31-2020
11:24 AM

177 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

08-01-2020
08:05 AM

177 Views

xgy_upc

Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.

08-05-2020
03:33 PM

177 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

08-05-2020
06:49 PM

177 Views

xgy_upc

Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-06-2020
09:38 AM

177 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

08-06-2020
06:58 PM

177 Views

xgy_upc

Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hello Alexis Andalon,

The value is FRAC(0.2) in the i16IputDuty.

Best Regards,

xiangguo

08-11-2020
08:13 AM

177 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hello 相国 尹,

Try with FRAC(-0.4).

Best Regards,

Alexis Andalon

08-11-2020
06:45 PM

177 Views

xgy_upc

Contributor III

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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

08-12-2020
08:14 AM

178 Views

Alexis_A

NXP TechSupport

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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