Is it possible to change the Resistor in Simulation at a particular time point?

Hello everyone,

I have a question about the Simulation in PLECS.

I have built a circuit model in PLECS and I want to change the value of resistor in Simulation at a particular time point.

For example:

00.2 R3=50; (t=time)

I have tried to write it in Simulation script, but I don’t know how to describe the time.

I am so confused about it. It’s appreciated if you could help me solve the problem. Thanks a lot!

You cannot easily change the resistor value in a running simulation.

The usual approach is to use a second resistor in parallel or series to the first resistor and use a switch to connect / disconnect it. The switch can be triggered by a step function, for example.

this value can be stepped?

You can model a step change in load using the approach Oliver described above.

I’ll add that there are variable resistance components in the PLECS library. The “Variable Resistor” component introduces an algebraic loop in the simulation, which I would recommend avoiding. However, the “Variable Resistor with Constant Capacitor” and “Variable Resistor with Constant Inductor” components do not introduce algebraic loops because the terminal conditions of the resistor are defined by the capacitor voltage or inductor current.

You can also “step” the resistance values using a simulation script if you want to analyze a range of loading scenarios (akin to the .STEP SPICE macro). See the “Buck Converter with Parameter Sweep” demo model for an example.

Hi, Bryan, thank you for your reply.
I will try.


I find than you can use the initialization to simulate a parameter with an array.

such as, R=[1,2,3,4,5]

if you want change the value which involve simulation time, maybe you need a FUNCTION BLCOK clock’, and then setup an function which parameters is a function of time.

Yes, that is a good point. You can also use 1D look-up tables for the same purpose, just be cognizant of interpolation/extrapolation behavior in between the defined sample points. By default the data will be interpolated, but you can have zero-order hold like behavior by repeating datapoints. An example script is below, where timeVector and outputVector are the X and Y vectors for a 1D look-up table.

time = [1,2,3];
values = [600e-9,1e-6,2e-6];
interpolationBehavior = 1; % 1= linear, 2=zoh/stepwise.

if interpolationBehavior==1 % Linear interpolation
	timeVector = time;
	outputVector = values;
else % stepwise
	timeVector = [repelem(time,1,2)(2:end),time(end)];
	outputVector = repelem(values,1,2)(1:end);
end