Task Sampling Time

Hi, my switching frequency is 300 kHz. I tried to set the sampling time of the control time 1/300 kHz in the coder to run the control loop every switching cycle. However, it always tell me that the sampling time is too small. I have to change to 3/300 kHz to solve it which is not what I expect.

Hello,
The fastest sample time that our code can be run on the C2000 chips is 5e-6, but generally we recommend at least the sample time you chose to make it work (3/300kHz = 1e-5 seconds). This is because running any faster leads to task overruns.

But this is okay, because the PWM can run at faster rates than the base sample time of the chip. Instead of a PWM driving the base task, an internal timer will do so instead. The only downside here is that instead of being able to update something like the duty cycle every cycle of the PWM, in this case the fastest you can update the duty cycle is every 3 periods of the PWM.

Hope this explanation makes sense! Basically your base task can run slower than your PWMs, and this is actually fairly necessary for switching frequencies above 100 kHz.

Hi,
Thank you such much for the explanation! I understand low sampling time can give more time to run the control code. But will it cause undesired instability issues sometimes since larger delays degrades the phase margin?

Hi Xueshen,

Yes this is a trade-off and limitation of our Coder at very fast switching speeds, there would be some expected instability and degrade phase margin that you may need to design your controls around.

1 Like