Modelica示例——比较器电路
简介
运算放大器经常用作非线性器件来比较两个电压的幅值,在这种应用中,运算放大器用作开环配置,输入的一端(同相端+)是输入电压,输入的另一端(反相端-)是参考电压。输出端的电压在运放工作饱和电压值之间变化。
过零检测器
过零检测器的参考电压是0V电压,可以用“地”表示。
-电路
-仿真曲线
-程序
model ca
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {0, -14}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage1(V = 5, freqHz = 10, offset = 0, phase = 0, startTime = 0) annotation(
Placement(visible = true, transformation(origin = {0, -36}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage1(V = 15) annotation(
Placement(visible = true, transformation(origin = {52, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground2 annotation(
Placement(visible = true, transformation(origin = {82, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage2(V = -15) annotation(
Placement(visible = true, transformation(origin = {52, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground3 annotation(
Placement(visible = true, transformation(origin = {82, -42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted idealizedOpAmpLimted1 annotation(
Placement(visible = true, transformation(origin = {42, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground4 annotation(
Placement(visible = true, transformation(origin = {-22, -52}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(idealizedOpAmpLimted1.in_n, ground1.p) annotation(
Line(points = {{32, -4}, {0, -4}}, color = {0, 0, 255}));
connect(sineVoltage1.n, ground4.p) annotation(
Line(points = {{-10, -36}, {-22, -36}, {-22, -42}}, color = {0, 0, 255}));
connect(sineVoltage1.p, idealizedOpAmpLimted1.in_p) annotation(
Line(points = {{10, -36}, {21, -36}, {21, -16}, {32, -16}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_p, constantVoltage1.p) annotation(
Line(points = {{42, 0}, {42, 0}, {42, 22}, {42, 22}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_n, constantVoltage2.p) annotation(
Line(points = {{42, -20}, {42, -20}, {42, -32}, {42, -32}}, color = {0, 0, 255}));
connect(constantVoltage2.n, ground3.p) annotation(
Line(points = {{62, -32}, {82, -32}, {82, -32}, {82, -32}}, color = {0, 0, 255}));
connect(constantVoltage1.n, ground2.p) annotation(
Line(points = {{62, 22}, {82, 22}, {82, 22}, {82, 22}}, color = {0, 0, 255}));
annotation(
uses(Modelica(version = "3.2.2")),
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.0002));
end ca;
非过零检测器
如果反相端输入不是零电压,而是一个其他的常值电压,则形成非过零检测器。
-电路
-仿真曲线
-程序
model ca
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {-22, -14}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage1(V = 5, freqHz = 10, offset = 0, phase = 0, startTime = 0) annotation(
Placement(visible = true, transformation(origin = {0, -36}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage1(V = 15) annotation(
Placement(visible = true, transformation(origin = {52, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground2 annotation(
Placement(visible = true, transformation(origin = {82, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage2(V = -15) annotation(
Placement(visible = true, transformation(origin = {52, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground3 annotation(
Placement(visible = true, transformation(origin = {82, -42}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted idealizedOpAmpLimted1 annotation(
Placement(visible = true, transformation(origin = {42, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground4 annotation(
Placement(visible = true, transformation(origin = {-22, -52}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage3(V = 2) annotation(
Placement(visible = true, transformation(origin = {6, -4}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
equation
connect(constantVoltage3.n, ground1.p) annotation(
Line(points = {{-4, -4}, {-22, -4}, {-22, -4}, {-22, -4}}, color = {0, 0, 255}));
connect(constantVoltage3.p, idealizedOpAmpLimted1.in_n) annotation(
Line(points = {{16, -4}, {32, -4}, {32, -4}, {32, -4}}, color = {0, 0, 255}));
connect(sineVoltage1.n, ground4.p) annotation(
Line(points = {{-10, -36}, {-22, -36}, {-22, -42}}, color = {0, 0, 255}));
connect(sineVoltage1.p, idealizedOpAmpLimted1.in_p) annotation(
Line(points = {{10, -36}, {21, -36}, {21, -16}, {32, -16}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_p, constantVoltage1.p) annotation(
Line(points = {{42, 0}, {42, 0}, {42, 22}, {42, 22}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_n, constantVoltage2.p) annotation(
Line(points = {{42, -20}, {42, -20}, {42, -32}, {42, -32}}, color = {0, 0, 255}));
connect(constantVoltage2.n, ground3.p) annotation(
Line(points = {{62, -32}, {82, -32}, {82, -32}, {82, -32}}, color = {0, 0, 255}));
connect(constantVoltage1.n, ground2.p) annotation(
Line(points = {{62, 22}, {82, 22}, {82, 22}, {82, 22}}, color = {0, 0, 255}));
annotation(
uses(Modelica(version = "3.2.2")),
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.0002));
end ca;
窗口比较器
如果将两个非零值比较器组合,可形成窗口比较器。只要输入Uin在窗口之内,则每个比较器的输入都为其低饱和电平,此时两个二极管都反相偏置,并且通过电阻接地。输出电压为0。当输入Uin在窗口之外,则某个比较器的输入为其高饱和电平,一个为低饱和电平,低饱和电平导致此路二极管反偏。
-电路
-曲线
-程序
model ca
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {-64, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage1(V = 12, freqHz = 4, offset = 0, phase = 0, startTime = 0) annotation(
Placement(visible = true, transformation(origin = {-42, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage1(V = 15) annotation(
Placement(visible = true, transformation(origin = {10, 58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground2 annotation(
Placement(visible = true, transformation(origin = {40, 48}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage2(V = -15) annotation(
Placement(visible = true, transformation(origin = {10, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground3 annotation(
Placement(visible = true, transformation(origin = {40, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted idealizedOpAmpLimted1 annotation(
Placement(visible = true, transformation(origin = {0, 26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground4 annotation(
Placement(visible = true, transformation(origin = {-64, -16}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage3(V = 6) annotation(
Placement(visible = true, transformation(origin = {-36, 32}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted idealizedOpAmpLimted2 annotation(
Placement(visible = true, transformation(origin = {0, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage4(V = 15) annotation(
Placement(visible = true, transformation(origin = {10, -14}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground5 annotation(
Placement(visible = true, transformation(origin = {42, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage5(V = -15) annotation(
Placement(visible = true, transformation(origin = {10, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage6(V = -4) annotation(
Placement(visible = true, transformation(origin = {-34, -46}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground6 annotation(
Placement(visible = true, transformation(origin = {-64, -56}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealDiode idealDiode1 annotation(
Placement(visible = true, transformation(origin = {28, 26}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealDiode idealDiode2 annotation(
Placement(visible = true, transformation(origin = {30, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1000) annotation(
Placement(visible = true, transformation(origin = {64, -54}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
Placement(visible = true, transformation(origin = {77, -9}, extent = {{-3, -3}, {3, 3}}, rotation = 0), iconTransformation(origin = {77, -9}, extent = {{-3, -3}, {3, 3}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground7 annotation(
Placement(visible = true, transformation(origin = {40, -24}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(idealDiode1.p, idealizedOpAmpLimted1.out) annotation(
Line(points = {{18, 26}, {10, 26}, {10, 26}, {10, 26}}, color = {0, 0, 255}));
connect(ground2.p, constantVoltage1.n) annotation(
Line(points = {{40, 58}, {20, 58}, {20, 58}, {20, 58}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.in_n, constantVoltage3.p) annotation(
Line(points = {{-10, 32}, {-26, 32}, {-26, 32}, {-26, 32}}, color = {0, 0, 255}));
connect(idealDiode2.p, idealizedOpAmpLimted2.out) annotation(
Line(points = {{20, -40}, {10, -40}, {10, -40}, {10, -40}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted2.in_p, constantVoltage6.p) annotation(
Line(points = {{-10, -46}, {-24, -46}, {-24, -46}, {-24, -46}}, color = {0, 0, 255}));
connect(resistor1.p, pin) annotation(
Line(points = {{64, -44}, {64, -44}, {64, -10}, {78, -10}, {78, -8}}, color = {0, 0, 255}));
connect(idealDiode1.n, pin) annotation(
Line(points = {{38, 26}, {64, 26}, {64, -10}, {78, -10}, {78, -8}, {78, -8}}, color = {0, 0, 255}));
connect(constantVoltage4.n, ground7.p) annotation(
Line(points = {{20, -14}, {40, -14}, {40, -14}, {40, -14}}, color = {0, 0, 255}));
connect(constantVoltage2.n, ground3.p) annotation(
Line(points = {{20, 4}, {30, 4}, {30, 6}, {40, 6}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_p, constantVoltage1.p) annotation(
Line(points = {{0, 36}, {0, 36}, {0, 58}, {0, 58}}, color = {0, 0, 255}));
connect(constantVoltage3.n, ground1.p) annotation(
Line(points = {{-46, 32}, {-64, 32}, {-64, 32}, {-64, 32}}, color = {0, 0, 255}));
connect(sineVoltage1.n, ground4.p) annotation(
Line(points = {{-52, 0}, {-64, 0}, {-64, -6}}, color = {0, 0, 255}));
connect(constantVoltage6.n, ground6.p) annotation(
Line(points = {{-44, -46}, {-64, -46}, {-64, -46}, {-64, -46}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.in_p, sineVoltage1.p) annotation(
Line(points = {{-10, 20}, {-10, 20}, {-10, 0}, {-32, 0}, {-32, 0}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted2.in_n, sineVoltage1.p) annotation(
Line(points = {{-10, -34}, {-10, 0}, {-32, 0}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted1.s_n, constantVoltage2.p) annotation(
Line(points = {{0, 14}, {0, 14}, {0, 2}, {0, 2}}, color = {0, 0, 255}));
connect(idealDiode2.n, pin) annotation(
Line(points = {{40, -40}, {64, -40}, {64, -10}, {78, -10}, {78, -10}, {78, -10}}, color = {0, 0, 255}));
connect(constantVoltage4.p, idealizedOpAmpLimted2.s_p) annotation(
Line(points = {{0, -16}, {0, -16}, {0, -32}, {0, -32}}, color = {0, 0, 255}));
connect(idealizedOpAmpLimted2.s_n, constantVoltage5.p) annotation(
Line(points = {{0, -52}, {0, -52}, {0, -66}, {0, -66}}, color = {0, 0, 255}));
connect(constantVoltage5.n, ground5.p) annotation(
Line(points = {{20, -64}, {42, -64}, {42, -64}, {42, -64}}, color = {0, 0, 255}));
connect(resistor1.n, ground5.p) annotation(
Line(points = {{64, -64}, {42, -64}, {42, -64}, {42, -64}}, color = {0, 0, 255}));
annotation(
uses(Modelica(version = "3.2.2")),
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.0002));
end ca;