Modulated PWM waveform Generation

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

Modulated PWM waveform Generation

1,306 Views
swatimali
Contributor I

I am using s32k144 controller I want to produce  PWM waveform with modulation feature.  If I use modulation feature is it possible to generate PWM with different durty cycle in their on time. for example if on time is of 40 msec and period is 60 msec, then for 20 msec 80% duty cycle and for next 20msec 20%duty cycle. How to generate this kind of waveform.

Thanks & Regards,

Swati Mali

0 Kudos
5 Replies

1,063 Views
allen_willson
NXP Employee
NXP Employee

Swati,

I created a demo using 3 of the 4 FTM channels on S32K144, which uses the Fault pins to modulate a frequency output for any duration within your desired period.  In the attached image, the signals on traces D0 and D1 are used to modulate the PWMs that are being output on D2 and D3.  The signals on D0 and D1 are generated by FTM0, and are wired to the fault inputs on FTM2 and FTM3.  FTM2 and FTM3 can be configured to generate independent PWM signals.  When a fault is active, the PWM is not output on the pin. The period is defined by FTM0, and this is shown on trace D4.

This method uses a lot of FTM resources.

modulated output using FTM Fault pins.jpg

Source code is attached. Sorry, but I don't think it is commented very well yet. You can contact me if you have questions.

-allen

0 Kudos

1,063 Views
bjrajendra
Senior Contributor I

Hi Allen,

I would like to know about the possibility of modulating on FTM2 & I'd raised few issues on using 

SIM->FTMOPT1=SIM_FTMOPT1_FTM3_OUTSEL(0x01); how does this help in modulation and what is its significance?

Similar thing I asked a question in FTM2 Output Modulation.

Kindly suggest to us in this regard.

Raju

0 Kudos

1,063 Views
allen_willson
NXP Employee
NXP Employee

Hello,

The SIM->FTMOPT registers perform the modulation function described in the reference manual section 45.1.7 FTM Modulation Implementation.  This is similar to what the demo performs, but not does not allow using across more than one FTM.  The diagram at Figure 45-4 FTM Output Modulation shows the direct influence of the channel FTM1_CH1 to the FTM0 output signals.  The limitation is that all signals of FTM0 are modulated by FTM1_CH1. 

Hopefully you have an evaluation board and you can play with these features.

0 Kudos

1,063 Views
bjrajendra
Senior Contributor I

Hi Allen,

Thanks for your swift response.

I code attached  isn't using SIM->FTMOPT1=SIM_FTMOPT1_FTM3_OUTSEL(0x01);

I analyzed the code you shared above, FTM0 with 40Hz, and both FTM1 & FTM2 with 1KHz. Also FTM1 & FTM2, CH0 are provided with 50% duty cycle .

1. I would like to know the reason why 50% duty cycle @ 1KHz on FTM1_CH1, though FTM1 doesn't support Modulation. Is this CnV registers in FTM1 support in generating the signals D2 and D3 on FTM0_CH0? In that case, what is the duty during the modulation period of D2 & D3? Is the modulating frequency is same as FTM1_CH1? Is this 50% can be controlled?

Kindly clarify,

Raju

0 Kudos

1,063 Views
bjrajendra
Senior Contributor I

Hi Allen,

Thanks, for your response.

Does this mean the FTM1_CH1 -> CnV register is used for the duty & generate PWM outputs on FTM0?

Raju

0 Kudos