Ticket #3580: testOM.mo

File testOM.mo, 16.2 KB (added by massimo ceraolo, 11 years ago)
Line 
1within ;
2encapsulated package testOM
3 import Modelica;
4
5 model test "Trifase con switches ideali individuali OM dev490 BAD"
6 parameter Real Rf=0.125;
7 parameter Real Lf=0.001;
8 parameter Real Cf=0.000634;
9 parameter Real Rld=30.0;
10 Modelica.Blocks.Sources.Constant ampl[3](k=0.7) annotation (Placement(
11 visible=true, transformation(
12 origin={78,70},
13 extent={{-10,10},{10,-10}},
14 rotation=180)));
15 Modelica.Blocks.Sources.Constant phase[3](k=-array(120*(j - 1) for j in 1:3))
16 annotation (Placement(visible=true, transformation(
17 origin={55,49},
18 extent={{-10,10},{10,-10}},
19 rotation=180)));
20 Modelica.Electrical.Analog.Sources.ConstantVoltage V1(V=100) annotation (
21 Placement(visible=true, transformation(
22 origin={-94,20},
23 extent={{-10,10},{10,-10}},
24 rotation=270)));
25 PwmPulser pwmPulser[3] annotation (Placement(visible=true, transformation(
26 origin={18,56},
27 extent={{-13,13},{13,-13}},
28 rotation=180)));
29 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S1 annotation (
30 Placement(visible=true, transformation(
31 origin={-74,60},
32 extent={{-10,-10},{10,10}},
33 rotation=-90)));
34 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S5 annotation (
35 Placement(visible=true, transformation(
36 origin={-34,60},
37 extent={{-10,-10},{10,10}},
38 rotation=-90)));
39 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S4 annotation (
40 Placement(visible=true, transformation(
41 origin={-74,-20},
42 extent={{-10,-10},{10,10}},
43 rotation=-90)));
44 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S6 annotation (
45 Placement(visible=true, transformation(
46 origin={-54,-20},
47 extent={{-10,-10},{10,10}},
48 rotation=-90)));
49 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S2 annotation (
50 Placement(visible=true, transformation(
51 origin={-34,-20},
52 extent={{-10,-10},{10,10}},
53 rotation=-90)));
54 Modelica.Electrical.Analog.Ideal.IdealClosingSwitch S3 annotation (
55 Placement(visible=true, transformation(
56 origin={-54,60},
57 extent={{-10,-15},{10,15}},
58 rotation=-90)));
59 Modelica.Electrical.Analog.Basic.Resistor Rf1(R=Rf)
60 annotation (Placement(transformation(extent={{4,14},{24,34}})));
61 Modelica.Electrical.Analog.Basic.Inductor Lf1(L=Lf)
62 annotation (Placement(transformation(extent={{30,14},{50,34}})));
63 Modelica.Electrical.Analog.Basic.Capacitor Ff1(C=Cf) annotation (Placement(
64 transformation(
65 extent={{-10,-10},{10,10}},
66 rotation=-90,
67 origin={62,14})));
68 Modelica.Electrical.Analog.Basic.Resistor Rld1(R=Rld) annotation (Placement(
69 transformation(
70 extent={{-10,-10},{10,10}},
71 rotation=-90,
72 origin={84,15})));
73 Modelica.Electrical.Analog.Basic.Resistor Rf2(R=Rf)
74 annotation (Placement(transformation(extent={{1,-20},{21,0}})));
75 Modelica.Electrical.Analog.Basic.Inductor Lf2(L=Lf)
76 annotation (Placement(transformation(extent={{27,-20},{47,0}})));
77 Modelica.Electrical.Analog.Basic.Capacitor Ff2(C=Cf) annotation (Placement(
78 transformation(
79 extent={{-10,-10},{10,10}},
80 rotation=-90,
81 origin={59,-20})));
82 Modelica.Electrical.Analog.Basic.Resistor Rld2(R=Rld) annotation (Placement(
83 transformation(
84 extent={{-10,-10},{10,10}},
85 rotation=-90,
86 origin={81,-19})));
87 Modelica.Electrical.Analog.Basic.Resistor Rf3(R=Rf)
88 annotation (Placement(transformation(extent={{3,-54},{23,-34}})));
89 Modelica.Electrical.Analog.Basic.Inductor Lf3(L=Lf)
90 annotation (Placement(transformation(extent={{29,-54},{49,-34}})));
91 Modelica.Electrical.Analog.Basic.Capacitor Ff3(C=Cf) annotation (Placement(
92 transformation(
93 extent={{-10,-10},{10,10}},
94 rotation=-90,
95 origin={61,-54})));
96 Modelica.Electrical.Analog.Basic.Resistor Rld3(R=Rld) annotation (Placement(
97 transformation(
98 extent={{-10,-10},{10,10}},
99 rotation=-90,
100 origin={83,-53})));
101 Modelica.Electrical.Analog.Basic.Ground ground
102 annotation (Placement(transformation(extent={{110,-47},{130,-27}})));
103 equation
104 connect(S1.n, S4.p) annotation (Line(
105 points={{-74,50},{-74,-10}},
106 color={0,0,255},
107 smooth=Smooth.None));
108 connect(S3.n, S6.p) annotation (Line(
109 points={{-54,50},{-54,-10}},
110 color={0,0,255},
111 smooth=Smooth.None));
112 connect(S5.n, S2.p) annotation (Line(
113 points={{-34,50},{-34,-10}},
114 color={0,0,255},
115 smooth=Smooth.None));
116 connect(S5.p, S1.p) annotation (Line(
117 points={{-34,70},{-34,79},{-74,79},{-74,70}},
118 color={0,0,255},
119 smooth=Smooth.None));
120 connect(S3.p, S1.p) annotation (Line(
121 points={{-54,70},{-54,79},{-74,79},{-74,70}},
122 color={0,0,255},
123 smooth=Smooth.None));
124 connect(S4.n, S2.n) annotation (Line(
125 points={{-74,-30},{-74,-40},{-34,-40},{-34,-30}},
126 color={0,0,255},
127 smooth=Smooth.None));
128 connect(S6.n, S2.n) annotation (Line(
129 points={{-54,-30},{-54,-40},{-34,-40},{-34,-30}},
130 color={0,0,255},
131 smooth=Smooth.None));
132 connect(pwmPulser[1].up, S1.control) annotation (Line(
133 points={{3.7,64.58},{-8,64.58},{-8,74},{-67,74},{-67,60}},
134 color={255,0,255},
135 smooth=Smooth.None));
136 connect(pwmPulser[2].up, S3.control) annotation (Line(
137 points={{3.7,64.58},{-16,64.58},{-16,67},{-43.5,67},{-43.5,60}},
138 color={255,0,255},
139 smooth=Smooth.None));
140 connect(pwmPulser[3].up, S5.control) annotation (Line(
141 points={{3.7,64.58},{-15,64.58},{-15,60},{-27,60}},
142 color={255,0,255},
143 smooth=Smooth.None));
144 connect(pwmPulser[1].down, S4.control) annotation (Line(
145 points={{3.7,48.46},{-5,48.46},{-5,-36},{-67,-36},{-67,-20}},
146 color={255,0,255},
147 smooth=Smooth.None));
148 connect(pwmPulser[2].down, S6.control) annotation (Line(
149 points={{3.7,48.46},{-5,48.46},{-5,-36},{-47,-36},{-47,-20}},
150 color={255,0,255},
151 smooth=Smooth.None));
152 connect(pwmPulser[3].down, S2.control) annotation (Line(
153 points={{3.7,48.46},{-5,48.46},{-5,-36},{-27,-36},{-27,-20}},
154 color={255,0,255},
155 smooth=Smooth.None));
156 connect(V1.p, S1.p) annotation (Line(
157 points={{-94,30},{-94,80},{-73,80},{-73,79},{-74,79},{-74,70}},
158 color={0,0,255},
159 smooth=Smooth.None));
160 connect(V1.n, S2.n) annotation (Line(
161 points={{-94,10},{-94,-41},{-73,-41},{-73,-39},{-74,-39},{-74,-40},{-34,
162 -40},{-34,-30}},
163 color={0,0,255},
164 smooth=Smooth.None));
165 connect(Rf1.n, Lf1.p) annotation (Line(
166 points={{24,24},{30,24}},
167 color={0,0,255},
168 smooth=Smooth.None));
169 connect(Lf1.n, Ff1.p) annotation (Line(
170 points={{50,24},{62,24}},
171 color={0,0,255},
172 smooth=Smooth.None));
173 connect(Rld1.p, Ff1.p) annotation (Line(
174 points={{84,25},{62,25},{62,24}},
175 color={0,0,255},
176 smooth=Smooth.None));
177 connect(Rf2.n, Lf2.p) annotation (Line(
178 points={{21,-10},{27,-10}},
179 color={0,0,255},
180 smooth=Smooth.None));
181 connect(Lf2.n, Ff2.p) annotation (Line(
182 points={{47,-10},{59,-10}},
183 color={0,0,255},
184 smooth=Smooth.None));
185 connect(Rld2.p, Ff2.p) annotation (Line(
186 points={{81,-9},{71,-9},{71,-10},{59,-10}},
187 color={0,0,255},
188 smooth=Smooth.None));
189 connect(Rf3.n, Lf3.p) annotation (Line(
190 points={{23,-44},{29,-44}},
191 color={0,0,255},
192 smooth=Smooth.None));
193 connect(Lf3.n, Ff3.p) annotation (Line(
194 points={{49,-44},{61,-44}},
195 color={0,0,255},
196 smooth=Smooth.None));
197 connect(Rld3.p, Ff3.p) annotation (Line(
198 points={{83,-43},{73,-43},{73,-44},{61,-44}},
199 color={0,0,255},
200 smooth=Smooth.None));
201 connect(Rf1.p, S4.p) annotation (Line(
202 points={{4,24},{4,24},{-14,24},{-14,24},{-14,37},{-74,37},{-74,-10}},
203 color={0,0,255},
204 smooth=Smooth.None));
205 connect(Rf2.p, S6.p) annotation (Line(
206 points={{1,-10},{-7,-10},{-7,-10},{-14,-10},{-14,14},{-54,14},{-54,-10}},
207
208 color={0,0,255},
209 smooth=Smooth.None));
210
211 connect(Rf3.p, S2.p) annotation (Line(
212 points={{3,-44},{3,-22},{-21,-22},{-21,4},{-34,4},{-34,-10}},
213 color={0,0,255},
214 smooth=Smooth.None));
215 connect(Ff1.n, Rld1.n) annotation (Line(
216 points={{62,4},{62,5},{84,5}},
217 color={0,0,255},
218 smooth=Smooth.None));
219 connect(ground.p, Rld1.n) annotation (Line(
220 points={{120,-27},{120,5},{84,5}},
221 color={0,0,255},
222 smooth=Smooth.None));
223 connect(ground.p, Rld2.n) annotation (Line(
224 points={{120,-27},{102,-27},{102,-29},{81,-29}},
225 color={0,0,255},
226 smooth=Smooth.None));
227 connect(Rld2.n, Ff2.n) annotation (Line(
228 points={{81,-29},{71,-29},{71,-30},{59,-30}},
229 color={0,0,255},
230 smooth=Smooth.None));
231 connect(ground.p, Rld3.n) annotation (Line(
232 points={{120,-27},{106,-27},{106,-63},{83,-63}},
233 color={0,0,255},
234 smooth=Smooth.None));
235 connect(Rld3.n, Ff3.n) annotation (Line(
236 points={{83,-63},{73,-63},{73,-64},{61,-64}},
237 color={0,0,255},
238 smooth=Smooth.None));
239 connect(ampl.y, pwmPulser.ampl) annotation (Line(points={{67,70},{55,70},{
240 41,70},{41,64.32},{33.6,64.32}}, color={0,0,127}));
241 connect(phase.y, pwmPulser.ph_deg) annotation (Line(points={{44,49},{40,49},
242 {40,48.98},{33.6,48.98}}, color={0,0,127}));
243 annotation (
244 experimentSetupOutput,
245 Documentation(info="<html>
246<p>Il risultato &egrave; identico a quello che si ha con interruttori pilotati e dioidi in antiparallelo entrambi iteali.</p>
247<p>Questo perch&eacute; con un controllo senza blanking time i due inverter sono identici.</p>
248<p>Il sisema pi&ugrave; fisico &egrave; superiore perch&eacute; consente di valutare anche gli effetti del blanking time.</p>
249</html>"),
250 experiment(
251 StartTime=0,
252 StopTime=0.1,
253 Tolerance=0.0001),
254 Diagram(coordinateSystem(
255 extent={{-100,-80},{140,100}},
256 preserveAspectRatio=false,
257 initialScale=0.1,
258 grid={1,1})),
259 Icon(coordinateSystem(
260 extent={{-100,-80},{140,100}},
261 preserveAspectRatio=false,
262 initialScale=0.1,
263 grid={1,1})));
264 end test;
265
266 model PwmPulser
267 Modelica.Blocks.Interfaces.RealInput ampl annotation (Placement(
268 transformation(extent={{-140,40},{-100,80}}), iconTransformation(
269 extent={{-140,44},{-100,84}})));
270 Modelica.Blocks.Interfaces.RealInput ph_deg annotation (Placement(
271 transformation(extent={{-138,-76},{-98,-36}}), iconTransformation(
272 extent={{-140,-74},{-100,-34}})));
273 parameter Real Fcar=1000 "Carrier Frequency";
274 import PI = Modelica.Constants.pi;
275 protected
276 Modelica.Blocks.Sources.Trapezoid carrier(
277 rising=1/(2*Fcar),
278 width=0,
279 falling=1/(2*Fcar),
280 period=1/Fcar,
281 amplitude=2,
282 offset=-1)
283 annotation (Placement(transformation(extent={{14,-56},{34,-36}})));
284 Modelica.Blocks.Math.Sin sin
285 annotation (Placement(transformation(extent={{-20,-28},{0,-8}})));
286 Modelica.Blocks.Continuous.Integrator integrator
287 annotation (Placement(transformation(extent={{-50,16},{-32,34}})));
288 Modelica.Blocks.Sources.RealExpression realExpression(y=2*PI*Fmod)
289 annotation (Placement(transformation(extent={{-90,14},{-64,36}})));
290 public
291 Modelica.Blocks.Math.Add add
292 annotation (Placement(transformation(extent={{-54,-28},{-34,-8}})));
293 Modelica.Blocks.Math.Gain ToRAD(k=PI/180)
294 annotation (Placement(transformation(extent={{-66,-62},{-54,-50}})));
295 Modelica.Blocks.Math.Product moduler
296 annotation (Placement(transformation(extent={{14,-22},{32,-4}})));
297 Modelica.Blocks.Interfaces.BooleanOutput up annotation (Placement(
298 transformation(extent={{100,10},{120,30}}), iconTransformation(extent
299 ={{100,56},{120,76}})));
300 Modelica.Blocks.Logical.Greater greater
301 annotation (Placement(transformation(extent={{46,-24},{66,-4}})));
302 Modelica.Blocks.Interfaces.BooleanOutput down annotation (Placement(
303 transformation(extent={{100,-62},{120,-42}}), iconTransformation(
304 extent={{100,-68},{120,-48}})));
305 Modelica.Blocks.Logical.Not not1
306 annotation (Placement(transformation(extent={{60,-60},{80,-40}})));
307 parameter Real Fmod=50 "Moduler Frequency";
308 equation
309 connect(ToRAD.u, ph_deg) annotation (Line(
310 points={{-67.2,-56},{-118,-56}},
311 color={0,0,127},
312 smooth=Smooth.None));
313 connect(sin.u, add.y) annotation (Line(
314 points={{-22,-18},{-33,-18}},
315 color={0,0,127},
316 smooth=Smooth.None));
317 connect(moduler.u2, sin.y) annotation (Line(
318 points={{12.2,-18.4},{14,-18.4},{14,-18},{1,-18}},
319 color={0,0,127},
320 smooth=Smooth.None));
321 connect(add.u1, integrator.y) annotation (Line(
322 points={{-56,-12},{-64,-12},{-64,2},{-24,2},{-24,25},{-31.1,25}},
323 color={0,0,127},
324 smooth=Smooth.None));
325 connect(moduler.u1, ampl) annotation (Line(
326 points={{12.2,-7.6},{12.2,60},{-120,60}},
327 color={0,0,127},
328 smooth=Smooth.None));
329 connect(add.u2, ToRAD.y) annotation (Line(
330 points={{-56,-24},{-64,-24},{-64,-34},{-46,-34},{-46,-56},{-53.4,-56}},
331
332 color={0,0,127},
333 smooth=Smooth.None));
334
335 connect(greater.u1, moduler.y) annotation (Line(
336 points={{44,-14},{46.45,-14},{46.45,-13},{32.9,-13}},
337 color={0,0,127},
338 smooth=Smooth.None));
339 connect(greater.u2, carrier.y) annotation (Line(
340 points={{44,-22},{44,-46},{35,-46}},
341 color={0,0,127},
342 smooth=Smooth.None));
343 connect(up, greater.y) annotation (Line(
344 points={{110,20},{74,20},{74,-14},{67,-14}},
345 color={255,0,255},
346 smooth=Smooth.None));
347 connect(not1.y, down) annotation (Line(
348 points={{81,-50},{84,-50},{84,-52},{110,-52}},
349 color={255,0,255},
350 smooth=Smooth.None));
351 connect(not1.u, greater.y) annotation (Line(
352 points={{58,-50},{52,-50},{52,-32},{74,-32},{74,-14},{67,-14}},
353 color={255,0,255},
354 smooth=Smooth.None));
355 connect(integrator.u, realExpression.y) annotation (Line(
356 points={{-51.8,25},{-62.7,25}},
357 color={0,0,127},
358 smooth=Smooth.None));
359 annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
360 -100},{100,100}})), Icon(graphics={
361 Rectangle(
362 extent={{-100,100},{100,-100}},
363 lineColor={0,0,127},
364 fillPattern=FillPattern.Solid,
365 fillColor={255,255,255}),
366 Text(
367 extent={{-100,88},{-42,60}},
368 lineColor={0,0,127},
369 textString="ampl"),
370 Text(
371 extent={{-98,-62},{-28,-88}},
372 lineColor={0,0,127},
373 textString="ph(?)"),
374 Text(
375 extent={{28,86},{100,60}},
376 lineColor={255,0,255},
377 textString="u"),
378 Text(
379 extent={{42,-62},{96,-88}},
380 lineColor={255,0,255},
381 textString="d",
382 fillColor={255,255,255},
383 fillPattern=FillPattern.Solid),
384 Line(
385 points={{-60,-60},{-40,62},{-20,-60},{0,60},{20,-62},{40,60},{60,-62},
386 {80,58}},
387 color={0,0,127},
388 smooth=Smooth.None),
389 Line(
390 points={{-80,20},{-38,40},{0,44},{42,40},{80,20}},
391 color={0,0,127},
392 smooth=Smooth.None,
393 thickness=0.5)}));
394 end PwmPulser;
395
396 annotation (uses(Modelica(version="3.2.1")));
397end testOM;