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.

the PI controller can not run normally

0 votes
53 views
I have a DPS - DAB matlab model, and I am realizing it in plecs, the parameters are same, but the PI controller's output is always 0, so can you help me find the problems?

two models are attached.

best wishes
asked Jul 9 by fire (47 points)

1 Answer

+1 vote
 
Best answer
The issue is due to a difference between MATLAB and C syntax in you C-Script.  In Matlab "1/2" in an S-Function will return 0.5, but C will return 0 since it treats 1 and 2 as integers and not floating point values.  Integer division will return an integer.  So your C-Script logic check was faulty and the output would always be zero.  Good practice is to add "." after any number if you want it to be a float (e.g. p=1./2.;) or simply enter in the value as a float (p=0.5;).

See the following example: https://onlinegdb.com/dupqaU-l_

Attached is a revised version of your model with the C-Script problem fixed.
answered Jul 11 by Bryan Lieblick (1,187 points)
selected Jul 12 by fire
Hey, I appreciate your answer, thanks.

And I have one little question.

In many discrete simulation systems, some use discrete PID and some use continuous PID,like the model above. In the continuous simulation system, discrete PID is also used.

And when I exchange the location of ZOH and PID(continue), the figure of scope1 hardly change, but the Input of PID(continue) is discrete, and  it can work normally, so why?

And when I replace the PID(continue) with PID(discrete), the figure of scope1 is not as good as PID(continue).

So I would like to ask that, what's the difference in the use of discrete PID and continuous PID? When should I choose PID(continue) or PID(discrete)?

best wishes
The discrete vs. continuous controls depend on the application.  Once you move into hardware you have to pick an implementation.

A series combination of a ZOH and a Continuous PID controller is not equivalent to a Discrete PID Controller.  You can look at the implementations of the two blocks to see the difference (See the "Continuous Time" and "Discrete Time" blocks in the library components).

With the Continuous PI implementation the block outputs and error integration be in continuous time.  They will be changing every simulation time step, even if you have a ZOH block.

A Discrete PI implementation the block outputs and error integration will occur only at discrete instants that you specify with the "Sample Time" paraemter.  I assume this is what you mean by "not as good".
...