yojimbo87
yojimbo87

Reputation: 68393

Inverted pendulum angle values in Modelica

I want to create a system that will simulate inverted wheel pendulum with moment exchange ilustrated below.

enter image description here

So far I have a system which consists of three models:

RotationalPendulum.mo

model RotationalPendulum
  import Modelica.SIunits;
  Modelica.Mechanics.Rotational.Interfaces.Flange_a p;
  parameter SIunits.Length L = 1.0;
  parameter SIunits.Mass m = 1.0;
protected
  SIunits.AngularVelocity omega;
  SIunits.AngularAcceleration alpha;
  parameter SIunits.MomentOfInertia J = m * L ^ 2;
  constant Real g = Modelica.Constants.g_n;
equation
  // equation to compute p.tau
end RotationalPendulum;

FrictionlessJoint.mo

model FrictionlessJoint
    Modelica.Mechanics.Rotational.Interfaces.Flange_a a;
    Modelica.Mechanics.Rotational.Interfaces.Flange_b b;
equation
    a.tau = 0;
    b.tau = 0;
end FrictionlessJoint;

PendulumSystem.mo

model PendulumSystem "Simple pendulum"
  RotationalPendulum pend(m = 1, p(phi(start = 1, fixed = true)));
  FrictionlessJoint joint;
  Modelica.Mechanics.Rotational.Components.Fixed fixed;
equation
  connect(pend.p,joint.a);
  connect(joint.b,fixed.flange);
end PendulumSystem;

In RotationalPendulum.mo model is an equation which should be responsible to compute value of Tau and has this form:

tau=gamma1*sin(q1)+kp*(q2+gamma2*q1)+kv*(d/dt(q2)+gamma2*d/dt(q1))

where gamma1, gamma2, kp, kv are constants and q1 = theta1, q2 = (theta1 + theta2).

The problem I have is that I don't know how to get value of theta1 since it's an angle of the rod, but the equation is located in the model of rotational pendulum where I can access only value of theta2 which is p.phi (if I'm not mistaken). Thanks for any ideas and help.

Upvotes: 2

Views: 1634

Answers (2)

modelicaFan
modelicaFan

Reputation: 148

Look at a similar double pendulum model as defined in Modelica_LinearSystems2:

Modelica_LinearSystems2.Controller.Examples.Components.DoublePendulum

To be found on github: https://github.com/modelica/Modelica_LinearSystems2

Upvotes: 0

Michael Tiller
Michael Tiller

Reputation: 9421

I don't know what constraints you have, but I would just use the Modelica MultiBody library. Your model would consist of a ground, a mass-less rod and a cylinder. The ground and rod would be connected by a revolute joint and the rod and cylinder would also be connected by a revolute joint. The revolute joint is, by default, frictionless.

Note: I don't entirely understand the point of solving for omega2. Is this wheel symmetric? If so, the wheel will simply continue to spin at it's initial velocity. So why not treat it as a point mass?

Upvotes: 2

Related Questions