SMD_WithBacklash

Gallery
Tutorial
Click on the image to view it full size

The Modelica By Example target code is:


within ModelicaByExample.Components.Rotational.Components;
model Backlash "A rotational backlash model"
  parameter Modelica.SIunits.RotationalSpringConstant c "Torsional stiffness";
  parameter Modelica.SIunits.Angle b(final min=0) "Total lash";
  extends ModelicaByExample.Components.Rotational.Interfaces.Compliant;
equation
  if phi_rel>b/2 then
    tau = c*(phi_rel-b/2);
  elseif phi_rel<-b/2 then
    tau = c*(phi_rel+b/2);
  else
    tau = 0 "In the lash region";
  end if;
end Backlash;

within ModelicaByExample.Components.Rotational.Examples;
model SMD_WithBacklash "The spring-mass-damper system with backlash"
  extends SMD(inertia2(phi(fixed=true, start=0)), inertia1(phi(fixed=true, start=0), w(start=5)));
  Components.Backlash backlash(c=1000, b(displayUnit="rad") = 0.5)
    annotation ...
equation
  connect(inertia1.flange_b, backlash.flange_a) annotation ...
  connect(backlash.flange_b, inertia2.flange_a) annotation ...
end SMD_WithBacklash;

This extends the SMD component from the previous diagram to build the following system:

This page contains content quoted, copied, or adapted for educational purposes from the Modelica By Example tutorials for educational purposes. The original © copyright is retained by Dr. Michael M. Tiller.

This SysML/SysPhS trail version uses slightly different and more concise naming. The Dependencies from the parts to the instances that defined the 'start' values are just for illustration.

The complete exported Modelica code for block SMD_WithBacklash is:


model SMD_WithBacklash
  SMD_WithBacklash _SMD_WithBacklash;
  model SMD_WithBacklash
    extends SMD(redeclare RotationalInertia i1(j.start=0.4,j.fixed=true,phi.start=0.0,phi.fixed=true,w.start=5.0,w.fixed=true),redeclare RotationalInertia i2(j.start=1.0,j.fixed=true,phi.start=0.0,phi.fixed=true,w.start=0.0,w.fixed=true));
    Backlash b(c.start=1000.0,c.fixed=true,b.start=0.5,b.fixed=true);
  equation
    connect(d2.fa,i2.fb);
    connect(s2.fa,i2.fb);
    connect(i2.fa,b.fb);
    connect(i2.fa,d1.fb);
    connect(i2.fa,s1.fb);
    connect(b.fa,i1.fb);
    connect(d1.fa,i1.fb);
    connect(s1.fa,i1.fb);
  end SMD_WithBacklash;
  model SMD
    Damper d1(d.start=0.2,d.fixed=true);
    Damper d2(d.start=1.0,d.fixed=true);
    Spring s1(c.start=11.0,c.fixed=true);
    Spring s2(c.start=5.0,c.fixed=true);
    replaceable RotationalInertia i1(j.start=0.4,j.fixed=true,phi.start=0.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    replaceable RotationalInertia i2(j.start=1.0,j.fixed=true,phi.start=1.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    Ground g;
  equation
    connect(g.f,d2.fb);
    connect(g.f,s2.fb);
    connect(i2.fb,d2.fa);
    connect(i2.fb,s2.fa);
    connect(d1.fb,i2.fa);
    connect(s1.fb,i2.fa);
    connect(d1.fa,i1.fb);
    connect(s1.fa,i1.fb);
  end SMD;
  model Backlash
    extends Compliant;
    parameter Angle b;
    parameter RotationalSpringConstant c;
  equation
    if phi_rel>b/2 then
tau=c*(phi_rel-b/2);
elseif phi_rel<-b/2 then
tau=c*(phi_rel+b/2);
else
tau=0;
end if;
  end Backlash;
  model RotationalInertia
    extends TwoFlange;
    AngularVelocity w;
    Angle phi;
    parameter Inertia j;
  equation
    phi=fa.phi;
    w=der(fa.phi);
    phi_rel=0;
    j*der(w)=fa.tau+fb.tau;
  end RotationalInertia;
  model Damper
    extends Compliant;
    parameter RotationalDampingConstant d;
  equation
    tau=d*der(phi_rel);
  end Damper;
  connector Flange_a
    extends Flange;
  end Flange_a;
  connector Flange_b
    extends Flange;
  end Flange_b;
  model Spring
    extends Compliant;
    parameter RotationalSpringConstant c;
  equation
    tau=c*phi_rel;
  end Spring;
  model Ground
    Flange_a f;
  equation
    f.phi=0;
  end Ground;
  model Compliant
    extends TwoFlange;
    Torque tau;
  equation
    tau=fa.tau;
    fa.tau+fb.tau=0;
  end Compliant;
  model TwoFlange
    Flange_a fa;
    Flange_b fb;
  protected
    Angle phi_rel;
  equation
    phi_rel=fa.phi-fb.phi;
  end TwoFlange;
  connector Flange
    flow Torque tau;
    Angle phi;
  end Flange;
  type Angle=Real(unit="rad");
  type RotationalSpringConstant=Real(unit="N.m/rad");
  type AngularVelocity=Real(unit="rad/s");
  type Inertia=Real(unit="kg.m2");
  type RotationalDampingConstant=Real(unit="N.m.s/rad");
  type Torque=Real(unit="N·m");
end SMD_WithBacklash;

Note how the i1 : RotationalInertia and i2 : RotationalInertia have been redefined to carry new (mostly different) Context-Specific Values for the 'start' values. As a result, only some of the Connectors from SMD can be inherited.

Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links