diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo b/Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo index 4ca9262c83..b95cf5b06a 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/Adder.mo @@ -20,7 +20,7 @@ model Adder "Inverting adder" extent={{10,10},{-10,-10}}, rotation=270, origin={40,0}))); - OpAmpCircuits.Add add(p1_2(i(start=0))) + OpAmpCircuits.Add add annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); equation connect(add.n1, ground.p) diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo b/Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo index 2193b8d5f1..1e28ba8047 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/ControlCircuit.mo @@ -12,30 +12,23 @@ model ControlCircuit "Control circuit" 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}}))); 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}}))); Blocks.Sources.Step stepB(height=10, startTime=0.1) annotation (Placement(transformation(extent={{-100,60},{-80,80}}))); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/DifferentialAmplifier.mo b/Modelica/Electrical/Analog/Examples/OpAmps/DifferentialAmplifier.mo index 695827c4c8..3e24c6cfe8 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/DifferentialAmplifier.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/DifferentialAmplifier.mo @@ -39,11 +39,9 @@ model DifferentialAmplifier "Differential amplifier" 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)) + 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}}))); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo b/Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo index 4ac11ef920..7c0837f45e 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/HighPass.mo @@ -12,8 +12,8 @@ model HighPass "High-pass filter" 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}}))); Sources.TrapezoidVoltage vIn( V=Vin, diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/InvertingSchmittTrigger.mo b/Modelica/Electrical/Analog/Examples/OpAmps/InvertingSchmittTrigger.mo index c0a6a7d99e..38d8fd1628 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/InvertingSchmittTrigger.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/InvertingSchmittTrigger.mo @@ -12,7 +12,9 @@ model InvertingSchmittTrigger "Inverting Schmitt trigger with hysteresis" Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp( Vps=Vps, Vns=Vns, - out(i(start=0))) + strict=false, + smoothed=false, + regularized=true) annotation (Placement(transformation(extent={{0,-10},{20,10}}))); Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(transformation(extent={{-20,-100},{0,-80}}))); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/LCOscillator.mo b/Modelica/Electrical/Analog/Examples/OpAmps/LCOscillator.mo index a6ff2407cd..92c0de64fa 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/LCOscillator.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/LCOscillator.mo @@ -19,7 +19,7 @@ model LCOscillator "LC oscillator" annotation (Placement(transformation(extent={{-50,10},{-30,-10}}))); Modelica.Electrical.Analog.Basic.Resistor r(R=R) annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); - Modelica.Electrical.Analog.Basic.Resistor r2(R=R2, i(start=0)) annotation ( + Modelica.Electrical.Analog.Basic.Resistor r2(R=R2) annotation ( Placement(transformation( extent={{-10,-10},{10,10}}, rotation=270, diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/Multivibrator.mo b/Modelica/Electrical/Analog/Examples/OpAmps/Multivibrator.mo index 6d4ec8857b..5292feeb6a 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/Multivibrator.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/Multivibrator.mo @@ -11,8 +11,9 @@ model Multivibrator "Multivibrator with Schmitt trigger" 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}}))); + strict=false, + regularized=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( @@ -20,7 +21,7 @@ model Multivibrator "Multivibrator with Schmitt trigger" extent={{-10,10},{10,-10}}, rotation=270, origin={50,-20}))); - Modelica.Electrical.Analog.Basic.Resistor r1(R=R1, i(start=0)) annotation ( + Modelica.Electrical.Analog.Basic.Resistor r1(R=R1, p(i(start=0))) annotation ( Placement(transformation( extent={{-10,-10},{10,10}}, rotation=270, @@ -31,7 +32,7 @@ model Multivibrator "Multivibrator with Schmitt trigger" 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)) + Modelica.Electrical.Analog.Basic.Capacitor c(C=C, v(start=0.1, fixed=true)) annotation (Placement(transformation( extent={{10,-10},{-10,10}}, rotation=90, diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/FirstOrder.mo b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/FirstOrder.mo index 4a6b17fb98..6be87b23a1 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/FirstOrder.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/FirstOrder.mo @@ -1,6 +1,6 @@ within Modelica.Electrical.Analog.Examples.OpAmps.OpAmpCircuits; model FirstOrder "Lowpass filter operational amplifier circuit" - extends PartialOpAmp(v2(start=0)); + extends PartialOpAmp; import Modelica.Constants.pi; parameter Real k(final min=0)=1 "Desired amplification"; parameter SI.Resistance R1=1000 "Resistance at negative input of OpAmp"; diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/Integrator.mo b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/Integrator.mo index ec70dd2148..cb04b70b28 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/Integrator.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/Integrator.mo @@ -1,6 +1,6 @@ within Modelica.Electrical.Analog.Examples.OpAmps.OpAmpCircuits; model Integrator "Integrating operational amplifier circuit" - extends PartialOpAmp(v2(start=0)); + extends PartialOpAmp; import Modelica.Constants.pi; parameter Real k(final min=0)=1 "Desired amplification at frequency f"; parameter SI.Frequency f "Frequency"; diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PI.mo b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PI.mo index 22b7778ea4..9357d017d5 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PI.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PI.mo @@ -1,6 +1,6 @@ within Modelica.Electrical.Analog.Examples.OpAmps.OpAmpCircuits; model PI "PI controller operational amplifier circuit" - extends PartialOpAmp(v2(start=0)); + extends PartialOpAmp; import Modelica.Constants.pi; parameter Real k(final min=0)=1 "Desired amplification"; parameter SI.Resistance R1=1000 "Resistance at negative input of OpAmp"; @@ -13,6 +13,7 @@ model PI "PI controller operational amplifier circuit" annotation (Placement(transformation(extent={{30,20},{10,40}}))); Basic.Capacitor c(C=C) annotation (Placement(transformation(extent={{60,20},{40,40}}))); + SI.Voltage v(start=0)=c.v "Capacitor voltage = state"; equation connect(n1, n2) annotation (Line(points={{-100,-100},{100,-100}}, color={0,0,255})); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PartialOpAmp.mo b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PartialOpAmp.mo index 6ffb3ad7cc..3d10243efa 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PartialOpAmp.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/OpAmpCircuits/PartialOpAmp.mo @@ -9,8 +9,7 @@ partial model PartialOpAmp V0=V0, final useSupply=false, final Vps=Vps, - final Vns=Vns, - out(i(start=0, fixed=false))) + final Vns=Vns) annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); annotation (Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Text( diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/SchmittTrigger.mo b/Modelica/Electrical/Analog/Examples/OpAmps/SchmittTrigger.mo index f56e8fa332..f6b9878f47 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/SchmittTrigger.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/SchmittTrigger.mo @@ -12,7 +12,9 @@ model SchmittTrigger "Schmitt trigger with hysteresis" Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp( Vps=Vps, Vns=Vns, - out(i(start=0))) + strict=false, + smoothed=false, + regularized=true) annotation (Placement(transformation(extent={{0,10},{20,-10}}))); Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(transformation(extent={{-20,-100},{0,-80}}))); @@ -64,8 +66,7 @@ equation

The example is taken from: U. Tietze and C. Schenk, Halbleiter-Schaltungstechnik (German), 11th edition, Springer 1999, Chapter 6.5.2

"), experiment( - StartTime=0, - StopTime=1, - Tolerance=1e-006, - Interval=0.001)); + Interval=0.001, + Tolerance=1e-06, + __Dymola_Algorithm="Dassl")); end SchmittTrigger; diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/SignalGenerator.mo b/Modelica/Electrical/Analog/Examples/OpAmps/SignalGenerator.mo index 758dae6781..8043276fb8 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/SignalGenerator.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/SignalGenerator.mo @@ -14,9 +14,9 @@ model SignalGenerator "Rectangle-Triangle generator" Vps=Vps, Vns=Vns, strict=false, - homotopyType=Modelica.Blocks.Types.LimiterHomotopy.LowerLimit) + regularized=true) annotation (Placement(transformation(extent={{-60,10},{-40,-10}}))); - Modelica.Electrical.Analog.Basic.Resistor r2(R=R2, i(start=Vps/R2)) + Modelica.Electrical.Analog.Basic.Resistor r2(R=R2, p(i(start=0))) annotation (Placement(transformation( extent={{10,10},{-10,-10}}, rotation=180, @@ -29,11 +29,9 @@ model SignalGenerator "Rectangle-Triangle generator" annotation (Placement(transformation(extent={{-10,-60},{10,-40}}))); Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp2( Vps=Vps, - Vns=Vns, - v_in(start=0), - strict=false) + Vns=Vns) annotation (Placement(transformation(extent={{30,-10},{50,10}}))); - Modelica.Electrical.Analog.Basic.Capacitor c(C=C, v(fixed=true, start=0)) + Modelica.Electrical.Analog.Basic.Capacitor c(C=C, v(fixed=true, start=10)) annotation (Placement(transformation(extent={{50,20},{30,40}}))); Modelica.Electrical.Analog.Basic.Resistor r(R=R) annotation (Placement(transformation(extent={{-10,20},{10,40}}))); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/Subtracter.mo b/Modelica/Electrical/Analog/Examples/OpAmps/Subtracter.mo index a9b3196d9e..cd0ae24e0e 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/Subtracter.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/Subtracter.mo @@ -20,7 +20,7 @@ model Subtracter "Inverting subtracter" extent={{10,10},{-10,-10}}, rotation=270, origin={40,0}))); - OpAmpCircuits.Feedback feedback(p1_2(i(start=0))) + OpAmpCircuits.Feedback feedback annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); equation connect(feedback.n1, ground.p) diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/VoltageFollower.mo b/Modelica/Electrical/Analog/Examples/OpAmps/VoltageFollower.mo index b5e84476d8..a39b3562d9 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/VoltageFollower.mo +++ b/Modelica/Electrical/Analog/Examples/OpAmps/VoltageFollower.mo @@ -10,8 +10,7 @@ model VoltageFollower "Reproduce input voltage" parameter SI.Resistance Rl=1 "Load resistance"; Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimited opAmp( Vps=Vps, - Vns=Vns, - v_in(start=0)) + Vns=Vns) annotation (Placement(transformation(extent={{0,-10},{20,10}}))); Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(transformation(extent={{-20,-100},{0,-80}}))); diff --git a/Modelica/Electrical/Analog/Examples/OpAmps/package.order b/Modelica/Electrical/Analog/Examples/OpAmps/package.order index e898c26d8d..359c907cc1 100644 --- a/Modelica/Electrical/Analog/Examples/OpAmps/package.order +++ b/Modelica/Electrical/Analog/Examples/OpAmps/package.order @@ -13,6 +13,6 @@ Comparator InvertingSchmittTrigger SchmittTrigger Multivibrator -SignalGenerator LCOscillator +SignalGenerator OpAmpCircuits diff --git a/Modelica/Electrical/Analog/Ideal/IdealizedOpAmpLimited.mo b/Modelica/Electrical/Analog/Ideal/IdealizedOpAmpLimited.mo index c495ebc903..1bea35a7c0 100644 --- a/Modelica/Electrical/Analog/Ideal/IdealizedOpAmpLimited.mo +++ b/Modelica/Electrical/Analog/Ideal/IdealizedOpAmpLimited.mo @@ -7,14 +7,19 @@ model IdealizedOpAmpLimited "Idealized operational amplifier with limitation" annotation (Dialog(enable=not useSupply)); parameter SI.Voltage Vns=-15 "Negative supply voltage" annotation (Dialog(enable=not useSupply)); - parameter Boolean strict=true "= true, if strict limits with noEvent(..)" + parameter Boolean strict=false "= true, if strict limits with noEvent(..)" + annotation (Evaluate=true, choices(checkBox=true), Dialog(tab="Advanced")); + parameter Boolean smoothed=false "= true, if usage of smooth(0, ..)" + annotation (Evaluate=true, choices(checkBox=true), Dialog(tab="Advanced")); + parameter Boolean regularized=false "= true, if regularization instead of strict / smoothed" annotation (Evaluate=true, choices(checkBox=true), Dialog(tab="Advanced")); parameter Modelica.Blocks.Types.LimiterHomotopy homotopyType = Modelica.Blocks.Types.LimiterHomotopy.NoHomotopy "Simplified model for homotopy-based initialization" annotation (Evaluate=true, Dialog(group="Initialization")); - SI.Voltage vps "Positive supply voltage"; - SI.Voltage vns "Negative supply voltage"; - SI.Voltage v_in=in_p.v - in_n.v "Input voltage difference"; + SI.Voltage vps(start=Vps) "Positive supply voltage"; + SI.Voltage vns(start=Vns) "Negative supply voltage"; + SI.Voltage v_in(start=0)=in_p.v - in_n.v "Input voltage difference"; SI.Voltage v_out=out.v "Output voltage to ground"; + SI.Current i_out(start=0)=-out.i "Output current"; SI.Power p_in=in_p.v*in_p.i + in_n.v*in_n.i "Input power"; SI.Power p_out=out.v*out.i "Output power"; SI.Power p_s=-(p_in + p_out) "Supply power"; @@ -49,19 +54,41 @@ equation else if homotopyType == Modelica.Blocks.Types.LimiterHomotopy.UpperLimit then vps else if homotopyType == Modelica.Blocks.Types.LimiterHomotopy.LowerLimit then vns else 0); - if strict then + if regularized then if homotopyType == Modelica.Blocks.Types.LimiterHomotopy.NoHomotopy then - v_out = smooth(0, noEvent(if V0*v_in>vps then vps else if V0*v_in0 then vps else -vns)*(2/(1 + Modelica.Math.exp(-v_in/(0.01*(if v_in>0 then vps else -vns)/V0)))-1); else - v_out = homotopy(actual = smooth(0, noEvent(if V0*v_in>vps then vps else if V0*v_in0 then vps else -vns)*(2/(1 + Modelica.Math.exp(-v_in/(0.01*(if v_in>0 then vps else -vns)/V0)))-1), simplified=simplifiedExpr); end if; else - if homotopyType == Modelica.Blocks.Types.LimiterHomotopy.NoHomotopy then - v_out = smooth(0, if V0*v_in>vps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_invps then vps else if V0*v_in

Supply voltage is either defined by parameter Vps and Vns or by (optional) pins s_p and s_n.

In the first case the necessary power is drawn from an implicit internal supply, in the second case from the external supply.

+

You may choose between different implementations for calculating output voltage from input voltage:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
regularizedsmoothedstrict explanation
true uses a regularization formula which is nearly linear around 0 and saturates at positive resp. negative supply
false false false uses a linear relationship and saturates at positive resp. negative supply without using smooth and/or noEvent
false true false uses a linear relationship and saturates at positive resp. negative supply using smooth but without noEvent
false false true uses a linear relationship and saturates at positive resp. negative supply without using smooth but using noEvent
false true true uses a linear relationship and saturates at positive resp. negative supply using both smooth and noEvent
+

+Recommendation:
+Use of the opAmp in the linear range: regularized = false, smoothed = false, strict = false.
+Use of the opAmp as switching device: regularized = true, smoothed = false, strict = false. +

If initialization is problematic for a model containing this as a component you can set the homotopyType parameter. Using Linear ignores the saturation initially which simplifies the initialization, and may help if the component is connected with negative feedback; but generally fails if the feedback is positive.