Ticket #6287: DC_Drive.2.mo

File DC_Drive.2.mo, 17.7 KB (added by ahaumer@…, 4 years ago)

New version of the test library

Line 
1within ;
2package DC_Drive "Test library of controlled DCPM drives"
3 extends Modelica.Icons.Package;
4
5 model DCPM_CurrentControlled "Current controlled DCPM drive"
6 extends Modelica.Icons.Example;
7 import Modelica.Constants.pi;
8 parameter DCPM_Utilities.DriveData driveData(redeclare
9 DC_Drive.DCPM_Utilities.M48V machineData)
10 annotation (Placement(transformation(extent={{60,60},{80,80}})));
11 DCPM_Utilities.DCPM dcpm(
12 machineData=driveData.machineData,
13 iA(fixed=true),
14 phi(fixed=true),
15 w(fixed=true))
16 annotation (Placement(transformation(extent={{20,-80},{40,-60}})));
17 Modelica.Electrical.Analog.Basic.Ground ground
18 annotation (Placement(
19 transformation(
20 extent={{-10,-10},{10,10}},
21 rotation=270,
22 origin={10,-50})));
23 Modelica.Blocks.Sources.Step iRef(
24 height=driveData.machineData.IANominal,
25 offset=0,
26 startTime=0.1)
27 annotation (Placement(transformation(extent={{-40,30},{-20,50}})));
28 Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(
29 J=driveData.JL,
30 phi(fixed=false),
31 w(fixed=false))
32 annotation (Placement(transformation(extent={{50,-80},{70,-60}})));
33 Modelica.Mechanics.Rotational.Sources.LinearSpeedDependentTorque torqueLoad(
34 tau_nominal=-driveData.machineData.tauNominal,
35 TorqueDirection=false,
36 w_nominal=driveData.machineData.wNominal)
37 annotation (Placement(transformation(extent={{100,-80},{80,-60}})));
38 Modelica.Electrical.Analog.Sources.SignalVoltage voltageSource
39 annotation (Placement(transformation(extent={{40,-20},{20,0}})));
40 Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
41 annotation (Placement(transformation(
42 extent={{-10,10},{10,-10}},
43 rotation=90,
44 origin={20,-30})));
45 Modelica.Blocks.Continuous.FirstOrder deadTime(
46 k=1,
47 T=driveData.Td,
48 initType=Modelica.Blocks.Types.Init.InitialOutput,
49 y_start=0) annotation (Placement(transformation(
50 extent={{-10,-10},{10,10}},
51 rotation=270,
52 origin={30,20})));
53 Modelica.Electrical.Machines.Examples.ControlledDCDrives.Utilities.LimitedPI currentController(
54 k=driveData.controllerData.kpI,
55 Ti=driveData.controllerData.TiI,
56 useFF=true,
57 KFF=driveData.machineData.kPhi,
58 yMax=driveData.VBat,
59 initType=Modelica.Blocks.Types.Init.InitialOutput,
60 x_start=0,
61 y_start=0) annotation (Placement(transformation(extent={{-10,30},{10,50}})));
62 equation
63 connect(dcpm.shaft, inertiaLoad.flange_a)
64 annotation (Line(points={{40,-70},{50,-70}}, color={0,0,0}));
65 connect(torqueLoad.flange, inertiaLoad.flange_b)
66 annotation (Line(points={{80,-70},{70,-70}}, color={0,0,0}));
67 connect(ground.p,dcpm. pin_n)
68 annotation (Line(points={{20,-50},{24,-50},{24,-60}}, color={0,0,255}));
69 connect(ground.p, currentSensor.p)
70 annotation (Line(points={{20,-50},{20,-40}}, color={0,0,255}));
71 connect(currentSensor.n,voltageSource. n)
72 annotation (Line(points={{20,-20},{20,-10}},
73 color={0,0,255}));
74 connect(voltageSource.p,dcpm. pin_p)
75 annotation (Line(points={{40,-10},{40,-50},{36,-50},{36,-60}},
76 color={0,0,255}));
77 connect(deadTime.y, voltageSource.v)
78 annotation (Line(points={{30,9},{30,2}}, color={0,0,127}));
79 connect(iRef.y, currentController.u)
80 annotation (Line(points={{-19,40},{-12,40}}, color={0,0,127}));
81 connect(currentSensor.i, currentController.u_m)
82 annotation (Line(points={{9,-30},{-6,-30},{-6,28}}, color={0,0,127}));
83 connect(dcpm.w, currentController.feedForward)
84 annotation (Line(points={{19,-70},{0,-70},{0,28}}, color={0,0,127}));
85 connect(currentController.y, deadTime.u)
86 annotation (Line(points={{11,40},{30,40},{30,32}}, color={0,0,127}));
87 annotation (experiment(
88 StopTime=1,
89 Interval=0.0001,
90 Tolerance=1e-06), Documentation(info="<html>
91<p>
92Simulates a current controlled DCPM machine. The load applies a linearly speed dependent torque, which in the end causes the drive to operate in nominal operation.
93</p>
94<p>
95Additionally, the handling of parameter records can be tested:
96By simply redeclaring the machine parameter record instantiated in the drive parameter record, a machine with different parameters can be simulated.
97</p>
98</html>"));
99 end DCPM_CurrentControlled;
100
101 model DCPM_SpeedControlled "Current controlled DCPM drive"
102 extends Modelica.Icons.Example;
103 import Modelica.Constants.pi;
104 parameter DCPM_Utilities.DriveData driveData(redeclare
105 DC_Drive.DCPM_Utilities.M48V machineData)
106 annotation (Placement(transformation(extent={{60,60},{80,80}})));
107 DCPM_Utilities.DCPM dcpm(
108 machineData=driveData.machineData,
109 iA(fixed=true),
110 phi(fixed=true),
111 w(fixed=true))
112 annotation (Placement(transformation(extent={{20,-80},{40,-60}})));
113 Modelica.Electrical.Analog.Basic.Ground ground
114 annotation (Placement(
115 transformation(
116 extent={{-10,-10},{10,10}},
117 rotation=270,
118 origin={10,-50})));
119 Modelica.Blocks.Sources.Step wRef(
120 height=driveData.machineData.wNominal,
121 offset=0,
122 startTime=0.1)
123 annotation (Placement(transformation(extent={{-100,30},{-80,50}})));
124 Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(
125 J=driveData.JL,
126 phi(fixed=false),
127 w(fixed=false))
128 annotation (Placement(transformation(extent={{50,-80},{70,-60}})));
129 Modelica.Mechanics.Rotational.Sources.TorqueStep torqueLoad(
130 stepTorque=-driveData.machineData.tauNominal,
131 offsetTorque=0,
132 startTime=0.7)
133 annotation (Placement(transformation(extent={{100,-80},{80,-60}})));
134 Modelica.Electrical.Analog.Sources.SignalVoltage voltageSource
135 annotation (Placement(transformation(extent={{40,-20},{20,0}})));
136 Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
137 annotation (Placement(transformation(
138 extent={{-10,10},{10,-10}},
139 rotation=90,
140 origin={20,-30})));
141 Modelica.Blocks.Continuous.FirstOrder deadTime(
142 k=1,
143 T=driveData.Td,
144 initType=Modelica.Blocks.Types.Init.InitialOutput,
145 y_start=0) annotation (Placement(transformation(
146 extent={{-10,-10},{10,10}},
147 rotation=270,
148 origin={30,20})));
149 Modelica.Electrical.Machines.Examples.ControlledDCDrives.Utilities.LimitedPI currentController(
150 k=driveData.controllerData.kpI,
151 Ti=driveData.controllerData.TiI,
152 useFF=true,
153 KFF=driveData.machineData.kPhi,
154 yMax=driveData.VBat,
155 initType=Modelica.Blocks.Types.Init.InitialOutput,
156 x_start=0,
157 y_start=0) annotation (Placement(transformation(extent={{-10,30},{10,50}})));
158 Modelica.Blocks.Continuous.FirstOrder preFilter(
159 k=1,
160 T=driveData.controllerData.Tiw,
161 initType=Modelica.Blocks.Types.Init.InitialOutput,
162 y_start=0)
163 annotation (Placement(transformation(extent={{-70,30},{-50,50}})));
164 Modelica.Electrical.Machines.Examples.ControlledDCDrives.Utilities.LimitedPI
165 speedController(
166 k=driveData.controllerData.kpw/driveData.machineData.kPhi,
167 Ti=driveData.controllerData.Tiw,
168 useFF=false,
169 yMax=driveData.IMax,
170 initType=Modelica.Blocks.Types.Init.InitialOutput,
171 x_start=0,
172 y_start=0)
173 annotation (Placement(transformation(extent={{-40,30},{-20,50}})));
174 equation
175 connect(dcpm.shaft, inertiaLoad.flange_a)
176 annotation (Line(points={{40,-70},{50,-70}}, color={0,0,0}));
177 connect(torqueLoad.flange, inertiaLoad.flange_b)
178 annotation (Line(points={{80,-70},{70,-70}}, color={0,0,0}));
179 connect(ground.p,dcpm. pin_n)
180 annotation (Line(points={{20,-50},{24,-50},{24,-60}}, color={0,0,255}));
181 connect(ground.p, currentSensor.p)
182 annotation (Line(points={{20,-50},{20,-40}}, color={0,0,255}));
183 connect(currentSensor.n,voltageSource. n)
184 annotation (Line(points={{20,-20},{20,-10}},
185 color={0,0,255}));
186 connect(voltageSource.p,dcpm. pin_p)
187 annotation (Line(points={{40,-10},{40,-50},{36,-50},{36,-60}},
188 color={0,0,255}));
189 connect(deadTime.y, voltageSource.v)
190 annotation (Line(points={{30,9},{30,2}}, color={0,0,127}));
191 connect(currentSensor.i, currentController.u_m)
192 annotation (Line(points={{9,-30},{-6,-30},{-6,28}}, color={0,0,127}));
193 connect(dcpm.w, currentController.feedForward)
194 annotation (Line(points={{19,-70},{0,-70},{0,28}}, color={0,0,127}));
195 connect(wRef.y, preFilter.u)
196 annotation (Line(points={{-79,40},{-72,40}}, color={0,0,127}));
197 connect(currentController.y, deadTime.u)
198 annotation (Line(points={{11,40},{30,40},{30,32}}, color={0,0,127}));
199 connect(preFilter.y, speedController.u)
200 annotation (Line(points={{-49,40},{-42,40}}, color={0,0,127}));
201 connect(speedController.y, currentController.u)
202 annotation (Line(points={{-19,40},{-12,40}}, color={0,0,127}));
203 connect(dcpm.w, speedController.u_m) annotation (Line(points={{19,-70},{
204 -36,-70},{-36,28}}, color={0,0,127}));
205 annotation (experiment(
206 StopTime=1,
207 Interval=0.0001,
208 Tolerance=1e-06), Documentation(info="<html>
209<p>
210Simulates a speed controlled DCPM machine. The load applies a torque step, which in the end causes the drive to operate in nominal operation.
211</p>
212<p>
213Additionally, the handling of parameter records can be tested:
214By simply redeclaring the machine parameter record instantiated in the drive parameter record, a machine with different parameters can be simulated.
215</p>
216</html>"));
217 end DCPM_SpeedControlled;
218
219 package DCPM_Utilities "Utilities for DC_Drives"
220 extends Modelica.Icons.UtilitiesPackage;
221 model DCPM "Simple DC PM model"
222 extends Modelica.Electrical.Machines.Icons.Machine;
223 parameter MachineData machineData
224 annotation (Placement(transformation(extent={{60,40},{80,60}})));
225 output Modelica.SIunits.Current iA(start=0)=resistor.i "Armature current";
226 output Modelica.SIunits.Angle phi(start=0)=shaft.phi "Shaft angle";
227 Modelica.Blocks.Interfaces.RealOutput w(start=0, unit="rad/s", displayUnit="1/min")
228 annotation (Placement(transformation(
229 extent={{-10,-10},{10,10}},
230 rotation=180,
231 origin={-110,0})));
232 Modelica.Electrical.Analog.Interfaces.PositivePin pin_p "Positive armature pin"
233 annotation (Placement(transformation(extent={{50,90},{70,110}})));
234 Modelica.Electrical.Analog.Interfaces.NegativePin pin_n "Negative armature pin"
235 annotation (Placement(transformation(extent={{-70,90},{-50,110}})));
236 Modelica.Mechanics.Rotational.Interfaces.Flange_a shaft "Shaft"
237 annotation (Placement(transformation(extent={{90,-10},{110,10}})));
238 Modelica.Electrical.Analog.Basic.Resistor resistor(R=machineData.RA,
239 T_ref=293.15)
240 annotation (Placement(transformation(extent={{-10,-10},{10,10}},
241 rotation=270,
242 origin={0,60})));
243 Modelica.Electrical.Analog.Basic.Inductor inductor(L=machineData.LA)
244 annotation (Placement(transformation(extent={{-10,-10},{10,10}},
245 rotation=270,
246 origin={0,30})));
247 Modelica.Electrical.Analog.Basic.EMF emf(k=machineData.kPhi)
248 annotation (Placement(
249 transformation(
250 extent={{-10,-10},{10,10}},
251 rotation=0,
252 origin={0,0})));
253 Modelica.Mechanics.Rotational.Components.Inertia inertia(J=machineData.J)
254 annotation (Placement(transformation(extent={{40,-10},{60,10}})));
255 Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
256 annotation (Placement(transformation(
257 extent={{-10,-10},{10,10}},
258 rotation=270,
259 origin={80,-30})));
260 equation
261 connect(resistor.n, inductor.p)
262 annotation (Line(points={{-1.77636e-15,50},{0,50},{0,40},{0,40}},color={0,0,255}));
263 connect(inductor.n, emf.p)
264 annotation (Line(points={{-1.77636e-15,20},{0,20},{0,10}},color={0,0,255}));
265 connect(emf.flange, inertia.flange_a)
266 annotation (Line(points={{10,0},{40,0}}, color={0,0,0}));
267 connect(resistor.p, pin_p)
268 annotation (Line(points={{0,70},{0,80},{60,80},{60,100}}, color={0,0,255}));
269 connect(emf.n, pin_n)
270 annotation (Line(points={{0,-10},{0,-20},{-60,-20},{-60,100}}, color={0,0,255}));
271 connect(inertia.flange_b, shaft)
272 annotation (Line(points={{60,0},{100,0}}, color={0,0,0}));
273 connect(inertia.flange_b, speedSensor.flange)
274 annotation (Line(points={{60,0},{80,0},{80,-20}}, color={0,0,0}));
275 connect(speedSensor.w, w)
276 annotation (Line(points={{80,-41},{80,-60},{-80,-60}, {-80,0},{-110,0}}, color={0,0,127}));
277 annotation (
278 Icon(graphics={Text(
279 extent={{-100,-100},{100,-140}},
280 lineColor={28,108,200},
281 textString="%name")}), Documentation(info="<html>
282<p>
283Simple model of a DC PM machine, comprising armature resistance, armature inductance, emf (including torque generation), inertia and pseed measurement.
284</p>
285</html>"));
286 end DCPM;
287
288 record DriveData "Parameters of the whole drive"
289 extends Modelica.Icons.Record;
290 import Modelica.Constants.pi;
291 replaceable parameter DC_Drive.DCPM_Utilities.MachineData machineData
292 annotation (choicesAllMatching=true, Placement(transformation(extent={{-10,40},
293 {10,60}})));
294
295 parameter ControllerData controllerData(
296 kpI=machineData.LA/(2*Td),
297 TiI=machineData.LA/machineData.RA,
298 Tsub=2*Td,
299 kpw=(machineData.J + JL)/(2*controllerData.Tsub),
300 Tiw=4*controllerData.Tsub)
301 annotation (Placement(transformation(extent={{-10,0},{10,20}})));
302 parameter Modelica.SIunits.Inertia JL=machineData.J "Load inertia";
303 parameter Modelica.SIunits.Voltage VBat=1.2*machineData.VANominal "Battery voltage";
304 parameter Modelica.SIunits.Current IMax=1.5*machineData.IANominal "Max. armature current";
305 parameter Modelica.SIunits.Frequency fSwitch=1e3 "Switching frequency";
306 parameter Modelica.SIunits.Time Td=0.5/fSwitch "Dead time of inverter"
307 annotation(Dialog(enable=false));
308 annotation(defaultComponentPrefixes="parameter", defaultComponentName="driveData",
309 Documentation(info="<html>
310<p>
311The drive parameter record contains the machine parameter record, additional parameters and fills the controller parameter record.
312Simulating another machine (with different parameters), the machine parameter record can be redeclared.
313</p>
314</html>"));
315 end DriveData;
316
317 record ControllerData "Controller parameters"
318 extends Modelica.Icons.Record;
319 parameter Real kpI "Proportional gain of current controller";
320 parameter Modelica.SIunits.Time TiI "Integral time constant of current controller";
321 parameter Modelica.SIunits.Time Tsub "Substitute time constant";
322 parameter Real kpw "Porportional gain of speed controller";
323 parameter Modelica.SIunits.Time Tiw "Integral time constant of speed controller";
324 annotation(defaultComponentPrefixes="parameter", defaultComponentName="controllerData",
325 Documentation(info="<html>
326<p>
327The controller parameter record is used in the drive parameters record, and filled in that record (based on the machine parameters).
328</p>
329</html>"));
330 end ControllerData;
331
332 record MachineData "Standard machine parameters"
333 extends Modelica.Icons.Record;
334 import Modelica.Constants.pi;
335 parameter Modelica.SIunits.Voltage VANominal=100 "Nominal armature voltage";
336 parameter Modelica.SIunits.Current IANominal=100 "Nominal armature current";
337 parameter Modelica.SIunits.AngularVelocity wNominal=1425*pi/30 "Nominal speed";
338 parameter Modelica.SIunits.Resistance RA=0.05 "Armature resistance";
339 parameter Modelica.SIunits.Inductance LA=0.0015 "Armature inductance";
340 parameter Modelica.SIunits.Voltage ViNominal=VANominal - RA*IANominal "Nominal induced voltage"
341 annotation(Dialog(enable=false));
342 parameter Modelica.SIunits.ElectricalTorqueConstant kPhi=ViNominal/wNominal "Flux constant";
343 parameter Modelica.SIunits.Inertia J=0.29 "Rotor inertia";
344 parameter Modelica.SIunits.Torque tauNominal=kPhi*IANominal "Nominal torque"
345 annotation(Dialog(enable=false));
346 annotation(defaultComponentPrefixes="parameter", defaultComponentName="machineData",
347 Documentation(info="<html>
348<p>
349The machine parameter record contains all necessary parameters of a DC PM machine.
350It is used to parameterize the DCPM model, and it is used in the drive parameter record.
351Extending from this record, the parameters of other machines (with different parameters) can be saved.
352</p>
353</html>"));
354 end MachineData;
355
356 record M48V "Real machine 48 V"
357 import Modelica.Constants.pi;
358 extends DC_Drive.DCPM_Utilities.MachineData(
359 VANominal=48,
360 IANominal=25,
361 wNominal=3500*pi/30,
362 RA=0.24,
363 LA=0.004,
364 J=0.0008);
365 annotation(defaultComponentPrefixes="parameter", defaultComponentName="machineData",
366 Documentation(info="<html>
367<p>
368Machine parameters of a real 48 W / 1 kW DCPM machine.
369</p>
370</html>"));
371 end M48V;
372 end DCPM_Utilities;
373 annotation (uses(Modelica(version="3.2.3")));
374end DC_Drive;