Hello
I was trying to use frequency update block for Model Based Dev toolbox for Mpc574x (snapshot below) for Flex PWM (model is attached)
I observed that the PWM block is not switching anymore (when I update the frequency of switching to 1000 Hz) The low side remains 0 and the high side remains high.
So, it means the Duty Cycle remains 100 % somehow for the complementary PWM when I propose it to be 50%(see below scope).
Could you please investigate the behavior?
Or maybe I am doing something wrong
Solved! Go to Solution.
Hello abhishek.kumar@chassisbrakes.com,
The problem you are facing has multiple causes:
1. The input for PWM duty cycle must be provided in values between 0-1.0, proportional with the duty cycle percentage. Ex: for 50% duty cycle, the input must be 0.5. (this helps a lot using the AMMCLIB library alongside with the other blocks)
2. Updating the frequency in the model during the run time must be performed with some constraints: you can not provide greater modulo value in Ticks than 0xFFFF at a certain prescaler.
- in the following attached images, it can be observed that for 10 Hz the program uses the prescaler 128 and the modulo value is 62500. The frequency update block will change only the Ticks value and keeps the prescaler so the new modulo value will be 62-63, so you loose a lot of resolution.
- if you need to use the timer only at 1000Hz, please set this up in the PWM config block, because it will choose the best modulo value and the best prescaler for the frequency selected in order to have the best counter resolution. The same settings must be applied with the dead time: if you need a constant dead time value just set in the configuration block.
3. Now, your model runs at 0.0001 seconds step time. So for each step you want also to change the frequency, which I think is a little to much. Also, there is a limitation here. You can not use in the same function a frequency update and a duty cycle update because the peripheral will refuse to update one of them due to the fact that at the end of each block it calls the FLEXPWM_DRV_LoadCommands function. So please update the frequency (if you really need this inside your model at run time) at higher time periods.
Also, if you are using the MPC5744 EVB the PA10 and PA11 pins are connected to a level shifter and the actual output pins if not using the MOTORGD shield are bad.
So please use the frequency update block inside another block, perhaps an interrupt or something called at a different time interval not in step, something like in the following immage.
Hope this helps you,
Marius
Hello abhishek.kumar@chassisbrakes.com,
The problem you are facing has multiple causes:
1. The input for PWM duty cycle must be provided in values between 0-1.0, proportional with the duty cycle percentage. Ex: for 50% duty cycle, the input must be 0.5. (this helps a lot using the AMMCLIB library alongside with the other blocks)
2. Updating the frequency in the model during the run time must be performed with some constraints: you can not provide greater modulo value in Ticks than 0xFFFF at a certain prescaler.
- in the following attached images, it can be observed that for 10 Hz the program uses the prescaler 128 and the modulo value is 62500. The frequency update block will change only the Ticks value and keeps the prescaler so the new modulo value will be 62-63, so you loose a lot of resolution.
- if you need to use the timer only at 1000Hz, please set this up in the PWM config block, because it will choose the best modulo value and the best prescaler for the frequency selected in order to have the best counter resolution. The same settings must be applied with the dead time: if you need a constant dead time value just set in the configuration block.
3. Now, your model runs at 0.0001 seconds step time. So for each step you want also to change the frequency, which I think is a little to much. Also, there is a limitation here. You can not use in the same function a frequency update and a duty cycle update because the peripheral will refuse to update one of them due to the fact that at the end of each block it calls the FLEXPWM_DRV_LoadCommands function. So please update the frequency (if you really need this inside your model at run time) at higher time periods.
Also, if you are using the MPC5744 EVB the PA10 and PA11 pins are connected to a level shifter and the actual output pins if not using the MOTORGD shield are bad.
So please use the frequency update block inside another block, perhaps an interrupt or something called at a different time interval not in step, something like in the following immage.
Hope this helps you,
Marius