Modelica示例——数模变换电路示例

数模转换(D\A conversion)是一种重要的接口处理,它将数字信号转为模拟信号,驱动外部设备。

本示例中D\A转换方法使用了比例加法器。加法器的输入电阻值表示输入码的二进制权重。

电路

曲线

V=-(0*(1000/1000)+1*(1000/2000)+0*(1000/4000)+1*(1000/8000))

  = -(1/2+1/8)

  = -0.625

程序

model cb
  Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {-92, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Ideal.IdealizedOpAmpLimted idealizedOpAmpLimted2 annotation(
    Placement(visible = true, transformation(origin = {16, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground5 annotation(
    Placement(visible = true, transformation(origin = {58, -74}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage5(V = -15) annotation(
    Placement(visible = true, transformation(origin = {26, -64}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground6 annotation(
    Placement(visible = true, transformation(origin = {-48, -56}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1000)  annotation(
    Placement(visible = true, transformation(origin = {30, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage1(V = 15) annotation(
    Placement(visible = true, transformation(origin = {26, -10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground2 annotation(
    Placement(visible = true, transformation(origin = {60, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
    Placement(visible = true, transformation(origin = {99, -41}, extent = {{-3, -3}, {3, 3}}, rotation = 0), iconTransformation(origin = {99, -41}, extent = {{-3, -3}, {3, 3}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Resistor resistor2(R = 8000) annotation(
    Placement(visible = true, transformation(origin = {-34, 26}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Basic.Resistor resistor3(R = 4000) annotation(
    Placement(visible = true, transformation(origin = {-34, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Basic.Resistor resistor4(R = 2000) annotation(
    Placement(visible = true, transformation(origin = {-34, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Basic.Resistor resistor5(R = 1000) annotation(
    Placement(visible = true, transformation(origin = {-34, -22}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage2(V = 1) annotation(
    Placement(visible = true, transformation(origin = {-78, 26}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
equation
  connect(idealizedOpAmpLimted2.in_p, ground6.p) annotation(
    Line(points = {{6, -46}, {-48, -46}, {-48, -46}, {-48, -46}}, color = {0, 0, 255}));
  connect(pin, idealizedOpAmpLimted2.out) annotation(
    Line(points = {{100, -40}, {26, -40}, {26, -40}, {26, -40}}, color = {0, 0, 255}));
  connect(resistor5.n, ground6.p) annotation(
    Line(points = {{-44, -22}, {-48, -22}, {-48, -46}, {-48, -46}, {-48, -46}}, color = {0, 0, 255}));
  connect(resistor3.n, ground6.p) annotation(
    Line(points = {{-44, 10}, {-48, 10}, {-48, -46}, {-48, -46}, {-48, -46}}, color = {0, 0, 255}));
  connect(resistor4.n, constantVoltage2.p) annotation(
    Line(points = {{-44, -6}, {-68, -6}, {-68, 26}, {-68, 26}, {-68, 26}}, color = {0, 0, 255}));
  connect(resistor2.n, constantVoltage2.p) annotation(
    Line(points = {{-44, 26}, {-68, 26}, {-68, 26}, {-68, 26}}, color = {0, 0, 255}));
  connect(constantVoltage2.n, ground1.p) annotation(
    Line(points = {{-88, 26}, {-92, 26}, {-92, 12}}, color = {0, 0, 255}));
  connect(resistor2.p, idealizedOpAmpLimted2.in_n) annotation(
    Line(points = {{-22, 26}, {-4, 26}, {-4, -34}, {8, -34}, {8, -34}}, color = {0, 0, 255}));
  connect(resistor3.p, idealizedOpAmpLimted2.in_n) annotation(
    Line(points = {{-22, 10}, {-4, 10}, {-4, -34}, {8, -34}, {8, -34}}, color = {0, 0, 255}));
  connect(resistor4.p, idealizedOpAmpLimted2.in_n) annotation(
    Line(points = {{-22, -6}, {-4, -6}, {-4, -34}, {8, -34}, {8, -34}, {8, -34}}, color = {0, 0, 255}));
  connect(resistor5.p, idealizedOpAmpLimted2.in_n) annotation(
    Line(points = {{-22, -22}, {-4, -22}, {-4, -34}, {8, -34}, {8, -34}, {8, -34}}, color = {0, 0, 255}));
  connect(idealizedOpAmpLimted2.out, resistor1.p) annotation(
    Line(points = {{26, -40}, {78, -40}, {78, 22}, {40, 22}, {40, 22}, {40, 22}}, color = {0, 0, 255}));
  connect(resistor1.n, idealizedOpAmpLimted2.in_n) annotation(
    Line(points = {{22, 22}, {8, 22}, {8, -34}, {8, -34}, {8, -34}}, color = {0, 0, 255}));
  connect(idealizedOpAmpLimted2.s_n, constantVoltage5.p) annotation(
    Line(points = {{18, -50}, {18, -50}, {18, -64}, {18, -64}}, color = {0, 0, 255}));
  connect(constantVoltage1.p, idealizedOpAmpLimted2.s_p) annotation(
    Line(points = {{16, -10}, {16, -10}, {16, -30}, {16, -30}}, color = {0, 0, 255}));
  connect(constantVoltage5.n, ground5.p) annotation(
    Line(points = {{36, -64}, {58, -64}, {58, -64}, {58, -64}}, color = {0, 0, 255}));
  connect(ground2.p, constantVoltage1.n) annotation(
    Line(points = {{60, -10}, {36, -10}, {36, -10}, {36, -10}}, color = {0, 0, 255}));
  annotation(
    uses(Modelica(version = "3.2.2")),
    experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.0002));
end cb;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值