Skip to content
AmplifierWithOpAmpDetailed.md

AmplifierWithOpAmpDetailed

Inverting operational amplifier circuit built using a detailed op-amp model.

This circuit implements an inverting amplifier configuration utilizing an OpAmpDetailed component. An input signal, generated by input_signal1 (a sine wave with 12V amplitude, 1kHz frequency) and conditioned by voltage_source_1, is applied to the inverting input terminal of the operational amplifier via the input resistor (R_in = 10kΩ). The non-inverting input of the op-amp is connected to the circuit ground. The operational amplifier is powered by voltage_source_2(+15V) andvoltage_source_3(-15V), which are driven byinput_signal2andinput_signal3respectively. The output of the amplifier is connected to a loadresistor2(10kΩ). The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback resistorresistor1 (R_f = 20kΩ) to the input resistor. Given the component values Rin=10kΩ (parameter R of resistor) and Rf=20kΩ (parameter R of resistor1), the ideal gain is -2. The behavior of OpAmpDetailed will introduce non-ideal characteristics.

Usage

ElectricalComponents.AmplifierWithOpAmpDetailed()

Behavior

[connect(inputsignal1+y,voltagesource_1+V)connect(inputsignal2+y,voltagesource_2+V)connect(inputsignal3+y,voltagesource_3+V)connect(ground+g,voltagesource_1+n,opamp+p,resistor2+n,voltagesource_3+n,voltagesource_2+n)connect(resistor+n,opamp+n,resistor1+p)connect(resistor1+n,opamp+outp,resistor2+p)connect(resistor+p,voltagesource_1+p)connect(opamp+p_supply,voltagesource_2+p)connect(opamp+n_supply,voltagesource_3+p)opamp.v_pos(t)=opamp.p_supply.v(t)opamp.v_neg(t)=opamp.n_supply.v(t)opamp.p.i(t)=opamp.i_vos(t)opamp.n.i(t)=opamp.i_c3(t)+opamp.i_4(t)opamp.i_r2(t)0=opamp.i_3(t)opamp.i_vos(t)+opamp.i_c3(t)+opamp.i_r2(t)opamp.n.v(t)+opamp.p.v(t)=opamp.v_in(t)+opamp.v_vos(t)opamp.v_4(t)=opamp.n.v(t)opamp.v_3(t)=opamp.v_vos(t)+opamp.p.v(t)opamp.v_vos(t)=opamp.Vosopamp.i_3(t)=opamp.I1+opamp.v_3(t)opamp.Rcmopamp.v_in(t)=opamp.Rdmopamp.i_r2(t)opamp.i_c3(t)=opamp.Cindopamp.v_in(t)dtopamp.i_4(t)=opamp.I2+opamp.v_4(t)opamp.Rcmdopamp.q_fr1(t)dt=6.283185307179586opamp.fp2(opamp.v_in(t)opamp.q_fr1(t))dopamp.q_fr2(t)dt6.283185307179586opamp.fp3+opamp.q_fr2(t)=opamp.q_fr1(t)+dopamp.q_fr1(t)dt6.283185307179586opamp.fzdopamp.q_fr3(t)dt=6.283185307179586opamp.fp4(opamp.q_fr3(t)+opamp.q_fr2(t))opamp.q_sum(t)=opamp.Avcm_val(opamp.v_3(t)+opamp.v_4(t))+opamp.Avd0_valopamp.q_fr3(t)opamp.q_sum_help(t)=ifelse((opamp.q_sum(t)>opamp.vcp_abs+opamp.v_pos(t))(opamp.q_fp1(t)opamp.vcp_abs+opamp.v_pos(t)),opamp.vcp_abs+opamp.v_pos(t),ifelse((opamp.q_sum(t)<opamp.vcm_abs+opamp.v_neg(t))(opamp.q_fp1(t)opamp.vcm_abs+opamp.v_neg(t)),opamp.vcm_abs+opamp.v_neg(t),opamp.q_sum(t)))dopamp.q_fp1(t)dt=6.283185307179586opamp.fp1(opamp.q_fp1(t)+opamp.q_sum_help(t))dopamp.x(t)dt=opamp.q_fp1(t)opamp.v_source(t)opamp.Tsdopamp.v_source(t)dt=ifelse(dopamp.x(t)dt>opamp.sr_p_val,opamp.sr_p_val,ifelse(dopamp.x(t)dt<opamp.sr_m_val,opamp.sr_m_val,dopamp.x(t)dt))opamp.v_out(t)=opamp.outp.v(t)opamp.i_out(t)=opamp.outp.i(t)opamp.i_out(t)=ifelse(opamp.v_out(t)>opamp.v_source(t)+opamp.Imaxsi_valopamp.Rout,opamp.Imaxsi_val,ifelse(opamp.v_out(t)<opamp.v_source(t)opamp.Imaxso_valopamp.Rout,opamp.Imaxso_val,opamp.v_out(t)opamp.v_source(t)opamp.Rout))opamp.p_supply.i(t)=0opamp.n_supply.i(t)=0resistor.v(t)=resistor.n.v(t)+resistor.p.v(t)resistor.i(t)=resistor.p.i(t)resistor.p.i(t)+resistor.n.i(t)=0resistor.v(t)=resistor.Rresistor.i(t)resistor1.v(t)=resistor1.n.v(t)+resistor1.p.v(t)resistor1.i(t)=resistor1.p.i(t)resistor1.p.i(t)+resistor1.n.i(t)=0resistor1.v(t)=resistor1.Rresistor1.i(t)resistor2.v(t)=resistor2.p.v(t)resistor2.n.v(t)resistor2.i(t)=resistor2.p.i(t)resistor2.p.i(t)+resistor2.n.i(t)=0resistor2.v(t)=resistor2.Rresistor2.i(t)voltagesource_1.v(t)=voltagesource_1.p.v(t)voltagesource_1.n.v(t)voltagesource_1.i(t)=voltagesource_1.p.i(t)voltagesource_1.p.i(t)+voltagesource_1.n.i(t)=0voltagesource_1.v(t)=voltagesource_1.uVvoltagesource_1.V(t)voltagesource_2.v(t)=voltagesource_2.p.v(t)voltagesource_2.n.v(t)voltagesource_2.i(t)=voltagesource_2.p.i(t)voltagesource_2.n.i(t)+voltagesource_2.p.i(t)=0voltagesource_2.v(t)=voltagesource_2.uVvoltagesource_2.V(t)voltagesource_3.v(t)=voltagesource_3.n.v(t)+voltagesource_3.p.v(t)voltagesource_3.i(t)=voltagesource_3.p.i(t)voltagesource_3.n.i(t)+voltagesource_3.p.i(t)=0voltagesource_3.v(t)=voltagesource_3.uVvoltagesource_3.V(t)inputsignal1.y(t)=inputsignal1.offset+inputsignal1.amplitudeifelse(tinputsignal1.start_time,sin(inputsignal1.phase+6.283185307179586inputsignal1.frequency(inputsignal1.start_time+t)),sin(inputsignal1.phase))inputsignal2.y(t)=inputsignal2.kinputsignal3.y(t)=inputsignal3.kground.g.v(t)=0]

Source

dyad
"""
Inverting operational amplifier circuit built using a detailed op-amp model.

This circuit implements an inverting amplifier configuration utilizing an `OpAmpDetailed` component.
An input signal, generated by `input_signal1` (a sine wave with 12V amplitude, 1kHz frequency)
and conditioned by `voltage_source_1`, is applied to the inverting input terminal of the operational
amplifier via the input `resistor` (R_in = 10kΩ). The non-inverting input of the op-amp is
connected to the circuit ground. The operational amplifier is powered by `voltage_source_2` (+15V)
and `voltage_source_3` (-15V), which are driven by `input_signal2` and `input_signal3` respectively.
The output of the amplifier is connected to a load `resistor2` (10kΩ).
The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback
resistor `resistor1` (R_f = 20kΩ) to the input `resistor`.
Given the component values $R_{in} = 10k\Omega$ (parameter `R` of `resistor`) and
$R_f = 20k\Omega$ (parameter `R` of `resistor1`), the ideal gain is -2.
The behavior of `OpAmpDetailed` will introduce non-ideal characteristics.
"""
test component AmplifierWithOpAmpDetailed
  "Detailed operational amplifier model instance, forming the core of the amplifier."
  op_amp = OpAmpDetailed() {
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}}
  }
  "Input resistor (R_in), value 10kOhm, connecting the input signal to the op-amp's inverting input."
  resistor = Resistor(R = 10000) {
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}}
  }
  "Feedback resistor (R_f), value 20kOhm, from op-amp output to inverting input, sets gain."
  resistor1 = Resistor(R = 20000) {
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}}
  }
  "Load resistor, value 10kOhm, connected from the op-amp output to ground."
  resistor2 = Resistor(R = 10000) {
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}}
    }
  }
  "Ideal voltage source component for applying the input AC signal."
  voltage_source_1 = VoltageSource() {
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}}
  }
  "Ideal voltage source component for the positive power supply (+15V)."
  voltage_source_2 = VoltageSource() {
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}}
  }
  "Ideal voltage source component for the negative power supply (-15V)."
  voltage_source_3 = VoltageSource() {
    "Dyad": {
      "placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}}
    }
  }
  "Sine wave signal generator (12V amplitude, 1kHz) for the amplifier's input."
  input_signal1 = BlockComponents.Sine(amplitude = 12, frequency = 1000, offset = 0) {
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}}
    }
  }
  "Constant signal generator providing +15V for the positive op-amp supply."
  input_signal2 = BlockComponents.Constant(k = 15) {
    "Dyad": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}}
  }
  "Constant signal generator providing -15V for the negative op-amp supply."
  input_signal3 = BlockComponents.Constant(k = -15) {
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}}
    }
  }
  "Electrical ground reference component for the circuit."
  ground = Ground() {
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}}
    }
  }
relations
  connect(input_signal1.y, voltage_source_1.V) {"Dyad": {"edges": [{"S": 1, "E": 2}]}}
  connect(input_signal2.y, voltage_source_2.V) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 1200, "y": 250}, {"x": 1200, "y": 550}, {"x": 650, "y": 550}],
          "E": 2
        }
      ]
    }
  }
  connect(input_signal3.y, voltage_source_3.V) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 650, "y": 1300},
            {"x": 650, "y": 1150},
            {"x": 500, "y": 1150},
            {"x": 500, "y": 950}
          ],
          "E": 2
        }
      ]
    }
  }
  initial resistor2.i = 0
  initial op_amp.q_fp1 = 0
  initial op_amp.q_fr1 = 0
  initial op_amp.q_fr2 = 0
  initial op_amp.q_fr3 = 0
  connect(ground.g, voltage_source_1.n, op_amp.p, resistor2.n, voltage_source_3.n, voltage_source_2.n) {
    "Dyad": {
      "edges": [
        {"S": 1, "E": -2},
        {"S": -3, "E": 2},
        {"S": -3, "M": [{"x": 350, "y": 690}], "E": 3},
        {"S": -2, "E": 4},
        {"S": -1, "E": 5},
        {"S": -2, "M": [{"x": 1050, "y": 1100}, {"x": 1050, "y": 400}], "E": 6},
        {"S": -1, "E": -2},
        {"S": -1, "M": [{"x": 350, "y": 1100}], "E": -3}
      ],
      "junctions": [{"x": 650, "y": 1100}, {"x": 900, "y": 1100}, {"x": 350, "y": 950}]
    }
  }
  connect(resistor.n, op_amp.n, resistor1.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": 350, "y": 100}], "E": 3}
      ],
      "junctions": [{"x": 350, "y": 610}]
    }
  }
  connect(resistor1.n, op_amp.outp, resistor2.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 900, "y": 100}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 650}]
    }
  }
  connect(resistor.p, voltage_source_1.p) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]}
  }
  connect(op_amp.p_supply, voltage_source_2.p) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}
  connect(op_amp.n_supply, voltage_source_3.p) {
    "Dyad": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]}
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 0.1,
        "atol": {"op_amp.outp.v": 0.4},
        "reltol": 0.001,
        "expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]}
      }
    }
  }
}
end
Flattened Source
dyad
"""
Inverting operational amplifier circuit built using a detailed op-amp model.

This circuit implements an inverting amplifier configuration utilizing an `OpAmpDetailed` component.
An input signal, generated by `input_signal1` (a sine wave with 12V amplitude, 1kHz frequency)
and conditioned by `voltage_source_1`, is applied to the inverting input terminal of the operational
amplifier via the input `resistor` (R_in = 10kΩ). The non-inverting input of the op-amp is
connected to the circuit ground. The operational amplifier is powered by `voltage_source_2` (+15V)
and `voltage_source_3` (-15V), which are driven by `input_signal2` and `input_signal3` respectively.
The output of the amplifier is connected to a load `resistor2` (10kΩ).
The voltage gain of this inverting amplifier is primarily determined by the ratio of the feedback
resistor `resistor1` (R_f = 20kΩ) to the input `resistor`.
Given the component values $R_{in} = 10k\Omega$ (parameter `R` of `resistor`) and
$R_f = 20k\Omega$ (parameter `R` of `resistor1`), the ideal gain is -2.
The behavior of `OpAmpDetailed` will introduce non-ideal characteristics.
"""
test component AmplifierWithOpAmpDetailed
  "Detailed operational amplifier model instance, forming the core of the amplifier."
  op_amp = OpAmpDetailed() {
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}}
  }
  "Input resistor (R_in), value 10kOhm, connecting the input signal to the op-amp's inverting input."
  resistor = Resistor(R = 10000) {
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}}
  }
  "Feedback resistor (R_f), value 20kOhm, from op-amp output to inverting input, sets gain."
  resistor1 = Resistor(R = 20000) {
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}}
  }
  "Load resistor, value 10kOhm, connected from the op-amp output to ground."
  resistor2 = Resistor(R = 10000) {
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}}
    }
  }
  "Ideal voltage source component for applying the input AC signal."
  voltage_source_1 = VoltageSource() {
    "Dyad": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}}
  }
  "Ideal voltage source component for the positive power supply (+15V)."
  voltage_source_2 = VoltageSource() {
    "Dyad": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}}
  }
  "Ideal voltage source component for the negative power supply (-15V)."
  voltage_source_3 = VoltageSource() {
    "Dyad": {
      "placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}}
    }
  }
  "Sine wave signal generator (12V amplitude, 1kHz) for the amplifier's input."
  input_signal1 = BlockComponents.Sine(amplitude = 12, frequency = 1000, offset = 0) {
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}}
    }
  }
  "Constant signal generator providing +15V for the positive op-amp supply."
  input_signal2 = BlockComponents.Constant(k = 15) {
    "Dyad": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}}
  }
  "Constant signal generator providing -15V for the negative op-amp supply."
  input_signal3 = BlockComponents.Constant(k = -15) {
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}}
    }
  }
  "Electrical ground reference component for the circuit."
  ground = Ground() {
    "Dyad": {
      "placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}}
    }
  }
relations
  connect(input_signal1.y, voltage_source_1.V) {"Dyad": {"edges": [{"S": 1, "E": 2}]}}
  connect(input_signal2.y, voltage_source_2.V) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 1200, "y": 250}, {"x": 1200, "y": 550}, {"x": 650, "y": 550}],
          "E": 2
        }
      ]
    }
  }
  connect(input_signal3.y, voltage_source_3.V) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 650, "y": 1300},
            {"x": 650, "y": 1150},
            {"x": 500, "y": 1150},
            {"x": 500, "y": 950}
          ],
          "E": 2
        }
      ]
    }
  }
  initial resistor2.i = 0
  initial op_amp.q_fp1 = 0
  initial op_amp.q_fr1 = 0
  initial op_amp.q_fr2 = 0
  initial op_amp.q_fr3 = 0
  connect(ground.g, voltage_source_1.n, op_amp.p, resistor2.n, voltage_source_3.n, voltage_source_2.n) {
    "Dyad": {
      "edges": [
        {"S": 1, "E": -2},
        {"S": -3, "E": 2},
        {"S": -3, "M": [{"x": 350, "y": 690}], "E": 3},
        {"S": -2, "E": 4},
        {"S": -1, "E": 5},
        {"S": -2, "M": [{"x": 1050, "y": 1100}, {"x": 1050, "y": 400}], "E": 6},
        {"S": -1, "E": -2},
        {"S": -1, "M": [{"x": 350, "y": 1100}], "E": -3}
      ],
      "junctions": [{"x": 650, "y": 1100}, {"x": 900, "y": 1100}, {"x": 350, "y": 950}]
    }
  }
  connect(resistor.n, op_amp.n, resistor1.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": 350, "y": 100}], "E": 3}
      ],
      "junctions": [{"x": 350, "y": 610}]
    }
  }
  connect(resistor1.n, op_amp.outp, resistor2.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 900, "y": 100}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 650}]
    }
  }
  connect(resistor.p, voltage_source_1.p) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]}
  }
  connect(op_amp.p_supply, voltage_source_2.p) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}
  connect(op_amp.n_supply, voltage_source_3.p) {
    "Dyad": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]}
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 0.1,
        "atol": {"op_amp.outp.v": 0.4},
        "reltol": 0.001,
        "expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt