AmplifierWithOpAmpDetailed
IconAmplifierWithOpAmpDetailed
Simple Amplifier circuit which uses OpAmpDetailed
Usage
AmplifierWithOpAmpDetailed()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( input_{signal1_{+}y(t)}, voltage_{source\_1_{+}V(t)} \right) \\ \mathrm{connect}\left( input_{signal2_{+}y(t)}, voltage_{source\_2_{+}V(t)} \right) \\ \mathrm{connect}\left( input_{signal3_{+}y(t)}, voltage_{source\_3_{+}V(t)} \right) \\ \mathrm{connect}\left( ground_{+}g, voltage_{source\_1_{+}n}, op_{amp_{+}p}, resistor2_{+}n, voltage_{source\_3_{+}n}, voltage_{source\_2_{+}n} \right) \\ \mathrm{connect}\left( resistor_{+}n, op_{amp_{+}n}, resistor1_{+}p \right) \\ \mathrm{connect}\left( resistor1_{+}n, op_{amp_{+}outp}, resistor2_{+}p \right) \\ \mathrm{connect}\left( resistor_{+}p, voltage_{source\_1_{+}p} \right) \\ \mathrm{connect}\left( op_{amp_{+}p\_supply}, voltage_{source\_2_{+}p} \right) \\ \mathrm{connect}\left( op_{amp_{+}n\_supply}, voltage_{source\_3_{+}p} \right) \\ \mathtt{op\_amp.v\_pos}\left( t \right) = \mathtt{op\_amp.p\_supply.v}\left( t \right) \\ \mathtt{op\_amp.v\_neg}\left( t \right) = \mathtt{op\_amp.n\_supply.v}\left( t \right) \\ \mathtt{op\_amp.p.i}\left( t \right) = \mathtt{op\_amp.i\_vos}\left( t \right) \\ \mathtt{op\_amp.n.i}\left( t \right) = - \mathtt{op\_amp.i\_c3}\left( t \right) - \mathtt{op\_amp.i\_r2}\left( t \right) + \mathtt{op\_amp.i\_4}\left( t \right) \\ 0 = \mathtt{op\_amp.i\_3}\left( t \right) + \mathtt{op\_amp.i\_c3}\left( t \right) - \mathtt{op\_amp.i\_vos}\left( t \right) + \mathtt{op\_amp.i\_r2}\left( t \right) \\ \mathtt{op\_amp.p.v}\left( t \right) - \mathtt{op\_amp.n.v}\left( t \right) = \mathtt{op\_amp.v\_vos}\left( t \right) + \mathtt{op\_amp.v\_in}\left( t \right) \\ \mathtt{op\_amp.v\_4}\left( t \right) = \mathtt{op\_amp.n.v}\left( t \right) \\ \mathtt{op\_amp.v\_3}\left( t \right) = \mathtt{op\_amp.p.v}\left( t \right) - \mathtt{op\_amp.v\_vos}\left( t \right) \\ \mathtt{op\_amp.v\_vos}\left( t \right) = \mathtt{op\_amp.Vos} \\ \mathtt{op\_amp.i\_3}\left( t \right) = \mathtt{op\_amp.I1} + \frac{\mathtt{op\_amp.v\_3}\left( t \right)}{\mathtt{op\_amp.Rcm}} \\ \mathtt{op\_amp.v\_in}\left( t \right) = \mathtt{op\_amp.Rdm} \mathtt{op\_amp.i\_r2}\left( t \right) \\ \mathtt{op\_amp.i\_c3}\left( t \right) = \mathtt{op\_amp.Cin} \frac{\mathrm{d} \mathtt{op\_amp.v\_in}\left( t \right)}{\mathrm{d}t} \\ \mathtt{op\_amp.i\_4}\left( t \right) = \mathtt{op\_amp.I2} + \frac{\mathtt{op\_amp.v\_4}\left( t \right)}{\mathtt{op\_amp.Rcm}} \\ \frac{\mathrm{d} \mathtt{op\_amp.q\_fr1}\left( t \right)}{\mathrm{d}t} = 6.2832 \mathtt{op\_amp.fp2} \left( - \mathtt{op\_amp.q\_fr1}\left( t \right) + \mathtt{op\_amp.v\_in}\left( t \right) \right) \\ \frac{\frac{\mathrm{d} \mathtt{op\_amp.q\_fr2}\left( t \right)}{\mathrm{d}t}}{6.2832 \mathtt{op\_amp.fp3}} + \mathtt{op\_amp.q\_fr2}\left( t \right) = \frac{\frac{\mathrm{d} \mathtt{op\_amp.q\_fr1}\left( t \right)}{\mathrm{d}t}}{6.2832 \mathtt{op\_amp.fz}} + \mathtt{op\_amp.q\_fr1}\left( t \right) \\ \frac{\mathrm{d} \mathtt{op\_amp.q\_fr3}\left( t \right)}{\mathrm{d}t} = 6.2832 \mathtt{op\_amp.fp4} \left( - \mathtt{op\_amp.q\_fr3}\left( t \right) + \mathtt{op\_amp.q\_fr2}\left( t \right) \right) \\ \mathtt{op\_amp.q\_sum}\left( t \right) = \mathtt{op\_amp.Avcm\_val} \left( \mathtt{op\_amp.v\_4}\left( t \right) + \mathtt{op\_amp.v\_3}\left( t \right) \right) + \mathtt{op\_amp.Avd0\_val} \mathtt{op\_amp.q\_fr3}\left( t \right) \\ \mathtt{op\_amp.q\_sum\_help}\left( t \right) = ifelse\left( \left( \mathtt{op\_amp.q\_sum}\left( t \right) > - \mathtt{op\_amp.vcp\_abs} + \mathtt{op\_amp.v\_pos}\left( t \right) \right) \wedge \left( \mathtt{op\_amp.q\_fp1}\left( t \right) \geq - \mathtt{op\_amp.vcp\_abs} + \mathtt{op\_amp.v\_pos}\left( t \right) \right), - \mathtt{op\_amp.vcp\_abs} + \mathtt{op\_amp.v\_pos}\left( t \right), ifelse\left( \left( \mathtt{op\_amp.q\_sum}\left( t \right) < \mathtt{op\_amp.vcm\_abs} + \mathtt{op\_amp.v\_neg}\left( t \right) \right) \wedge \left( \mathtt{op\_amp.q\_fp1}\left( t \right) \leq \mathtt{op\_amp.vcm\_abs} + \mathtt{op\_amp.v\_neg}\left( t \right) \right), \mathtt{op\_amp.vcm\_abs} + \mathtt{op\_amp.v\_neg}\left( t \right), \mathtt{op\_amp.q\_sum}\left( t \right) \right) \right) \\ \frac{\mathrm{d} \mathtt{op\_amp.q\_fp1}\left( t \right)}{\mathrm{d}t} = 6.2832 \mathtt{op\_amp.fp1} \left( - \mathtt{op\_amp.q\_fp1}\left( t \right) + \mathtt{op\_amp.q\_sum\_help}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{op\_amp.x}\left( t \right)}{\mathrm{d}t} = \frac{ - \mathtt{op\_amp.v\_source}\left( t \right) + \mathtt{op\_amp.q\_fp1}\left( t \right)}{\mathtt{op\_amp.Ts}} \\ \frac{\mathrm{d} \mathtt{op\_amp.v\_source}\left( t \right)}{\mathrm{d}t} = ifelse\left( \frac{\mathrm{d} \mathtt{op\_amp.x}\left( t \right)}{\mathrm{d}t} > \mathtt{op\_amp.sr\_p\_val}, \mathtt{op\_amp.sr\_p\_val}, ifelse\left( \frac{\mathrm{d} \mathtt{op\_amp.x}\left( t \right)}{\mathrm{d}t} < \mathtt{op\_amp.sr\_m\_val}, \mathtt{op\_amp.sr\_m\_val}, \frac{\mathrm{d} \mathtt{op\_amp.x}\left( t \right)}{\mathrm{d}t} \right) \right) \\ \mathtt{op\_amp.v\_out}\left( t \right) = \mathtt{op\_amp.outp.v}\left( t \right) \\ \mathtt{op\_amp.i\_out}\left( t \right) = \mathtt{op\_amp.outp.i}\left( t \right) \\ \mathtt{op\_amp.i\_out}\left( t \right) = ifelse\left( \mathtt{op\_amp.v\_out}\left( t \right) > \mathtt{op\_amp.v\_source}\left( t \right) + \mathtt{op\_amp.Imaxsi\_val} \mathtt{op\_amp.Rout}, \mathtt{op\_amp.Imaxsi\_val}, ifelse\left( \mathtt{op\_amp.v\_out}\left( t \right) < \mathtt{op\_amp.v\_source}\left( t \right) - \mathtt{op\_amp.Imaxso\_val} \mathtt{op\_amp.Rout}, - \mathtt{op\_amp.Imaxso\_val}, \frac{ - \mathtt{op\_amp.v\_source}\left( t \right) + \mathtt{op\_amp.v\_out}\left( t \right)}{\mathtt{op\_amp.Rout}} \right) \right) \\ \mathtt{op\_amp.p\_supply.i}\left( t \right) = 0 \\ \mathtt{op\_amp.n\_supply.i}\left( t \right) = 0 \\ \mathtt{resistor.v}\left( t \right) = - \mathtt{resistor.n.v}\left( t \right) + \mathtt{resistor.p.v}\left( t \right) \\ \mathtt{resistor.i}\left( t \right) = \mathtt{resistor.p.i}\left( t \right) \\ \mathtt{resistor.p.i}\left( t \right) + \mathtt{resistor.n.i}\left( t \right) = 0 \\ \mathtt{resistor.v}\left( t \right) = \mathtt{resistor.R} \mathtt{resistor.i}\left( t \right) \\ \mathtt{resistor1.v}\left( t \right) = - \mathtt{resistor1.n.v}\left( t \right) + \mathtt{resistor1.p.v}\left( t \right) \\ \mathtt{resistor1.i}\left( t \right) = \mathtt{resistor1.p.i}\left( t \right) \\ \mathtt{resistor1.n.i}\left( t \right) + \mathtt{resistor1.p.i}\left( t \right) = 0 \\ \mathtt{resistor1.v}\left( t \right) = \mathtt{resistor1.R} \mathtt{resistor1.i}\left( t \right) \\ \mathtt{resistor2.v}\left( t \right) = - \mathtt{resistor2.n.v}\left( t \right) + \mathtt{resistor2.p.v}\left( t \right) \\ \mathtt{resistor2.i}\left( t \right) = \mathtt{resistor2.p.i}\left( t \right) \\ \mathtt{resistor2.p.i}\left( t \right) + \mathtt{resistor2.n.i}\left( t \right) = 0 \\ \mathtt{resistor2.v}\left( t \right) = \mathtt{resistor2.R} \mathtt{resistor2.i}\left( t \right) \\ \mathtt{voltage\_source\_1.v}\left( t \right) = - \mathtt{voltage\_source\_1.n.v}\left( t \right) + \mathtt{voltage\_source\_1.p.v}\left( t \right) \\ \mathtt{voltage\_source\_1.i}\left( t \right) = \mathtt{voltage\_source\_1.p.i}\left( t \right) \\ \mathtt{voltage\_source\_1.p.i}\left( t \right) + \mathtt{voltage\_source\_1.n.i}\left( t \right) = 0 \\ \mathtt{voltage\_source\_1.v}\left( t \right) = \mathtt{voltage\_source\_1.uV} \mathtt{voltage\_source\_1.V}\left( t \right) \\ \mathtt{voltage\_source\_2.v}\left( t \right) = - \mathtt{voltage\_source\_2.n.v}\left( t \right) + \mathtt{voltage\_source\_2.p.v}\left( t \right) \\ \mathtt{voltage\_source\_2.i}\left( t \right) = \mathtt{voltage\_source\_2.p.i}\left( t \right) \\ \mathtt{voltage\_source\_2.n.i}\left( t \right) + \mathtt{voltage\_source\_2.p.i}\left( t \right) = 0 \\ \mathtt{voltage\_source\_2.v}\left( t \right) = \mathtt{voltage\_source\_2.uV} \mathtt{voltage\_source\_2.V}\left( t \right) \\ \mathtt{voltage\_source\_3.v}\left( t \right) = - \mathtt{voltage\_source\_3.n.v}\left( t \right) + \mathtt{voltage\_source\_3.p.v}\left( t \right) \\ \mathtt{voltage\_source\_3.i}\left( t \right) = \mathtt{voltage\_source\_3.p.i}\left( t \right) \\ \mathtt{voltage\_source\_3.p.i}\left( t \right) + \mathtt{voltage\_source\_3.n.i}\left( t \right) = 0 \\ \mathtt{voltage\_source\_3.v}\left( t \right) = \mathtt{voltage\_source\_3.uV} \mathtt{voltage\_source\_3.V}\left( t \right) \\ \mathtt{input\_signal1.y}\left( t \right) = ifelse\left( \mathtt{input\_signal1.start\_time} < t, \mathtt{input\_signal1.offset} + \mathtt{input\_signal1.amplitude} \sin\left( \mathtt{input\_signal1.phase} + 6.2832 \mathtt{input\_signal1.frequency} \left( - \mathtt{input\_signal1.start\_time} + t \right) \right), \mathtt{input\_signal1.offset} \right) \\ \mathtt{input\_signal2.y}\left( t \right) = \mathtt{input\_signal2.k} \\ \mathtt{input\_signal3.y}\left( t \right) = \mathtt{input\_signal3.k} \\ \mathtt{ground.g.v}\left( t \right) = 0 \\ \end{array} \right] \end{equation} \]
Source
# Simple Amplifier circuit which uses OpAmpDetailed
test component AmplifierWithOpAmpDetailed
op_amp = OpAmpDetailed() [{
"JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}}
}]
resistor = Resistor(R=10000) [{
"JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}}
}]
resistor1 = Resistor(R=20000) [{
"JuliaSim": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}}
}]
resistor2 = Resistor(R=10000) [{
"JuliaSim": {
"placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}}
}
}]
voltage_source_1 = VoltageSource() [{
"JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}}
}]
voltage_source_2 = VoltageSource() [{
"JuliaSim": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}}
}]
voltage_source_3 = VoltageSource() [{
"JuliaSim": {
"placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}}
}
}]
input_signal1 = BlockComponents.Sine(amplitude=12, frequency=1000, offset=0) [{
"JuliaSim": {
"placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}}
}
}]
input_signal2 = BlockComponents.Constant(k=15) [{
"JuliaSim": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}}
}]
input_signal3 = BlockComponents.Constant(k=-15) [{
"JuliaSim": {
"placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}}
}
}]
ground = Ground() [{
"JuliaSim": {
"placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}}
}
}]
relations
connect(input_signal1.y, voltage_source_1.V) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}]
connect(input_signal2.y, voltage_source_2.V) [{
"JuliaSim": {
"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) [{
"JuliaSim": {
"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) [{
"JuliaSim": {
"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) [{
"JuliaSim": {
"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) [{
"JuliaSim": {
"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) [{
"JuliaSim": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]}
}]
connect(op_amp.p_supply, voltage_source_2.p) [{"JuliaSim": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}]
connect(op_amp.n_supply, voltage_source_3.p) [{
"JuliaSim": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]}
}]
metadata {
"JuliaSim": {
"tests": {
"case1": {
"stop": 0.1,
"atol": {"op_amp.outp.v": 0.01},
"expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]}
}
}
}
}
end
Flattened Source
# Simple Amplifier circuit which uses OpAmpDetailed test component AmplifierWithOpAmpDetailed op_amp = OpAmpDetailed() [{ "JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 550, "x2": 600, "y2": 750, "rot": 0}}} }] resistor = Resistor(R=10000) [{ "JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 510, "x2": 300, "y2": 710, "rot": 0}}} }] resistor1 = Resistor(R=20000) [{ "JuliaSim": {"placement": {"icon": {"x1": 550, "y1": 0, "x2": 750, "y2": 200, "rot": 0}}} }] resistor2 = Resistor(R=10000) [{ "JuliaSim": { "placement": {"icon": {"x1": 800, "y1": 700, "x2": 1000, "y2": 900, "rot": 90}} } }] voltage_source_1 = VoltageSource() [{ "JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 850, "x2": 300, "y2": 1050, "rot": 0}}} }] voltage_source_2 = VoltageSource() [{ "JuliaSim": {"placement": {"icon": {"x1": 550, "y1": 300, "x2": 750, "y2": 500, "rot": 0}}} }] voltage_source_3 = VoltageSource() [{ "JuliaSim": { "placement": {"icon": {"x1": 550, "y1": 850, "x2": 750, "y2": 1050, "rot": 90}} } }] input_signal1 = BlockComponents.Sine(amplitude=12, frequency=1000, offset=0) [{ "JuliaSim": { "placement": {"icon": {"x1": 100, "y1": 1200, "x2": 300, "y2": 1400, "rot": 270}} } }] input_signal2 = BlockComponents.Constant(k=15) [{ "JuliaSim": {"placement": {"icon": {"x1": 950, "y1": 150, "x2": 1150, "y2": 350, "rot": 0}}} }] input_signal3 = BlockComponents.Constant(k=-15) [{ "JuliaSim": { "placement": {"icon": {"x1": 400, "y1": 1200, "x2": 600, "y2": 1400, "rot": 0}} } }] ground = Ground() [{ "JuliaSim": { "placement": {"icon": {"x1": 800, "y1": 1200, "x2": 1000, "y2": 1400, "rot": 0}} } }] relations connect(input_signal1.y, voltage_source_1.V) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}] connect(input_signal2.y, voltage_source_2.V) [{ "JuliaSim": { "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) [{ "JuliaSim": { "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) [{ "JuliaSim": { "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) [{ "JuliaSim": { "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) [{ "JuliaSim": { "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) [{ "JuliaSim": {"edges": [{"S": 1, "M": [{"x": 50, "y": 610}, {"x": 50, "y": 950}], "E": 2}]} }] connect(op_amp.p_supply, voltage_source_2.p) [{"JuliaSim": {"edges": [{"S": 1, "M": [{"x": 500, "y": 400}], "E": 2}]}}] connect(op_amp.n_supply, voltage_source_3.p) [{ "JuliaSim": {"edges": [{"S": 2, "M": [{"x": 650, "y": 800}, {"x": 500, "y": 800}], "E": 1}]} }] metadata { "JuliaSim": { "tests": { "case1": { "stop": 0.1, "atol": {"op_amp.outp.v": 0.01}, "expect": {"signals": ["op_amp.outp.v", "voltage_source_1.p.v"]} } } } } end