Widlar current source (mirror)
For the Widlar current source shown in the figure, find $R_1$ and $R_E$ in order to obtain $I_{ref}=100\,\mu$A, $I_{C2}=5\,\mu$A, assuming $V_{BE}\approx 0.7\,$V and $\beta$ to be large.
Note that the simulation results would be slightly different than the theoretical values since we are using a realistic BJT model and not an ideal BJT model.
In [1]:
from IPython.display import Image
Image(filename =r'EC_BJT_mirror_1_fig_1.png', width=170)
Out[1]:
In [2]:
# run this cell to view the circuit file.
%pycat EC_BJT_mirror_1_orig.in
We now replace strings such as \$RE with the value of our choice by running the python script given below. It takes an existing circuit file EC_BJT_mirror_1_orig.in and produces a new circuit file EC_BJT_mirror_1.in, after replacing \$RE (etc) with the values of our choice.
In [3]:
import gseim_calc as calc
s_RE = '10k' # to be changed by user
s_R1 = '10k' # to be changed by user
s_RL = '1k'
l = [
('$RE', s_RE),
('$R1', s_R1),
('$RL', s_RL),
]
calc.replace_strings_1("EC_BJT_mirror_1_orig.in", "EC_BJT_mirror_1.in", l)
print('EC_BJT_mirror_1.in is ready for execution')
EC_BJT_mirror_1.in is ready for execution
Execute the following cell to run NGSPICE on EC_BJT_mirror_1.in.
In [4]:
import ngspice_calc as ngcalc
ngcalc.run_ngspice('EC_BJT_mirror_1.in')
Circuit: bjt widlar current source Doing analysis at TEMP = 27.000000 and TNOM = 27.000000 No. of Data Columns : 5 No. of Data Rows : 1 Total analysis time (seconds) = 0 Total elapsed time (seconds) = 0.149 Total DRAM available = 7739.715 MB. DRAM currently available = 2164.176 MB. Total ngspice program size = 19.586 MB. Resident set size = 9.461 MB. Shared ngspice pages = 7.840 MB. Text (code) pages = 5.789 MB. Stack = 0 bytes. Library pages = 1.836 MB.
Out[4]:
'EC_BJT_mirror_1.raw'
In [5]:
# get output file information from the circuit file
s = ngcalc.slv('EC_BJT_mirror_1.in')
for i in range(s.num_plots()):
print(f" plot {i}: {s.plotname(i)} | type: {s.analysis_type(i)} | vars: {s.variables(i)}")
plot 0: Operating Point | type: op | vars: ['v(b)', 'v(e2)', 'v(c2)', 'i(vx1)', 'i(vx2)']
In [6]:
V_B = s.get_array('v(b)')[0]
V_E2 = s.get_array('v(E2)')[0]
V_C2 = s.get_array('v(C2)')[0]
I_ref = s.get_array('i(vx2)')[0]
I_C2 = s.get_array('i(vx1)')[0]
print(f'V_B = {V_B:7.4f} V')
print(f'V_E2 = {V_E2:7.4f} V')
print(f'V_C2 = {V_C2:7.4f} V')
print(f'Iref = {I_ref:11.4e} A')
print(f'IC2 = {I_C2:11.4e} A')
V_B = 0.6771 V V_E2 = 0.1105 V V_C2 = 7.9893 V Iref = 7.3229e-04 A IC2 = 1.0715e-05 A
This notebook was contributed by Prof. M. B. Patil, IIT Bombay. He may be contacted at mbpatil@ee.iitb.ac.in.
In [ ]: