Type mismatch for equation

14 Ansichten (letzte 30 Tage)
Hoang Anh Dung
Hoang Anh Dung am 6 Jan. 2022
Kommentiert: PhiLL am 26 Apr. 2023
Error compiling Simscape network for model RobotAssembly.
Caused by:
['RobotAssembly/PS Integrator']: Type mismatch for equation. The left hand side of the equation is {[1x1 double], '1/s'} and the right hand side of the equation is [1x1 double]. In foundation.signal.linear.integrator (line 59)
x = [1x1 double]
I = [1x1 double]
Component: Simulink | Category: Model error
And the code in integrator.ssc file is as below:
component integrator
% PS Integrator :0.75 :fixed
% This block performs continuous-time integration of the input Physical Signal.
% The output resets to the initial condition when the optional reset signal, R,
% triggers. The initial condition can be a fixed parameter or defined via
% physical signal, X0.
% Copyright 2019-2020 The MathWorks, Inc.
inputs
I; % :left
end
outputs
O; % :right
end
inputs(ExternalAccess=none)
R; % R:left
X0; % X0:left
end
parameters
reset_method = foundation.enum.IntegratorResetSpec.None; % External reset
initial_condition_spec = foundation.enum.IntegratorICSpec.Internal; % Initial condition source
end
parameters(ExternalAccess=none)
x0 = { 0, 's' }; % Initial condition
end
if initial_condition_spec == foundation.enum.IntegratorICSpec.Internal % Parameterized initial condition
annotations
x0 : ExternalAccess=modify;
end
parameters
IC = x0;
end
variables(Access = private)
x = {value = x0.*ones(size(I)), priority = priority.high};
end
else % Physical signal initial condition
annotations
X0: ExternalAccess=modify;
end
intermediates(ExternalAccess=none)
IC = X0;
end
outputs(Access = private)
x
end
equations(Initial=true)
x == IC.*ones(size(I));
end
end
if reset_method == foundation.enum.IntegratorResetSpec.None % No reset
equations
x.der == I;
end
else
annotations
R : ExternalAccess=modify;
end
outputs(Access = private, ExternalAccess=none)
y
end
% Declare reset event variable
variables(ExternalAccess = none, Event = true)
reset = {value = 0, priority = priority.high};
end
% Set criteria for reset
if reset_method == foundation.enum.IntegratorResetSpec.Either % Rising or falling edges
events
when edge(R>0) || edge(R<0) || edge(R==0)
reset = 1
elsewhen edge(reset) % Immediately put reset back to 0
reset = 0;
end
end
else
if reset_method == foundation.enum.IntegratorResetSpec.Rising % Rising edge
intermediates(ExternalAccess=none)
reset_condition = R>0;
end
else % Falling edge
intermediates(ExternalAccess=none)
reset_condition = R<=0;
end
end
events
when edge(reset_condition)
reset = 1
elsewhen edge(reset) % Immediately put reset back to 0
reset = 0;
end
end
end
equations
if reset % Triggers only for one moment
x == IC
else
y == I
end
x.der == y;
end
end
equations
O == x;
end
annotations
x0 : UnitDropdown = common
end
end
I used smimport(xml file) from solidwork and add PS Constant and PS Integrator to rotate wheel but error
  1 Kommentar
PhiLL
PhiLL am 26 Apr. 2023
把ps积分器中的单位改为rad

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simscape Multibody finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by