1 | package DCDrive
|
---|
2 | block ZOH "Zero order holder of a sampled-data system"
|
---|
3 | extends Modelica.Blocks.Interfaces.SISO;
|
---|
4 |
|
---|
5 | parameter Modelica.SIunits.Time samplePeriod(min=100*Modelica.Constants.eps, start=0.1) = 1 "Sample period of component";
|
---|
6 | parameter Modelica.SIunits.Time startTime=0 "First sample time instant";
|
---|
7 | protected
|
---|
8 | Real old (start=0, fixed=true);
|
---|
9 | // Real next (start=0, fixed=true);
|
---|
10 | equation
|
---|
11 | when sample(startTime, samplePeriod) then
|
---|
12 | old = pre(u);
|
---|
13 | end when;
|
---|
14 | y = pre(old);
|
---|
15 | annotation (
|
---|
16 | Icon(
|
---|
17 | coordinateSystem(initialScale = 0.1),
|
---|
18 | graphics={Line(points = {{-78, -42}, {-52, -42}, {-52, 0}, {-26, 0}, {-26, 24}, {-6, 24}, {-6, 64}, {18, 64}, {18, 20}, {38, 20}, {38, 0}, {44, 0}, {44, 0}, {62, 0}}, color = {0, 0, 127}), Text(origin = {0, -120}, extent = {{-120, 20}, {120, -20}}, textString = "period=%samplePeriod", fontSize = 16)}),
|
---|
19 | Documentation(info= "<html><head></head><body><p>
|
---|
20 | This block was redefined in order to test if it will fail like the original ZOH supplied in library. Unfortunately it fails like that, freezing its output after a cretain time of simulation, leading to conclude that sample stops working. Using the original ZOH (Modelica.Blocks.Discrete.ZeroOrderHold, the simulation does not even finish.</p><p>The output is identical to the sampled input signal at sample
|
---|
21 | time instants and holds the output at the value of the last
|
---|
22 | sample instant during the sample points.
|
---|
23 | </p>
|
---|
24 | </body></html>"),
|
---|
25 | experiment(StartTime = 0, StopTime = 1, Tolerance = 0.0001, Interval = 0.001),
|
---|
26 | __OpenModelica_simulationFlags(iim = "symbolic", lv = "LOG_STATS", maxStepSize = "0.7e-6", s = "rungekuttaSsc"));
|
---|
27 | end ZOH;
|
---|
28 |
|
---|
29 | block SawTooth "Generate saw tooth signal"
|
---|
30 | parameter Real amplitude=1 "Amplitude of saw tooth";
|
---|
31 | parameter Modelica.SIunits.Time period(final min=Modelica.Constants.small,start=1) = 1
|
---|
32 | "Time for one period";
|
---|
33 | parameter Real offset=0 "Offset of output signals";
|
---|
34 | parameter Modelica.SIunits.Time startTime=0 "Output = offset for time < startTime";
|
---|
35 | extends Modelica.Blocks.Interfaces.SO;
|
---|
36 | protected
|
---|
37 | Real amp = amplitude/period;
|
---|
38 | //initial algorithm
|
---|
39 | // amp := amplitude / period;
|
---|
40 | equation
|
---|
41 | y = amp * OpenModelica.Internal.realMod(time - startTime, period);
|
---|
42 | //y = OpenModelica.Internal.realMod(time - startTime, period);
|
---|
43 | annotation (
|
---|
44 | Icon(coordinateSystem(
|
---|
45 | preserveAspectRatio=true,
|
---|
46 | extent={{-100,-100},{100,100}}), graphics={
|
---|
47 | Line(points={{-80,68},{-80,-80}}, color={192,192,192}),
|
---|
48 | Polygon(
|
---|
49 | points={{-80,90},{-88,68},{-72,68},{-80,90}},
|
---|
50 | lineColor={192,192,192},
|
---|
51 | fillColor={192,192,192},
|
---|
52 | fillPattern=FillPattern.Solid),
|
---|
53 | Line(points={{-90,-70},{82,-70}}, color={192,192,192}),
|
---|
54 | Polygon(
|
---|
55 | points={{90,-70},{68,-62},{68,-78},{90,-70}},
|
---|
56 | lineColor={192,192,192},
|
---|
57 | fillColor={192,192,192},
|
---|
58 | fillPattern=FillPattern.Solid),
|
---|
59 | Line(points={{-80,-70},{-60,-70},{0,40},{0,-70},{60,41},{60,-70}}),
|
---|
60 | Text(
|
---|
61 | extent={{-147,-152},{153,-112}},
|
---|
62 | lineColor={0,0,0},
|
---|
63 | textString="period=%period")}),
|
---|
64 | Diagram(coordinateSystem(
|
---|
65 | preserveAspectRatio=true,
|
---|
66 | extent={{-100,-100},{100,100}}), graphics={
|
---|
67 | Polygon(
|
---|
68 | points={{-80,90},{-86,68},{-74,68},{-80,90}},
|
---|
69 | lineColor={95,95,95},
|
---|
70 | fillColor={95,95,95},
|
---|
71 | fillPattern=FillPattern.Solid),
|
---|
72 | Line(points={{-80,68},{-80,-80}}, color={95,95,95}),
|
---|
73 | Line(points={{-90,-70},{82,-70}}, color={95,95,95}),
|
---|
74 | Polygon(
|
---|
75 | points={{90,-70},{68,-65},{68,-75},{90,-70}},
|
---|
76 | lineColor={95,95,95},
|
---|
77 | fillColor={95,95,95},
|
---|
78 | fillPattern=FillPattern.Solid),
|
---|
79 | Polygon(
|
---|
80 | points={{-34,-20},{-37,-33},{-31,-33},{-34,-20}},
|
---|
81 | lineColor={95,95,95},
|
---|
82 | fillColor={95,95,95},
|
---|
83 | fillPattern=FillPattern.Solid),
|
---|
84 | Line(points={{-34,-20},{-34,-70}}, color={95,95,95}),
|
---|
85 | Polygon(
|
---|
86 | points={{-34,-70},{-37,-57},{-31,-57},{-34,-70},{-34,-70}},
|
---|
87 | lineColor={95,95,95},
|
---|
88 | fillColor={95,95,95},
|
---|
89 | fillPattern=FillPattern.Solid),
|
---|
90 | Text(
|
---|
91 | extent={{-65,-39},{-29,-47}},
|
---|
92 | lineColor={0,0,0},
|
---|
93 | textString="offset"),
|
---|
94 | Text(
|
---|
95 | extent={{-29,-72},{13,-80}},
|
---|
96 | lineColor={0,0,0},
|
---|
97 | textString="startTime"),
|
---|
98 | Text(
|
---|
99 | extent={{-82,92},{-43,76}},
|
---|
100 | lineColor={0,0,0},
|
---|
101 | textString="y"),
|
---|
102 | Text(
|
---|
103 | extent={{67,-78},{88,-87}},
|
---|
104 | lineColor={0,0,0},
|
---|
105 | textString="time"),
|
---|
106 | Line(points={{-10,-20},{-10,-70}}, color={95,95,95}),
|
---|
107 | Line(points={{-10,88},{-10,-20}}, color={95,95,95}),
|
---|
108 | Line(points={{30,88},{30,59}}, color={95,95,95}),
|
---|
109 | Line(points={{-10,83},{30,83}}, color={95,95,95}),
|
---|
110 | Text(
|
---|
111 | extent={{-12,94},{34,85}},
|
---|
112 | lineColor={0,0,0},
|
---|
113 | textString="period"),
|
---|
114 | Line(points={{-44,60},{30,60}}, color={95,95,95}),
|
---|
115 | Line(points={{-34,47},{-34,-20}},color={95,95,95}),
|
---|
116 | Text(
|
---|
117 | extent={{-73,25},{-36,16}},
|
---|
118 | lineColor={0,0,0},
|
---|
119 | textString="amplitude"),
|
---|
120 | Polygon(
|
---|
121 | points={{-34,60},{-37,47},{-31,47},{-34,60}},
|
---|
122 | lineColor={95,95,95},
|
---|
123 | fillColor={95,95,95},
|
---|
124 | fillPattern=FillPattern.Solid),
|
---|
125 | Polygon(
|
---|
126 | points={{-34,-20},{-37,-7},{-31,-7},{-34,-20},{-34,-20}},
|
---|
127 | lineColor={95,95,95},
|
---|
128 | fillColor={95,95,95},
|
---|
129 | fillPattern=FillPattern.Solid),
|
---|
130 | Polygon(
|
---|
131 | points={{-10,83},{-1,85},{-1,81},{-10,83}},
|
---|
132 | lineColor={95,95,95},
|
---|
133 | fillColor={95,95,95},
|
---|
134 | fillPattern=FillPattern.Solid),
|
---|
135 | Polygon(
|
---|
136 | points={{30,83},{22,85},{22,81},{30,83}},
|
---|
137 | lineColor={95,95,95},
|
---|
138 | fillColor={95,95,95},
|
---|
139 | fillPattern=FillPattern.Solid),
|
---|
140 | Line(
|
---|
141 | points={{-80,-20},{-10,-20},{30,60},{30,-20},{72,60},{72,-20}},
|
---|
142 | color={0,0,255},
|
---|
143 | thickness=0.5)}),
|
---|
144 | Documentation(info= "<html><head></head><body><p>This block was redefined because the original sawtooth presented some bugs in the simulatios. It crashes during simulation.</p><p>The Real output y is a saw tooth signal:</p>
|
---|
145 |
|
---|
146 | <p>
|
---|
147 | <img src=\"modelica://Modelica/Resources/Images/Blocks/Sources/SawTooth.png\" alt=\"SawTooth.png\">
|
---|
148 | </p>
|
---|
149 | </body></html>"));
|
---|
150 | end SawTooth;
|
---|
151 |
|
---|
152 | model SimpleDCMachine2
|
---|
153 | import Modelica.SIunits;
|
---|
154 | import Modelica.Constants.pi;
|
---|
155 | constant Real M_2PI = 2 * pi;
|
---|
156 | parameter SIunits.Resistance Ra = 5.4 "Armature resistance";
|
---|
157 | parameter SIunits.Inductance La = 25e-3 "Armature auto-inductance";
|
---|
158 | parameter SIunits.MomentOfInertia J = 4.2e-3 "Moment of inertia of rotor";
|
---|
159 | parameter SIunits.CoefficientOfFriction B = 3.032e-3 "Shaft coefficient of friction";
|
---|
160 | parameter SIunits.MagneticFlux Phi = 0.72 "Magnetic flux amplitude";
|
---|
161 | // Variables
|
---|
162 | // SIunits.ActivePower Pt;
|
---|
163 | // SIunits.ReactivePower Qt;
|
---|
164 | // Connectors
|
---|
165 | Modelica.Electrical.Analog.Interfaces.PositivePin Vp "Armature positive terminal" annotation(
|
---|
166 | Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
167 | Modelica.Electrical.Analog.Interfaces.NegativePin Vn "Armature negative terminal" annotation(
|
---|
168 | Placement(visible = true, transformation(origin = {-100, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
169 | Modelica.Mechanics.Rotational.Interfaces.Flange_a Axle "Rotos axis" annotation(
|
---|
170 | Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
171 | Modelica.Electrical.Analog.Basic.Resistor R1(R = Ra) annotation(
|
---|
172 | Placement(visible = true, transformation(origin = {-68, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
173 | Modelica.Electrical.Analog.Basic.Inductor L1(L = La) annotation(
|
---|
174 | Placement(visible = true, transformation(origin = {-36, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
175 | Modelica.Mechanics.Rotational.Components.Inertia inertia1(J = J) annotation(
|
---|
176 | Placement(visible = true, transformation(origin = {82, -18}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
|
---|
177 | Modelica.Mechanics.Rotational.Components.Damper damper1(d = B) annotation(
|
---|
178 | Placement(visible = true, transformation(origin = {82, -44}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
---|
179 | Modelica.Mechanics.Rotational.Sources.Torque torque1 annotation(
|
---|
180 | Placement(visible = true, transformation(origin = {62, -58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
181 | Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor1 annotation(
|
---|
182 | Placement(visible = true, transformation(origin = {-12, -58}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
|
---|
183 | Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor1 annotation(
|
---|
184 | Placement(visible = true, transformation(origin = {60, 12}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
185 | Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage1 annotation(
|
---|
186 | Placement(visible = true, transformation(origin = {-12, -24}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
---|
187 | Modelica.Blocks.Math.Gain gain1(k = Phi) annotation(
|
---|
188 | Placement(visible = true, transformation(origin = {26, 12}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
189 | Modelica.Blocks.Math.Gain gain2(k = Phi) annotation(
|
---|
190 | Placement(visible = true, transformation(origin = {24, -58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
191 | equation
|
---|
192 | connect(gain2.y, torque1.tau) annotation(
|
---|
193 | Line(points = {{36, -58}, {50, -58}, {50, -58}, {50, -58}}, color = {0, 0, 127}));
|
---|
194 | connect(currentSensor1.i, gain2.u) annotation(
|
---|
195 | Line(points = {{-2, -58}, {12, -58}, {12, -58}, {12, -58}, {12, -58}}, color = {0, 0, 127}));
|
---|
196 | connect(damper1.flange_b, torque1.flange) annotation(
|
---|
197 | Line(points = {{82, -54}, {82, -58}, {72, -58}}));
|
---|
198 | connect(inertia1.flange_a, damper1.flange_a) annotation(
|
---|
199 | Line(points = {{82, -28}, {82, -34}}));
|
---|
200 | connect(inertia1.flange_b, Axle) annotation(
|
---|
201 | Line(points = {{82, -8}, {82, 0}, {100, 0}}));
|
---|
202 | connect(gain1.y, signalVoltage1.v) annotation(
|
---|
203 | Line(points = {{14, 12}, {6, 12}, {6, -24}, {-4, -24}, {-4, -24}}, color = {0, 0, 127}));
|
---|
204 | connect(speedSensor1.w, gain1.u) annotation(
|
---|
205 | Line(points = {{48, 12}, {40, 12}, {40, 12}, {38, 12}}, color = {0, 0, 127}));
|
---|
206 | connect(signalVoltage1.p, L1.n) annotation(
|
---|
207 | Line(points = {{-12, -14}, {-12, 0}, {-26, 0}}, color = {0, 0, 255}));
|
---|
208 | connect(currentSensor1.p, signalVoltage1.n) annotation(
|
---|
209 | Line(points = {{-12, -48}, {-12, -48}, {-12, -34}, {-12, -34}}, color = {0, 0, 255}));
|
---|
210 | connect(Axle, speedSensor1.flange) annotation(
|
---|
211 | Line(points = {{100, 0}, {82, 0}, {82, 12}, {70, 12}, {70, 12}}));
|
---|
212 | connect(Vn, currentSensor1.n) annotation(
|
---|
213 | Line(points = {{-100, -80}, {-12, -80}, {-12, -68}, {-12, -68}}, color = {0, 0, 255}));
|
---|
214 | connect(L1.p, R1.n) annotation(
|
---|
215 | Line(points = {{-46, 0}, {-58, 0}, {-58, 0}, {-58, 0}}, color = {0, 0, 255}));
|
---|
216 | connect(Vp, R1.p) annotation(
|
---|
217 | Line(points = {{-100, 0}, {-78, 0}, {-78, 0}, {-78, 0}}, color = {0, 0, 255}));
|
---|
218 | annotation(
|
---|
219 | Icon(graphics = {Rectangle(origin = {80, -80}, rotation = -90, fillColor = {0, 255, 0}, fillPattern = FillPattern.Solid, extent = {{-130, 10}, {-100, -10}}), Rectangle(origin = {80, -20}, rotation = -90, fillColor = {255, 0, 0}, fillPattern = FillPattern.Solid, extent = {{-100, 10}, {-70, -10}}), Ellipse(extent = {{-70, -70}, {70, 70}}, endAngle = 360), Line(origin = {-28.9818, -58.4058}, points = {{-41.0182, -21.5942}, {-17.0182, 6.40582}}), Line(origin = {0.0972863, -78.99}, points = {{45.9027, 26.99}, {69.9027, -1.01003}, {-70.0973, -1.01003}}), Ellipse(extent = {{-40, -40}, {40, 40}}, endAngle = 360), Line(origin = {69.9552, -22.1621}, points = {{-29.9552, 22.1621}, {30.0448, 22.1621}}), Line(origin = {-94.991, -51.6674}, points = {{28.991, 25.991}, {-5.009, -8.009}, {-5.00902, -28.009}}), Line(origin = {-80.7929, -4.20711}, points = {{-19.2071, 4.20711}, {10.7929, 4.20711}}), Text(origin = {4, 105}, extent = {{-98, 27}, {98, -27}}, textString = "%name")}, coordinateSystem(initialScale = 0.1)),
|
---|
220 | experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-6, Interval = 0.0020202),
|
---|
221 | __OpenModelica_simulationFlags(lv = "LOG_STATS", s = "dassl"));
|
---|
222 | end SimpleDCMachine2;
|
---|
223 |
|
---|
224 | block Chopper4Logic
|
---|
225 | parameter Real period = 100e-6 "PWM period";
|
---|
226 | Modelica.Blocks.Logical.And and1 annotation(
|
---|
227 | Placement(visible = true, transformation(origin = {62, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
228 | Modelica.Blocks.Interfaces.RealInput duty annotation(
|
---|
229 | Placement(visible = true, transformation(origin = {-98, 68}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
230 | Modelica.Blocks.Interfaces.BooleanOutput H1 annotation(
|
---|
231 | Placement(visible = true, transformation(origin = {110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
232 | Modelica.Blocks.Interfaces.BooleanOutput L1 annotation(
|
---|
233 | Placement(visible = true, transformation(origin = {110, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
234 | Modelica.Blocks.Logical.GreaterEqual greaterEqual1 annotation(
|
---|
235 | Placement(visible = true, transformation(origin = {-50, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
236 | Modelica.Blocks.Math.Abs abs1 annotation(
|
---|
237 | Placement(visible = true, transformation(origin = {-54, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
238 | Modelica.Blocks.Logical.GreaterEqual greaterEqual2 annotation(
|
---|
239 | Placement(visible = true, transformation(origin = {-24, -38}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
240 | Modelica.Blocks.Sources.Constant const(k = 0) annotation(
|
---|
241 | Placement(visible = true, transformation(origin = {-68, 48}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
242 | Modelica.Blocks.Logical.Not not1 annotation(
|
---|
243 | Placement(visible = true, transformation(origin = {28, -38}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
244 | Modelica.Blocks.Logical.And and12 annotation(
|
---|
245 | Placement(visible = true, transformation(origin = {74, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
246 | Modelica.Blocks.Interfaces.BooleanOutput H2 annotation(
|
---|
247 | Placement(visible = true, transformation(origin = {110, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
248 | Modelica.Blocks.Logical.Not not11 annotation(
|
---|
249 | Placement(visible = true, transformation(origin = {26, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
250 | Modelica.Blocks.Interfaces.BooleanOutput L2 annotation(
|
---|
251 | Placement(visible = true, transformation(origin = {110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
252 | Modelica.Blocks.Logical.Or or1 annotation(
|
---|
253 | Placement(visible = true, transformation(origin = {74, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
254 | Modelica.Blocks.Logical.Or or11 annotation(
|
---|
255 | Placement(visible = true, transformation(origin = {74, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
256 | SawTooth sawTooth1(period = period) annotation(
|
---|
257 | Placement(visible = true, transformation(origin = {-84, -46}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
258 | equation
|
---|
259 | connect(greaterEqual2.u2, sawTooth1.y) annotation(
|
---|
260 | Line(points = {{-36, -46}, {-72, -46}, {-72, -46}, {-72, -46}}, color = {0, 0, 127}));
|
---|
261 | //greaterEqual2.u2 = OpenModelica.Internal.realMod(time, period);
|
---|
262 | connect(or11.u1, not11.y) annotation(
|
---|
263 | Line(points = {{62, -20}, {48, -20}, {48, 20}, {38, 20}, {38, 20}}, color = {255, 0, 255}));
|
---|
264 | connect(not1.y, or11.u2) annotation(
|
---|
265 | Line(points = {{40, -38}, {50, -38}, {50, -28}, {62, -28}, {62, -28}}, color = {255, 0, 255}));
|
---|
266 | connect(not1.y, or1.u1) annotation(
|
---|
267 | Line(points = {{40, -38}, {50, -38}, {50, -60}, {62, -60}, {62, -60}}, color = {255, 0, 255}));
|
---|
268 | connect(greaterEqual1.y, or1.u2) annotation(
|
---|
269 | Line(points = {{-38, 80}, {-6, 80}, {-6, -68}, {62, -68}, {62, -68}}, color = {255, 0, 255}));
|
---|
270 | connect(L1, or11.y) annotation(
|
---|
271 | Line(points = {{110, -20}, {84, -20}, {84, -20}, {86, -20}}, color = {255, 0, 255}));
|
---|
272 | connect(L2, or1.y) annotation(
|
---|
273 | Line(points = {{110, -60}, {86, -60}, {86, -60}, {86, -60}}, color = {255, 0, 255}));
|
---|
274 | connect(and1.y, H1) annotation(
|
---|
275 | Line(points = {{73, 80}, {90, 80}, {90, 60}, {110, 60}}, color = {255, 0, 255}));
|
---|
276 | connect(not11.u, greaterEqual1.y) annotation(
|
---|
277 | Line(points = {{14, 20}, {-6, 20}, {-6, 80}, {-38, 80}}, color = {255, 0, 255}));
|
---|
278 | connect(and12.u2, greaterEqual2.y) annotation(
|
---|
279 | Line(points = {{62, 12}, {40, 12}, {40, -8}, {4, -8}, {4, -38}, {-12, -38}}, color = {255, 0, 255}));
|
---|
280 | connect(and12.u1, not11.y) annotation(
|
---|
281 | Line(points = {{62, 20}, {38, 20}}, color = {255, 0, 255}));
|
---|
282 | connect(H2, and12.y) annotation(
|
---|
283 | Line(points = {{110, 20}, {85, 20}}, color = {255, 0, 255}));
|
---|
284 | connect(greaterEqual2.y, not1.u) annotation(
|
---|
285 | Line(points = {{-12, -38}, {14, -38}, {14, -38}, {16, -38}}, color = {255, 0, 255}));
|
---|
286 | connect(greaterEqual1.y, and1.u1) annotation(
|
---|
287 | Line(points = {{-38, 80}, {50, 80}}, color = {255, 0, 255}));
|
---|
288 | connect(greaterEqual2.y, and1.u2) annotation(
|
---|
289 | Line(points = {{-12, -38}, {4, -38}, {4, 72}, {50, 72}}, color = {255, 0, 255}));
|
---|
290 | connect(const.y, greaterEqual1.u2) annotation(
|
---|
291 | Line(points = {{-56, 48}, {-48, 48}, {-48, 66}, {-74, 66}, {-74, 72}, {-62, 72}, {-62, 72}}, color = {0, 0, 127}));
|
---|
292 | connect(abs1.y, greaterEqual2.u1) annotation(
|
---|
293 | Line(points = {{-42, -6}, {-40, -6}, {-40, -38}, {-36, -38}, {-36, -38}}, color = {0, 0, 127}));
|
---|
294 | connect(greaterEqual1.u1, duty) annotation(
|
---|
295 | Line(points = {{-62, 80}, {-84, 80}, {-84, 68}, {-98, 68}, {-98, 68}}, color = {0, 0, 127}));
|
---|
296 | connect(duty, abs1.u) annotation(
|
---|
297 | Line(points = {{-98, 68}, {-84, 68}, {-84, -6}, {-66, -6}, {-66, -6}}, color = {0, 0, 255}));
|
---|
298 | annotation(
|
---|
299 | uses(Modelica(version = "3.2.2")),
|
---|
300 | Icon(graphics = {Text(origin = {-2, 125}, extent = {{-90, 19}, {90, -19}}, textString = "%name"), Rectangle(origin = {1, -1}, extent = {{-101, 101}, {99, -99}}), Text(origin = {-4, -119}, extent = {{-140, 17}, {140, -17}}, textString = "period=%period"), Text(origin = {62, 60}, extent = {{-8, 20}, {26, -20}}, textString = "H1", fontSize = 16), Text(origin = {62, 20}, extent = {{-8, 20}, {26, -20}}, textString = "H2", fontSize = 16), Text(origin = {64, -20}, extent = {{-8, 20}, {26, -20}}, textString = "L1", fontSize = 16), Text(origin = {64, -62}, extent = {{-8, 20}, {26, -20}}, textString = "L2", fontSize = 16), Text(origin = {-52, 62}, extent = {{-40, 18}, {18, -18}}, textString = "duty", fontSize = 16)}, coordinateSystem(initialScale = 0.1)),
|
---|
301 | experiment(StartTime = 0, StopTime = 0.3, Tolerance = 0.0001, Interval = 6e-06),
|
---|
302 | __OpenModelica_simulationFlags(iim = "symbolic", lv = "LOG_STATS", s = "dassl"));
|
---|
303 | end Chopper4Logic;
|
---|
304 |
|
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 | model DCMotorTest4
|
---|
309 | extends Modelica.Icons.Example;
|
---|
310 | Modelica.Electrical.Analog.Sources.ConstantVoltage VBUS(V = 180) annotation(
|
---|
311 | Placement(visible = true, transformation(origin = {-8, 36}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
---|
312 | DCDrive.Chopper4Logic chopper4Logic1(period = 100.123e-6) annotation(
|
---|
313 | Placement(visible = true, transformation(origin = {10, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
314 | Modelica.Blocks.Sources.Constant const(k = 209) annotation(
|
---|
315 | Placement(visible = true, transformation(origin = {-178, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
316 | Modelica.Electrical.PowerConverters.DCAC.SinglePhase2Level singlePhase2Level1 annotation(
|
---|
317 | Placement(visible = true, transformation(origin = {64, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
318 | Modelica.Electrical.PowerConverters.DCAC.SinglePhase2Level singlePhase2Level2 annotation(
|
---|
319 | Placement(visible = true, transformation(origin = {38, 24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
320 | DCDrive.SimpleDCMachine2 simpleDCMachine21(Ra = 6) annotation(
|
---|
321 | Placement(visible = true, transformation(origin = {114, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
322 | Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor1 annotation(
|
---|
323 | Placement(visible = true, transformation(origin = {88, 24}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
324 | Modelica.Blocks.Math.Feedback feedback1 annotation(
|
---|
325 | Placement(visible = true, transformation(origin = {-56, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
326 | Modelica.Blocks.Math.Gain gain1(k = 100) annotation(
|
---|
327 | Placement(visible = true, transformation(origin = {-24, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
328 | // ZOH zeroOrderHold1(samplePeriod = 100e-6) annotation(
|
---|
329 | // Placement(visible = true, transformation(origin = {58, -30}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
330 | Modelica.Blocks.Discrete.ZeroOrderHold zeroOrderHold1(samplePeriod = 100e-6) annotation(
|
---|
331 | Placement(visible = true, transformation(origin = {58, -30}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
332 | Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor1 annotation(
|
---|
333 | Placement(visible = true, transformation(origin = {132, 30}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
|
---|
334 | Modelica.Blocks.Math.Gain gain2(k = 1) annotation(
|
---|
335 | Placement(visible = true, transformation(origin = {-114, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
336 | Modelica.Blocks.Math.Feedback feedback2 annotation(
|
---|
337 | Placement(visible = true, transformation(origin = {-148, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
338 | Modelica.Blocks.Nonlinear.Limiter limiter1(limitsAtInit = true, uMax = 6) annotation(
|
---|
339 | Placement(visible = true, transformation(origin = {-82, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
|
---|
340 | ZOH zeroOrderHold2(samplePeriod = 100e-6) annotation(
|
---|
341 | Placement(visible = true, transformation(origin = {96, -44}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
|
---|
342 | equation
|
---|
343 | connect(zeroOrderHold2.y, feedback2.u2) annotation(
|
---|
344 | Line(points = {{85, -44}, {-148, -44}, {-148, -8}}, color = {0, 0, 127}));
|
---|
345 | connect(speedSensor1.w, zeroOrderHold2.u) annotation(
|
---|
346 | Line(points = {{132, 19}, {132, -44}, {108, -44}}, color = {0, 0, 127}));
|
---|
347 | connect(gain2.y, limiter1.u) annotation(
|
---|
348 | Line(points = {{-102, 0}, {-96, 0}, {-96, 0}, {-94, 0}}, color = {0, 0, 127}));
|
---|
349 | connect(feedback1.u1, limiter1.y) annotation(
|
---|
350 | Line(points = {{-64, 0}, {-72, 0}, {-72, 0}, {-70, 0}}, color = {0, 0, 127}));
|
---|
351 | connect(feedback2.y, gain2.u) annotation(
|
---|
352 | Line(points = {{-139, 0}, {-126, 0}}, color = {0, 0, 127}));
|
---|
353 | connect(const.y, feedback2.u1) annotation(
|
---|
354 | Line(points = {{-167, 0}, {-156, 0}}, color = {0, 0, 127}));
|
---|
355 | connect(speedSensor1.flange, simpleDCMachine21.Axle) annotation(
|
---|
356 | Line(points = {{132, 40}, {133, 40}, {133, 50}, {124, 50}}));
|
---|
357 | connect(currentSensor1.i, zeroOrderHold1.u) annotation(
|
---|
358 | Line(points = {{88, 14}, {88, 14}, {88, -30}, {70, -30}, {70, -30}}, color = {0, 0, 127}));
|
---|
359 | connect(zeroOrderHold1.y, feedback1.u2) annotation(
|
---|
360 | Line(points = {{47, -30}, {-55, -30}, {-55, -8}, {-55, -8}}, color = {0, 0, 127}));
|
---|
361 | connect(chopper4Logic1.duty, gain1.y) annotation(
|
---|
362 | Line(points = {{-1, 0}, {-13, 0}, {-13, 0}, {-13, 0}}, color = {0, 0, 127}));
|
---|
363 | connect(gain1.u, feedback1.y) annotation(
|
---|
364 | Line(points = {{-36, 0}, {-48, 0}, {-48, 0}, {-46, 0}}, color = {0, 0, 127}));
|
---|
365 | connect(simpleDCMachine21.Vn, currentSensor1.p) annotation(
|
---|
366 | Line(points = {{104, 42}, {104, 42}, {104, 24}, {98, 24}, {98, 24}}, color = {0, 0, 255}));
|
---|
367 | connect(currentSensor1.n, singlePhase2Level2.ac) annotation(
|
---|
368 | Line(points = {{78, 24}, {48, 24}, {48, 24}, {48, 24}}, color = {0, 0, 255}));
|
---|
369 | connect(simpleDCMachine21.Vp, singlePhase2Level1.ac) annotation(
|
---|
370 | Line(points = {{104, 50}, {74, 50}, {74, 50}, {74, 50}}, color = {0, 0, 255}));
|
---|
371 | connect(chopper4Logic1.L2, singlePhase2Level2.fire_n) annotation(
|
---|
372 | Line(points = {{21, -12}, {43, -12}, {43, 12}}, color = {255, 0, 255}));
|
---|
373 | connect(VBUS.n, singlePhase2Level2.dc_n) annotation(
|
---|
374 | Line(points = {{-8, 26}, {-8, 18}, {28, 18}}, color = {0, 0, 255}));
|
---|
375 | connect(singlePhase2Level2.dc_p, VBUS.p) annotation(
|
---|
376 | Line(points = {{28, 30}, {10, 30}, {10, 46}, {-8, 46}}, color = {0, 0, 255}));
|
---|
377 | connect(chopper4Logic1.H2, singlePhase2Level2.fire_p) annotation(
|
---|
378 | Line(points = {{21, -4}, {31, -4}, {31, 12}}, color = {255, 0, 255}));
|
---|
379 | connect(singlePhase2Level1.dc_n, VBUS.n) annotation(
|
---|
380 | Line(points = {{54, 44}, {16, 44}, {16, 26}, {-8, 26}}, color = {0, 0, 255}));
|
---|
381 | connect(VBUS.p, singlePhase2Level1.dc_p) annotation(
|
---|
382 | Line(points = {{-8, 46}, {-8, 56}, {54, 56}}, color = {0, 0, 255}));
|
---|
383 | connect(chopper4Logic1.L1, singlePhase2Level1.fire_n) annotation(
|
---|
384 | Line(points = {{21, -8}, {69, -8}, {69, 38}}, color = {255, 0, 255}));
|
---|
385 | connect(chopper4Logic1.H1, singlePhase2Level1.fire_p) annotation(
|
---|
386 | Line(points = {{21, 0}, {57, 0}, {57, 38}}, color = {255, 0, 255}));
|
---|
387 | annotation(
|
---|
388 | experiment(StartTime = 0, StopTime = 0.5, Tolerance = 0.0001, Interval = 6e-07),
|
---|
389 | __OpenModelica_simulationFlags(lv = "LOG_STATS", s = "rungekuttaSsc", iim = "symbolic", maxStepSize = "0.7e-6"));
|
---|
390 | end DCMotorTest4;
|
---|
391 |
|
---|
392 |
|
---|
393 | annotation(
|
---|
394 | uses(Modelica(version = "3.2.2")));
|
---|
395 | end DCDrive;
|
---|