PWM signal using Simulink

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM signal using Simulink

Jump to solution
1,659 Views
fernando_barrio
Contributor III

Hi,

I am currently using the latest toolbox (2018.R1) and I am trying to create a PWM signal for motor control without any luck. I am testing using LEDs for visualization, I know they work because they light up with the GPIO high signal. I have also tried various modules and output pins, I am currently sending a duty cycle of 0.5, because I noticed in the C code it gets multiplied by a value of about 32700. I have attached a screenshot of my settings on my block, do you guys have any suggestions? 

Thank you in advance.

pastedImage_1.png

pastedImage_2.png

1 Solution
1,463 Views
mariuslucianand
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

I tried to replicate your use case and the result was successful: the PWM period is 100ms, as you can see in the image attached. For the CH4(PD13) I used a duty cycle of 25%(0.25) while on the CH5(PD14) I used a duty cycle of 50%(0.5). 

IMG_20181213_095537.jpg

The duty cycle must be provided as "single" data type values in the interval [0.0, 1.0], proportional with the percentage of the duty cycle. This makes easier the usage of the PWM blocks alongside with the AMMCLIB blocks. 

As a suggestion for your issue, please be sure that in the General Tab of the PWM blocks, the checkbox "Start PWM signals generation immediately after initialization" is checked because your board might not start the PWM and no signals generated. To be honest with you I don't think I understand your LED testing mechanism, so if the problem continues please consider attaching your model here and I will have a look. 

I am waiting for your response!

Best regards, 

Marius

View solution in original post

2 Replies
1,464 Views
mariuslucianand
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

I tried to replicate your use case and the result was successful: the PWM period is 100ms, as you can see in the image attached. For the CH4(PD13) I used a duty cycle of 25%(0.25) while on the CH5(PD14) I used a duty cycle of 50%(0.5). 

IMG_20181213_095537.jpg

The duty cycle must be provided as "single" data type values in the interval [0.0, 1.0], proportional with the percentage of the duty cycle. This makes easier the usage of the PWM blocks alongside with the AMMCLIB blocks. 

As a suggestion for your issue, please be sure that in the General Tab of the PWM blocks, the checkbox "Start PWM signals generation immediately after initialization" is checked because your board might not start the PWM and no signals generated. To be honest with you I don't think I understand your LED testing mechanism, so if the problem continues please consider attaching your model here and I will have a look. 

I am waiting for your response!

Best regards, 

Marius

1,463 Views
fernando_barrio
Contributor III

Hi mariuslucianandrei‌,

That is exactly what I was missing, I did not see the Initialization option in the advanced settings.

Thank you for your help,

Fernando 

0 Kudos
Reply