Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

How can I imitate a for loop within a C-Script block?

0 votes

I want to track a 'triangular' reference which basically turns on and off two IGBTs in order to increase output current (by closing IGBTs) and decrease output current (by opening IGBT when voltage across capacitor is below 1 V and also the current is higher than reference). However, if output current is greater than reference BUT voltage across capacitor is not below 1V yet, then continue to fire both IGBT's to maintain the capacitor discharging. The next figure, shows that for some reason it is not following the reference at all.

As attachments you have my circuit and code.

asked Apr 30, 2018 by Zrakk (18 points)
Can you explain in more detail what output you are expecting?

In any case, you should reconsider your algorithm. As can be seen, as soon as you turn on the IGBTs the capacitor voltage decreases, then increases again when the IGBTs are turned off. This will result in the IGBTs toggling on and off in every simulation step.

Please log in or register to answer this question.