Building/Coding A Custom Clutch in Simscape
Show older comments
Hi All,
I am trying to build a custom clutch using in simscape based on the code from the rotational hard-stop in the foundation library of simscape.
I am trying to alter the code so that under certain circumstances in the system when the rotational hard-stop is disconnected via a clutch the position of the slider in the rotational hard-stop is reset to 0. I have added an output port to show the position of the slider and an input port to trigger the reset of the angle of the slider. (see code below)
nodes
R = foundation.mechanical.rotational.rotational % R:left
C = foundation.mechanical.rotational.rotational % C:right
end
inputs
X = { 0, 'N'}; %Reset voltage
end
outputs
A = { 0 ,'rad'}; %A:right
end
variables
t = { 0, 'N*m'}; %torque through
phi = { 0, 'rad'};
w = { 0, 'rad/s'};
Z = { 1, 'N' }; % Voltage switch point
end
parameters
upper_bnd = { 0.1, 'rad' }; % Upper bound
lower_bnd = { -0.1, 'rad' }; % Lower bound
stiff_up = { 1e6, 'N*m/rad' }; % Contact stiffness at upper bound
stiff_low = { 1e6, 'N*m/rad' }; % Contact stiffness at lower bound
D_up = { 0.01, 'N*m*s/rad' }; % Contact damping at upper bound
D_low = { 0.01, 'N*m*s/rad' }; % Contact damping at lower bound
initial_angle = { 0, 'rad' }; % Initial angular position
end
function setup
if lower_bnd > upper_bnd
pm_error('simscape:LessThanOrEqual','Lower bound','Upper bound')
end
if stiff_up < 0
pm_error('simscape:GreaterThanOrEqualToZero','Contact stiffness at upper bound')
end
if stiff_low < 0
pm_error('simscape:GreaterThanOrEqualToZero','Contact stiffness at lower bound')
end
if D_up < 0
pm_error('simscape:GreaterThanOrEqualToZero','Contact damping at upper bound')
end
if D_low < 0
pm_error('simscape:GreaterThanOrEqualToZero','Contact damping at lower bound')
end
across( w, R.w, C.w);
through( t, R.t, C.t);
phi = initial_angle;
end
equations
if (phi > upper_bnd)
% Slider hits upper bound
t == stiff_up * (phi - upper_bnd) + D_up * w;
elseif (phi < lower_bnd)
% Slider hits lower bound
t == stiff_low * (phi - lower_bnd) + D_low * w;
else
% Slider is between hard stops
t == {0, 'N*m'};
end
if (X > Z)
phi == 0;
else
phi.der == w;
end
A == phi;
end
end
I have tried adding an extra if function at the end of the equations section but when ever I try to run the model it comes up with an error basically saying if you have a differential on one branch of an if function you have to have one on the other....
I realise this is a long post and a lot to ask but I don't have much time to get this done. Does anyone have any suggestions on how to reset the angle of rotational hard stop???
A separate question, are there any books anyone can recommend on programming in simscape of just simscape in general???
Many thanks in advance for any help. Regards Nick
1 Comment
Sergey Omeliantchuck
on 27 Mar 2017
I make this code for my custom electromagnetic clutch
component elclutch2
% Electromagnetic clutch Merobel
% Copyright 2017 NPP VIUS, Inc.
nodes
p = foundation.electrical.electrical; % +:top
n = foundation.electrical.electrical; % -:bottom
R = foundation.mechanical.rotational.rotational; % R:top
C = foundation.mechanical.rotational.rotational; % C:bottom
end
parameters
K = { 0.1, 'V/(rad/s)' }; % Constant v == K*w;
S = { 0.1, '(N*m)/A' }; % Constant t == -S*i;
m = { 0.1, 'N*m' }; % Minimal torque
vel_thr = { 1e-4, 'rad/s' }; % Linear region velocity threshold
end
variables
i = { 0, 'A' }; % Current
v = { 0, 'V' }; % Voltage
t = { 0, 'N*m' }; % Torque
w = { 0, 'rad/s' }; % Angular velocity
end
branches
i : p.i -> n.i;
t : R.t -> C.t;
end
equations
v == K*w;
v == p.v - n.v;
w == R.w - C.w;
%t == -m-S*i;
% if (w <= vel_thr)
% % Linear region
% t == -m;
% else
t == -m-S*i;
% end
end
end
Answers (0)
Categories
Find more on Electromagnetic Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!