Simplified C Block + PWM Generation
Hi guys!
I'm having some trouble with my simulations using simplified C block to generate modulation signals for a PWM block.
I have a discrete controller working fine in a general simulation (look a brief at pic 1 attached). However, when I try to use SimCoder elements, my modulation signal goes insane (see attachment 2)…I haven't been able to figure that out.
Some observations:
- I'm sure that my signals are within the range for the ADC block, controller, and all calculations.
- I'm using the same timestep for both simulations (I actually only created a new file, changing for using inputs with ADC block and the PWM block with the same characteristics). It's 8.33333E-007, so I think it should be enough for a 24kHz switching.
- I'm using the same sampling intervals (ZOHs) in both simulations.
I've made some tests and my PWM scheme seems to work fine in SimCoder, so I'm thinking the issue is somehow related to how my code is running inside the Simplified C block. I'm confused once it works fine without the SimCoder elements.
Let me know if you need any further information.
Thanks a lot!
Answers
-
Ps. My target is a F28335 DSP.
0 -
Hi Augusto,
I suspect that you have not considered digital delay. The PWM simcoder block introduces a 1/Z delay which is not present in your previous implementation, you should be able to mimic it by adding the delay element to the modulation waveform just before the comparator elements. Please have a look at this tutorial video.
-Albert
0 -
Hi Albert,
Sorry for taking so long…I couldn't get back to the simulation for some days.
I got your point…I checked and you were right, I didn't account for the 1/Z delay attached to the PWM block from SimCoder.
I'm facing a problem though…I already have this 1/Z delay accounted on my P+Resonant controller inside the C Block (and that's the reason why my simulation works fine for the "non-SimCode" environment/simulation). Now my "plant" has changed with this PWM block.
Thus, here comes another question…is there any possible way to use this PWM block (or other pwm generation block) bypassing or disregarding its inherited 1/Z delay? If there is no way, I'll have a cumbersome task remodeling my controller.
Many thanks again!
0