OpAmpDetailed
IconOpAmpDetailed
Detailed model of an operational amplifier
Usage
OpAmpDetailed(Rdm=2.0e6, Rcm=2.0e9, Cin=1.4e-12, Vos=1.0e-3, Ib=80.0e-9, Ios=20.0e-9, vcp=0.0, vcm=0.0, Avd0=106.0, CMRR=90.0, fp1=5.0, fp2=2.0e6, fp3=20.0e6, fp4=100.0e6, fz=5.0e6, sr_p=0.5e6, sr_m=0.5e6, Rout=75.0, Imaxso=25.0e-3, Imaxsi=25.0e-3, Ts=0.0000012, vcp_abs=abs(vcp), vcm_abs=abs(vcm), I1=Ib+Ios/2.0, I2=Ib-Ios/2.0, Avd0_val=10.0^(Avd0/20.0), Avcm_val=(Avd0_val/(10.0^(CMRR/20.0)))/2.0, sr_p_val=abs(sr_p), sr_m_val=-abs(sr_m), Imaxso_val=abs(Imaxso), Imaxsi_val=abs(Imaxsi))
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
Rdm | Input resistance (differential input mode) | Ω | 2000000 |
Rcm | Input resistance (common mode) | Ω | 2000000000 |
Cin | Input capacitance | F | 1.4e-12 |
Vos | Input offset voltage | V | 0.001 |
Ib | Input bias current | A | 8e-8 |
Ios | Input offset current | A | 2e-8 |
vcp | Correction value for limiting by p_supply | V | 0 |
vcm | Correction value for limiting by n_supply | V | 0 |
Avd0 | Differential amplifier [dB] | dB | 106 |
CMRR | Common-mode rejection [dB] | dB | 90 |
fp1 | Dominant pole | Hz | 5 |
fp2 | Pole frequency | Hz | 2000000 |
fp3 | Pole frequency | Hz | 20000000 |
fp4 | Pole frequency | Hz | 100000000 |
fz | Zero frequency | Hz | 5000000 |
sr_p | Slew rate for increase | V/s | 500000 |
sr_m | Slew rate for decrease | V/s | 500000 |
Rout | Output resistance | Ω | 75 |
Imaxso | Maximal output current (source current) | A | 0.025 |
Imaxsi | Maximal output current (sink current) | A | 0.025 |
Ts | Sampling Time | number of intervals: 2500, stop time: 0.003 | s |
vcp_abs | Positive correction value for limiting by p_supply | V | abs(vcp) |
vcm_abs | Positive correction value for limiting by n_supply | V | abs(vcm) |
I1 | Current of internal source I1 | A | Ib + Ios / 2 |
I2 | Current of internal source I2 | A | Ib - Ios / 2 |
Avd0_val | Differential mode gain | – | 10 ^ (Avd0 / 20) |
Avcm_val | Common mode gain | – | (Avd0_val / (10 ^ (CMRR / 20))) / 2 |
sr_p_val | Value of slew rate for increase | V/s | abs(sr_p) |
sr_m_val | Negative value of slew rate for increase | V/s | -abs(sr_m) |
Imaxso_val | Orientation out outp | A | abs(Imaxso) |
Imaxsi_val | Orientation into outp | A | abs(Imaxsi) |
Connectors
Variables
Name | Description | Units |
---|---|---|
v_pos | V | |
v_neg | V | |
v_vos | V | |
v_3 | V | |
v_in | V | |
v_4 | V | |
i_vos | A | |
i_3 | A | |
i_r2 | A | |
i_c3 | A | |
i_4 | A | |
q_fr1 | – | |
q_fr2 | – | |
q_fr3 | – | |
q_sum | V | |
q_sum_help | V | |
q_fp1 | V | |
v_source | V | |
x | Auxiliary variable for slew rate | V |
v_out | V | |
i_out | A |
Behavior
\[ \begin{align} \mathtt{v\_pos}\left( t \right) &= \mathtt{p\_supply.v}\left( t \right) \\ \mathtt{v\_neg}\left( t \right) &= \mathtt{n\_supply.v}\left( t \right) \\ \mathtt{p.i}\left( t \right) &= \mathtt{i\_vos}\left( t \right) \\ \mathtt{n.i}\left( t \right) &= \mathtt{i\_4}\left( t \right) - \mathtt{i\_c3}\left( t \right) - \mathtt{i\_r2}\left( t \right) \\ 0 &= \mathtt{i\_3}\left( t \right) - \mathtt{i\_vos}\left( t \right) + \mathtt{i\_c3}\left( t \right) + \mathtt{i\_r2}\left( t \right) \\ \mathtt{p.v}\left( t \right) - \mathtt{n.v}\left( t \right) &= \mathtt{v\_in}\left( t \right) + \mathtt{v\_vos}\left( t \right) \\ \mathtt{v\_4}\left( t \right) &= \mathtt{n.v}\left( t \right) \\ \mathtt{v\_3}\left( t \right) &= \mathtt{p.v}\left( t \right) - \mathtt{v\_vos}\left( t \right) \\ \mathtt{v\_vos}\left( t \right) &= \mathtt{Vos} \\ \mathtt{i\_3}\left( t \right) &= \mathtt{I1} + \frac{\mathtt{v\_3}\left( t \right)}{\mathtt{Rcm}} \\ \mathtt{v\_in}\left( t \right) &= \mathtt{Rdm} \mathtt{i\_r2}\left( t \right) \\ \mathtt{i\_c3}\left( t \right) &= \mathtt{Cin} \frac{\mathrm{d} \mathtt{v\_in}\left( t \right)}{\mathrm{d}t} \\ \mathtt{i\_4}\left( t \right) &= \mathtt{I2} + \frac{\mathtt{v\_4}\left( t \right)}{\mathtt{Rcm}} \\ \frac{\mathrm{d} \mathtt{q\_fr1}\left( t \right)}{\mathrm{d}t} &= 6.2832 \mathtt{fp2} \left( \mathtt{v\_in}\left( t \right) - \mathtt{q\_fr1}\left( t \right) \right) \\ \mathtt{q\_fr2}\left( t \right) + \frac{\frac{\mathrm{d} \mathtt{q\_fr2}\left( t \right)}{\mathrm{d}t}}{6.2832 \mathtt{fp3}} &= \mathtt{q\_fr1}\left( t \right) + \frac{\frac{\mathrm{d} \mathtt{q\_fr1}\left( t \right)}{\mathrm{d}t}}{6.2832 \mathtt{fz}} \\ \frac{\mathrm{d} \mathtt{q\_fr3}\left( t \right)}{\mathrm{d}t} &= 6.2832 \mathtt{fp4} \left( \mathtt{q\_fr2}\left( t \right) - \mathtt{q\_fr3}\left( t \right) \right) \\ \mathtt{q\_sum}\left( t \right) &= \mathtt{Avcm\_val} \left( \mathtt{v\_4}\left( t \right) + \mathtt{v\_3}\left( t \right) \right) + \mathtt{Avd0\_val} \mathtt{q\_fr3}\left( t \right) \\ \mathtt{q\_sum\_help}\left( t \right) &= ifelse\left( \left( \mathtt{q\_sum}\left( t \right) > - \mathtt{vcp\_abs} + \mathtt{v\_pos}\left( t \right) \right) \wedge \left( \mathtt{q\_fp1}\left( t \right) \geq - \mathtt{vcp\_abs} + \mathtt{v\_pos}\left( t \right) \right), - \mathtt{vcp\_abs} + \mathtt{v\_pos}\left( t \right), ifelse\left( \left( \mathtt{q\_sum}\left( t \right) < \mathtt{vcm\_abs} + \mathtt{v\_neg}\left( t \right) \right) \wedge \left( \mathtt{q\_fp1}\left( t \right) \leq \mathtt{vcm\_abs} + \mathtt{v\_neg}\left( t \right) \right), \mathtt{vcm\_abs} + \mathtt{v\_neg}\left( t \right), \mathtt{q\_sum}\left( t \right) \right) \right) \\ \frac{\mathrm{d} \mathtt{q\_fp1}\left( t \right)}{\mathrm{d}t} &= 6.2832 \mathtt{fp1} \left( - \mathtt{q\_fp1}\left( t \right) + \mathtt{q\_sum\_help}\left( t \right) \right) \\ \frac{\mathrm{d} x\left( t \right)}{\mathrm{d}t} &= \frac{\mathtt{q\_fp1}\left( t \right) - \mathtt{v\_source}\left( t \right)}{\mathtt{Ts}} \\ \frac{\mathrm{d} \mathtt{v\_source}\left( t \right)}{\mathrm{d}t} &= ifelse\left( \frac{\mathrm{d} x\left( t \right)}{\mathrm{d}t} > \mathtt{sr\_p\_val}, \mathtt{sr\_p\_val}, ifelse\left( \frac{\mathrm{d} x\left( t \right)}{\mathrm{d}t} < \mathtt{sr\_m\_val}, \mathtt{sr\_m\_val}, \frac{\mathrm{d} x\left( t \right)}{\mathrm{d}t} \right) \right) \\ \mathtt{v\_out}\left( t \right) &= \mathtt{outp.v}\left( t \right) \\ \mathtt{i\_out}\left( t \right) &= \mathtt{outp.i}\left( t \right) \\ \mathtt{i\_out}\left( t \right) &= ifelse\left( \mathtt{v\_out}\left( t \right) > \mathtt{v\_source}\left( t \right) + \mathtt{Imaxsi\_val} \mathtt{Rout}, \mathtt{Imaxsi\_val}, ifelse\left( \mathtt{v\_out}\left( t \right) < \mathtt{v\_source}\left( t \right) - \mathtt{Imaxso\_val} \mathtt{Rout}, - \mathtt{Imaxso\_val}, \frac{ - \mathtt{v\_source}\left( t \right) + \mathtt{v\_out}\left( t \right)}{\mathtt{Rout}} \right) \right) \\ \mathtt{p\_supply.i}\left( t \right) &= 0 \\ \mathtt{n\_supply.i}\left( t \right) &= 0 \end{align} \]
Source
# Detailed model of an operational amplifier
component OpAmpDetailed
# Positive pin of the input port
p = Pin() [{
"JuliaSim": {
"placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 650, "x2": 50, "y2": 750}}
}
}]
# Negative pin of the input port
n = Pin() [{
"JuliaSim": {
"placement": {"icon": {"iconName": "neg", "x1": -50, "y1": 250, "x2": 50, "y2": 350}}
}
}]
# Output pin
outp = Pin() [{
"JuliaSim": {
"placement": {"icon": {"iconName": "pos", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
}
}]
# Positive output voltage limitation
p_supply = Pin() [{
"JuliaSim": {
"placement": {"icon": {"iconName": "pos", "x1": 450, "y1": -50, "x2": 550, "y2": 50}}
}
}]
# Negative output voltage limitation
n_supply = Pin() [{
"JuliaSim": {
"placement": {"icon": {"iconName": "neg", "x1": 450, "y1": 950, "x2": 550, "y2": 1050}}
}
}]
# Input resistance (differential input mode)
parameter Rdm::Resistance = 2.0e6
# Input resistance (common mode)
parameter Rcm::Resistance = 2.0e9
# Input capacitance
parameter Cin::Capacitance = 1.4e-12
# Input offset voltage
parameter Vos::Voltage = 1.0e-3
# Input bias current
parameter Ib::Current = 80.0e-9
# Input offset current
parameter Ios::Current = 20.0e-9
# Correction value for limiting by `p_supply`
parameter vcp::Voltage = 0.0
# Correction value for limiting by `n_supply`
parameter vcm::Voltage = 0.0
# Differential amplifier [dB]
parameter Avd0::SoundPowerLevel = 106.0
# Common-mode rejection [dB]
parameter CMRR::SoundPowerLevel = 90.0
# Dominant pole
parameter fp1::Frequency = 5.0
# Pole frequency
parameter fp2::Frequency = 2.0e6
# Pole frequency
parameter fp3::Frequency = 20.0e6
# Pole frequency
parameter fp4::Frequency = 100.0e6
# Zero frequency
parameter fz::Frequency = 5.0e6
# Slew rate for increase
parameter sr_p::VoltageSlope = 0.5e6
# Slew rate for decrease
parameter sr_m::VoltageSlope = 0.5e6
# Output resistance
parameter Rout::Resistance = 75.0
# Maximal output current (source current)
parameter Imaxso::Current = 25.0e-3
# Maximal output current (sink current)
parameter Imaxsi::Current = 25.0e-3
# Sampling Time | number of intervals: 2500, stop time: 0.003
parameter Ts::Time = 0.0000012
# Positive correction value for limiting by `p_supply`
final parameter vcp_abs::Voltage = abs(vcp)
# Positive correction value for limiting by `n_supply`
final parameter vcm_abs::Voltage = abs(vcm)
# Current of internal source I1
final parameter I1::Current = Ib+Ios/2.0
# Current of internal source I2
final parameter I2::Current = Ib-Ios/2.0
# Differential mode gain
final parameter Avd0_val::Real = 10.0^(Avd0/20.0)
# Common mode gain
final parameter Avcm_val::Real = (Avd0_val/(10.0^(CMRR/20.0)))/2.0
# Value of slew rate for increase
final parameter sr_p_val::VoltageSlope = abs(sr_p)
# Negative value of slew rate for increase
final parameter sr_m_val::VoltageSlope = -abs(sr_m)
# Orientation out outp
final parameter Imaxso_val::Current = abs(Imaxso)
# Orientation into outp
final parameter Imaxsi_val::Current = abs(Imaxsi)
variable v_pos::Voltage
variable v_neg::Voltage
variable v_vos::Voltage
variable v_3::Voltage
variable v_in::Voltage
variable v_4::Voltage
variable i_vos::Current
variable i_3::Current
variable i_r2::Current
variable i_c3::Current
variable i_4::Current
variable q_fr1::Real
variable q_fr2::Real
variable q_fr3::Real
variable q_sum::Voltage
variable q_sum_help::Voltage
variable q_fp1::Voltage
variable v_source::Voltage
# Auxiliary variable for slew rate
variable x::Voltage
variable v_out::Voltage
variable i_out::Current
relations
initial v_source = q_fp1
initial x = 0
# power supply
v_pos = p_supply.v
v_neg = n_supply.v
# input stage
p.i = i_vos
n.i = i_4-i_r2-i_c3
0 = i_3+i_r2+i_c3-i_vos
p.v-n.v = v_vos+v_in
v_4 = n.v
v_3 = p.v-v_vos
v_vos = Vos
i_3 = I1+v_3/Rcm
v_in = Rdm*i_r2
i_c3 = Cin*der(v_in)
i_4 = I2+v_4/Rcm
# Frequency response
der(q_fr1) = 2.0*π*fp2*(v_in-q_fr1)
q_fr2+(1.0/(2.0*π*fp3))*der(q_fr2) = q_fr1+(1.0/(2.0*π*fz))*der(q_fr1)
der(q_fr3) = 2.0*π*fp4*(q_fr2-q_fr3)
# gain stage
q_sum = Avd0_val*q_fr3+Avcm_val*(v_3+v_4)
q_sum_help = limit_q_sum(q_sum, q_fp1, v_pos, v_neg, vcp_abs, vcm_abs)
der(q_fp1) = 2.0*π*fp1*(q_sum_help-q_fp1)
# slew rate stage
der(x) = (q_fp1-v_source)/Ts
der(v_source) = ifelse(der(x)>sr_p_val, sr_p_val, ifelse(der(x)<sr_m_val, sr_m_val, der(x)))
# output stage
v_out = outp.v
i_out = outp.i
i_out = limit_out_current(v_source, v_out, Rout, Imaxsi_val, Imaxso_val)
p_supply.i = 0
n_supply.i = 0
end
Flattened Source
# Detailed model of an operational amplifier component OpAmpDetailed # Positive pin of the input port p = Pin() [{ "JuliaSim": { "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 650, "x2": 50, "y2": 750}} } }] # Negative pin of the input port n = Pin() [{ "JuliaSim": { "placement": {"icon": {"iconName": "neg", "x1": -50, "y1": 250, "x2": 50, "y2": 350}} } }] # Output pin outp = Pin() [{ "JuliaSim": { "placement": {"icon": {"iconName": "pos", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}} } }] # Positive output voltage limitation p_supply = Pin() [{ "JuliaSim": { "placement": {"icon": {"iconName": "pos", "x1": 450, "y1": -50, "x2": 550, "y2": 50}} } }] # Negative output voltage limitation n_supply = Pin() [{ "JuliaSim": { "placement": {"icon": {"iconName": "neg", "x1": 450, "y1": 950, "x2": 550, "y2": 1050}} } }] # Input resistance (differential input mode) parameter Rdm::Resistance = 2.0e6 # Input resistance (common mode) parameter Rcm::Resistance = 2.0e9 # Input capacitance parameter Cin::Capacitance = 1.4e-12 # Input offset voltage parameter Vos::Voltage = 1.0e-3 # Input bias current parameter Ib::Current = 80.0e-9 # Input offset current parameter Ios::Current = 20.0e-9 # Correction value for limiting by `p_supply` parameter vcp::Voltage = 0.0 # Correction value for limiting by `n_supply` parameter vcm::Voltage = 0.0 # Differential amplifier [dB] parameter Avd0::SoundPowerLevel = 106.0 # Common-mode rejection [dB] parameter CMRR::SoundPowerLevel = 90.0 # Dominant pole parameter fp1::Frequency = 5.0 # Pole frequency parameter fp2::Frequency = 2.0e6 # Pole frequency parameter fp3::Frequency = 20.0e6 # Pole frequency parameter fp4::Frequency = 100.0e6 # Zero frequency parameter fz::Frequency = 5.0e6 # Slew rate for increase parameter sr_p::VoltageSlope = 0.5e6 # Slew rate for decrease parameter sr_m::VoltageSlope = 0.5e6 # Output resistance parameter Rout::Resistance = 75.0 # Maximal output current (source current) parameter Imaxso::Current = 25.0e-3 # Maximal output current (sink current) parameter Imaxsi::Current = 25.0e-3 # Sampling Time | number of intervals: 2500, stop time: 0.003 parameter Ts::Time = 0.0000012 # Positive correction value for limiting by `p_supply` final parameter vcp_abs::Voltage = abs(vcp) # Positive correction value for limiting by `n_supply` final parameter vcm_abs::Voltage = abs(vcm) # Current of internal source I1 final parameter I1::Current = Ib+Ios/2.0 # Current of internal source I2 final parameter I2::Current = Ib-Ios/2.0 # Differential mode gain final parameter Avd0_val::Real = 10.0^(Avd0/20.0) # Common mode gain final parameter Avcm_val::Real = (Avd0_val/(10.0^(CMRR/20.0)))/2.0 # Value of slew rate for increase final parameter sr_p_val::VoltageSlope = abs(sr_p) # Negative value of slew rate for increase final parameter sr_m_val::VoltageSlope = -abs(sr_m) # Orientation out outp final parameter Imaxso_val::Current = abs(Imaxso) # Orientation into outp final parameter Imaxsi_val::Current = abs(Imaxsi) variable v_pos::Voltage variable v_neg::Voltage variable v_vos::Voltage variable v_3::Voltage variable v_in::Voltage variable v_4::Voltage variable i_vos::Current variable i_3::Current variable i_r2::Current variable i_c3::Current variable i_4::Current variable q_fr1::Real variable q_fr2::Real variable q_fr3::Real variable q_sum::Voltage variable q_sum_help::Voltage variable q_fp1::Voltage variable v_source::Voltage # Auxiliary variable for slew rate variable x::Voltage variable v_out::Voltage variable i_out::Current relations initial v_source = q_fp1 initial x = 0 # power supply v_pos = p_supply.v v_neg = n_supply.v # input stage p.i = i_vos n.i = i_4-i_r2-i_c3 0 = i_3+i_r2+i_c3-i_vos p.v-n.v = v_vos+v_in v_4 = n.v v_3 = p.v-v_vos v_vos = Vos i_3 = I1+v_3/Rcm v_in = Rdm*i_r2 i_c3 = Cin*der(v_in) i_4 = I2+v_4/Rcm # Frequency response der(q_fr1) = 2.0*π*fp2*(v_in-q_fr1) q_fr2+(1.0/(2.0*π*fp3))*der(q_fr2) = q_fr1+(1.0/(2.0*π*fz))*der(q_fr1) der(q_fr3) = 2.0*π*fp4*(q_fr2-q_fr3) # gain stage q_sum = Avd0_val*q_fr3+Avcm_val*(v_3+v_4) q_sum_help = limit_q_sum(q_sum, q_fp1, v_pos, v_neg, vcp_abs, vcm_abs) der(q_fp1) = 2.0*π*fp1*(q_sum_help-q_fp1) # slew rate stage der(x) = (q_fp1-v_source)/Ts der(v_source) = ifelse(der(x)>sr_p_val, sr_p_val, ifelse(der(x)
Test Cases
Related
- Examples
- Experiments
- Analyses
- Tests