Error: "Number of variables exceeds number of equations." Probably a mistake in my code, but where?

조회 수: 33 (최근 30일)
Hello, i try to program a simple Simscape-Block which calculates a braking moment for an output signal by using an external force and some parameters. When i try to run the model in the test environment, the error-message "Number of variables exceeds number of equations. Check for missing reference node." comes up. I'm pretty sure its a mistake in the code, but where? I already tried not to inlcude v = {0, ...) and across(v, ...), but that didnt change anything. The code is the following:
component Multi_Disc_Brake
nodes
R = foundation.mechanical.translational.translational; % R:left
C = foundation.mechanical.translational.translational; % C:right
end
parameters
n = {1, '1'}; % Number of rotating discs
r_i = {1, 'm'}; % Radii of inner discs
r_a = {2, 'm'}; % Radii of outer discs
my = {1, '1'}; % Friction coefficient
end
variables
f = {0, 'N'};
M_B = {0, 'N*m'};
r_m = {0, 'm'};
v = {0, 'm/s'};
end
outputs
out = {0, 'N*m'}; % M(t):right:top
end
function setup
if n <= 0
error ('Number of discs must be greater than zero');
end
if r_i <= 0
error ('Inner radii must be greater than zero');
end
if r_a <= 0
error ('Outer radii must be greater than zero');
end
if r_i >= r_a
error ('Inner radii has to be smaller than outer radii');
end
through (f, R.f, C.f);
across (v, R.v, C.v);
end
equations
let
r_m = (2/3)*((r_a^3 - r_i^3)/(r_a^2 - r_i^2)); % Centre radius
in
M_B == my*f*r_m*2*n; % Calculation of the braking moment
end
out == M_B;
end
end
Thank you in advance for your help!
Matt

답변 (2개)

Ryan G
Ryan G 2013년 3월 15일
Sounds like you understand the basics of the error. Without digging to deep I see 4 variables and maybe 2 or 3 equations (I'm not sure how Simscape counts equations in let-in format). So at best you still have 1 more variable than equation.
That being said I don't see v utilized in the equations section nor do I see either of your nodes being used. In other words, right now I believe this would output a constant, which doesn't make sense for a Simscape component.
I might be missing something here, let me know if I'm wrong.

Matthias
Matthias 2013년 3월 15일
편집: Matthias 2013년 3월 15일
Hi Ryan! Thanks for your answer. The thing is, even if i remove every line with the velocity, the same error occurs. I included v because i saw this in codes of blocks from the simscape library and assumed it is necessary because the through-variable f (force) should always come with an across-variable v (velocity). In this case the vlocity should just transfer from node R to C. Concerning the equations, i thought variable f comes from node R as input and is thereby defined. M_B is determined in the equation section as well as r_m. That's why i'm confused.I need to get the value of the force f from node R for calculating the moment M_B. I also tried deleting the "let..in"-expression, but nothing changes.
Here is the code without the velocity but with the same error:
component Multi_Disc_Brake
nodes
R = foundation.mechanical.translational.translational; % R:left
C = foundation.mechanical.translational.translational; % C:right
end
parameters
n = {1, '1'}; % Number of rotating discs
r_i = {1, 'm'}; % Radii of inner discs
r_a = {2, 'm'}; % Radii of outer discs
my = {1, '1'}; % Friction coefficient
end
variables
f = {0, 'N'};
M_B = {0, 'N*m'};
r_m = {0, 'm'};
end
outputs
out = {0, 'N*m'}; % M(t):right:top
end
function setup
if n <= 0
error ('Number of discs must be greater than zero');
end
if r_i <= 0
error ('Inner radii must be greater than zero');
end
if r_a <= 0
error ('Outer radii must be greater than zero');
end
if r_i >= r_a
error ('Inner radii has to be smaller than outer radii');
end
through (f, R.f, C.f);
end
equations
let
r_m = (2/3)*((r_a^3 - r_i^3)/(r_a^2 - r_i^2)); % Centre radius
in
M_B == my*f*r_m*2*n; % Calculation of the braking moment
end
out == M_B;
end
end
Also, Matlab creates a warning when opening the test-environmentmodel without v in the block: "Warning: In instatiating linked block '.../Multi-Dioc-Brake' : Multi-Disc-Brake block (mask) does not have a parameter named 'v_Log' In general\private\openmdl at 13 In general\private\openslx at 9 In open at 159 In uiopen at 196
greetings, Matthias
  댓글 수: 6
Matthias
Matthias 2013년 3월 18일
Yeah, thats a good idea. I wrote a new code now, starting with a similar code to a translational reference block. This code works in the model, but generates a warning:
"Warning: The model 'Lamellenbremse_Testumgebung' does not have continuous states, hence Simulink is using the solver 'VariableStepDiscrete' instead of solver 'ode15s'. You can disable this diagnostic by explicitly specifying a discrete solver in the solver tab of the Configuration Parameters dialog, or by setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics tab of the Configuration Parameters dialog"
I will need the solver ode15s, so i'm not sure if this will work in my final model. The code i used is the following:
component Multi_Disc_Brake
nodes
V = foundation.mechanical.translational.translational; % R:left
end
parameters
k = {1, 'm'}; % Number of rotating discs
end
variables
f = {0, 'N'};
M_B = {0, 'N*m'};
end
outputs
out = {0, 'N*m'}; % M(t):right:top
end
function setup
through (f, V.f, []);
end
equations
M_B == k*f; % Calculation of the braking moment
out == M_B;
V.v == 0;
end
end
It seems like "V.v == 0" solved the problem, but i have no idea why and what exactly happens in the code.
Matthias
Matthias 2013년 3월 18일
I've found another solution, this time with a physical force. It seems that i need to insert a line describing the force f in the equations section by any means. However, if i change the mass for example, there is no change in B_M, because the acceleration R.v_der is zero as i guess. Can anybody tell me why i need this line although nothing changes in the calculation of B_M?
here is the code:
component Multi_Disc_Brake
nodes
R = foundation.mechanical.translational.translational; % R:left
C = foundation.mechanical.translational.translational; % C:right
end
parameters
k = {1, 'm'};
m = {1, 'kg'};
end
variables
f = {0, 'N'};
M_B = {0, 'N*m'};
v = {0, 'm/s'};
end
outputs
out = {0, 'N*m'}; % M(t):right:top
end
function setup
through (f, R.f, C.f);
across (v, R.v, C.v);
end
equations
f == m * R.v.der;
M_B == k*f; % Calculation of the braking moment
out == M_B;
end
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Brakes and Detents에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by