Frequency Response Using ngspice

In the previous tutorials, we were only concerned about the DC characteristics, or what happens when we change the input voltages and currents very slowly. This means that the input frequencies are small enough, that we can treat all capacitors as open circuits, i.e. $Z_C\left(\omega\right) = \tfrac{1}{j\omega C} \rightarrow \infty$, and all inductors as short circuits, i.e. $Z_L\left(\omega\right) =j\omega L =0$.

However, in practice, the signals we are concerned with are time varying signals, which, according to Fourier, can be decomposed into its spectral components, where each component has its own frequency, magnitude, and phase. The goal of our frequency response analysis is to determine the small signal behavior of amplifiers in response to these time varying inputs. And since we are dealing with non-zero frequencies, we cannot treat our capacitors and inductors as open- or short-circuits.

The Transistor Transition Frequency ($f_T$)

Before we look at the frequency response of amplifiers, let us examine the effects of time varying inputs on a BJT. Consider the circuit below:

Figure 1: A circuit for obtaining $f_T$.

Note that, once again, we are using transistors Q1a and Q1b to generate $V_{BE1}$ to get $I_{C1}\approx I_{m1}$. We then use V1 to set $V_{CE1}$ to a reasonable value, ensuring that the transistor is in the forward-active region.

Let us add a small signal input, $i_{IN1}$, and let us see how the transistor behaves as we increase the frequency of the small signal input current. Note that we are using a large blocking inductor, $L_{blk1}\rightarrow \infty$, to prevent the small-signal current from going into the bias circuit because we want all of this input current going into the base of Q1, but we also want the DC bias current and voltage to get to the base of Q1.

If we inject a low-frequency small-signal current into the base of Q1, we expect a small signal collector current equal to:

$i_c = g_m \cdot v_{be} = g_m \cdot r_{\pi} \cdot i_{in} = \beta \cdot i_{in}$

As we increase the frequency of the small-signal input current, the transistor parasitic capacitances cannot be ignored any longer. The largest of these capacitances are (1) the base-emitter capacitance, composed of the base-emitter junction capacitance and the base charging capacitance, $C_{\pi} = C_{je} + C_b$, and (2) the collector-base junction capacitance, $C_{\mu}$.

Thus, our expression for the small-signal collector current becomes:

$i_c=g_m\cdot v_{be} = g_m\cdot Z_{in} \cdot i_{in}=g_m\cdot \left(r_{\pi}\| \frac{1}{j\omega C_{\pi}}\|\frac{1}{j\omega C_{\mu}} \right)\cdot i_{in}$

Notice that at high input frequencies, the impedances of the two capacitors become significantly smaller than $r_{\pi}$. At this point, the voltage $v_{be}$ also becomes smaller, resulting in a smaller small-signal collector current, making it seem that the transistor $\beta$ is decreasing as well.

For a transistor to amplify an input signal, it has to have a current gain

$\left|A_i\right|=\left|\frac{i_c}{i_{in}}\right|\geqslant 1$

So one useful metric is to figure out the frequency at which the small-signal current gain is equal to 1. This is the transistor’s transition frequency. Note that since the collector of Q1 is at small-signal ground, it is also called the short-circuit current gain. Thus

$\left|\frac{i_c}{i_{in}}\right|= \left|g_m\cdot \left(\frac{1}{j\omega_T C_{\pi}}\|\frac{1}{j\omega_T C_{\mu}} \right)\right|=\left|\frac{g_m}{j\omega_T \left(C_{\pi}+C_{\mu}} \right)\right|= 1$

We can then express the transition frequency as:

$\omega_T=2\pi\cdot f_T = \frac{g_m}{C_{\pi}+C_{\mu}}$

Simulating $f_T$

Let’s use this SPICE netlist to determine the transition frequency of the 2N3904 NPN bipolar transistor.

* Transistor transition frequency
* LPA 2020-04-16

.include 2N390X.lib

.options savecurrents

* the npn 2N3904 transistor
Q1		c1 b1 0		2N3904

Iin1 	b1 0		dc 0 ac 1
Lblk1	b1a b1		1k

* the npn current mirror
Q1a		c1x b1a 0		2N3904
Q1b		vcc c1x b1a		2N3904
Im1		vcc c1x		0.9m
V1		c1 0 		dc 2.5

Vsup	vcc 0 		dc 2.5

.control

op
let ft_2n3904_sim = '@Q1[gm]/(2*3.14*(@Q1[cpi]+@Q1[cmu]))'
print @Q1[ic] @Q1[gm] @Q1[cpi] @Q1[cmu] ft_2n3904_sim

ac dec 1000 100k 10G
wrdata bjt_2n3904_ft_1mA_sim.dat i(V1)

let mag_iV1 = abs(i(V1))
meas ac ft_2n3904 when mag_iV1=1

alter Im1 = 9m

op
let ft_2n3904_sim = '@Q1[gm]/(2*3.14*(@Q1[cpi]+@Q1[cmu]))'
print @Q1[ic] @Q1[gm] @Q1[cpi] @Q1[cmu] ft_2n3904_sim

ac dec 1000 100k 10G
wrdata bjt_2n3904_ft_10mA_sim.dat i(V1)

let mag_iV1 = abs(i(V1))
meas ac ft_2n3904 when mag_iV1=1

.endc

.end

We add another input source specification, the ‘ac‘ magnitude, as seen in line 11, when we describe the source Iin1. Since the AC analysis is a small-signal analysis, i.e. it calculates the small-signal equivalent circuit from the bias voltages and currents, it is a linear analysis. Thus, if we assign the input a value of 1A, the resulting collector current value will be the same as the current gain.

To specify the AC analysis, we use the ac command in lines 28 and 40, with the format ac dec <nd> <fstart> <fstop>, where nd is the number of points per decade. the simulator then calculates the small signal response of the circuit from frequency fstart to frequency fstop. Note that the node voltages and currents are phasors (complex numbers).

We use the measure or meas command in lines 31, 32, 43, and 44 to find the frequency when the magnitude of the current through the voltage source V1 is equal to 1. Thus this frequency is the transition frequency of the BJT.

To calculate the transition frequency, we can also use the bias voltages and currents to calculate $g_m$, $C_{\pi}$, and $C_{\mu}$, as shown in lines 25 and 37.

Let’s simulate this circuit for two values of collector currents: 1mA and 10mA. We can use the alter command in line 34 to change the bias current. Running the simulation results in the following report:

******
** ngspice-31 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please get your ngspice manual from http://ngspice.sourceforge.net/docs.html
** Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html
******
ngspice 1 -> source bjt_2n3904_ft.sp

Circuit: * transistor transition frequency

Doing analysis at TEMP = 27.000000 and TNOM = 27.000000


No. of Data Rows : 1
@q1[ic] = 1.048843e-03
@q1[gm] = 3.474254e-02
@q1[cpi] = 2.246856e-11
@q1[cmu] = 1.990019e-12
ft_2n3904_sim = 2.261886e+08
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000


No. of Data Rows : 5001
ft_2n3904           =  2.219428e+08
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000


No. of Data Rows : 1
@q1[ic] = 1.027438e-02
@q1[gm] = 2.636559e-01
@q1[cpi] = 1.150564e-10
@q1[cmu] = 2.011312e-12
ft_2n3904_sim = 3.586252e+08
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

 Reference value :  1.60325e+08
No. of Data Rows : 5001
ft_2n3904           =  3.554370e+08
ngspice 2 -> 

From the simulation results, we can see that both the AC analysis and operating point analysis will give about the same value:

Bias currentTransition Frequency
1 mA221.94 MHz
10 mA355.44 MHz
Table 1: The transition frequency of the 2N3904 NPN BJT.

Using this Python script, we can plot the results of the AC analysis, as shown below:

Figure 2: The behavior of the small-signal collector current as the frequency of the small-signal input base current is increased.

Note that if we want to maintain the inherent gain of our transistors, we should operate well below the transition frequency, e.g. 1 to 2 decades below $f_T$. We also observe that $f_T$ is dependent on the DC collector current. In most cases, it is the frequency response requirements that determine the required bias currents.

End of Tutorial 9

Congratulations! You have just performed a SPICE AC analysis to determine the transition frequency, $f_T$ of the 2N3904 BJT.