I am trying to generate code for a TI C2000 target using PLECS Coder for a Dual Active Bridge (DAB) converter model (TI_DAB_60kW_Modified). However, the code generation fails with the following diagnostic error across multiple blocks:
“Sample time period and/or offset […] are not an integer multiple of the base step size (0.001).”
The errors are pointing to several blocks inside my Phase Shift Control subsystem, including:
Zero-Order Hold & C-Script blocks: Sample times of 3.333e-05 (30 kHz)
Triangular Wave: Sample times of 1.666e-05 (60 kHz) and 3.333e-05
Monoflops (Turn-on Delays 1-7): Sample times of 3e-07 (300 ns)
Currently, my system base sample time is set to 0.001 (1 ms), which doesn’t align with these high-frequency switching and delay periods.
My questions are:
What is the best practice for resolving this for a C2000 target?
I have attached a screenshot of the diagnostic errors for reference. Any guidance on how to properly configure the sample times for this setup would be greatly appreciated!
There is a way to refine the sample times, but the underlying issue is that you seem to be building a modulator out of discrete blocks. The modulation signals must be built out of the PWM components from the part of the TI C2000 target support library to use the ePWM peripheral of the C2000 hardware.
Your discretization step size is 0.001 seconds. Building a modulator will the discrete blocks will have the counter frequency and dead-time limited to the discretization you specify, whereas the ePWM peripheral uses a hardware clock with much higher resolution. You cannot set the step size arbitrarily low, as the MCU needs time perform the required calculations.
Thanks for the explaination, Could you please guide me on how to proceed further. In the TI C2000 target packages the following are availble. There is no ePWM.
The PWM blocks use the underlying ePWM peripheral hardware. There is a tutorial on getting started titled “Introduction to the TI C2000 Series” which is a good reference and includes a video.
I would also strong recommend looking at the TI C2000 Target Support Package demos for their implementation and documentation, accessible in the PLECS online help menus.