Hello. If I have included delays in my code for my controller, how do I implement it so that the delays are considered when the code is executed?
Show older comments

this is the simulink model where the buck-boost controller is connected to the gate ports of each switch to power up the converter. And Im thinking that the delays in my code are not considered when the code is executed because the ouput if too low
Answers (1)
Joel Van Sickel
on 3 Jan 2024
0 votes
The correct way to simulate a digital controller, so that you are incorporating the delay of the digital system is to utilize some of our discrete time simulation capabilities. I would recommend declaring a variable ts (any name will do) that you set to the update rate of your digital system that the code is running on. Then on all the inputs to the digital system, place a zero order hold block with time step of ts, then at the output of the digital system, place a unit delay with the same ts value. This will simulate the delay of the digital system. However, what you are doing is a bit more sophisticated, so you might want to use this block instead, it will simulate slower, but will give you more control over the signal: https://www.mathworks.com/help/simulink/slref/variabletimedelay.html
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!