Flex PWM and SineWave Gen Conflicting?

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

Flex PWM and SineWave Gen Conflicting?

Jump to solution
764 Views
zcampbell
Contributor I

Hello MBDT Community,

I am having trouble in the attached model getting the sine wave to generate.  I am not sure what is wrong.  No errors are produced by any of the compilation tools.  I am using the sinewave voltage to drive a signal into a resolver and without this signal I cannot determine position of rotor.  Thank you for any help that can be provided.

0 Kudos
1 Solution
715 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @zcampbell,

I am sorry, I must have missed the thread you've opened...

Anyway, I had a look at your model, and as I've seen, there was no sinewave on the PD7 pin. In order to get that Sine on the pin, I had to enable the Reload Output trigger for the FlexPWM0, Channel 0. Let me describe what I've done below.

Go to the FlexPWM0 Ch0 block and under the Output Triggers, check the reload interrupt.

mariuslucianand_0-1612382138916.png

Obviously, this will install an interrupt, so we have to add the interrupt handler block in the model. For that, I went to MBDT library and I've added the FlexPWM ISR Handler block. In our toolbox, that trigger is enabled at the same time with the interrupt. So, now that we have enabled the trigger, the first time when the interrupt occurred, we will just disable that interrupt, so for the entire time of the model execution, the interrupt, useless for your application will not be trigger anymore. To do so, we have to add the FlexPWM_ISR_Enable_Disable block in the interrupt triggered S-function and select the Module 0, Submodule 0 and reload interrupt.

mariuslucianand_1-1612382298773.png

These changes enabled the SineWave on the PD7 pin (Yellow). you can see the FlexPWM0, Ch0 (Blue) and the CTU trigger (Red).

mariuslucianand_2-1612383091709.png

At one time, before generating the code, Simulink warned me of an error related to some TLC file. I cannot explain why, but I had to delete the Stateflow that toggled the pin from inside the commented code in the CTU interrupt, which you are not using it. I've just replaced it with a constant 0. because you were not using that piece of the model. 

I've attached the modified model.

Hope this helps,

Marius

View solution in original post

3 Replies
716 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @zcampbell,

I am sorry, I must have missed the thread you've opened...

Anyway, I had a look at your model, and as I've seen, there was no sinewave on the PD7 pin. In order to get that Sine on the pin, I had to enable the Reload Output trigger for the FlexPWM0, Channel 0. Let me describe what I've done below.

Go to the FlexPWM0 Ch0 block and under the Output Triggers, check the reload interrupt.

mariuslucianand_0-1612382138916.png

Obviously, this will install an interrupt, so we have to add the interrupt handler block in the model. For that, I went to MBDT library and I've added the FlexPWM ISR Handler block. In our toolbox, that trigger is enabled at the same time with the interrupt. So, now that we have enabled the trigger, the first time when the interrupt occurred, we will just disable that interrupt, so for the entire time of the model execution, the interrupt, useless for your application will not be trigger anymore. To do so, we have to add the FlexPWM_ISR_Enable_Disable block in the interrupt triggered S-function and select the Module 0, Submodule 0 and reload interrupt.

mariuslucianand_1-1612382298773.png

These changes enabled the SineWave on the PD7 pin (Yellow). you can see the FlexPWM0, Ch0 (Blue) and the CTU trigger (Red).

mariuslucianand_2-1612383091709.png

At one time, before generating the code, Simulink warned me of an error related to some TLC file. I cannot explain why, but I had to delete the Stateflow that toggled the pin from inside the commented code in the CTU interrupt, which you are not using it. I've just replaced it with a constant 0. because you were not using that piece of the model. 

I've attached the modified model.

Hope this helps,

Marius

723 Views
zcampbell
Contributor I

@mariuslucianand I know you're not the only contributor to the community, but am hoping you may be able to take a look to see what is wrong with the model in the attached.

0 Kudos
748 Views
zcampbell
Contributor I

Further information regarding model:

SPC5744P development board is the hardware.  

The sine wave generation is not starting in a reliable manner.  Intermittently, when reset the board will start the sine wave properly.  But the module is not running reliably.  I am wondering if there is something I can do to make the sine wave module startup or run more reliably.

0 Kudos