Problem creating Simscape component for a spring with preload.
显示 更早的评论
I am trying to create a mechanical tanslation spring component which has a preload. When force is applied to the spring below the preload limit the spring should not move. Above the preload the spring will follow a normal spring but the force is reduced through it by the preload. Refer to the component script below. This is one of many numerous attepts to get the proper result. This particular script results in an error of "Error compiling Simscape network... Number of equations exceeds number of variables." I have bee able to either get the movement to be correct or either the output force to be correct, but not both at the same time. This attempt uses two outputs nodes so that the input force could be split, with one node being the expected spring movement and the force through the spring. Also attached is a related model using the custom component. Any help in resoving this would be appreciated, or if there is another way to accomplished this. Thanks,
component spring_preload23
% Translational Spring with Preload23
% The block represents an ideal mechanical linear compression spring
% with a preload.
%
% Connections R and C are mechanical translational conserving ports.
% The block positive direction is from port R to port C. This means that
% the force is positive if it acts in the direction from R to C. The force
% through the spring is zero until the preload value is reached.
% Before the preload is reached the force is routed to the case port.
nodes
R = foundation.mechanical.translational.translational; % R:left
C = foundation.mechanical.translational.translational; % C:right
C2 = foundation.mechanical.translational.translational; % Case:right
end
parameters
spr_rate = { 100, 'N/m' }; % Spring rate
preload = { 0, 'N' }; % Preload (at 0 position)
end
components(Hidden=true)
In_Force_Sensor = foundation.mechanical.sensors.force;
Grnd = foundation.mechanical.translational.reference;
end
variables
x1 = { 0, 'm'}; % Deformation of main spring
f_in = { 0, 'N'}; % Input Force
f_out = { 0, 'N'}; % Output Force through main spring
f_case = { 0, 'N'}; % Output Force to case
end
function setup
if spr_rate <= 0
pm_error('simscape:GreaterThanZero','Spring rate' )
end
end
branches
% f_in : R.f -> *;
f_out : C.f -> *;
f_case : C2.f -> *;
end
connections
connect(R, In_Force_Sensor.R);
connect(In_Force_Sensor.C, Grnd.V);
end
equations
f_in == In_Force_Sensor.f
if f_in < preload
x1 == { 0, 'm'};
f_case == f_in;
else
x1 == (f_in - preload) / spr_rate;
f_case == preload;
end
f_out == In_Force_Sensor.f - f_case;
C.v == x1.der;
end
end
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Model Statistics 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!