Operational Amplifier

Circuit description

A non-inverting op amp is an operational amplifier circuit with an output voltage that is in phase with the input voltage. Its complement is the inverting op amp, which produces an output signal that is 180 degrees out of phase.

opamp

Goals

  • Calculate the output voltage of Operational amplifier $U$
  • Calculate the aplification gain of Op Amp as $\frac{U}{Ug}$
  • Calculate the power of Op Amp as $I_OpAmp*U$
  • Calculate the power of R3

Modeling the circuit

First we include Symbolics.jl and CircuitS.

using Symbolics
include("../CircuitS.jl")

Then we create the circuit and add all of the elements as shown in the picture above:

circuit = create_circuit()
add_element([Resistor, "R1", 0, 2], circuit)
add_element([Resistor, "R2", 2, 3], circuit)
add_element([Resistor, "R3", 0, 3], circuit)
add_element([Resistor, "R4", 4, 1], circuit)
add_element([Voltage, "Ug", 4, 0], circuit)
add_element([OpAmp, "OpAmp", [1, 2], 3], circuit)

Simulation

After we've built everything, we initialise and simulate the circuit:

init_circuit(circuit)
result = simulate(circuit)

println(result)
Dict{Any, Any} with 6 entries:
  "V3"      => (Ug*(R1 + R2)) / R1
  "V2"      => Ug
  "V4"      => Ug
  "I_Ug"    => 0
  "I_OpAmp" => (Ug*(-R1 - R2 - R3)) / (R1*R3)
  "V1"      => Ug

The output voltage of the operational amplifier is the voltage of node 3, so we can just print it from the result:

println(result["V3"])
(Ug*(R1 + R2)) / R1

For the amplification gain, we can simply divide the voltage V3 by Ug, but we first need to define Ug as a symbol, so we can do calculations with it:

@variables Ug
A = result["V3"]/Ug
println(A)
(R1 + R2) / R1

We can calculate the power of OpAmp as $V3*I_OpAmp$

P1 = result["V3"]*result["I_OpAmp"]
println(P1)
((R1 + R2)*(-R1 - R2 - R3)*(Ug^2)) / (R3*(R1^2))

And for R3 as $\frac{V3^2}{R3}$

@variables R3
P2 = (result["V3"]^2)/R3
println(P2)
(((Ug*(R1 + R2)) / R1)^2) / R3