Skip to content

Commit 742bc58

Browse files
authored
Merge pull request #4643 from AHaumer/OpAmpRedesign
ImprovedOpAmpLimited replaces IdealizedOpAmpLimited (which is deprecated), with finite gain, saturation, optional supply and optional firstOrder rise of output which improves stability. The examples in Modelica.Electrical.Analog.Examples.OpAmps are adapted to use the new ImprovedOpAmpLimited and harmonized polarity of output voltage sensor.
2 parents a1d503b + 9209342 commit 742bc58

37 files changed

Lines changed: 416 additions & 200 deletions

Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ model Adder "Inverting adder"
55
parameter SI.Frequency f=10 "Frequency of input voltage";
66
Modelica.Electrical.Analog.Basic.Ground ground
77
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
8-
Sources.SineVoltage vIn1(V=Vin, f=f) annotation (Placement(
9-
transformation(
8+
Modelica.Electrical.Analog.Sources.SineVoltage vIn1(V=Vin, f=f) annotation
9+
(Placement(transformation(
1010
extent={{-10,-10},{10,10}},
1111
rotation=270,
1212
origin={-60,0})));
13-
Sources.ConstantVoltage vIn2(V=Vin) annotation (Placement(
14-
transformation(
13+
Modelica.Electrical.Analog.Sources.ConstantVoltage vIn2(V=Vin) annotation (
14+
Placement(transformation(
1515
extent={{-10,-10},{10,10}},
1616
rotation=270,
1717
origin={-40,-10})));
1818
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
1919
transformation(
20-
extent={{10,10},{-10,-10}},
20+
extent={{-10,10},{10,-10}},
2121
rotation=270,
2222
origin={40,0})));
23-
OpAmpCircuits.Add add(p1_2(i(start=0)))
23+
OpAmpCircuits.Add add
2424
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
2525
equation
2626
connect(add.n1, ground.p)
@@ -33,13 +33,12 @@ equation
3333
annotation (Line(points={{-10,-20},{-40,-20}}, color={0,0,255}));
3434
connect(ground.p, vIn1.n)
3535
annotation (Line(points={{-10,-20},{-60,-20},{-60,-10}}, color={0,0,255}));
36-
connect(add.p2, vOut.n)
36+
connect(add.p2, vOut.p)
3737
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
38-
connect(add.n2, vOut.p)
38+
connect(add.n2, vOut.n)
3939
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
4040
annotation (Documentation(info="<html>
4141
<p>This is an inverting adder.</p>
42-
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
4342
</html>"),
4443
experiment(
4544
StartTime=0,

Modelica/Electrical/Analog/Examples/OpAmps/Comparator.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ model Comparator "Comparator"
88
parameter SI.Voltage Vref=0 "Reference voltage";
99
parameter Real k=(Vref - Vns)/(Vps - Vns) "Calculated potentiometer ratio to reach Vref";
1010
parameter SI.Resistance R=1000 "Resistance of potentiometer";
11-
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(Vps=Vps, Vns=
12-
Vns) annotation (Placement(transformation(extent={{0,10},{20,-10}})));
11+
Modelica.Electrical.Analog.Ideal.ImprovedOpAmpLimited opAmp(Vps=Vps, Vns=Vns)
12+
annotation (Placement(transformation(extent={{0,10},{20,-10}})));
1313
Modelica.Electrical.Analog.Basic.Ground ground
1414
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
1515
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(

Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,50 @@ model ControlCircuit "Control circuit"
77
parameter Real kp=T2/(2*T1) "Proportional gain";
88
Modelica.Electrical.Analog.Basic.Ground ground
99
annotation (Placement(transformation(extent={{-100,-100},{-80,-80}})));
10-
Sources.StepVoltage stepA(V=10, startTime=0.1) annotation (Placement(
11-
transformation(
10+
Modelica.Electrical.Analog.Sources.StepVoltage stepA(V=10, startTime=0.1)
11+
annotation (Placement(transformation(
1212
extent={{-10,-10},{10,10}},
1313
rotation=270,
1414
origin={-90,-62})));
15-
OpAmpCircuits.Feedback feedbackA(p1(i(start=0)))
15+
OpAmpCircuits.Feedback feedbackA(i1(start=0), i2(start=0))
1616
annotation (Placement(transformation(extent={{-70,-40},{-50,-20}})));
1717
OpAmpCircuits.PI PIA(
18-
v2(fixed=true),
1918
k=kp,
2019
T=Ti,
21-
opAmp(v_in(start=0)))
20+
v(fixed=true))
2221
annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));
2322
OpAmpCircuits.FirstOrder firstOrder1A(
24-
v2(fixed=true),
25-
T=T1,
26-
opAmp(v_in(start=0)))
23+
T=T1, v(fixed=true))
2724
annotation (Placement(transformation(extent={{-10,-40},{10,-20}})));
28-
OpAmpCircuits.Add addA(i1_2(start=0), r(i(start=0)))
25+
OpAmpCircuits.Add addA(r(i(start=0)))
2926
annotation (Placement(transformation(extent={{30,-40},{50,-20}})));
30-
Sources.StepVoltage step1A(V=1, startTime=0.5) annotation (Placement(
31-
transformation(
27+
Modelica.Electrical.Analog.Sources.StepVoltage step1A(V=1, startTime=0.5)
28+
annotation (Placement(transformation(
3229
extent={{-10,-10},{10,10}},
3330
rotation=270,
3431
origin={20,-60})));
3532
OpAmpCircuits.FirstOrder firstOrder2A(
36-
v2(fixed=true),
37-
T=T2,
38-
opAmp(v_in(start=0)))
33+
T=T2, v(fixed=true))
3934
annotation (Placement(transformation(extent={{60,-40},{80,-20}})));
40-
Blocks.Sources.Step stepB(height=10, startTime=0.1)
35+
Modelica.Blocks.Sources.Step stepB(height=10, startTime=0.1)
4136
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
42-
Blocks.Math.Feedback feedbackB
37+
Modelica.Blocks.Math.Feedback feedbackB
4338
annotation (Placement(transformation(extent={{-70,60},{-50,80}})));
44-
Blocks.Continuous.PI PIB(
39+
Modelica.Blocks.Continuous.PI PIB(
4540
k=kp,
4641
T=Ti,
4742
initType=Modelica.Blocks.Types.Init.InitialOutput)
4843
annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
49-
Blocks.Continuous.FirstOrder firstOrder1B(T=T1, initType=Modelica.Blocks.Types.Init.InitialOutput)
44+
Modelica.Blocks.Continuous.FirstOrder firstOrder1B(T=T1, initType=Modelica.Blocks.Types.Init.InitialOutput)
5045
annotation (Placement(transformation(extent={{-10,60},{10,80}})));
51-
Blocks.Math.Add addB
46+
Modelica.Blocks.Math.Add addB
5247
annotation (Placement(transformation(extent={{30,60},{50,80}})));
53-
Blocks.Sources.Step step1B(height=1, startTime=0.5)
54-
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
48+
Modelica.Blocks.Sources.Step step1B(height=1, startTime=0.5) annotation (
49+
Placement(transformation(
50+
extent={{-10,-10},{10,10}},
5551
rotation=90,
5652
origin={20,30})));
57-
Blocks.Continuous.FirstOrder firstOrder2B(T=T2, initType=Modelica.Blocks.Types.Init.InitialOutput)
53+
Modelica.Blocks.Continuous.FirstOrder firstOrder2B(T=T2, initType=Modelica.Blocks.Types.Init.InitialOutput)
5854
annotation (Placement(transformation(extent={{60,60},{80,80}})));
5955
equation
6056
connect(stepA.n, ground.p)

Modelica/Electrical/Analog/Examples/OpAmps/DifferentialAmplifier.mo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
within Modelica.Electrical.Analog.Examples.OpAmps;
22
model DifferentialAmplifier "Differential amplifier"
33
extends Modelica.Icons.Example;
4-
parameter
5-
Modelica.Electrical.Analog.Examples.OpAmps.OpAmpCircuits.DifferentialAmplifierData
6-
data "Parameters for source, OpAmp and measurement"
7-
annotation (Placement(transformation(extent={{50,10},{70,30}})));
4+
parameter OpAmps.OpAmpCircuits.DifferentialAmplifierData data
5+
"Parameters for source, OpAmp and measurement"
6+
annotation (Placement(transformation(extent={{50,10},{70,30}})));
87
Modelica.Electrical.Analog.Sources.SineVoltage sourceVoltage1(
98
V=sqrt(2/3)*data.VSource,
109
phase=1.0471975511966,
@@ -33,7 +32,7 @@ model DifferentialAmplifier "Differential amplifier"
3332
Modelica.Electrical.Analog.Basic.Resistor resistorGround(R=data.RGround,
3433
i(start=0, fixed=false))
3534
annotation (Placement(transformation(extent={{-60,-70},{-40,-50}})));
36-
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
35+
Modelica.Electrical.Analog.Ideal.ImprovedOpAmpLimited opAmp(
3736
V0=data.V0,
3837
useSupply=true,
3938
Vps=+data.VSupply,

Modelica/Electrical/Analog/Examples/OpAmps/Differentiator.mo

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ model Differentiator "Differentiating amplifier"
55
parameter SI.Frequency f=10 "Frequency of input voltage";
66
Modelica.Electrical.Analog.Basic.Ground ground
77
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
8-
Sources.TrapezoidVoltage vIn(
8+
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
99
V=2*Vin,
1010
rising=0.2/f,
1111
width=0.3/f,
1212
falling=0.2/f,
1313
period=1/f,
1414
nperiod=-1,
1515
offset=-Vin,
16-
startTime=-(vIn.rising + vIn.width/2))
17-
annotation (Placement(
16+
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
1817
transformation(
1918
extent={{-10,-10},{10,10}},
2019
rotation=270,
@@ -42,7 +41,6 @@ equation
4241
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
4342
annotation (Documentation(info="<html>
4443
<p>This is a (inverting) differentiating amplifier. Resistance R can be chosen, capacitance C is defined by the desired time constant resp. frequency.</p>
45-
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
4644
</html>"),
4745
experiment(
4846
StartTime=0,

Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ model HighPass "High-pass filter"
1515
OpAmpCircuits.Derivative derivative(T=1/(2*pi*fG),
1616
v(fixed=true))
1717
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
18-
Sources.TrapezoidVoltage vIn(
18+
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
1919
V=Vin,
2020
rising=0.2/f,
2121
width=0.3/f,
2222
falling=0.2/f,
2323
period=1/f,
2424
nperiod=-1,
2525
offset=0,
26-
startTime=-(vIn.rising + vIn.width/2))
27-
annotation (Placement(
26+
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
2827
transformation(
2928
extent={{-10,-10},{10,10}},
3029
rotation=270,
@@ -43,7 +42,6 @@ equation
4342
annotation (Documentation(info="<html>
4443
<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>
4544
<p>The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 13.3</p>
46-
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
4745
</html>"),
4846
experiment(
4947
StartTime=0,

Modelica/Electrical/Analog/Examples/OpAmps/Integrator.mo

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ model Integrator "Integrating amplifier"
1515
f=f,
1616
v(fixed=true))
1717
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
18-
Sources.TrapezoidVoltage vIn(
18+
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
1919
V=2*Vin,
2020
rising=0.2/f,
2121
width=0.3/f,
2222
falling=0.2/f,
2323
period=1/f,
2424
nperiod=-1,
2525
offset=-Vin,
26-
startTime=-(vIn.rising + vIn.width/2))
27-
annotation (Placement(
26+
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
2827
transformation(
2928
extent={{-10,-10},{10,10}},
3029
rotation=270,
@@ -42,7 +41,6 @@ equation
4241
annotation (Line(points={{-40,-10},{-10,-10}}, color={0,0,255}));
4342
annotation (Documentation(info="<html>
4443
<p>This is an (inverting) integrating amplifier. Resistance R can be chosen, capacitance C is defined by the desired time constant resp. frequency.</p>
45-
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
4644
</html>"),
4745
experiment(
4846
StartTime=0,

Modelica/Electrical/Analog/Examples/OpAmps/InvertingAmplifier.mo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ model InvertingAmplifier "Inverting amplifier"
2020
origin={-40,0})));
2121
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
2222
transformation(
23-
extent={{10,10},{-10,-10}},
23+
extent={{-10,10},{10,-10}},
2424
rotation=270,
2525
origin={40,0})));
2626
OpAmpCircuits.Gain gain(k=2)
@@ -32,14 +32,13 @@ equation
3232
annotation (Line(points={{-10,-10},{-10,-20}}, color={0,0,255}));
3333
connect(gain.n1, vIn.n)
3434
annotation (Line(points={{-10,-10},{-40,-10}}, color={0,0,255}));
35-
connect(gain.p2, vOut.n)
36-
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
37-
connect(gain.n2, vOut.p)
35+
connect(gain.n2, vOut.n)
3836
annotation (Line(points={{10,-10},{40,-10}}, color={0,0,255}));
37+
connect(gain.p2, vOut.p)
38+
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
3939
annotation (
4040
Documentation(info="<html>
4141
<p>This is an inverting amplifier.</p>
42-
<p>Note: <code>vOut</code> measure the negative output voltage.</p>
4342
</html>"),
4443
experiment(
4544
StartTime=0,

Modelica/Electrical/Analog/Examples/OpAmps/InvertingSchmittTrigger.mo

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ model InvertingSchmittTrigger "Inverting Schmitt trigger with hysteresis"
88
parameter SI.Voltage vHys=1 "(Positive) hysteresis voltage";
99
parameter Real k=vHys/Vps "Auxiliary calculated parameter to be used in R2 calculation";
1010
parameter SI.Resistance R1=1000 "Arbitrary resistance";
11-
parameter SI.Resistance R2=(1 - k)/k*R1 "Calculated resistance to reach hysteresis voltage";
12-
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
13-
Vps=Vps,
14-
Vns=Vns,
15-
out(i(start=0)))
11+
parameter SI.Resistance R2=(1 - k)/k*R1
12+
"Calculated resistance to reach hysteresis voltage";
13+
Modelica.Electrical.Analog.Ideal.ImprovedOpAmpLimited opAmp(Vps=Vps, Vns=Vns)
1614
annotation (Placement(transformation(extent={{0,-10},{20,10}})));
1715
Modelica.Electrical.Analog.Basic.Ground ground
1816
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));

Modelica/Electrical/Analog/Examples/OpAmps/LCOscillator.mo

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ model LCOscillator "LC oscillator"
66
parameter SI.Frequency f=1000 "Desired frequency";
77
parameter Real A=1.001 "Amplification constant: A > 1 amplification, A = 1 pure sinusoidal oscillation, A < 0 damping";
88
parameter SI.Inductance L=0.001 "Arbitrary inductance > 0";
9-
parameter SI.Capacitance C=1/((2*pi*f)^2*L) "Calculated capacitance to reach frequency f";
9+
parameter SI.Capacitance C=1/((2*pi*f)^2*L)
10+
"Calculated capacitance to reach frequency f";
1011
parameter SI.Resistance R=10000.0 "Damping resistance";
11-
parameter SI.Resistance R1=10000.0 "Arbitrary high resistance";
12-
parameter SI.Resistance R2=(A - 1)*R1 "Calculated resistance to reach amplification A";
12+
parameter SI.Resistance R1=10000.0
13+
"Arbitrary high resistance";
14+
parameter SI.Resistance R2=(A - 1)*R1
15+
"Calculated resistance to reach amplification A";
1316
parameter Real gamma=(1 - A)/(2*R*C) "Calculated characteristical parameter";
1417
Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(
1518
transformation(
1619
origin={20,-50},
1720
extent={{-10,-10},{10,10}})));
18-
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp
21+
Modelica.Electrical.Analog.Ideal.ImprovedOpAmpLimited opAmp
1922
annotation (Placement(transformation(extent={{-50,10},{-30,-10}})));
2023
Modelica.Electrical.Analog.Basic.Resistor r(R=R)
2124
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));

0 commit comments

Comments
 (0)