# Problem with Varistor created with Simscape Custom Component

4 views (last 30 days)
Answered: Sayan on 8 Dec 2023
Hi,
I developed a varistor using Simscape language and it partially works. When the voltage across the varistor exceeds a certain negative voltage (around -1kV) the simulation breaks and results diverge and I have no idea why. On the other side, the component behaves fine when the voltage aplied is positive by I need a component that works well on both polarities.
Btw, I know that there is a Varistor Component in simscape but I realized that it has a bug and therefore I'm trying to develop one of my own.
This is the simscape code: as a Current Source
component MOV
% Varistor Modeled as a Current Source
nodes
p = foundation.electrical.electrical; % :top
n = foundation.electrical.electrical; % :bottom
end
annotations
Icon = 'MOV_a.jpg';
end
parameters
V1 = { 1, 'V' }; % Leakage to Normal voltage transition
V2 = { 30, 'V' }; % Normal to Upturn voltage transitino
R1 = {1e9,'Ohm'}; % Insulation Resistance
R2 = { 1,'Ohm'}; % Upturn Resistance
a = { 30,'1'} % powerlaw exponent
end
variables
i = { 0, 'A' }; % Current
v = {value = { 0, 'V' }, priority = priority.high}; % Voltage
end
branches
i : p.i -> n.i; % Current through from node p to node n
end
equations
v == p.v - n.v; % Voltage across between node p and node n
% k = 1/(a*R1*V1^(a-1));
% c1 = V1/R1 - k*V1^a;
% c2 = k*(V2^a - V1^a) + V1/R1 - V2/R2;
%
if (abs(v) < V1)
i == v/R1
elseif(abs(v) > V2)
i == v/R2 + (1/(a*R1*V1^(a-1)))*(V2^a - V1^a) + V1/R1 - V2/R2;
else
i == (1/(a*R1*V1^(a-1)))*v^a + V1/R1 - (1/(a*R1*V1^(a-1)))*V1^a;
end
end
end
This is the circuit to test the model:
And this is the result of the simulation:
Ass you can see the MOV clamps the voltage in the negative semiperiod but at aroung 1000 V the voltage across the MOV drops (reaching a nonsensical value of 10^11 and then it remains at that value for the rest of the simulation)
I suppose the is an error in the simscape code but I have revised over and over and can't seem to find the bug, please help!
(FIND THE SIMULINK MODEL AND COMPONENT ATTACHED)

Sayan on 8 Dec 2023
Hi Santiago Alfonso Ospina Botero,.
I understand from your issue that you are simulating the behavior of the existing Varistor block by creating a block using the Simscape language, and the result is not as expected.
I have checked your previous question on the MATLAB answer community titled "There is a problem with the Simscape Varistor Model" where you plotted the I-V characteristics of the Varistor by developing the equations.
In both the Desmos file and the Simscape language file, I have found a common mistake.
• In the Desmos file, while developing the equation of "k" you are using the high-value resistance of leakage, which should be replaced with the low-value resistance of the upturn region.
• In the Simscape file too, you have used high-value resistance, as shown in this code snippet.
elseif(abs(v) > V2)
i == v/R2 + (1/(a*R1*V1^(a-1)))*(V2^a - V1^a) + V1/R1 - V2/R2;%line 41
else
i == (1/(a*R1*V1^(a-1)))*v^a + V1/R1 - (1/(a*R1*V1^(a-1)))*V1^a;%line 43
%in both the equation R1 should be replaced with upturn resistance R2 the term 1/(a*R1*V1^(a-1)
You can find the equations in the following documentation.
Hope this helps in resolving the issue.

### Categories

Find more on Parameterization Methods in Help Center and File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!