Difference between revisions of "229-A2.1"

From Microlab Classes
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
== Visualizing Nonlinearity ==
 
== Visualizing Nonlinearity ==
Let us examine the effects of varying the coefficients of the power series model of our transfer function. Fig. 1 shows the an even function with only second order coefficients. This is typical of ideal square-law single-ended MOS amplifiers where a quadratic term dominates.  
+
Let us examine the effects of varying the coefficients of the power series model of our transfer function using this Python [https://github.com/louisalarcon/ee229/blob/master/src/a2.1.py script]. Fig. 1 shows the an even function with only second order coefficients. This is typical of ideal square-law single-ended MOS amplifiers where a quadratic term dominates.  
  
 
{|
 
{|
Line 13: Line 13:
 
|}
 
|}
  
Fig. 2 shows an odd function with only third order coefficients. This is a good estimate for differential circuits, where the common-mode terms cancel out. For example, the outputs of a differential amplifier can be expressed as:
+
[[File:Diff amp.png|thumb|300px|Figure 3: A differential amplifier.]]
 +
Fig. 2 shows an odd function with only third order coefficients. This is a good estimate for differential circuits, where the common-mode terms cancel out. For example, the outputs of a differential amplifier in Fig. 3 can be expressed as:
  
 
{{NumBlk|::|<math>v_\mathrm{o}^+ = \alpha_0 + \alpha_1 \left(\frac{v_\mathrm{id}}{2}\right) + \alpha_2 \left(\frac{v_\mathrm{id}}{2}\right)^2 + \alpha_3 \left(\frac{v_\mathrm{id}}{2}\right)^3</math>|{{EquationRef|1}}}}
 
{{NumBlk|::|<math>v_\mathrm{o}^+ = \alpha_0 + \alpha_1 \left(\frac{v_\mathrm{id}}{2}\right) + \alpha_2 \left(\frac{v_\mathrm{id}}{2}\right)^2 + \alpha_3 \left(\frac{v_\mathrm{id}}{2}\right)^3</math>|{{EquationRef|1}}}}
Line 31: Line 32:
 
* We choose the number of samples to be integer powers of 2, e.g. 1024, 2048, 4096, etc. so we can take advantage of the FFT algorithm's speedup.
 
* We choose the number of samples to be integer powers of 2, e.g. 1024, 2048, 4096, etc. so we can take advantage of the FFT algorithm's speedup.
  
For example, let us set a sampling frequency, <math>f_s = 40\,\mathrm{MHz}</math>, and generate a sinusoid with 673 periods, with the number of samples <math>N=2^{10}=1024</math>. Let us then choose a sinusoid that is an integer multiple of <math>\tfrac{f_s}{N}</math>. Thus, we get <math>f_\mathrm{in}=100\cdot \tfrac{f_s}{N}=3.90625\,\mathrm{MHz}</math>. The spectrum of our single sinusoid is shown in Fig. 3.  
+
For example, using this Python [https://github.com/louisalarcon/ee229/blob/master/src/a2.1.py script], let us set a sampling frequency, <math>f_s = 40\,\mathrm{MHz}</math>, and generate a sinusoid with 673 periods, with the number of samples <math>N=2^{10}=1024</math>. Let us then choose a sinusoid that is an integer multiple of <math>\tfrac{f_s}{N}</math>. Thus, we get <math>f_\mathrm{in}=100\cdot \tfrac{f_s}{N}=3.90625\,\mathrm{MHz}</math>. The spectrum of our single sinusoid is shown in Fig. 4.  
  
 
{|
 
{|
|[[File:Single tone.png|thumb|400px|Figure 3: The spectrum of a single tone at <math>3.906\,\mathrm{MHz}</math>.]]
+
|[[File:Single tone.png|thumb|400px|Figure 4: The spectrum of a single tone at <math>3.906\,\mathrm{MHz}</math>.]]
|[[File:Harmonic disto.png|thumb|400px|Figure 4: The spectrum of the output of a nonlinear stage.]]
+
|[[File:Harmonic disto.png|thumb|400px|Figure 5: The spectrum of the output of a nonlinear stage.]]
 
|-
 
|-
 
|}
 
|}
  
If we pass this input sinusoid through a nonlinear stage with <math>\alpha_1 = 10</math>, <math>\alpha_2 = 0.5</math>, and <math>\alpha_3 = -3</math>, we get the spectrum in Fig. 4. As expected, we get the second and third harmonic frequency components at <math>7.8125\,\mathrm{MHz}</math> and <math>11.71875\,\mathrm{MHz}</math> respectively.
+
If we pass this input sinusoid through a nonlinear stage with <math>\alpha_1 = 10</math>, <math>\alpha_2 = 0.5</math>, and <math>\alpha_3 = -3</math>, we get the spectrum in Fig. 5. As expected, we get the second and third harmonic frequency components at <math>7.8125\,\mathrm{MHz}</math> and <math>11.71875\,\mathrm{MHz}</math> respectively.
 +
 
 +
Note that the y-axis of Figs. 4 and 5 are normalized to the fundamental, i.e. the fundamental will always have a value of 0dB. Also, we can see that the numeric noise floor is around -300dB, due to the finite floating point range of the computer I am using. In real systems, we will be limited by electronic noise, which we will cover in the next module.
 +
 
 +
We can define the fractional harmonic distortion metric as the ratio of the amplitude of the harmonic to the fundamental. Thus, we can calculate the second fractional harmonic distortion, (<math>HD_2</math>), as:
 +
 
 +
{{NumBlk|::|<math>HD_2 = 20\log\left(\frac{\frac{\alpha_2}{2}}{\alpha_1 + \frac{3\alpha_3}{4}}\right) = -29.83\,\mathrm{dB}</math>|{{EquationRef|4}}}}
 +
 
 +
And the third fractional harmonic distortion, (<math>HD_3</math>), as:
 +
 
 +
{{NumBlk|::|<math>HD_3 = 20\log\left(\frac{\frac{\alpha_3}{4}}{\alpha_1 + \frac{3\alpha_3}{4}}\right) = -20.28\,\mathrm{dB}</math>|{{EquationRef|5}}}}
 +
 
 +
This agrees with our FFT results.
 +
 
 +
== Activity 1 ==
 +
Modify the Python [https://github.com/louisalarcon/ee229/blob/master/src/a2.1.py script] used above to:
 +
# Generate the frequency spectrum of two tones with <math>f_1=100\cdot \tfrac{f_s}{N}=3.90625\,\mathrm{MHz}</math> and <math>f_2=120\cdot \tfrac{f_s}{N}=4.6875\,\mathrm{MHz}</math>.
 +
# Then plot the spectrum when the two input tones are passed through a nonlinear stage with <math>\alpha_1 = 10</math>, <math>\alpha_2 = 0.5</math>, and <math>\alpha_3 = -3</math>.
 +
# Compare the frequency locations of the harmonic and intermodulation tones to their theoretical locations.
 +
# Compare the simulated and theoretical values of the harmonic and intermodulation terms.
 +
 
 +
=== Submissions ===
 +
Submit via email a 1-page report, excluding the graphs, detailing how you performed the steps outlined above. Include your graphs in your report.
 +
 
 +
== Activity 2 ==
 +
[[File:Ce amp.png|thumb|400px}|Figure 6: A common-emitter amplifier.]]
 +
Let's look at a more practical example. Given the common-emitter amplifier shown in Fig. 6, let us calculate the collector current as a function of the input voltage. Recall that
 +
 
 +
{{NumBlk|::|<math>I_C = I_S\cdot e^{\frac{V_{BE}}{V_T}}</math>|{{EquationRef|6}}}}
 +
 
 +
If <math>V_{BE}=v_i + V_Q</math>, where <math>V_Q</math> is the quiescent or DC voltage that results in the DC quiescent current, <math>I_Q</math>, express the small change in collector current, <math>i_c</math> due to a small change in the base-emitter voltage, <math>v_i</math>, as a power series:
 +
 
 +
{{NumBlk|::|<math>i_c = \alpha_0 + \alpha_1 v_i + \alpha_2 v_i^2 + \alpha_3 v_i^3 + \ldots </math>|{{EquationRef|7}}}}
 +
 
 +
Hint: <math>e^x = 1 + x + \tfrac{x^2}{2!} + \tfrac{x^3}{3!} + \ldots</math>.
 +
 
 +
# Find expressions for the values of <math>\alpha_i</math> for <math>i=0,1,2,3</math>.
 +
 
 +
=== Submissions ===
 +
Submit via email a 1-page report detailing your answer.

Latest revision as of 14:04, 21 September 2020

Activity: Nonlinearity in Circuits

  • Instructions: This activity is structured as a tutorial with a design problem at the end. Should you have any questions, clarifications, or issues, please contact your instructor as soon as possible.
  • At the end of this activity, the student should be able to:
  1. Understand and observe the effects of nonlinearity in electronic circuits.

Visualizing Nonlinearity

Let us examine the effects of varying the coefficients of the power series model of our transfer function using this Python script. Fig. 1 shows the an even function with only second order coefficients. This is typical of ideal square-law single-ended MOS amplifiers where a quadratic term dominates.

Figure 1: An even function with positive and negative second order coefficients.
Figure 2: An odd function with positive and negative third order coefficients.
Figure 3: A differential amplifier.

Fig. 2 shows an odd function with only third order coefficients. This is a good estimate for differential circuits, where the common-mode terms cancel out. For example, the outputs of a differential amplifier in Fig. 3 can be expressed as:

 

 

 

 

(1)

 

 

 

 

(2)

Then the differential output is:

 

 

 

 

(3)

We can also see from Fig. 2 that the negative third (and other odd) order coefficients model the output saturation in real amplifiers as the output level approaches the supply voltages. Thus, in most cases, the third order nonlinearity dominates.

Spectral Response

Let us also try to visualize the effects of nonlinearity in the frequency domain, where our main tool would be the discrete Fourier transform (DFT) or the fast Fourier transform (FFT). When performing an FFT, we want our sinusoids (or tones) to fall into just one frequency bin. To do this, we must make sure that:

  • We use a sampling frequency much higher than twice our highest frequency of interest, or .
  • We choose a prime number of whole periods so we do not get spurious tones in the frequency response. Note that the FFT assumes the input is periodic. If not, we will get spectral leakage.
  • We choose the number of samples to be integer powers of 2, e.g. 1024, 2048, 4096, etc. so we can take advantage of the FFT algorithm's speedup.

For example, using this Python script, let us set a sampling frequency, , and generate a sinusoid with 673 periods, with the number of samples . Let us then choose a sinusoid that is an integer multiple of . Thus, we get . The spectrum of our single sinusoid is shown in Fig. 4.

Figure 4: The spectrum of a single tone at .
Figure 5: The spectrum of the output of a nonlinear stage.

If we pass this input sinusoid through a nonlinear stage with , , and , we get the spectrum in Fig. 5. As expected, we get the second and third harmonic frequency components at and respectively.

Note that the y-axis of Figs. 4 and 5 are normalized to the fundamental, i.e. the fundamental will always have a value of 0dB. Also, we can see that the numeric noise floor is around -300dB, due to the finite floating point range of the computer I am using. In real systems, we will be limited by electronic noise, which we will cover in the next module.

We can define the fractional harmonic distortion metric as the ratio of the amplitude of the harmonic to the fundamental. Thus, we can calculate the second fractional harmonic distortion, (), as:

 

 

 

 

(4)

And the third fractional harmonic distortion, (), as:

 

 

 

 

(5)

This agrees with our FFT results.

Activity 1

Modify the Python script used above to:

  1. Generate the frequency spectrum of two tones with and .
  2. Then plot the spectrum when the two input tones are passed through a nonlinear stage with , , and .
  3. Compare the frequency locations of the harmonic and intermodulation tones to their theoretical locations.
  4. Compare the simulated and theoretical values of the harmonic and intermodulation terms.

Submissions

Submit via email a 1-page report, excluding the graphs, detailing how you performed the steps outlined above. Include your graphs in your report.

Activity 2

Figure 6: A common-emitter amplifier.

Let's look at a more practical example. Given the common-emitter amplifier shown in Fig. 6, let us calculate the collector current as a function of the input voltage. Recall that

 

 

 

 

(6)

If , where is the quiescent or DC voltage that results in the DC quiescent current, , express the small change in collector current, due to a small change in the base-emitter voltage, , as a power series:

 

 

 

 

(7)

Hint: .

  1. Find expressions for the values of for .

Submissions

Submit via email a 1-page report detailing your answer.