/
OpAmps.mo
1708 lines (1680 loc) · 81 KB
/
OpAmps.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.Electrical.Analog.Examples;
package OpAmps "Examples with operational amplifiers"
extends Modelica.Icons.ExamplesPackage;
model NonInvertingAmplifier "Non-inverting amplifier"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
V=2*Vin,
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
offset=-Vin,
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Buffer buffer(k=2)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.n, buffer.n1)
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
connect(vIn.p, buffer.p1)
annotation (Line(points={{-40,10},{-10,10}}, color={0,0,255}));
connect(buffer.p2, vOut.p)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(buffer.n2, vOut.n)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
connect(buffer.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a non inverting amplifier.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end NonInvertingAmplifier;
model InvertingAmplifier "Inverting amplifier"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
V=2*Vin,
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
offset=-Vin,
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Gain gain(k=2)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.p, gain.p1)
annotation (Line(points={{-40,10},{-10,10}}, color={0,0,255}));
connect(gain.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
connect(gain.n1, vIn.n)
annotation (Line(points={{-10,-10},{-40,-10}}, color={0,0,255}));
connect(gain.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(gain.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
annotation (
Documentation(info="<html>
<p>This is an inverting amplifier.</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end InvertingAmplifier;
model DifferentialAmplifier "Differential amplifier"
extends Modelica.Icons.Example;
parameter
Modelica.Electrical.Analog.Examples.OpAmps.OpAmpCircuits.DifferentialAmplifierData
data "Parameters for source, OpAmp and measurement"
annotation (Placement(transformation(extent={{50,10},{70,30}})));
Modelica.Electrical.Analog.Sources.SineVoltage sourceVoltage1(
V=sqrt(2/3)*data.VSource,
phase=1.0471975511966,
f=data.fSource) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-120,-40})));
Modelica.Electrical.Analog.Sources.SineVoltage sourceVoltage2(
V=sqrt(2/3)*data.VSource,
phase=-1.0471975511966,
f=data.fSource) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-100,-40})));
Modelica.Electrical.Analog.Basic.Resistor resistanceLoad(R=data.RLoad)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=0,
origin={-110,60})));
Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensorSource
annotation (Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=90,
origin={-80,0})));
Modelica.Blocks.Math.Gain gain(k=-1/data.k)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Electrical.Analog.Basic.Resistor resistorGround(R=data.RGround,
i(start=0, fixed=false))
annotation (Placement(transformation(extent={{-60,-70},{-40,-50}})));
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
V0=data.V0,
useSupply=true,
Vps=+data.VSupply,
Vns=-data.VSupply)
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
Modelica.Electrical.Analog.Basic.Resistor resistor1(R=data.R1,
i(start=0, fixed=false))
annotation (Placement(transformation(extent={{-60,20},{-40,40}})));
Modelica.Electrical.Analog.Basic.Resistor resistor2(R=data.R2,
i(start=0, fixed=false))
annotation (Placement(transformation(extent={{-60,-40},{-40,-20}})));
Modelica.Electrical.Analog.Basic.Resistor resistor3(R=data.R3)
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Modelica.Electrical.Analog.Basic.Resistor resistor4(R=data.R4)
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Electrical.Analog.Sources.ConstantVoltage positiveSupply(V=+data.VSupply)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={40,-30})));
Modelica.Electrical.Analog.Sources.ConstantVoltage negativeSupply(V=-data.VSupply)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={20,-30})));
Modelica.Electrical.Analog.Basic.Resistor resistanceInstrument(R=data.RInstrument)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={60,-30})));
Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor annotation (
Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=90,
origin={80,-30})));
Modelica.Blocks.Math.RootMeanSquare rootMeanSquare(f=data.fSource)
annotation (Placement(transformation(extent={{100,-40},{120,-20}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-120,-90},{-100,-70}})));
protected
Modelica.Electrical.Analog.Interfaces.NegativePin groundSource
"Negative electrical pin"
annotation (Placement(transformation(extent={{-114,-64},{-106,-56}})));
Modelica.Electrical.Analog.Interfaces.NegativePin groundOpAmp
"Negative electrical pin"
annotation (Placement(transformation(extent={{-4,-64},{4,-56}})));
equation
connect(voltageSensor.v, rootMeanSquare.u)
annotation (Line(points={{91,-30},{98,-30}}, color={0,0,127}));
connect(resistor4.n, groundOpAmp)
annotation (Line(points={{0,-30},{0,-60}}, color={0,0,255}));
connect(groundOpAmp, resistorGround.n)
annotation (Line(points={{0,-60},{-40,-60}}, color={0,0,255}));
connect(groundOpAmp, resistanceInstrument.n)
annotation (Line(points={{0,-60},{60,-60},{60,-40}}, color={0,0,255}));
connect(groundOpAmp, voltageSensor.n)
annotation (Line(points={{0,-60},{80,-60},{80,-40}}, color={0,0,255}));
connect(groundOpAmp, positiveSupply.n)
annotation (Line(points={{0,-60},{40,-60},{40,-40}},
color={0,0,255}));
connect(groundOpAmp, negativeSupply.n)
annotation (Line(points={{0,-60},{20,-60},{20,-40}},
color={0,0,255}));
connect(negativeSupply.p, opAmp.s_n)
annotation (Line(points={{20,-20},{20,-10},{-10,-10}},
color={0,0,255}));
connect(opAmp.s_p, positiveSupply.p)
annotation (Line(points={{-10,10},{40,10},{40,-20}},
color={0,0,255}));
connect(sourceVoltage1.n, groundSource)
annotation (Line(points={{-120,-50},{-120,-60},{-110,-60}},
color={0,0,255}));
connect(groundSource,sourceVoltage2. n) annotation (Line(points={{-110,-60},{-100,
-60},{-100,-50}},color={0,0,255}));
connect(groundSource, resistorGround.p)
annotation (Line(points={{-110,-60},{-60,-60}}, color={0,0,255}));
connect(groundSource, ground.p)
annotation (Line(points={{-110,-60},{-110,-70}}, color={0,0,255}));
connect(sourceVoltage1.p, resistor1.p)
annotation (Line(points={{-120,-30},{-120,30},{-60,30}}, color={0,0,255}));
connect(sourceVoltage2.p, resistor2.p)
annotation (Line(points={{-100,-30},{-60,-30}},color={0,0,255}));
connect(voltageSensorSource.v, gain.u)
annotation (Line(points={{-69,0},{-62,0}}, color={0,0,127}));
connect(sourceVoltage2.p, voltageSensorSource.n) annotation (Line(points={{-100,
-30},{-100,-20},{-80,-20},{-80,-10}}, color={0,0,255}));
connect(sourceVoltage1.p, voltageSensorSource.p) annotation (Line(points={{-120,
-30},{-120,20},{-80,20},{-80,10}}, color={0,0,255}));
connect(sourceVoltage1.p, resistanceLoad.p) annotation (Line(points={{-120,-30},
{-120,40},{-130,40},{-130,60},{-120,60}}, color={0,0,255}));
connect(sourceVoltage2.p, resistanceLoad.n) annotation (Line(points={{-100,-30},
{-100,40},{-90,40},{-90,60},{-100,60}}, color={0,0,255}));
connect(resistor3.n, resistanceInstrument.p) annotation (Line(points={{0,30},
{20,30},{20,0},{60,0},{60,-20}}, color={0,0,255}));
connect(resistor3.n, voltageSensor.p) annotation (Line(points={{0,30},{20,
30},{20,0},{80,0},{80,-20}}, color={0,0,255}));
connect(resistor3.n, opAmp.out)
annotation (Line(points={{0,30},{20,30},{20,0},{0,0}}, color={0,0,255}));
connect(resistor1.n, resistor3.p)
annotation (Line(points={{-40,30},{-20,30}}, color={0,0,255}));
connect(resistor2.n, resistor4.p)
annotation (Line(points={{-40,-30},{-20,-30}}, color={0,0,255}));
connect(resistor2.n, opAmp.in_p) annotation (Line(points={{-40,-30},{-30,
-30},{-30,-6},{-20,-6}}, color={0,0,255}));
connect(resistor1.n, opAmp.in_n) annotation (Line(points={{-40,30},{-30,30},
{-30,6},{-20,6}}, color={0,0,255}));
annotation (experiment(
StopTime=0.2,
Interval=0.0001,
Tolerance=1e-06),
Diagram(coordinateSystem(extent={{-140,-100},{140,100}})),
Icon(coordinateSystem(extent={{-100,-100},{100,100}})),
Documentation(info="<html>
<p>
This model demonstrates a differential amplifier to attenuate the input voltage to a level that can be handled by the measurement instrument.
</p>
<p>
Two sinusoidal source voltages with a phase shift of 120° (e.g., two phases of a three-phase system) feed a load resistor.
The voltage at the load resistor has to be measured but is too high for direct measurement.
</p>
<h4>Notes</h4>
<ul>
<li>The output of the amplifier is inverted with respect to the differential input, as well as attenuated by the factor 1/data.k.</li>
<li>The influence of the measurement instrument's input resistance on the measurement result is small.</li>
<li>The current consumption of the amplifier inputs at the source circuit is small (<code>resistor1.i</code> and <code>resistor2.i</code>).</li>
<li>The common of the source and the common of the amplifier are connected by a ground resistor.
In case this resistance is low, a small current is flowing between the amplifier's common and the source's common (<code>resistorGround.i</code>).
In case this resistance is high, the amplifier's common is floating with respect to the source's common with a high voltage (<code>resistorGround.v</code>).</li>
</ul>
</html>"));
end DifferentialAmplifier;
model Adder "Inverting adder"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.SineVoltage vIn1(V=Vin, f=f) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-60,0})));
Sources.ConstantVoltage vIn2(V=Vin) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,-10})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Add add(p1_2(i(start=0)))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(add.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
connect(vIn1.p, add.p1)
annotation (Line(points={{-60,10},{-10,10}}, color={0,0,255}));
connect(vIn2.p, add.p1_2)
annotation (Line(points={{-40,0},{-10,0}}, color={0,0,255}));
connect(ground.p, vIn2.n)
annotation (Line(points={{-10,-20},{-40,-20}}, color={0,0,255}));
connect(ground.p, vIn1.n)
annotation (Line(points={{-10,-20},{-60,-20},{-60,-10}}, color={0,0,255}));
connect(add.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(add.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is an inverting adder.</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Adder;
model Subtracter "Inverting subtracter"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.SineVoltage vIn1(V=Vin, f=f) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-60,0})));
Sources.ConstantVoltage vIn2(V=Vin) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,-10})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Feedback feedback(p1_2(i(start=0)))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(feedback.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
connect(vIn1.p, feedback.p1)
annotation (Line(points={{-60,10},{-10,10}}, color={0,0,255}));
connect(vIn2.p, feedback.p1_2)
annotation (Line(points={{-40,0},{-10,0}}, color={0,0,255}));
connect(ground.p, vIn2.n)
annotation (Line(points={{-10,-20},{-40,-20}}, color={0,0,255}));
connect(ground.p, vIn1.n)
annotation (Line(points={{-10,-20},{-60,-20},{-60,-10}}, color={0,0,255}));
connect(feedback.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(feedback.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is an inverting subtracter.</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Subtracter;
model Differentiator "Differentiating amplifier"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.SineVoltage vIn(V=Vin,
f=f) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Der der_(f=f, v(fixed=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.p, der_.p1)
annotation (Line(points={{-40,10},{-10,10}}, color={0,0,255}));
connect(vIn.n, der_.n1)
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
connect(der_.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
connect(der_.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(der_.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a (inverting) differentiating amplifier. Resistance R can be chosen, capacitance C is defined by the desired time constant resp. frequency.</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Differentiator;
model Integrator "Integrating amplifier"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.SineVoltage vIn(V=Vin, f=f)
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Integrator integrator(
v2(fixed=true, start=Vin), f=f,
opAmp(v_in(start=0)))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.p, integrator.p1)
annotation (Line(points={{-40,10},{-10,10}}, color={0,0,255}));
connect(vIn.n, integrator.n1)
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
connect(integrator.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
connect(integrator.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(integrator.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is an (inverting) integrating amplifier. Resistance R can be chosen, capacitance C is defined by the desired time constant resp. frequency.</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Integrator;
model LowPass "Low-pass filter"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.PulseVoltage vIn(
width=50,
period=1/f,
V=2*Vin,
offset=-Vin)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.FirstOrder firstOrder(
v2(fixed=true),
T=0.1/f,
opAmp(v_in(start=0)))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.n, firstOrder.n1)
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
connect(vIn.p, firstOrder.p1)
annotation (Line(points={{-40,10},{-10,10}}, color={0,0,255}));
connect(firstOrder.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(firstOrder.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
connect(firstOrder.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20},{-10,-20}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a (inverting) low pass filter. Resistance R1 can be chosen, resistance R2 is defined by the desired amplification k, capacitance C is defined by the desired cut-off frequency.</p>
<p>The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 13.3</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end LowPass;
model HighPass "High-pass filter"
extends Modelica.Icons.Example;
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Sources.PulseVoltage vIn(
width=50,
period=1/f,
V=2*Vin,
offset=-Vin)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Derivative derivative(T=0.1/f, v(fixed=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(vIn.p, derivative.p1) annotation (Line(points={{-40,10},{-26,10},{-26,
10},{-10,10}}, color={0,0,255}));
connect(vIn.n, derivative.n1)
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
connect(derivative.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(derivative.n2, vOut.p)
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
connect(derivative.n1, ground.p)
annotation (Line(points={{-10,-10},{-10,-20},{-10,-20}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a (inverting) high pass filter. Resistance R1 can be chosen, resistance R2 is defined by the desired amplification k, capacitance C is defined by the desired cut-off frequency.</p>
<p>The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 13.3</p>
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end HighPass;
model ControlCircuit "Control circuit"
extends Modelica.Icons.Example;
parameter Modelica.SIunits.Time T1=0.01 "Small time constant";
parameter Modelica.SIunits.Time T2=0.01 "Large time constant";
parameter Modelica.SIunits.Time Ti=T2 "Integral time constant";
parameter Real kp=T2/(2*T1) "Proportional gain";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-100,-100},{-80,-80}})));
Sources.StepVoltage stepA(V=10, startTime=0.1) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-90,-62})));
OpAmpCircuits.Feedback feedbackA(p1(i(start=0)))
annotation (Placement(transformation(extent={{-70,-40},{-50,-20}})));
OpAmpCircuits.PI PIA(
v2(fixed=true),
k=kp,
T=Ti,
opAmp(v_in(start=0)))
annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));
OpAmpCircuits.FirstOrder firstOrder1A(
v2(fixed=true),
T=T1,
opAmp(v_in(start=0)))
annotation (Placement(transformation(extent={{-10,-40},{10,-20}})));
OpAmpCircuits.Add addA(i1_2(start=0), r(i(start=0)))
annotation (Placement(transformation(extent={{30,-40},{50,-20}})));
Sources.StepVoltage step1A(V=1, startTime=0.5) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={20,-60})));
OpAmpCircuits.FirstOrder firstOrder2A(
v2(fixed=true),
T=T2,
opAmp(v_in(start=0)))
annotation (Placement(transformation(extent={{60,-40},{80,-20}})));
Blocks.Sources.Step stepB(height=10, startTime=0.1)
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
Blocks.Math.Feedback feedbackB
annotation (Placement(transformation(extent={{-70,60},{-50,80}})));
Blocks.Continuous.PI PIB(
k=kp,
T=Ti,
initType=Modelica.Blocks.Types.Init.InitialOutput)
annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
Blocks.Continuous.FirstOrder firstOrder1B(T=T1, initType=Modelica.Blocks.Types.Init.InitialOutput)
annotation (Placement(transformation(extent={{-10,60},{10,80}})));
Blocks.Math.Add addB
annotation (Placement(transformation(extent={{30,60},{50,80}})));
Blocks.Sources.Step step1B(height=1, startTime=0.5)
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=90,
origin={20,30})));
Blocks.Continuous.FirstOrder firstOrder2B(T=T2, initType=Modelica.Blocks.Types.Init.InitialOutput)
annotation (Placement(transformation(extent={{60,60},{80,80}})));
equation
connect(stepA.n, ground.p)
annotation (Line(points={{-90,-72},{-90,-80}}, color={0,0,255}));
connect(feedbackA.p2, PIA.p1)
annotation (Line(points={{-50,-20},{-40,-20}}, color={0,0,255}));
connect(feedbackA.n2, PIA.n1)
annotation (Line(points={{-50,-40},{-40,-40}}, color={0,0,255}));
connect(PIA.p2, firstOrder1A.p1)
annotation (Line(points={{-20,-20},{-10,-20}}, color={0,0,255}));
connect(PIA.n2, firstOrder1A.n1)
annotation (Line(points={{-20,-40},{-10,-40}}, color={0,0,255}));
connect(stepB.y,feedbackB. u1)
annotation (Line(points={{-79,70},{-68,70}}, color={0,0,127}));
connect(feedbackB.y,PIB. u)
annotation (Line(points={{-51,70},{-42,70}}, color={0,0,127}));
connect(PIB.y,firstOrder1B. u)
annotation (Line(points={{-19,70},{-12,70}},
color={0,0,127}));
connect(firstOrder1B.y, addB.u1) annotation (Line(points={{11,70},{19.5,70},{19.5,
76},{28,76}}, color={0,0,127}));
connect(addB.y, firstOrder2B.u)
annotation (Line(points={{51,70},{58,70}}, color={0,0,127}));
connect(step1B.y, addB.u2)
annotation (Line(points={{20,41},{20,64},{28,64}}, color={0,0,127}));
connect(firstOrder2B.y, feedbackB.u2) annotation (Line(points={{81,70},{90,70},
{90,50},{-60,50},{-60,62}}, color={0,0,127}));
connect(stepA.p, feedbackA.p1_2)
annotation (Line(points={{-90,-52},{-90,-30},{-70,-30}}, color={0,0,255}));
connect(firstOrder2A.p2, feedbackA.p1) annotation (Line(points={{80,-20},{80,-10},
{-70,-10},{-70,-20}}, color={0,0,255}));
connect(ground.p, feedbackA.n1)
annotation (Line(points={{-90,-80},{-70,-80},{-70,-40}}, color={0,0,255}));
connect(ground.p, step1A.n)
annotation (Line(points={{-90,-80},{20,-80},{20,-70}}, color={0,0,255}));
connect(firstOrder1A.n2, addA.n1)
annotation (Line(points={{10,-40},{30,-40}}, color={0,0,255}));
connect(firstOrder1A.p2, addA.p1)
annotation (Line(points={{10,-20},{30,-20}}, color={0,0,255}));
connect(step1A.p, addA.p1_2)
annotation (Line(points={{20,-50},{20,-30},{30,-30}}, color={0,0,255}));
connect(addA.p2, firstOrder2A.p1)
annotation (Line(points={{50,-20},{60,-20}}, color={0,0,255}));
connect(addA.n2, firstOrder2A.n1)
annotation (Line(points={{50,-40},{60,-40}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is an analog control circuit with operational amplifiers.</p>
<p>Compare the analog solution with the block circuit, e.g. <code>firstOrder2B.y</code> and <code>firstOrder2A.v2</code>.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end ControlCircuit;
model VoltageFollower "Reproduce input voltage"
extends Modelica.Icons.Example;
parameter SI.Voltage Vps=+15 "Positive supply";
parameter SI.Voltage Vns=-15 "Negative supply";
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
parameter SI.Resistance Ri=1
"Inner resistance of input voltage source";
parameter SI.Resistance Rl=1 "Load resistance";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
Vps=Vps,
Vns=Vns,
v_in(start=0))
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
V=2*Vin,
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
offset=-Vin,
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-80,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={60,-20})));
Modelica.Electrical.Analog.Basic.Resistor ri(R=Ri)
annotation (Placement(transformation(extent={{-60,0},{-40,20}})));
Modelica.Electrical.Analog.Basic.Resistor rl(R=Rl) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={30,-18})));
equation
connect(ground.p, vIn.n) annotation (Line(
points={{-10,-80},{-80,-80},{-80,-10}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{20,0},{60,0},{60,-10}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{-10,-80},{60,-80},{60,-30}}, color={0,0,255}));
connect(opAmp.out, opAmp.in_n) annotation (Line(
points={{20,0},{30,0},{30,20},{-10,20},{-10,6},{0,6}}, color={0,0,255}));
connect(vIn.p, ri.p) annotation (Line(
points={{-80,10},{-60,10}}, color={0,0,255}));
connect(ri.n, opAmp.in_p) annotation (Line(
points={{-40,10},{-20,10},{-20,-6},{0,-6}}, color={0,0,255}));
connect(opAmp.out, rl.p) annotation (Line(
points={{20,0},{30,0},{30,-8}}, color={0,0,255}));
connect(ground.p, rl.n) annotation (Line(
points={{-10,-80},{30,-80},{30,-28}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a voltage follower. It reproduces the input voltage at the output without loading the input voltage source with a stiff output.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end VoltageFollower;
model Comparator "Comparator"
extends Modelica.Icons.Example;
parameter SI.Voltage Vps=+15 "Positive supply";
parameter SI.Voltage Vns=-15 "Negative supply";
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
parameter SI.Voltage Vref=0 "Reference voltage";
parameter Real k=(Vref - Vns)/(Vps - Vns) "Calculated potentiometer ratio to reach Vref";
parameter SI.Resistance R=1000 "Resistance of potentiometer";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(Vps=Vps, Vns=
Vns) annotation (Placement(transformation(extent={{0,10},{20,-10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
startTime=-(vIn.rising + vIn.width/2),
V=2*Vin,
offset=-Vin) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-80,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={50,-20})));
Modelica.Electrical.Analog.Basic.Potentiometer potentiometer(R=R, rConstant=
k) annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
origin={-10,-30})));
Modelica.Electrical.Analog.Sources.SupplyVoltage supplyVoltage(Vps=Vps, Vns=
Vns) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
origin={-10,-50})));
equation
connect(vIn.p, opAmp.in_p) annotation (Line(
points={{-80,10},{-10,10},{-10,6},{0,6}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{20,0},{50,0},{50,-10}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{-10,-80},{50,-80},{50,-30}}, color={0,0,255}));
connect(ground.p, vIn.n) annotation (Line(
points={{-10,-80},{-80,-80},{-80,-10}}, color={0,0,255}));
connect(potentiometer.contact, opAmp.in_n) annotation (Line(
points={{0,-20},{0,-6}}, color={0,0,255}));
connect(potentiometer.pin_p, supplyVoltage.pin_p) annotation (Line(
points={{-20,-30},{-20,-50}}, color={0,0,255}));
connect(potentiometer.pin_n, supplyVoltage.pin_n) annotation (Line(
points={{0,-30},{0,-50}}, color={0,0,255}));
connect(ground.p, supplyVoltage.ground) annotation (Line(
points={{-10,-80},{-10,-50}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a comparator. Resistance R1 can be chosen, resistance R2 is defined by the desired reference voltage Vref (between Vn and Vp). The output switches between Vn for input voltage < Vref and Vp for input voltage > Vref.</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Comparator;
model InvertingSchmittTrigger "Inverting Schmitt trigger with hysteresis"
extends Modelica.Icons.Example;
parameter SI.Voltage Vps=+15 "Positive supply";
parameter SI.Voltage Vns=-15 "Negative supply";
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
parameter SI.Voltage vHys=1 "(Positive) hysteresis voltage";
parameter Real k=vHys/Vps "Auxiliary calculated parameter to be used in R2 calculation";
parameter SI.Resistance R1=1000 "Arbitrary resistance";
parameter SI.Resistance R2=(1 - k)/k*R1 "Calculated resistance to reach hysteresis voltage";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
Vps=Vps,
Vns=Vns,
out(i(start=0)))
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
startTime=-(vIn.rising + vIn.width/2),
V=2*Vin,
offset=-Vin) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-80,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={50,-20})));
Modelica.Electrical.Analog.Basic.Resistor r1(R=R1) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={30,-60})));
Modelica.Electrical.Analog.Basic.Resistor r2(R=R2) annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=90,
origin={30,-20})));
equation
connect(r2.n, r1.p) annotation (Line(
points={{30,-30},{30,-50}}, color={0,0,255}));
connect(ground.p, r1.n) annotation (Line(
points={{-10,-80},{30,-80},{30,-80},{30,-80},{30,-70},{30,-70}}, color={0,0,255}));
connect(opAmp.out, r2.p) annotation (Line(
points={{20,0},{30,0},{30,-10}}, color={0,0,255}));
connect(r2.n, opAmp.in_p) annotation (Line(
points={{30,-30},{30,-40},{-10,-40},{-10,-6},{0,-6}}, color={0,0,255}));
connect(vIn.p, opAmp.in_n) annotation (Line(
points={{-80,10},{-20,10},{-20,6},{0,6}}, color={0,0,255}));
connect(ground.p, vIn.n) annotation (Line(
points={{-10,-80},{-80,-80},{-80,-10}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{-10,-80},{50,-80},{50,-30}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{20,0},{50,0},{50,-10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a (inverting) Schmitt trigger. Resistance R1 can be chosen, resistance R2 is defined by the desired hysteresis. The output gets Vn for input voltage > 0 + vHys and Vp for input voltage < vHys*Vns/Vps.</p>
<p>The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 6.5.2</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end InvertingSchmittTrigger;
model SchmittTrigger "Schmitt trigger with hysteresis"
extends Modelica.Icons.Example;
parameter SI.Voltage Vps=+15 "Positive supply";
parameter SI.Voltage Vns=-15 "Negative supply";
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
parameter SI.Voltage vHys=1 "(Positive) hysteresis voltage";
parameter Real k=vHys/Vps "Auxiliary calculated parameter to be used in R2 calculation";
parameter SI.Resistance R1=1000 "Arbitrary resistance";
parameter SI.Resistance R2=R1/k "Calculated resistance to reach hysteresis voltage";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
Vps=Vps,
Vns=Vns,
out(i(start=0)))
annotation (Placement(transformation(extent={{0,10},{20,-10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
startTime=-(vIn.rising + vIn.width/2),
V=2*Vin,
offset=-Vin) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-80,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={50,-20})));
Modelica.Electrical.Analog.Basic.Resistor r1(R=R1) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
origin={-30,20})));
Modelica.Electrical.Analog.Basic.Resistor r2(R=R2) annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
rotation=180,
origin={10,20})));
equation
connect(ground.p, vIn.n) annotation (Line(
points={{-10,-80},{-80,-80},{-80,-10}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{-10,-80},{50,-80},{50,-30}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{20,0},{50,0},{50,-10}}, color={0,0,255}));
connect(opAmp.in_n, ground.p) annotation (Line(
points={{0,-6},{-10,-6},{-10,-80}}, color={0,0,255}));
connect(opAmp.out, r2.n) annotation (Line(
points={{20,0},{30,0},{30,20},{20,20}}, color={0,0,255}));
connect(r2.p, opAmp.in_p) annotation (Line(
points={{0,20},{-10,20},{-10,6},{0,6}}, color={0,0,255}));
connect(r2.p, r1.n) annotation (Line(
points={{0,20},{-20,20}}, color={0,0,255}));
connect(r1.p, vIn.p) annotation (Line(
points={{-40,20},{-80,20},{-80,10}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a (non-inverting) Schmitt trigger. Resistance R1 can be chosen, resistance R2 is defined by the desired hysteresis. The output gets Vp for input voltage > vHys and Vn for input voltage < vHys*Vns/Vps.</p>
<p>The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 6.5.2</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end SchmittTrigger;
model Multivibrator "Multivibrator with Schmitt trigger"
extends Modelica.Icons.Example;
parameter SI.Voltage Vps=+15 "Positive supply";
parameter SI.Voltage Vns=-15 "Negative supply";
parameter SI.Frequency f=10 "Desired frequency";
parameter SI.Resistance R1=1000 "Resistance 1 for adjusting the Schmitt trigger voltage level";
parameter SI.Resistance R2=1000 "Resistance 2 for adjusting the Schmitt trigger voltage level";
parameter SI.Resistance R=1000 "Arbitrary resistance";
parameter SI.Capacitance C=1/f/(2*R*log(1 + 2*R1/R2)) "Calculated capacitance to reach the desired frequency f";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
Vps=Vps,
Vns=Vns,
homotopyType = Modelica.Blocks.Types.LimiterHomotopy.LowerLimit,
strict = true) annotation (Placement(transformation(extent={{0,-10},{20,10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-80},{0,-60}})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={50,-20})));
Modelica.Electrical.Analog.Basic.Resistor r1(R=R1, i(start=0)) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-10,-40})));
Modelica.Electrical.Analog.Basic.Resistor r2(R=R2) annotation (Placement(
transformation(
extent={{10,10},{-10,-10}},
origin={10,-20})));
Modelica.Electrical.Analog.Basic.Resistor r(R=R)
annotation (Placement(transformation(extent={{20,20},{0,40}})));
Modelica.Electrical.Analog.Basic.Capacitor c(C=C, v(start=1, fixed=true))
annotation (Placement(transformation(
extent={{10,-10},{-10,10}},
rotation=90,
origin={-30,-40})));
equation
connect(ground.p, r1.n) annotation (Line(
points={{-10,-60},{-10,-50}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{-10,-60},{50,-60},{50,-30}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{20,0},{50,0},{50,-10}}, color={0,0,255}));
connect(ground.p, c.n) annotation (Line(
points={{-10,-60},{-30,-60},{-30,-50}}, color={0,0,255}));
connect(opAmp.out, r.p) annotation (Line(
points={{20,0},{30,0},{30,30},{20,30}}, color={0,0,255}));
connect(r.n, opAmp.in_n) annotation (Line(
points={{0,30},{-10,30},{-10,6},{0,6}}, color={0,0,255}));
connect(opAmp.out, r2.p) annotation (Line(
points={{20,0},{30,0},{30,-20},{20,-20}}, color={0,0,255}));
connect(r2.n, opAmp.in_p) annotation (Line(
points={{0,-20},{-10,-20},{-10,-6},{0,-6}}, color={0,0,255}));
connect(opAmp.in_p, r1.p) annotation (Line(
points={{0,-6},{-10,-6},{-10,-30}}, color={0,0,255}));
connect(r.n, c.p) annotation (Line(
points={{0,30},{-30,30},{-30,-30}}, color={0,0,255}));
annotation (Documentation(info="<html>
<p>This is a Multivibrator with Schmitt trigger according to:</p>
<p>U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 6.5.3</p>
</html>"),
experiment(
StartTime=0,
StopTime=1,
Tolerance=1e-006,
Interval=0.001));
end Multivibrator;
model SignalGenerator "Rectangle-Triangle generator"