Controller.mo 2.13 KB
Newer Older
1 2
within CarProject.Components;

Pierre Haessig's avatar
Pierre Haessig committed
3
model Controller "Speed controller"
4
  parameter Modelica.SIunits.Time tc = 5 "expected closed loop time constant (cf. Skogestad 2003)";
5 6 7 8 9 10 11 12
  Modelica.Blocks.Interfaces.RealOutput f "force control" annotation(
    Placement(visible = true, transformation(origin = {106, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput v_sp "speed set point" annotation(
    Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput v "speed measurement" annotation(
    Placement(visible = true, transformation(origin = {-100, -50}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-120, -40}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Math.Feedback feedback1 annotation(
    Placement(visible = true, transformation(origin = {-30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
13
  Modelica.Blocks.Continuous.PI PI(T = 4 * tc, k = 1000 / tc)  annotation(
14 15
    Placement(visible = true, transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
16 17 18 19
  connect(PI.y, f) annotation(
    Line(points = {{41, 0}, {106, 0}}, color = {0, 0, 127}));
  connect(feedback1.y, PI.u) annotation(
    Line(points = {{-20, 0}, {18, 0}}, color = {0, 0, 127}));
20 21 22 23 24 25
  connect(v_sp, feedback1.u1) annotation(
    Line(points = {{-100, 0}, {-38, 0}}, color = {0, 0, 127}));
  connect(v, feedback1.u2) annotation(
    Line(points = {{-100, -50}, {-30, -50}, {-30, -8}}, color = {0, 0, 127}));
  annotation(
    Icon(graphics = {Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {3, -2}, extent = {{-81, 80}, {81, -80}}, textString = "Speed\nControl"), Text(origin = {-120, 6}, extent = {{-20, 14}, {20, -12}}, textString = "v*"), Text(origin = {-124, -70}, extent = {{-16, 10}, {24, -18}}, textString = "v")}));end Controller;