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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
model SodaSeparator // 定义输入参数 input Real inletTemp "进口温度"; input Real inletPressure "进口压力"; input Real inletFlow "进口流量"; input Real inletConc "进口浓度"; // 定义输出参数 output Real outletTemp "出口温度"; output Real outletPressure "出口压力"; output Real outletFlow "出口流量"; output Real outletConc "出口浓度"; // 定义参数 parameter Real evapRate = 0.8 "汽水蒸发速率"; parameter Real sepEfficiency = 0.9 "汽水分离效率"; // 定义状态变量 Real vaporFlow(start=0) "汽流量"; Real liquidFlow(start=inletFlow) "液流量"; Real vaporConc(start=inletConc) "汽浓度"; Real liquidConc(start=inletConc) "液浓度"; equation // 定义汽水质量守恒方程 inletFlow = vaporFlow + liquidFlow; inletConc = (vaporConc * vaporFlow + liquidConc * liquidFlow) / inletFlow; // 定义汽水能量守恒方程 inletFlow * inletConc * (inletTemp + 273.15) = vaporFlow * 2257.0 + liquidFlow * 4190.0 * (outletTemp + 273.15); // 定义汽水动量守恒方程 inletFlow * inletPressure = vaporFlow * 101325.0 + liquidFlow * 101325.0; // 定义汽水分离方程 vaporFlow = evapRate * liquidFlow; liquidFlow = liquidFlow - vaporFlow; vaporConc = 1.0; liquidConc = inletConc * (1.0 - sepEfficiency); // 定义出口流量和浓度 outletFlow = liquidFlow + vaporFlow; outletConc = (vaporConc * vaporFlow + liquidConc * liquidFlow) / outletFlow; // 定义出口温度和压力 outletTemp = inletTemp - evapRate * ((liquidFlow * 4190.0 * (inletTemp + 273.15)) / (outletFlow * 2257.0)); outletPressure = inletPressure; end SodaSeparator;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值