how to represent a piecewise linear stiffness spring in simscape?

5 ビュー (過去 30 日間)
fangfines
fangfines 2011 年 3 月 24 日
I edited a .ssc file for simscape to represent a piecewise linear stiffness spring,but there is always something wrong, when the stiffness changed, the deformation of the spring changed suddenly too(diminishing), and here is the code, can someone help me? Thanks a lot!
component nlspring < foundation.mechanical.translational.branch
parameters
spr_rate1 = { 2500, 'N/m' }; % Spring rate
spr_rate2 = { 4000, 'N/m' }; % Spring rate
init_def = { 0, 'm' }; % Initial deformation
change_def = { 2.5e-3, 'm' }; % Stiffness changing deformation
end
variables
x = { 0, 'm '};
end
function setup
if spr_rate1 <= 0
pm_error('simscape:GreaterThanZero','spr_rate1' )
end
if spr_rate2 <= 0
pm_error('simscape:GreaterThanZero','spr_rate2' )
end
if change_def <= 0
pm_error('simscape:GreaterThanZero','change_def ' )
end
end
equations
if abs(x) < change_def
f == spr_rate1*x;
v == x.der;
else
f == spr_rate2*x;
v == x.der;
end
end
end

採用された回答

Arnaud Miege
Arnaud Miege 2011 年 3 月 24 日
I think you potentially have a discontinuity around +/-change_def. I would suggest changing the second equation to:
f == spr_rate2*(x-change_def)+spr_rate1*change_def;
to remove the discontinuity. I would also put the v == x.der; equation outside of the if...else statement. Finally, you need to add x = init_def; to the setup function.
HTH,
Arnaud
  1 件のコメント
fangfines
fangfines 2011 年 3 月 25 日
Thanks Greatly! it does work.
I only need to convert the "spring rate" that I need to satisfy your equation.
it's an alternative way and quit helpful, but I don't know what's wrong with my equations.
Anyway, thanks very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTroubleshooting についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by