MATLAB Answers

Having problems simpower simulation with s-function

3 views (last 30 days)
Alan Zhang
Alan Zhang on 29 Jul 2011
Dear all,
I am struggling with a simpower simulation with s-function. The simulation is simulating a simple AC circuit with normal RLC load and a variable resistor, in which the variable resistor is simulated with S-function and controlled current source. This variable resistance is determined by the voltage between this variable resistor and calculated by an iterative calculation in S-function. Please find the files followed by the link:
The problem is : this simulation with simpower toolbox and s-function couldn’t converge, while the same simulation applied with variable resistor with plecs toolbox works properly.
It seems to me that the problem with simpower and s-function may be caused by the delay generated by 1/z or memory block before the s-function . However, this memory or 1/z(delay) block had to be applied to make the simulink solver to solve algebraic loop caused by s-function and controlled current block. I couldn’t find a solution to make this simpower simulation converge just like it is in the plecs simulation.
Also I am wondering whether a variable resistor block in the simpower toolbox similar to the variable resistor in plecs toolbox is available in the later version of matlab (I couldn’t find it from matlab 2008b, and 2009a), that may solve my problem.
I will be really appreciated for your kind help! Best Regards,
Alan Zhang
Alan Zhang on 31 Jul 2011
There is an iterative calculation to calculate the variable resistor in the s function. Please find the files in

Sign in to comment.

Answers (1)

Arnaud Miege
Arnaud Miege on 1 Aug 2011
I don't have PLECS so I couldn't test the PLECS model. For the SimPowerSystems one, it's not clear to me what's causing the model to diverge. Have you tried using a MATLAB Function block (called Embedded MATLAB Function prior to R2011a) instead of an S-Function? It might make the debugging process easier. I suspect the problem is with the S-function.
With regards to the variable resistor in SimPowerSystems, have a look at the following:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!