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.

Transfer the code in matlab to plecs

0 votes
48 views
According to the guide of plecs documents, I try to transfer some code to plecs, but there are some questions confusing me for several days, so could you help me solve the questions, thank you

the matlab code and plecs simulation are as follows;
asked Jun 22 by fire (24 points)

1 Answer

0 votes
 
Best answer

Firstly, this model uses the Transport Delay for a phase shifted modulator.  This is not recommended.  See the excerpt from the Transport Delay's help below.  The modulator by itself will not work (e.g. setting the input to the gain block to 0.001 results in an error).  This must be resolved first.  In additional to the Dual Active Bridge demo model, there's some useful forum posts on phase shifted modulators and variable delay C-Scripts.

The C-Script is a good option to translate your SFunction, however your implementation mixes several concepts incorrectly. For your SFunction - are you executing it in discrete or continuous time?  Based on the zero-order hold in the PLECS model I'm assuming it's in discrete time.

Have you seen the PLECS: Using the C-Script Block tutorial? The discrete PI implementation referenced in the tutorial should give you a good starting place for your controller.

 

answered Jun 23 by Bryan Lieblick (1,069 points)
selected Jun 24 by fire
Thanks for your answer, but I'm confused the that what's the majorstep and minorstep?

and what's the meaning of "The modulator by itself will not work (e.g. setting the input to the gain block to 0.001 results in an error)." ?

could you tell me?

kind regards

wei

> "The modulator by itself will not work (e.g. setting the input to the gain block to 0.001 results in an error)." ?

Removing the C-Script and testing the model with just the modulator at a fixed duty cycle fails due shorting the output capacitor.  This is because of the modulator implementation.  See below.  You should resolve this first before looking into the C-Script.

> I'm confused the that what's the majorstep and minorstep?

The "Model Execution" section of the "How PLECS Works" section of the help describes major and minor time steps in detail.  The C-Script documentation also provides this helpful guidance: "In general, output signals should be continuous and smooth during minor time steps; discontinuities or sharp bends should only occur during major time steps. Whether or not the call is made for a major time step can be inquired with the IsMajorStep macro. "

...