필터 지우기
필터 지우기

Simulink Power Library custom block multi switch

조회 수: 1 (최근 30일)
Jannis Maq
Jannis Maq 2016년 5월 25일
답변: Joel Van Sickel 2020년 9월 17일
Hello,
I'm trying to build a multi switch which connects several terminals. Therefore I'm building a custom block. The model where the switch is to be integrated is build with the Power Library. First I tried to build a simple switch. But this isn't as simple as it sounds... The first big problem is: When I declare the nodes like this:
nodes
U0 = foundation.electrical.electrical; % +:top
U1 = foundation.electrical.electrical; % -:bottom
end
then I cant connect the custom block with components of the Power Library. I havent found anything about the domain of these components. Any suggestions here?
The second problem is, that I have no clue how to make the current go through (in closed position of the switch). First I delcared variable i as a through variable.
branches
i : U0.i -> U1.i; % Through variable i from node p to node n
end
But then it's getting tricky. Because something like
equations
U0.i == U1.i;
end
is not working, I declared a very small resistance and calculated the voltage across the terminals
equations
v == U0.v-U1.v;
i == (v)/R;
end
But this isn't working. Does anyone know how to make a nice switch?
I'm looking forward to your answer
PS: Here is the whole custom block code
component switch1
% switch
nodes
U0 = foundation.electrical.electrical; % +:top
U1 = foundation.electrical.electrical; % -:bottom
end
parameters
R = { 1e-10, 'Ohm' };
end
variables
i = { 0, 'A' }; % Current
v = {value = { 0, 'V' }, priority = priority.high}; % Voltage drop
end
function setup
end
branches
i : U0.i -> U1.i; % Through variable i from node p to node n
end
equations
v == U0.v-U1.v;
i == (v)/R;
end
end

답변 (1개)

Joel Van Sickel
Joel Van Sickel 2020년 9월 17일
Here is the code which is available from the switch block in simscape foundations:
component controlled_switch
% Switch
% The block represents a switch controlled by an external physical
% signal. If the external physical signal PS is greater than the threshold,
% then the switch is closed, otherwise the switch is open.
%
% The closed resistance is defined by parameter R_closed, and the open
% conductance is defined by parameter G_open. Both parameters must be
% greater than zero.
% Copyright 2005-2018 The MathWorks, Inc.
inputs
vT = { 0.0, '1' }; % PS:bottom
end
nodes
p = foundation.electrical.electrical; % :top
n = foundation.electrical.electrical; % :bottom
end
parameters
R_closed = { 0.01, 'Ohm' }; % Closed resistance R_closed
G_open = { 1e-8, '1/Ohm' }; % Open conductance G_open
Threshold = { 0.5, '1' }; % Threshold
end
variables
i = { 0, 'A' }; % Current
v = { 0, 'V' }; % Voltage
end
branches
i : p.i -> n.i;
end
equations
assert(R_closed>0)
assert(G_open>0)
v == p.v - n.v;
if vT > Threshold % Switch is closed
v == i*R_closed;
else % Switch is open
v == i/G_open;
end
end
end
Regards,
Joel

카테고리

Help CenterFile Exchange에서 Troubleshooting에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by