forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.mo
3301 lines (3035 loc) · 149 KB
/
package.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within Modelica;
package Blocks "Library of basic input/output control blocks (continuous, discrete, logical, table blocks)"
extends Modelica.Icons.Package;
import Modelica.Units.SI;
package Examples
"Library of examples to demonstrate the usage of package Blocks"
extends Modelica.Icons.ExamplesPackage;
model PID_Controller
"Demonstrates the usage of a Continuous.LimPID controller"
extends Modelica.Icons.Example;
parameter SI.Angle driveAngle=1.570796326794897
"Reference distance to move";
Modelica.Blocks.Continuous.LimPID PI(
k=100,
Ti=0.1,
yMax=12,
Ni=0.1,
initType=Modelica.Blocks.Types.Init.SteadyState,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
limiter(u(start = 0)),
Td=0.1) annotation (Placement(transformation(extent={{-56,-20},{-36,0}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia1(
phi(fixed=true, start=0),
J=1,
a(fixed=true, start=0)) annotation (Placement(transformation(extent={{2,-20},
{22,0}})));
Modelica.Mechanics.Rotational.Sources.Torque torque annotation (Placement(
transformation(extent={{-25,-20},{-5,0}})));
Modelica.Mechanics.Rotational.Components.SpringDamper spring(
c=1e4,
d=100,
stateSelect=StateSelect.prefer,
w_rel(fixed=true)) annotation (Placement(transformation(extent={{32,-20},
{52,0}})));
Modelica.Mechanics.Rotational.Components.Inertia inertia2(J=2) annotation (
Placement(transformation(extent={{60,-20},{80,0}})));
Modelica.Blocks.Sources.KinematicPTP kinematicPTP(
startTime=0.5,
deltaq={driveAngle},
qd_max={1},
qdd_max={1}) annotation (Placement(transformation(extent={{-92,20},{-72,
40}})));
Modelica.Blocks.Continuous.Integrator integrator(initType=Modelica.Blocks.Types.Init.InitialState)
annotation (Placement(transformation(extent={{-63,20},{-43,40}})));
Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor annotation (
Placement(transformation(extent={{22,-50},{2,-30}})));
Modelica.Mechanics.Rotational.Sources.ConstantTorque loadTorque(
tau_constant=10, useSupport=false) annotation (Placement(transformation(
extent={{98,-15},{88,-5}})));
initial equation
der(spring.w_rel) = 0;
equation
connect(spring.flange_b, inertia2.flange_a)
annotation (Line(points={{52,-10},{60,-10}}));
connect(inertia1.flange_b, spring.flange_a)
annotation (Line(points={{22,-10},{32,-10}}));
connect(torque.flange, inertia1.flange_a)
annotation (Line(points={{-5,-10},{2,-10}}));
connect(kinematicPTP.y[1], integrator.u)
annotation (Line(points={{-71,30},{-65,30}}, color={0,0,127}));
connect(speedSensor.flange, inertia1.flange_b)
annotation (Line(points={{22,-40},{22,-10}}));
connect(loadTorque.flange, inertia2.flange_b)
annotation (Line(points={{88,-10},{80,-10}}));
connect(PI.y, torque.tau)
annotation (Line(points={{-35,-10},{-27,-10}}, color={0,0,127}));
connect(speedSensor.w, PI.u_m)
annotation (Line(points={{1,-40},{-46,-40},{-46,-22}}, color={0,0,127}));
connect(integrator.y, PI.u_s) annotation (Line(points={{-42,30},{-37,30},{-37,
11},{-67,11},{-67,-10},{-58,-10}}, color={0,0,127}));
annotation (
Diagram(coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}), graphics={
Rectangle(extent={{-99,48},{-32,8}}, lineColor={255,0,0}),
Text(
extent={{-98,59},{-31,51}},
textColor={255,0,0},
textString="reference speed generation"),
Text(
extent={{-98,-46},{-60,-52}},
textColor={255,0,0},
textString="PI controller"),
Line(
points={{-76,-44},{-57,-23}},
color={255,0,0},
arrow={Arrow.None,Arrow.Filled}),
Rectangle(extent={{-25,6},{99,-50}}, lineColor={255,0,0}),
Text(
extent={{4,14},{71,7}},
textColor={255,0,0},
textString="plant (simple drive train)")}),
experiment(StopTime=4),
Documentation(info="<html>
<p>
This is a simple drive train controlled by a PID controller:
</p>
<ul>
<li> The two blocks \"kinematic_PTP\" and \"integrator\" are used to generate
the reference speed (= constant acceleration phase, constant speed phase,
constant deceleration phase until inertia is at rest). To check
whether the system starts in steady state, the reference speed is
zero until time = 0.5 s and then follows the sketched trajectory.</li>
<li> The block \"PI\" is an instance of \"Blocks.Continuous.LimPID\" which is
a PID controller where several practical important aspects, such as
anti-windup-compensation has been added. In this case, the control block
is used as PI controller.</li>
<li> The output of the controller is a torque that drives a motor inertia
\"inertia1\". Via a compliant spring/damper component, the load
inertia \"inertia2\" is attached. A constant external torque of 10 Nm
is acting on the load inertia.</li>
</ul>
<p>
The PI controller is initialized in steady state (initType=SteadyState)
and the drive shall also be initialized in steady state.
However, it is not possible to initialize \"inertia1\" in SteadyState, because
\"der(inertia1.phi)=inertia1.w=0\" is an input to the PI controller that
defines that the derivative of the integrator state is zero (= the same
condition that was already defined by option SteadyState of the PI controller).
Furthermore, one initial condition is missing, because the absolute position
of inertia1 or inertia2 is not defined. The solution shown in this examples is
to initialize the angle and the angular acceleration of \"inertia1\".
</p>
<p>
In the following figure, results of a typical simulation are shown:
</p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/PID_controller.png\"
alt=\"PID_controller.png\"><br>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/PID_controller2.png\"
alt=\"PID_controller2.png\">
<p>
In the upper figure the reference speed (= integrator.y) and
the actual speed (= inertia1.w) are shown. As can be seen,
the system initializes in steady state, since no transients
are present. The inertia follows the reference speed quite good
until the end of the constant speed phase. Then there is a deviation.
In the lower figure the reason can be seen: The output of the
controller (PI.y) is in its limits. The anti-windup compensation
works reasonably, since the input to the limiter (PI.limiter.u)
is forced back to its limit after a transient phase.
</p>
</html>",
figures = {
Figure(
title = "Anti-windup compensation",
identifier = "anti-windup",
preferred = true,
plots = {
Plot(
title = "Reference tracking",
identifier = "tracking",
curves = {
Curve(y = integrator.y, legend = "Reference speed"),
Curve(y = inertia1.w, legend = "Actual speed")}),
Plot(
title = "Anti-windup limiter",
identifier = "limiter",
curves = {
Curve(y = PI.limiter.u, legend = "Input to the anti-windup limiter"),
Curve(y = PI.y, legend = "Controller output")})},
caption = "%(plot:tracking) Reference speed (%(variable:integrator.y)) and the actual speed (%(variable:inertia1.w)). The system initializes in steady state, since no transients are present. The inertia follows the reference speed quite good until the end of the constant speed phase. Then there is a deviation.
%(plot:limiter) Here the reason for the deviation can be seen: The output of the controller (%(variable:PI.y)) is in its limits. The anti-windup compensation works reasonably, since the input to the limiter (%(variable:PI.limiter.u)) is forced back to its limit after a transient phase.
")}));
end PID_Controller;
model Filter "Demonstrates the Continuous.Filter block with various options"
extends Modelica.Icons.Example;
parameter Integer order=3 "Number of order of filter";
parameter SI.Frequency f_cut=2 "Cut-off frequency";
parameter Modelica.Blocks.Types.FilterType filterType=Modelica.Blocks.Types.FilterType.LowPass
"Type of filter (LowPass/HighPass)";
parameter Modelica.Blocks.Types.Init init=Modelica.Blocks.Types.Init.SteadyState
"Type of initialization (no init/steady state/initial state/initial output)";
parameter Boolean normalized=true "= true, if amplitude at f_cut = -3db, otherwise unmodified filter";
Modelica.Blocks.Sources.Step step(startTime=0.1, offset=0.1)
annotation (Placement(transformation(extent={{-60,40},{-40,60}})));
Modelica.Blocks.Continuous.Filter CriticalDamping(
analogFilter=Modelica.Blocks.Types.AnalogFilter.CriticalDamping,
normalized=normalized,
init=init,
filterType=filterType,
order=order,
f_cut=f_cut,
f_min=0.8*f_cut)
annotation (Placement(transformation(extent={{-20,40},{0,60}})));
Modelica.Blocks.Continuous.Filter Bessel(
normalized=normalized,
analogFilter=Modelica.Blocks.Types.AnalogFilter.Bessel,
init=init,
filterType=filterType,
order=order,
f_cut=f_cut,
f_min=0.8*f_cut)
annotation (Placement(transformation(extent={{-20,0},{0,20}})));
Modelica.Blocks.Continuous.Filter Butterworth(
normalized=normalized,
analogFilter=Modelica.Blocks.Types.AnalogFilter.Butterworth,
init=init,
filterType=filterType,
order=order,
f_cut=f_cut,
f_min=0.8*f_cut)
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Blocks.Continuous.Filter ChebyshevI(
normalized=normalized,
analogFilter=Modelica.Blocks.Types.AnalogFilter.ChebyshevI,
init=init,
filterType=filterType,
order=order,
f_cut=f_cut,
f_min=0.8*f_cut)
annotation (Placement(transformation(extent={{-20,-80},{0,-60}})));
equation
connect(step.y, CriticalDamping.u) annotation (Line(
points={{-39,50},{-22,50}}, color={0,0,127}));
connect(step.y, Bessel.u) annotation (Line(
points={{-39,50},{-32,50},{-32,10},{-22,10}}, color={0,0,127}));
connect(Butterworth.u, step.y) annotation (Line(
points={{-22,-30},{-32,-30},{-32,50},{-39,50}}, color={0,0,127}));
connect(ChebyshevI.u, step.y) annotation (Line(
points={{-22,-70},{-32,-70},{-32,50},{-39,50}}, color={0,0,127}));
annotation (
experiment(StopTime=0.9),
Documentation(info="<html>
<p>
This example demonstrates various options of the
<a href=\"modelica://Modelica.Blocks.Continuous.Filter\">Filter</a> block.
A step input starts at 0.1 s with an offset of 0.1, in order to demonstrate
the initialization options. This step input drives 4 filter blocks that
have identical parameters, with the only exception of the used analog filter type
(CriticalDamping, Bessel, Butterworth, Chebyshev of type I). All the main options
can be set via parameters and are then applied to all the 4 filters.
The default setting uses low pass filters of order 3 with a cut-off frequency of
2 Hz resulting in the following outputs:
</p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/Filter1.png\"
alt=\"Filter1.png\">
</html>"));
end Filter;
model FilterWithDifferentiation
"Demonstrates the use of low pass filters to determine derivatives of filters"
extends Modelica.Icons.Example;
parameter SI.Frequency f_cut=2 "Cut-off frequency";
Modelica.Blocks.Sources.Step step(startTime=0.1, offset=0.1)
annotation (Placement(transformation(extent={{-80,40},{-60,60}})));
Modelica.Blocks.Continuous.Filter Bessel(
f_cut=f_cut,
filterType=Modelica.Blocks.Types.FilterType.LowPass,
order=3,
analogFilter=Modelica.Blocks.Types.AnalogFilter.Bessel)
annotation (Placement(transformation(extent={{-40,40},{-20,60}})));
Continuous.Der der1
annotation (Placement(transformation(extent={{-6,40},{14,60}})));
Continuous.Der der2
annotation (Placement(transformation(extent={{30,40},{50,60}})));
Continuous.Der der3
annotation (Placement(transformation(extent={{62,40},{82,60}})));
equation
connect(step.y, Bessel.u) annotation (Line(
points={{-59,50},{-42,50}}, color={0,0,127}));
connect(Bessel.y, der1.u) annotation (Line(
points={{-19,50},{-8,50}}, color={0,0,127}));
connect(der1.y, der2.u) annotation (Line(
points={{15,50},{28,50}}, color={0,0,127}));
connect(der2.y, der3.u) annotation (Line(
points={{51,50},{60,50}}, color={0,0,127}));
annotation (
experiment(StopTime=0.9),
Documentation(info="<html>
<p>
This example demonstrates that the output of the
<a href=\"modelica://Modelica.Blocks.Continuous.Filter\">Filter</a> block
can be differentiated up to the order of the filter. This feature can be
used in order to make an inverse model realizable or to \"smooth\" a potential
discontinuous control signal.
</p>
</html>"));
end FilterWithDifferentiation;
model FilterWithRiseTime
"Demonstrates to use the rise time instead of the cut-off frequency to define a filter"
import Modelica.Constants.pi;
extends Modelica.Icons.Example;
parameter Integer order=2 "Filter order";
parameter SI.Time riseTime=2 "Time to reach the step input";
Continuous.Filter filter_fac5(f_cut=5/(2*pi*riseTime), order=order)
annotation (Placement(transformation(extent={{-20,-20},{0,0}})));
Sources.Step step(startTime=1)
annotation (Placement(transformation(extent={{-60,20},{-40,40}})));
Continuous.Filter filter_fac4(f_cut=4/(2*pi*riseTime), order=order)
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Continuous.Filter filter_fac3(f_cut=3/(2*pi*riseTime), order=order)
annotation (Placement(transformation(extent={{-20,62},{0,82}})));
equation
connect(step.y, filter_fac5.u) annotation (Line(
points={{-39,30},{-30,30},{-30,-10},{-22,-10}}, color={0,0,127}));
connect(step.y, filter_fac4.u) annotation (Line(
points={{-39,30},{-22,30}}, color={0,0,127}));
connect(step.y, filter_fac3.u) annotation (Line(
points={{-39,30},{-30,30},{-30,72},{-22,72}}, color={0,0,127}));
annotation (experiment(StopTime=4), Documentation(info="<html>
<p>
Filters are usually parameterized with the cut-off frequency.
Sometimes, it is more meaningful to parameterize a filter with its
rise time, i.e., the time it needs until the output reaches the end value
of a step input. This is performed with the formula:
</p>
<blockquote><pre>
f_cut = fac/(2*pi*riseTime);
</pre></blockquote>
<p>
where \"fac\" is typically 3, 4, or 5. The following image shows
the results of a simulation of this example model
(riseTime = 2 s, fac=3, 4, and 5):
</p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/FilterWithRiseTime.png\"
alt=\"FilterWithRiseTime.png\">
<p>
Since the step starts at 1 s, and the rise time is 2 s, the filter output y
shall reach the value of 1 after 1+2=3 s. Depending on the factor \"fac\" this is
reached with different precisions. This is summarized in the following table:
</p>
<blockquote><table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td>Filter order</td>
<td>Factor fac</td>
<td>Percentage of step value reached after rise time</td>
</tr>
<tr>
<td align=\"center\">1</td>
<td align=\"center\">3</td>
<td align=\"center\">95.1 %</td>
</tr>
<tr>
<td align=\"center\">1</td>
<td align=\"center\">4</td>
<td align=\"center\">98.2 %</td>
</tr>
<tr>
<td align=\"center\">1</td>
<td align=\"center\">5</td>
<td align=\"center\">99.3 %</td>
</tr>
<tr>
<td align=\"center\">2</td>
<td align=\"center\">3</td>
<td align=\"center\">94.7 %</td>
</tr>
<tr>
<td align=\"center\">2</td>
<td align=\"center\">4</td>
<td align=\"center\">98.6 %</td>
</tr>
<tr>
<td align=\"center\">2</td>
<td align=\"center\">5</td>
<td align=\"center\">99.6 %</td>
</tr>
</table></blockquote>
</html>"));
end FilterWithRiseTime;
model SlewRateLimiter
"Demonstrate usage of Nonlinear.SlewRateLimiter"
extends Modelica.Icons.Example;
parameter SI.Velocity vMax=2 "Max. velocity";
parameter SI.Acceleration aMax=20 "Max. acceleration";
SI.Position s=positionStep.y "Reference position";
SI.Position sSmoothed=positionSmoothed.y "Smoothed position";
SI.Velocity vLimited=limit_a.y "Limited velocity";
SI.Acceleration aLimited=a.y "Limited acceleration";
Modelica.Blocks.Sources.Step positionStep(startTime=0.1)
annotation (Placement(transformation(extent={{-80,-10},{-60,10}})));
Modelica.Blocks.Nonlinear.SlewRateLimiter limit_v(
initType=Modelica.Blocks.Types.Init.InitialOutput,
Rising=vMax,
y_start=positionStep.offset,
Td=0.0001)
annotation (Placement(transformation(extent={{-50,-10},{-30,10}})));
Modelica.Blocks.Continuous.Der v
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
Modelica.Blocks.Nonlinear.SlewRateLimiter limit_a(
initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=0,
Rising=20,
Td=0.0001)
annotation (Placement(transformation(extent={{10,-10},{30,10}})));
Modelica.Blocks.Continuous.Integrator positionSmoothed(
k=1,
initType=Modelica.Blocks.Types.Init.InitialOutput,
y_start=positionStep.offset)
annotation (Placement(transformation(extent={{50,-10},{70,10}})));
Modelica.Blocks.Continuous.Der a
annotation (Placement(transformation(extent={{50,-40},{70,-20}})));
equation
connect(positionStep.y, limit_v.u)
annotation (Line(points={{-59,0},{-52,0}}, color={0,0,127}));
connect(limit_v.y, v.u)
annotation (Line(points={{-29,0},{-22,0}}, color={0,0,127}));
connect(v.y, limit_a.u)
annotation (Line(points={{1,0},{8,0}}, color={0,0,127}));
connect(limit_a.y, positionSmoothed.u)
annotation (Line(points={{31,0},{39.5,0},{48,0}}, color={0,0,127}));
connect(limit_a.y, a.u) annotation (Line(points={{31,0},{40,0},{40,-30},{48,-30}},
color={0,0,127}));
annotation (experiment(StopTime=1.0, Interval=0.001), Documentation(info="<html>
<p>
This example demonstrates how to use the Nonlinear.SlewRateLimiter block to limit a position step with regards to velocity and acceleration:
</p>
<ul>
<li> The Sources.Step block <code>positionStep</code> demands an unphysical position step.</li>
<li> The first SlewRateLimiter block <code>limit_v</code> limits velocity.</li>
<li> The first Der block <code>v</code> calculates velocity from the smoothed position signal.</li>
<li> The second SlewRateLimiter block <code>limit_a</code> limits acceleration of the smoothed velocity signal.</li>
<li> The second Der block <code>a</code> calculates acceleration from the smoothed velocity signal.</li>
<li> The Integrator block <code>positionSmoothed</code> calculates smoothed position from the smoothed velocity signal.</li>
</ul>
<p>
A position controlled drive with limited velocity and limited acceleration (i.e. torque) is able to follow the smoothed reference position.
</p>
</html>"));
end SlewRateLimiter;
model InverseModel "Demonstrates the construction of an inverse model"
extends Modelica.Icons.Example;
Continuous.FirstOrder firstOrder1(
k=1,
T=0.3,
initType=Modelica.Blocks.Types.Init.SteadyState)
annotation (Placement(transformation(extent={{20,20},{0,40}})));
Sources.Sine sine(
f=2,
offset=1,
startTime=0.2)
annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
Math.InverseBlockConstraints inverseBlockConstraints
annotation (Placement(transformation(extent={{-10,20},{30,40}})));
Continuous.FirstOrder firstOrder2(
k=1,
T=0.3,
initType=Modelica.Blocks.Types.Init.SteadyState)
annotation (Placement(transformation(extent={{20,-20},{0,0}})));
Math.Feedback feedback
annotation (Placement(transformation(extent={{-40,0},{-60,-20}})));
Continuous.CriticalDamping criticalDamping(n=1, f=50*sine.f)
annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
equation
connect(firstOrder1.y, inverseBlockConstraints.u2) annotation (Line(
points={{-1,30},{-6,30}}, color={0,0,127}));
connect(inverseBlockConstraints.y2, firstOrder1.u) annotation (Line(
points={{27,30},{22,30}}, color={0,0,127}));
connect(firstOrder2.y, feedback.u1) annotation (Line(
points={{-1,-10},{-42,-10}}, color={0,0,127}));
connect(sine.y, criticalDamping.u) annotation (Line(
points={{-59,30},{-42,30}}, color={0,0,127}));
connect(criticalDamping.y, inverseBlockConstraints.u1) annotation (Line(
points={{-19,30},{-12,30}}, color={0,0,127}));
connect(sine.y, feedback.u2) annotation (Line(
points={{-59,30},{-50,30},{-50,-2}}, color={0,0,127}));
connect(inverseBlockConstraints.y1, firstOrder2.u) annotation (Line(
points={{31,30},{40,30},{40,-10},{22,-10}}, color={0,0,127}));
annotation (Documentation(info="<html>
<p>
This example demonstrates how to construct an inverse model in Modelica
(for more details see <a href=\"https://www.modelica.org/events/Conference2005/online_proceedings/Session3/Session3c3.pdf\">Looye, Thümmel, Kurze, Otter, Bals: Nonlinear Inverse Models for Control</a>).
</p>
<p>
For a linear, single input, single output system
</p>
<blockquote><pre>
y = n(s)/d(s) * u // plant model
</pre></blockquote>
<p>
the inverse model is derived by simply exchanging the numerator and
the denominator polynomial:
</p>
<blockquote><pre>
u = d(s)/n(s) * y // inverse plant model
</pre></blockquote>
<p>
If the denominator polynomial d(s) has a higher degree as the
numerator polynomial n(s) (which is usually the case for plant models),
then the inverse model is no longer proper, i.e., it is not causal.
To avoid this, an approximate inverse model is constructed by adding
a sufficient number of poles to the denominator of the inverse model.
This can be interpreted as filtering the desired output signal y:
</p>
<blockquote><pre>
u = d(s)/(n(s)*f(s)) * y // inverse plant model with filtered y
</pre></blockquote>
<p>
With Modelica it is in principal possible to construct inverse models not only
for linear but also for non-linear models and in particular for every
Modelica model. The basic construction mechanism is explained at hand
of this example:
</p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/InverseModelSchematic.png\"
alt=\"InverseModelSchematic.png\">
<p>
Here the first order block \"firstOrder1\" shall be inverted. This is performed
by connecting its inputs and outputs with an instance of block
Modelica.Blocks.Math.<strong>InverseBlockConstraints</strong>. By this connection,
the inputs and outputs are exchanged. The goal is to compute the input of the
\"firstOrder1\" block so that its output follows a given sine signal.
For this, the sine signal \"sin\" is first filtered with a \"CriticalDamping\"
filter of order 1 and then the output of this filter is connected to the output
of the \"firstOrder1\" block (via the InverseBlockConstraints block, since
2 outputs cannot be connected directly together in a block diagram).
</p>
<p>
In order to check the inversion, the computed input of \"firstOrder1\" is used
as input in an identical block \"firstOrder2\". The output of \"firstOrder2\" should
be the given \"sine\" function. The difference is constructed with the \"feedback\"
block. Since the \"sine\" function is filtered, one cannot expect that this difference
is zero. The higher the cut-off frequency of the filter, the closer is the
agreement. A typical simulation result is shown in the next figure:
</p>
<img src=\"modelica://Modelica/Resources/Images/Blocks/Examples/InverseModel.png\"
alt=\"InverseModel.png\">
</html>"), experiment(StopTime=1.0));
end InverseModel;
model ShowLogicalSources
"Demonstrates the usage of logical sources together with their diagram animation"
extends Modelica.Icons.Example;
Sources.BooleanTable table(table={2,4,6,8}) annotation (Placement(
transformation(extent={{-60,-100},{-40,-80}})));
Sources.BooleanConstant const annotation (Placement(transformation(extent={
{-60,60},{-40,80}})));
Sources.BooleanStep step(startTime=4) annotation (Placement(transformation(
extent={{-60,20},{-40,40}})));
Sources.BooleanPulse pulse(period=1.5) annotation (Placement(transformation(
extent={{-60,-20},{-40,0}})));
Sources.SampleTrigger sample(period=0.5) annotation (Placement(
transformation(extent={{-60,-60},{-40,-40}})));
Sources.BooleanExpression booleanExpression(y=pulse.y and step.y)
annotation (Placement(transformation(extent={{20,20},{80,40}})));
annotation (experiment(StopTime=10), Documentation(info="<html>
<p>
This simple example demonstrates the logical sources in
<a href=\"modelica://Modelica.Blocks.Sources\">Modelica.Blocks.Sources</a> and demonstrate
their diagram animation (see \"small circle\" close to the output connector).
The \"booleanExpression\" source shows how a logical expression can be defined
in its parameter menu referring to variables available on this level of the
model.
</p>
</html>"));
end ShowLogicalSources;
model LogicalNetwork1 "Demonstrates the usage of logical blocks"
extends Modelica.Icons.Example;
Sources.BooleanTable table2(table={1,3,5,7}) annotation (Placement(
transformation(extent={{-80,-20},{-60,0}})));
Sources.BooleanTable table1(table={2,4,6,8}) annotation (Placement(
transformation(extent={{-80,20},{-60,40}})));
Logical.Not Not1 annotation (Placement(transformation(extent={{-40,-20},{-20,
0}})));
Logical.And And1 annotation (Placement(transformation(extent={{0,-20},{20,0}})));
Logical.Or Or1 annotation (Placement(transformation(extent={{40,20},{60,40}})));
Logical.Pre Pre1 annotation (Placement(transformation(extent={{-40,-60},{-20,
-40}})));
equation
connect(table2.y, Not1.u)
annotation (Line(points={{-59,-10},{-42,-10}}, color={255,0,255}));
connect(And1.y, Or1.u2) annotation (Line(points={{21,-10},{28,-10},{28,22},
{38,22}}, color={255,0,255}));
connect(table1.y, Or1.u1)
annotation (Line(points={{-59,30},{38,30}}, color={255,0,255}));
connect(Not1.y, And1.u1)
annotation (Line(points={{-19,-10},{-2,-10}}, color={255,0,255}));
connect(Pre1.y, And1.u2) annotation (Line(points={{-19,-50},{-10,-50},{-10,
-18},{-2,-18}}, color={255,0,255}));
connect(Or1.y, Pre1.u) annotation (Line(points={{61,30},{68,30},{68,-70},{-60,
-70},{-60,-50},{-42,-50}}, color={255,0,255}));
annotation (experiment(StopTime=10), Documentation(info="<html>
<p>
This example demonstrates a network of logical blocks. Note, that
the Boolean values of the input and output signals are visualized
in the diagram animation, by the small \"circles\" close to the connectors.
If a \"circle\" is \"white\", the signal is <strong>false</strong>. It a
\"circle\" is \"green\", the signal is <strong>true</strong>.
</p>
</html>"));
end LogicalNetwork1;
model RealNetwork1 "Demonstrates the usage of blocks from Modelica.Blocks.Math"
extends Modelica.Icons.Example;
Modelica.Blocks.Math.MultiSum add(nu=2)
annotation (Placement(transformation(extent={{-14,64},{-2,76}})));
Sources.Sine sine(amplitude=3, f=0.1)
annotation (Placement(transformation(extent={{-96,60},{-76,80}})));
Sources.Step integerStep(height=3, startTime=2)
annotation (Placement(transformation(extent={{-60,30},{-40,50}})));
Sources.Constant integerConstant(k=1)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Blocks.Interaction.Show.RealValue showValue
annotation (Placement(transformation(extent={{66,60},{86,80}})));
Math.MultiProduct product(nu=2)
annotation (Placement(transformation(extent={{6,24},{18,36}})));
Modelica.Blocks.Interaction.Show.RealValue showValue1(significantDigits=2)
annotation (Placement(transformation(extent={{64,20},{84,40}})));
Sources.BooleanPulse booleanPulse1(period=1)
annotation (Placement(transformation(extent={{-12,-30},{8,-10}})));
Math.MultiSwitch multiSwitch(
nu=2,
expr={4,6},
y_default=2)
annotation (Placement(transformation(extent={{28,-60},{68,-40}})));
Sources.BooleanPulse booleanPulse2(period=2, width=80)
annotation (Placement(transformation(extent={{-12,-70},{8,-50}})));
Modelica.Blocks.Interaction.Show.RealValue showValue3(
use_numberPort=false,
number=multiSwitch.y,
significantDigits=1)
annotation (Placement(transformation(extent={{40,-84},{60,-64}})));
Math.LinearDependency linearDependency1(
y0=1,
k1=2,
k2=3) annotation (Placement(transformation(extent={{40,80},{60,100}})));
Math.MinMax minMax(nu=2)
annotation (Placement(transformation(extent={{58,-16},{78,4}})));
equation
connect(booleanPulse1.y, multiSwitch.u[1]) annotation (Line(
points={{9,-20},{18,-20},{18,-48},{28,-48},{28,-48.5}}, color={255,0,255}));
connect(booleanPulse2.y, multiSwitch.u[2]) annotation (Line(
points={{9,-60},{18,-60},{18,-52},{28,-52},{28,-51.5}}, color={255,0,255}));
connect(sine.y, add.u[1]) annotation (Line(
points={{-75,70},{-46.5,70},{-46.5,72.1},{-14,72.1}}, color={0,0,127}));
connect(integerStep.y, add.u[2]) annotation (Line(
points={{-39,40},{-28,40},{-28,67.9},{-14,67.9}}, color={0,0,127}));
connect(add.y, showValue.numberPort) annotation (Line(
points={{-0.98,70},{64.5,70}}, color={0,0,127}));
connect(integerStep.y, product.u[1]) annotation (Line(
points={{-39,40},{-20,40},{-20,32.1},{6,32.1}}, color={0,0,127}));
connect(integerConstant.y, product.u[2]) annotation (Line(
points={{-39,0},{-20,0},{-20,27.9},{6,27.9}}, color={0,0,127}));
connect(product.y, showValue1.numberPort) annotation (Line(
points={{19.02,30},{62.5,30}}, color={0,0,127}));
connect(add.y, linearDependency1.u1) annotation (Line(
points={{-0.98,70},{20,70},{20,96},{38,96}}, color={0,0,127}));
connect(product.y, linearDependency1.u2) annotation (Line(
points={{19.02,30},{30,30},{30,84},{38,84}}, color={0,0,127}));
connect(add.y, minMax.u[1]) annotation (Line(
points={{-0.98,70},{48,70},{48,-2.5},{58,-2.5}}, color={0,0,127}));
connect(product.y, minMax.u[2]) annotation (Line(
points={{19.02,30},{40,30},{40,-9.5},{58,-9.5}}, color={0,0,127}));
annotation (
experiment(StopTime=10),
Documentation(info="<html>
<p>
This example demonstrates a network of mathematical Real blocks.
from package <a href=\"modelica://Modelica.Blocks.Math\">Modelica.Blocks.Math</a>.
Note, that
</p>
<ul>
<li> at the right side of the model, several Math.ShowValue blocks
are present, that visualize the actual value of the respective Real
signal in a diagram animation.</li>
<li> the Boolean values of the input and output signals are visualized
in the diagram animation, by the small \"circles\" close to the connectors.
If a \"circle\" is \"white\", the signal is <strong>false</strong>. If a
\"circle\" is \"green\", the signal is <strong>true</strong>.</li>
</ul>
</html>"));
end RealNetwork1;
model IntegerNetwork1
"Demonstrates the usage of blocks from Modelica.Blocks.MathInteger"
extends Modelica.Icons.Example;
MathInteger.Sum sum(nu=3)
annotation (Placement(transformation(extent={{-14,64},{-2,76}})));
Sources.Sine sine(amplitude=3, f=0.1)
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
Math.RealToInteger realToInteger
annotation (Placement(transformation(extent={{-60,60},{-40,80}})));
Sources.IntegerStep integerStep(height=3, startTime=2)
annotation (Placement(transformation(extent={{-60,30},{-40,50}})));
Sources.IntegerConstant integerConstant(k=1)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Blocks.Interaction.Show.IntegerValue showValue
annotation (Placement(transformation(extent={{40,60},{60,80}})));
MathInteger.Product product(nu=2)
annotation (Placement(transformation(extent={{16,24},{28,36}})));
Modelica.Blocks.Interaction.Show.IntegerValue showValue1
annotation (Placement(transformation(extent={{40,20},{60,40}})));
MathInteger.TriggeredAdd triggeredAdd(use_reset=false, use_set=false)
annotation (Placement(transformation(extent={{16,-6},{28,6}})));
Sources.BooleanPulse booleanPulse1(period=1)
annotation (Placement(transformation(extent={{-12,-30},{8,-10}})));
Modelica.Blocks.Interaction.Show.IntegerValue showValue2
annotation (Placement(transformation(extent={{40,-10},{60,10}})));
MathInteger.MultiSwitch multiSwitch1(
nu=2,
expr={4,6},
y_default=2,
use_pre_as_default=false)
annotation (Placement(transformation(extent={{28,-60},{68,-40}})));
Sources.BooleanPulse booleanPulse2(period=2, width=80)
annotation (Placement(transformation(extent={{-12,-70},{8,-50}})));
Modelica.Blocks.Interaction.Show.IntegerValue showValue3(use_numberPort=
false, number=multiSwitch1.y)
annotation (Placement(transformation(extent={{40,-84},{60,-64}})));
equation
connect(sine.y, realToInteger.u) annotation (Line(
points={{-79,70},{-62,70}}, color={0,0,127}));
connect(realToInteger.y, sum.u[1]) annotation (Line(
points={{-39,70},{-32,70},{-32,72},{-14,72},{-14,72.8}}, color={255,127,0}));
connect(integerStep.y, sum.u[2]) annotation (Line(
points={{-39,40},{-28,40},{-28,70},{-14,70}}, color={255,127,0}));
connect(integerConstant.y, sum.u[3]) annotation (Line(
points={{-39,0},{-22,0},{-22,67.2},{-14,67.2}}, color={255,127,0}));
connect(sum.y, showValue.numberPort) annotation (Line(
points={{-1.1,70},{38.5,70}}, color={255,127,0}));
connect(sum.y, product.u[1]) annotation (Line(
points={{-1.1,70},{4,70},{4,32.1},{16,32.1}}, color={255,127,0}));
connect(integerStep.y, product.u[2]) annotation (Line(
points={{-39,40},{-8,40},{-8,27.9},{16,27.9}}, color={255,127,0}));
connect(product.y, showValue1.numberPort) annotation (Line(
points={{28.9,30},{38.5,30}}, color={255,127,0}));
connect(integerConstant.y, triggeredAdd.u) annotation (Line(
points={{-39,0},{13.6,0}}, color={255,127,0}));
connect(booleanPulse1.y, triggeredAdd.trigger) annotation (Line(
points={{9,-20},{18.4,-20},{18.4,-7.2}}, color={255,0,255}));
connect(triggeredAdd.y, showValue2.numberPort) annotation (Line(
points={{29.2,0},{38.5,0}}, color={255,127,0}));
connect(booleanPulse1.y, multiSwitch1.u[1]) annotation (Line(
points={{9,-20},{18,-20},{18,-48},{28,-48},{28,-48.5}}, color={255,0,255}));
connect(booleanPulse2.y, multiSwitch1.u[2]) annotation (Line(
points={{9,-60},{18,-60},{18,-52},{28,-52},{28,-51.5}}, color={255,0,255}));
annotation (experiment(StopTime=10), Documentation(info="<html>
<p>
This example demonstrates a network of Integer blocks.
from package <a href=\"modelica://Modelica.Blocks.MathInteger\">Modelica.Blocks.MathInteger</a>.
Note, that
</p>
<ul>
<li> at the right side of the model, several MathInteger.ShowValue blocks
are present, that visualize the actual value of the respective Integer
signal in a diagram animation.</li>
<li> the Boolean values of the input and output signals are visualized
in the diagram animation, by the small \"circles\" close to the connectors.
If a \"circle\" is \"white\", the signal is <strong>false</strong>. If a
\"circle\" is \"green\", the signal is <strong>true</strong>.</li>
</ul>
</html>"));
end IntegerNetwork1;
model BooleanNetwork1
"Demonstrates the usage of blocks from Modelica.Blocks.MathBoolean"
extends Modelica.Icons.Example;
Modelica.Blocks.Interaction.Show.BooleanValue showValue
annotation (Placement(transformation(extent={{-36,74},{-16,94}})));
MathBoolean.And and1(nu=3)
annotation (Placement(transformation(extent={{-58,64},{-46,76}})));
Sources.BooleanPulse booleanPulse1(width=20, period=1)
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
Sources.BooleanPulse booleanPulse2(period=1, width=80)
annotation (Placement(transformation(extent={{-100,-4},{-80,16}})));
Sources.BooleanStep booleanStep(startTime=1.5)
annotation (Placement(transformation(extent={{-100,28},{-80,48}})));
MathBoolean.Or or1(nu=2)
annotation (Placement(transformation(extent={{-28,62},{-16,74}})));
MathBoolean.Xor xor1(nu=2)
annotation (Placement(transformation(extent={{-2,60},{10,72}})));
Modelica.Blocks.Interaction.Show.BooleanValue showValue2
annotation (Placement(transformation(extent={{-2,74},{18,94}})));
Modelica.Blocks.Interaction.Show.BooleanValue showValue3
annotation (Placement(transformation(extent={{24,56},{44,76}})));
MathBoolean.Nand nand1(nu=2)
annotation (Placement(transformation(extent={{22,40},{34,52}})));
MathBoolean.Nor or2(nu=2)
annotation (Placement(transformation(extent={{46,38},{58,50}})));
Modelica.Blocks.Interaction.Show.BooleanValue showValue4
annotation (Placement(transformation(extent={{90,34},{110,54}})));
MathBoolean.Not nor1
annotation (Placement(transformation(extent={{68,40},{76,48}})));
MathBoolean.OnDelay onDelay(delayTime=1)
annotation (Placement(transformation(extent={{-56,-94},{-48,-86}})));
MathBoolean.RisingEdge rising
annotation (Placement(transformation(extent={{-56,-15},{-48,-7}})));
MathBoolean.MultiSwitch set1(nu=2, expr={false,true})
annotation (Placement(transformation(extent={{-30,-23},{10,-3}})));
MathBoolean.FallingEdge falling
annotation (Placement(transformation(extent={{-56,-32},{-48,-24}})));
Sources.BooleanTable booleanTable(table={2,4,6,6.5,7,9,11})
annotation (Placement(transformation(extent={{-100,-100},{-80,-80}})));
MathBoolean.ChangingEdge changing
annotation (Placement(transformation(extent={{-56,-59},{-48,-51}})));
MathInteger.TriggeredAdd triggeredAdd
annotation (Placement(transformation(extent={{14,-56},{26,-44}})));
Sources.IntegerConstant integerConstant(k=2)
annotation (Placement(transformation(extent={{-20,-60},{0,-40}})));
Modelica.Blocks.Interaction.Show.IntegerValue showValue1
annotation (Placement(transformation(extent={{40,-60},{60,-40}})));
Modelica.Blocks.Interaction.Show.BooleanValue showValue5
annotation (Placement(transformation(extent={{24,-23},{44,-3}})));
Modelica.Blocks.Interaction.Show.BooleanValue showValue6
annotation (Placement(transformation(extent={{-32,-100},{-12,-80}})));
Logical.RSFlipFlop rSFlipFlop
annotation (Placement(transformation(extent={{70,-90},{90,-70}})));
Sources.SampleTrigger sampleTriggerSet(period=0.5, startTime=0)
annotation (Placement(transformation(extent={{40,-76},{54,-62}})));
Sources.SampleTrigger sampleTriggerReset(period=0.5, startTime=0.3)
annotation (Placement(transformation(extent={{40,-98},{54,-84}})));
equation
connect(booleanPulse1.y, and1.u[1]) annotation (Line(
points={{-79,70},{-68,70},{-68,72.8},{-58,72.8}}, color={255,0,255}));
connect(booleanStep.y, and1.u[2]) annotation (Line(
points={{-79,38},{-64,38},{-64,70},{-58,70}}, color={255,0,255}));
connect(booleanPulse2.y, and1.u[3]) annotation (Line(
points={{-79,6},{-62,6},{-62,67.2},{-58,67.2}}, color={255,0,255}));
connect(and1.y, or1.u[1]) annotation (Line(
points={{-45.1,70},{-36.4,70},{-36.4,70.1},{-28,70.1}}, color={255,0,255}));
connect(booleanPulse2.y, or1.u[2]) annotation (Line(
points={{-79,6},{-40,6},{-40,65.9},{-28,65.9}}, color={255,0,255}));
connect(or1.y, xor1.u[1]) annotation (Line(
points={{-15.1,68},{-8,68},{-8,68.1},{-2,68.1}}, color={255,0,255}));
connect(booleanPulse2.y, xor1.u[2]) annotation (Line(
points={{-79,6},{-12,6},{-12,63.9},{-2,63.9}}, color={255,0,255}));
connect(and1.y, showValue.activePort) annotation (Line(
points={{-45.1,70},{-42,70},{-42,84},{-37.5,84}}, color={255,0,255}));
connect(or1.y, showValue2.activePort) annotation (Line(
points={{-15.1,68},{-12,68},{-12,84},{-3.5,84}}, color={255,0,255}));
connect(xor1.y, showValue3.activePort) annotation (Line(
points={{10.9,66},{22.5,66}}, color={255,0,255}));
connect(xor1.y, nand1.u[1]) annotation (Line(
points={{10.9,66},{16,66},{16,48.1},{22,48.1}}, color={255,0,255}));
connect(booleanPulse2.y, nand1.u[2]) annotation (Line(
points={{-79,6},{16,6},{16,44},{22,44},{22,43.9}}, color={255,0,255}));
connect(nand1.y, or2.u[1]) annotation (Line(
points={{34.9,46},{46,46},{46,46.1}}, color={255,0,255}));
connect(booleanPulse2.y, or2.u[2]) annotation (Line(
points={{-79,6},{42,6},{42,41.9},{46,41.9}}, color={255,0,255}));
connect(or2.y, nor1.u) annotation (Line(
points={{58.9,44},{66.4,44}}, color={255,0,255}));
connect(nor1.y, showValue4.activePort) annotation (Line(
points={{76.8,44},{88.5,44}}, color={255,0,255}));
connect(booleanPulse2.y, rising.u) annotation (Line(
points={{-79,6},{-62,6},{-62,-11},{-57.6,-11}}, color={255,0,255}));
connect(rising.y, set1.u[1]) annotation (Line(
points={{-47.2,-11},{-38.6,-11},{-38.6,-11.5},{-30,-11.5}}, color={255,0,255}));
connect(falling.y, set1.u[2]) annotation (Line(
points={{-47.2,-28},{-40,-28},{-40,-14.5},{-30,-14.5}}, color={255,0,255}));
connect(booleanPulse2.y, falling.u) annotation (Line(
points={{-79,6},{-62,6},{-62,-28},{-57.6,-28}}, color={255,0,255}));
connect(booleanTable.y, onDelay.u) annotation (Line(
points={{-79,-90},{-57.6,-90}}, color={255,0,255}));
connect(booleanPulse2.y, changing.u) annotation (Line(
points={{-79,6},{-62,6},{-62,-55},{-57.6,-55}}, color={255,0,255}));
connect(integerConstant.y, triggeredAdd.u) annotation (Line(
points={{1,-50},{11.6,-50}}, color={255,127,0}));
connect(changing.y, triggeredAdd.trigger) annotation (Line(
points={{-47.2,-55},{-30,-55},{-30,-74},{16.4,-74},{16.4,-57.2}}, color={255,0,255}));
connect(triggeredAdd.y, showValue1.numberPort) annotation (Line(
points={{27.2,-50},{38.5,-50}}, color={255,127,0}));
connect(set1.y, showValue5.activePort) annotation (Line(
points={{11,-13},{22.5,-13}}, color={255,0,255}));
connect(onDelay.y, showValue6.activePort) annotation (Line(
points={{-47.2,-90},{-33.5,-90}}, color={255,0,255}));
connect(sampleTriggerSet.y, rSFlipFlop.S) annotation (Line(
points={{54.7,-69},{60,-69},{60,-74},{68,-74}}, color={255,0,255}));
connect(sampleTriggerReset.y, rSFlipFlop.R) annotation (Line(
points={{54.7,-91},{60,-91},{60,-86},{68,-86}}, color={255,0,255}));
annotation (experiment(StopTime=10), Documentation(info="<html>
<p>
This example demonstrates a network of Boolean blocks
from package <a href=\"modelica://Modelica.Blocks.MathBoolean\">Modelica.Blocks.MathBoolean</a>.
Note, that
</p>
<ul>
<li> at the right side of the model, several MathBoolean.ShowValue blocks
are present, that visualize the actual value of the respective Boolean
signal in a diagram animation (\"green\" means \"true\").</li>
<li> the Boolean values of the input and output signals are visualized
in the diagram animation, by the small \"circles\" close to the connectors.
If a \"circle\" is \"white\", the signal is <strong>false</strong>. If a
\"circle\" is \"green\", the signal is <strong>true</strong>.</li>
</ul>
</html>"));
end BooleanNetwork1;
model Interaction1
"Demonstrates the usage of blocks from Modelica.Blocks.Interaction.Show"
extends Modelica.Icons.Example;
Interaction.Show.IntegerValue integerValue
annotation (Placement(transformation(extent={{-40,20},{-20,40}})));
Sources.IntegerTable integerTable(table=[0, 0; 1, 2; 2, 4; 3, 6; 4, 4; 6, 2])
annotation (Placement(transformation(extent={{-80,20},{-60,40}})));
Sources.TimeTable timeTable(table=[0, 0; 1, 2.1; 2, 4.2; 3, 6.3; 4, 4.2; 6,
2.1; 6, 2.1])
annotation (Placement(transformation(extent={{-80,60},{-60,80}})));
Interaction.Show.RealValue realValue
annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
Sources.BooleanTable booleanTable(table={1,2,3,4,5,6,7,8,9})
annotation (Placement(transformation(extent={{-80,-20},{-60,0}})));
Interaction.Show.BooleanValue booleanValue
annotation (Placement(transformation(extent={{-40,-20},{-20,0}})));
Sources.RadioButtonSource start(buttonTimeTable={1,3}, reset={stop.on})
annotation (Placement(transformation(extent={{24,64},{36,76}})));
Sources.RadioButtonSource stop(buttonTimeTable={2,4}, reset={start.on})
annotation (Placement(transformation(extent={{48,64},{60,76}})));
equation
connect(integerTable.y, integerValue.numberPort) annotation (Line(
points={{-59,30},{-41.5,30}}, color={255,127,0}));
connect(timeTable.y, realValue.numberPort) annotation (Line(
points={{-59,70},{-41.5,70}}, color={0,0,127}));
connect(booleanTable.y, booleanValue.activePort) annotation (Line(
points={{-59,-10},{-41.5,-10}}, color={255,0,255}));
annotation (experiment(StopTime=10), Documentation(info="<html>
<p>
This example demonstrates a network of blocks
from package <a href=\"modelica://Modelica.Blocks.Interaction\">Modelica.Blocks.Interaction</a>
to show how diagram animations can be constructed.
</p>
</html>"));
end Interaction1;
model BusUsage "Demonstrates the usage of a signal bus"
extends Modelica.Icons.Example;
public
Modelica.Blocks.Sources.IntegerStep integerStep(
height=1,
offset=2,
startTime=0.5) annotation (Placement(transformation(extent={{-60,-40},{-40,
-20}})));
Modelica.Blocks.Sources.BooleanStep booleanStep(startTime=0.5) annotation (