Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
AHaumer committed Jan 10, 2025
1 parent 3e0b6c8 commit b2bb095
Show file tree
Hide file tree
Showing 30 changed files with 385 additions and 498 deletions.
22 changes: 11 additions & 11 deletions Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model Adder "Inverting adder"
extends Modelica.Icons.Example;
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
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.SineVoltage vIn1(V=Vin, f=f) annotation (
Placement(transformation(
Sources.SineVoltage vIn1(V=Vin, f=f) annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-60,0})));
Modelica.Electrical.Analog.Sources.ConstantVoltage vIn2(V=Vin) annotation (
Placement(transformation(
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}},
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Add add
Expand All @@ -33,10 +33,10 @@ equation
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(vOut.p, add.p2)
annotation (Line(points={{40,10},{10,10}}, color={0,0,255}));
connect(vOut.n, add.n2)
annotation (Line(points={{40,-10},{10,-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>
Expand Down
53 changes: 21 additions & 32 deletions Modelica/Electrical/Analog/Examples/OpAmps/Comparator.mo
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model Comparator "Comparator"
extends Modelica.Icons.Example;
parameter Real V0=15000.0 "No-load amplification";
parameter Modelica.Units.SI.Voltage Vps=+15 "Positive supply";
parameter Modelica.Units.SI.Voltage Vns=-15 "Negative supply";
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
parameter Modelica.Units.SI.Voltage Vref=0 "Reference voltage";
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 Modelica.Units.SI.Resistance R=1000 "Resistance of potentiometer";
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp(
V0=V0,
useSupply=false,
Vps=Vps,
Vns=Vns,
regularized=true,
smoothed=false,
strict=false)
annotation (Placement(transformation(extent={{-10,10},{10,-10}})));
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={{-10,-100},{10,-80}})));
annotation (Placement(transformation(extent={{-20,-100},{0,-80}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
rising=0.2/f,
width=0.3/f,
Expand All @@ -31,40 +23,37 @@ model Comparator "Comparator"
offset=-Vin) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={-40,0})));
origin={-80,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={40,-10})));
origin={50,-20})));
Modelica.Electrical.Analog.Basic.Potentiometer potentiometer(R=R, rConstant=
k) annotation (Placement(transformation(
extent={{-10,10},{10,-10}},
origin={-20,-30})));
origin={-10,-30})));
Modelica.Electrical.Analog.Sources.SupplyVoltage supplyVoltage(Vps=Vps, Vns=
Vns) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
origin={-20,-50})));
origin={-10,-50})));
equation
connect(vIn.p, opAmp.in_p) annotation (Line(
points={{-40,10},{-10,10},{-10,6}}, color={0,0,255}));
points={{-80,10},{-10,10},{-10,6},{0,6}}, color={0,0,255}));
connect(opAmp.out, vOut.p) annotation (Line(
points={{10,0},{40,0}}, color={0,0,255}));
points={{20,0},{50,0},{50,-10}}, color={0,0,255}));
connect(ground.p, vOut.n) annotation (Line(
points={{0,-80},{40,-80},{40,-20}}, color={0,0,255}));
points={{-10,-80},{50,-80},{50,-30}}, color={0,0,255}));
connect(ground.p, vIn.n) annotation (Line(
points={{0,-80},{-40,-80},{-40,-10}}, color={0,0,255}));
points={{-10,-80},{-80,-80},{-80,-10}}, color={0,0,255}));
connect(potentiometer.contact, opAmp.in_n) annotation (Line(
points={{-10,-20},{-10,-6}},
color={0,0,255}));
points={{0,-20},{0,-6}}, color={0,0,255}));
connect(potentiometer.pin_p, supplyVoltage.pin_p) annotation (Line(
points={{-30,-30},{-30,-50}}, color={0,0,255}));
points={{-20,-30},{-20,-50}}, color={0,0,255}));
connect(potentiometer.pin_n, supplyVoltage.pin_n) annotation (Line(
points={{-10,-30},{-10,-50}},
color={0,0,255}));
points={{0,-30},{0,-50}}, color={0,0,255}));
connect(ground.p, supplyVoltage.ground) annotation (Line(
points={{0,-80},{-20,-80},{-20,-50}},
color={0,0,255}));
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 &lt; Vref and Vp for input voltage &gt; Vref.</p>
</html>"),
Expand Down
50 changes: 20 additions & 30 deletions Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo
Original file line number Diff line number Diff line change
@@ -1,63 +1,53 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model ControlCircuit "Control circuit"
extends Modelica.Icons.Example;
parameter Modelica.Units.SI.Time T1=0.01 "Small time constant";
parameter Modelica.Units.SI.Time T2=0.01 "Large time constant";
parameter Modelica.Units.SI.Time Ti=T2 "Integral time constant";
parameter SI.Time T1=0.01 "Small time constant";
parameter SI.Time T2=0.01 "Large time constant";
parameter SI.Time Ti=T2 "Integral time constant";
parameter Real kp=T2/(2*T1) "Proportional gain";
Modelica.Units.SI.Voltage yA=firstOrder2A.v2 "Result obtained with opAmps";
output Real yB=firstOrder2B.y "Exact result";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-100,-100},{-80,-80}})));
Modelica.Electrical.Analog.Sources.StepVoltage stepA(V=10, startTime=0.1)
annotation (Placement(transformation(
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)))
OpAmpCircuits.Feedback feedbackA
annotation (Placement(transformation(extent={{-70,-40},{-50,-20}})));
OpAmpCircuits.PI PIA(
v2(fixed=true),
k=kp,
T=Ti,
opAmp(v_in(start=0)))
v(fixed=true))
annotation (Placement(transformation(extent={{-40,-40},{-20,-20}})));
OpAmpCircuits.FirstOrder firstOrder1A(
v2(fixed=true),
T=T1,
opAmp(v_in(start=0)))
OpAmpCircuits.FirstOrder firstOrder1A(T=T1, v(fixed=true))
annotation (Placement(transformation(extent={{-10,-40},{10,-20}})));
OpAmpCircuits.Add addA(i1_2(start=0), r(i(start=0)))
OpAmpCircuits.Add addA
annotation (Placement(transformation(extent={{30,-40},{50,-20}})));
Modelica.Electrical.Analog.Sources.StepVoltage step1A(V=1, startTime=0.5)
annotation (Placement(transformation(
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)))
OpAmpCircuits.FirstOrder firstOrder2A(T=T2, v(fixed=true))
annotation (Placement(transformation(extent={{60,-40},{80,-20}})));
Modelica.Blocks.Sources.Step stepB(height=10, startTime=0.1)
Blocks.Sources.Step stepB(height=10, startTime=0.1)
annotation (Placement(transformation(extent={{-100,60},{-80,80}})));
Modelica.Blocks.Math.Feedback feedbackB
Blocks.Math.Feedback feedbackB
annotation (Placement(transformation(extent={{-70,60},{-50,80}})));
Modelica.Blocks.Continuous.PI PIB(
Blocks.Continuous.PI PIB(
k=kp,
T=Ti,
initType=Modelica.Blocks.Types.Init.InitialOutput)
annotation (Placement(transformation(extent={{-40,60},{-20,80}})));
Modelica.Blocks.Continuous.FirstOrder firstOrder1B(T=T1, initType=Modelica.Blocks.Types.Init.InitialOutput)
Blocks.Continuous.FirstOrder firstOrder1B(T=T1, initType=Modelica.Blocks.Types.Init.InitialOutput)
annotation (Placement(transformation(extent={{-10,60},{10,80}})));
Modelica.Blocks.Math.Add addB
Blocks.Math.Add addB
annotation (Placement(transformation(extent={{30,60},{50,80}})));
Modelica.Blocks.Sources.Step step1B(height=1, startTime=0.5) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
Blocks.Sources.Step step1B(height=1, startTime=0.5)
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=90,
origin={20,30})));
Modelica.Blocks.Continuous.FirstOrder firstOrder2B(T=T2, initType=Modelica.Blocks.Types.Init.InitialOutput)
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model DifferentialAmplifier "Differential amplifier"
extends Modelica.Icons.Example;
parameter OpAmps.OpAmpCircuits.DifferentialAmplifierData data
"Parameters for source, OpAmp and measurement"
annotation (Placement(transformation(extent={{50,10},{70,30}})));
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,
Expand Down Expand Up @@ -36,18 +37,11 @@ model DifferentialAmplifier "Differential amplifier"
V0=data.V0,
useSupply=true,
Vps=+data.VSupply,
Vns=-data.VSupply,
regularized=false,
smoothed=false,
strict=false,
vps(start=+data.VSupply),
vns(start=-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))
Modelica.Electrical.Analog.Basic.Resistor resistor1(R=data.R1)
annotation (Placement(transformation(extent={{-60,20},{-40,40}})));
Modelica.Electrical.Analog.Basic.Resistor resistor2(R=data.R2,
i(start=0, fixed=false))
Modelica.Electrical.Analog.Basic.Resistor resistor2(R=data.R2)
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}})));
Expand Down
9 changes: 5 additions & 4 deletions Modelica/Electrical/Analog/Examples/OpAmps/Differentiator.mo
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model Differentiator "Differentiating amplifier"
extends Modelica.Icons.Example;
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
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(
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(
startTime=-(vIn.rising + vIn.width/2))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
Expand Down
15 changes: 8 additions & 7 deletions Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ within Modelica.Electrical.Analog.Examples.OpAmps;
model HighPass "High-pass filter"
extends Modelica.Icons.Example;
import Modelica.Constants.pi;
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
parameter Modelica.Units.SI.Frequency fG=f/10 "Limiting frequency";
parameter SI.Voltage Vin=5 "Amplitude of input voltage";
parameter SI.Frequency f=10 "Frequency of input voltage";
parameter SI.Frequency fG=f/10 "Limiting frequency";
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Derivative derivative(T=1/(2*pi*fG),
v(fixed=true))
OpAmpCircuits.Derivative derivative(
T=1/(2*pi*fG), v(fixed=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
Sources.TrapezoidVoltage vIn(
V=Vin,
rising=0.2/f,
width=0.3/f,
falling=0.2/f,
period=1/f,
nperiod=-1,
offset=0,
startTime=-(vIn.rising + vIn.width/2)) annotation (Placement(
startTime=-(vIn.rising + vIn.width/2))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
Expand Down
9 changes: 5 additions & 4 deletions Modelica/Electrical/Analog/Examples/OpAmps/Integrator.mo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model Integrator "Integrating amplifier"
extends Modelica.Icons.Example;
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
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.Sensors.VoltageSensor vOut annotation (Placement(
Expand All @@ -15,15 +15,16 @@ model Integrator "Integrating amplifier"
f=f,
v(fixed=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Electrical.Analog.Sources.TrapezoidVoltage vIn(
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(
startTime=-(vIn.rising + vIn.width/2))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
Expand Down
11 changes: 6 additions & 5 deletions Modelica/Electrical/Analog/Examples/OpAmps/InvertingAmplifier.mo
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
within Modelica.Electrical.Analog.Examples.OpAmps;
model InvertingAmplifier "Inverting amplifier"
extends Modelica.Icons.Example;
parameter Modelica.Units.SI.Voltage Vin=5 "Amplitude of input voltage";
parameter Modelica.Units.SI.Frequency f=10 "Frequency of input voltage";
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(
Expand All @@ -20,7 +20,7 @@ model InvertingAmplifier "Inverting amplifier"
origin={-40,0})));
Modelica.Electrical.Analog.Sensors.VoltageSensor vOut annotation (Placement(
transformation(
extent={{-10,10},{10,-10}},
extent={{10,10},{-10,-10}},
rotation=270,
origin={40,0})));
OpAmpCircuits.Gain gain(k=2)
Expand All @@ -32,13 +32,14 @@ equation
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.p)
connect(gain.p2, vOut.n)
annotation (Line(points={{10,10},{40,10}}, color={0,0,255}));
connect(gain.n2, vOut.n)
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,
Expand Down
Loading

0 comments on commit b2bb095

Please sign in to comment.