Skip to content

Commit 91f19f7

Browse files
committed
added position controlled example
1 parent 2c8f8a2 commit 91f19f7

File tree

2 files changed

+183
-16
lines changed

2 files changed

+183
-16
lines changed

Modelica/Electrical/Machines.mo

Lines changed: 183 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4824,8 +4824,8 @@ This package contains test examples of DC machines.
48244824
offset=0,
48254825
startTime=0.1) annotation (Placement(transformation(
48264826
extent={{-10,-10},{10,10}},
4827-
rotation=270,
4828-
origin={-30,50})));
4827+
rotation=0,
4828+
origin={-40,30})));
48294829
equation
48304830
connect(loadInertia.flange_b, loadTorque.flange)
48314831
annotation (Line(points={{70,0},{80,0}}, color={0,0,0}));
@@ -4845,7 +4845,7 @@ This package contains test examples of DC machines.
48454845
points={{19,24},{10,24},{10,10},{-16,10},{-16,18}}, color={0,0,
48464846
127}));
48474847
connect(speedSensor.w, currentController.feedForward) annotation (Line(
4848-
points={{50,-31},{50,-42},{-4,-42},{-4,18}}, color={0,0,127}));
4848+
points={{50,-31},{50,-40},{-4,-40},{-4,18}}, color={0,0,127}));
48494849
connect(constantVoltage.n, ground.p)
48504850
annotation (Line(points={{20,80},{20,60}}, color={0,0,255}));
48514851
connect(ground.p, idealDCDCinverter.pin_nBat)
@@ -4854,16 +4854,19 @@ This package contains test examples of DC machines.
48544854
annotation (Line(points={{40,80},{40,70}}, color={0,0,255}));
48554855
connect(resistor.n, idealDCDCinverter.pin_pBat)
48564856
annotation (Line(points={{40,50},{40,40}}, color={0,0,255}));
4857-
connect(step.y, currentController.u) annotation (Line(points={{-30,39},
4858-
{-30,30},{-22,30}}, color={0,0,127}));
4859-
annotation (experiment(StopTime=2, Interval=0.0001), Documentation(info=
4860-
"<html>
4857+
connect(step.y, currentController.u)
4858+
annotation (Line(points={{-29,30},{-22,30}}, color={0,0,127}));
4859+
annotation (experiment(StopTime=2, Interval=0.0001), Documentation(info="<html>
48614860
<p>This model demonstrates how a current controller for a DC PM drive works.</p>
48624861
<p>
48634862
Electrical power is taken from a battery (constant voltage with inner resistance) and fed to the motor via an ideal DC-DC inverter.
48644863
The current controller is parameterized according to the absolute optimum.
48654864
</p>
48664865
<p>At time=0.1 s a reference current step is applied, causing the drive to accelerate until motor torque and load torque are at an equilibrium.</p>
4866+
<p>
4867+
Further reading:
4868+
<a href=\"modelica://Modelica/Resources/Documentation/Electrical/Machines/DriveControl.pdf\">Tutorial at the Modelica Conference 2017</a>
4869+
</p>
48674870
</html>"));
48684871
end CurrentControlledDCPM;
48694872

@@ -4947,9 +4950,9 @@ The current controller is parameterized according to the absolute optimum.
49474950
startTime=0.1,
49484951
height=dcpmDriveData.dcpmData.wNominal) annotation (Placement(
49494952
transformation(
4950-
extent={{-10,-10},{10,10}},
4951-
rotation=270,
4952-
origin={-90,50})));
4953+
extent={{-10,10},{10,-10}},
4954+
rotation=180,
4955+
origin={-70,60})));
49534956
equation
49544957
connect(loadInertia.flange_b, loadTorque.flange)
49554958
annotation (Line(points={{70,0},{80,0}}, color={0,0,0}));
@@ -4969,7 +4972,7 @@ The current controller is parameterized according to the absolute optimum.
49694972
points={{19,24},{10,24},{10,10},{-16,10},{-16,18}}, color={0,0,
49704973
127}));
49714974
connect(speedSensor.w, currentController.feedForward) annotation (Line(
4972-
points={{50,-31},{50,-42},{-4,-42},{-4,18}}, color={0,0,127}));
4975+
points={{50,-31},{50,-40},{-4,-40},{-4,18}}, color={0,0,127}));
49734976
connect(constantVoltage.n, ground.p)
49744977
annotation (Line(points={{20,80},{20,60}}, color={0,0,255}));
49754978
connect(ground.p, idealDCDCinverter.pin_nBat)
@@ -4980,25 +4983,180 @@ The current controller is parameterized according to the absolute optimum.
49804983
annotation (Line(points={{40,50},{40,40}}, color={0,0,255}));
49814984
connect(speedController.y, currentController.u)
49824985
annotation (Line(points={{-29,30},{-22,30}}, color={0,0,127}));
4983-
connect(speedSensor.w, speedController.u_m) annotation (Line(points={{
4984-
50,-31},{50,-42},{-46,-42},{-46,18}}, color={0,0,127}));
4986+
connect(speedSensor.w, speedController.u_m) annotation (Line(points={{50,-31},
4987+
{50,-40},{-46,-40},{-46,18}}, color={0,0,127}));
49854988
connect(preFilter.y, speedController.u)
49864989
annotation (Line(points={{-59,30},{-52,30}}, color={0,0,127}));
4987-
connect(step.y, preFilter.u) annotation (Line(points={{-90,39},{-90,30},
4988-
{-82,30}}, color={0,0,127}));
4990+
connect(step.y, preFilter.u) annotation (Line(points={{-81,60},{-90,60},
4991+
{-90,30},{-82,30}}, color={0,0,127}));
49894992
annotation (experiment(Interval=0.0001), Documentation(info="<html>
49904993
<p>This model demonstrates how a speed controller for a current controlled DC PM drive works.</p>
49914994
<p>
49924995
Electrical power is taken from a battery (constant voltage with inner resistance) and fed to the motor via an ideal DC-DC inverter.
4993-
The current controller is parameterized according to the absolute optimum.
4996+
The inner current controller is parameterized according to the absolute optimum.
49944997
The outer control loop is formed by the speed controller which is parameterized according to the symmetrical optimum.
49954998
</p>
49964999
<p>
49975000
At time=0.1 s a reference speed step is applied, causing the drive to accelerate to the desired speed.
49985001
At time=0.8 s a load torque step is applied, causing to drive to decelerate until the speed controller brings the drive back to the desired speed.
49995002
</p>
5003+
<p>
5004+
Further reading:
5005+
<a href=\"modelica://Modelica/Resources/Documentation/Electrical/Machines/DriveControl.pdf\">Tutorial at the Modelica Conference 2017</a>
5006+
</p>
50005007
</html>"));
50015008
end SpeedControlledDCPM;
5009+
5010+
model PositionControlledDCPM "Position controlled DC PM drive"
5011+
extends Modelica.Icons.Example;
5012+
parameter Modelica.Electrical.Machines.Utilities.DcpmDriveData dcpmDriveData
5013+
annotation (Placement(transformation(extent={{50,20},{70,40}})));
5014+
Modelica.Mechanics.Rotational.Sources.TorqueStep
5015+
loadTorque(
5016+
stepTorque=-dcpmDriveData.tauNominal,
5017+
offsetTorque=0,
5018+
startTime=2)
5019+
annotation (Placement(transformation(extent={{100,-10},{80,10}})));
5020+
Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=
5021+
dcpmDriveData.JL)
5022+
annotation (Placement(transformation(extent={{50,-10},{70,10}})));
5023+
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation (
5024+
Placement(transformation(
5025+
extent={{-10,-10},{10,10}},
5026+
rotation=270,
5027+
origin={50,-20})));
5028+
Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_PermanentMagnet dcpm(
5029+
TaOperational=dcpmDriveData.dcpmData.TaNominal,
5030+
VaNominal=dcpmDriveData.dcpmData.VaNominal,
5031+
IaNominal=dcpmDriveData.dcpmData.IaNominal,
5032+
wNominal=dcpmDriveData.dcpmData.wNominal,
5033+
TaNominal=dcpmDriveData.dcpmData.TaNominal,
5034+
Ra=dcpmDriveData.dcpmData.Ra,
5035+
TaRef=dcpmDriveData.dcpmData.TaRef,
5036+
La=dcpmDriveData.dcpmData.La,
5037+
Jr=dcpmDriveData.dcpmData.Jr,
5038+
frictionParameters=dcpmDriveData.dcpmData.frictionParameters,
5039+
phiMechanical(fixed=true),
5040+
wMechanical(fixed=true),
5041+
coreParameters=dcpmDriveData.dcpmData.coreParameters,
5042+
strayLoadParameters=dcpmDriveData.dcpmData.strayLoadParameters,
5043+
brushParameters=dcpmDriveData.dcpmData.brushParameters,
5044+
ia(fixed=true),
5045+
Js=dcpmDriveData.dcpmData.Js,
5046+
alpha20a=dcpmDriveData.dcpmData.alpha20a)
5047+
annotation (Placement(transformation(extent={{20,-10},{40,10}})));
5048+
Modelica.Electrical.Machines.Utilities.IdealDCDCinverter idealDCDCinverter(Td=
5049+
dcpmDriveData.Td)
5050+
annotation (Placement(transformation(extent={{20,20},{40,40}})));
5051+
Modelica.Electrical.Analog.Basic.Resistor resistor(R=0.05*dcpmDriveData.dcpmData.VaNominal
5052+
/dcpmDriveData.dcpmData.IaNominal) annotation (Placement(
5053+
transformation(
5054+
extent={{-10,-10},{10,10}},
5055+
rotation=270,
5056+
origin={40,60})));
5057+
Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(
5058+
transformation(
5059+
extent={{-10,-10},{10,10}},
5060+
rotation=270,
5061+
origin={10,60})));
5062+
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=
5063+
dcpmDriveData.VaMax)
5064+
annotation (Placement(transformation(extent={{40,70},{20,90}})));
5065+
Modelica.Electrical.Machines.Utilities.LimitedPI currentController(
5066+
constantLimits=false,
5067+
k=dcpmDriveData.kpI,
5068+
Ti=dcpmDriveData.TiI,
5069+
kFF=dcpmDriveData.kPhi,
5070+
initType=Modelica.Blocks.Types.Init.InitialOutput)
5071+
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
5072+
Modelica.Electrical.Machines.Utilities.LimitedPI speedController(
5073+
initType=Modelica.Blocks.Types.Init.InitialOutput,
5074+
k=dcpmDriveData.kpw,
5075+
Ti=dcpmDriveData.Tiw,
5076+
with_FF=false,
5077+
constantLimits=true,
5078+
yMax=dcpmDriveData.IaMax)
5079+
annotation (Placement(transformation(extent={{-50,20},{-30,40}})));
5080+
Modelica.Electrical.Machines.Utilities.LimitedPI positionController(
5081+
with_FF=false,
5082+
constantLimits=true,
5083+
k=dcpmDriveData.kpP,
5084+
useI=false,
5085+
yMax=dcpmDriveData.wMax,
5086+
initType=Modelica.Blocks.Types.Init.SteadyState)
5087+
annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
5088+
Modelica.Mechanics.Rotational.Sensors.AngleSensor angleSensor
5089+
annotation (Placement(transformation(
5090+
extent={{-10,-10},{10,10}},
5091+
rotation=270,
5092+
origin={40,-58})));
5093+
Modelica.Blocks.Sources.KinematicPTP2 kinematicPTP(
5094+
startTime=0.1,
5095+
qd_max={dcpmDriveData.wMax},
5096+
qdd_max={dcpmDriveData.aMax},
5097+
q_end={200}) annotation (Placement(transformation(
5098+
extent={{-10,10},{10,-10}},
5099+
rotation=180,
5100+
origin={-70,60})));
5101+
equation
5102+
connect(loadInertia.flange_b, loadTorque.flange)
5103+
annotation (Line(points={{70,0},{80,0}}, color={0,0,0}));
5104+
connect(dcpm.flange, loadInertia.flange_a)
5105+
annotation (Line(points={{40,0},{50,0}}, color={0,0,0}));
5106+
connect(speedSensor.flange, dcpm.flange)
5107+
annotation (Line(points={{50,-10},{50,0},{40,0}}, color={0,0,0}));
5108+
connect(idealDCDCinverter.pin_nMot, dcpm.pin_an)
5109+
annotation (Line(points={{24,20},{24,10}}, color={0,0,255}));
5110+
connect(idealDCDCinverter.pin_pMot, dcpm.pin_ap)
5111+
annotation (Line(points={{36,20},{36,10}}, color={0,0,255}));
5112+
connect(idealDCDCinverter.vBat, currentController.yMaxVar)
5113+
annotation (Line(points={{19,36},{2,36}}, color={0,0,127}));
5114+
connect(idealDCDCinverter.vRef, currentController.y)
5115+
annotation (Line(points={{18,30},{1,30}}, color={0,0,127}));
5116+
connect(idealDCDCinverter.iMot, currentController.u_m) annotation (Line(
5117+
points={{19,24},{10,24},{10,10},{-16,10},{-16,18}}, color={0,0,
5118+
127}));
5119+
connect(speedSensor.w, currentController.feedForward) annotation (Line(
5120+
points={{50,-31},{50,-40},{-4,-40},{-4,18}}, color={0,0,127}));
5121+
connect(constantVoltage.n, ground.p)
5122+
annotation (Line(points={{20,80},{20,60}}, color={0,0,255}));
5123+
connect(ground.p, idealDCDCinverter.pin_nBat)
5124+
annotation (Line(points={{20,60},{20,40}}, color={0,0,255}));
5125+
connect(constantVoltage.p, resistor.p)
5126+
annotation (Line(points={{40,80},{40,70}}, color={0,0,255}));
5127+
connect(resistor.n, idealDCDCinverter.pin_pBat)
5128+
annotation (Line(points={{40,50},{40,40}}, color={0,0,255}));
5129+
connect(speedController.y, currentController.u)
5130+
annotation (Line(points={{-29,30},{-22,30}}, color={0,0,127}));
5131+
connect(speedSensor.w, speedController.u_m) annotation (Line(points={{50,-31},
5132+
{50,-40},{-46,-40},{-46,18}}, color={0,0,127}));
5133+
connect(positionController.y, speedController.u)
5134+
annotation (Line(points={{-59,30},{-52,30}}, color={0,0,127}));
5135+
connect(dcpm.flange, angleSensor.flange) annotation (Line(points={{40,0},
5136+
{50,0},{50,-10},{40,-10},{40,-48}}, color={0,0,0}));
5137+
connect(angleSensor.phi, positionController.u_m) annotation (Line(
5138+
points={{40,-69},{40,-80},{-76,-80},{-76,18}}, color={0,0,127}));
5139+
connect(kinematicPTP.q[1], positionController.u) annotation (Line(
5140+
points={{-81,68},{-90,68},{-90,30},{-82,30}}, color={0,0,127}));
5141+
annotation (experiment(StopTime=2.5, Interval=0.0001),
5142+
Documentation(info="<html>
5143+
<p>This model demonstrates how a position controller for a speed controlled DC PM drive works.</p>
5144+
<p>
5145+
Electrical power is taken from a battery (constant voltage with inner resistance) and fed to the motor via an ideal DC-DC inverter.
5146+
The inner current controller is parameterized according to the absolute optimum.
5147+
The middle control loop is formed by the speed controller which is parameterized according to the symmetrical optimum.
5148+
The outer control loop is formed by the position controller which is parameterized to avoid an overshot in the position.
5149+
</p>
5150+
<p>
5151+
At time=0.1 s the kinematicPTP starts to prescribe the reference position with limited speed and limited acceleration.
5152+
At time=2 s a load torque step is applied, causing to drive to slighlty leave the end position until the position controller brings the drive back to the desired position.
5153+
</p>
5154+
<p>
5155+
Further reading:
5156+
<a href=\"modelica://Modelica/Resources/Documentation/Electrical/Machines/DriveControl.pdf\">Tutorial at the Modelica Conference 2017</a>
5157+
</p>
5158+
</html>"));
5159+
end PositionControlledDCPM;
50025160
annotation (Documentation(info="<html>
50035161
This package contains test examples demonstrating control of electric drives.
50045162
</html>"));
@@ -16668,12 +16826,21 @@ normally given in a technical description, according to the standard EN&nbsp;600
1666816826
annotation(Dialog(tab="Controller", group="Speed controller"));
1666916827
parameter Modelica.SIunits.Current IaMax=1.5*dcpmData.IaNominal "Maximum current"
1667016828
annotation(Dialog(tab="Controller", group="Speed controller"));
16829+
parameter Modelica.SIunits.Torque tauMax=kPhi*IaMax "Maximum torque"
16830+
annotation(Dialog(tab="Controller", group="Speed controller", enable=false));
1667116831
parameter Real kpw=(JL + dcpmData.Jr)/(2*Tsub)/kPhi "Proportional gain"
1667216832
annotation(Dialog(tab="Controller", group="Speed controller", enable=false));
1667316833
parameter Modelica.SIunits.Time Tiw=4*Tsub "Integral time constant"
1667416834
annotation(Dialog(tab="Controller", group="Speed controller", enable=false));
1667516835
parameter Modelica.SIunits.Time Tfw=Tiw "Filter time constant"
1667616836
annotation(Dialog(tab="Controller", group="Speed controller", enable=false));
16837+
//Position controller
16838+
parameter Modelica.SIunits.AngularVelocity wMax=dcpmData.wNominal*dcpmData.VaNominal/dcpmData.ViNominal "Maximum speed"
16839+
annotation(Dialog(tab="Controller", group="Position controller"));
16840+
parameter Modelica.SIunits.AngularAcceleration aMax=tauMax/(JL + dcpmData.Jr) "Maximum acceleration"
16841+
annotation(Dialog(tab="Controller", group="Position controller", enable=false));
16842+
parameter Real kpP=1/(16*Tsub) "Proportional gain"
16843+
annotation(Dialog(tab="Controller", group="Position controller", enable=false));
1667716844
annotation (
1667816845
defaultComponentName="dcpmDriveData",
1667916846
defaultComponentPrefixes="parameter",
Binary file not shown.

0 commit comments

Comments
 (0)