ELEC 380 Electronic Circuits II Tutorial and Simulations for Micro-Cap IV

By Adam Zielinski (Posted at:http://wwwece.uvic.ca/~adam/)

Version: August 22, 2002

ELEC 380 Electronic Circuits II - Tutorial

1-1

TUTORIAL This manual is written for Micro-Cap IV - Electronic Circuit Analysis Program for Macintosh computers. The PC Version of the program is available at: www.spectrum-soft.com. Prior to proceeding please familiarize yourself with the Simulation Tutorial for ELEC 330 posted at: http://www.ece.uvic.ca/~adam/ this Tutorial we will explore other. In interesting features of the Micro-Cap IV that are relevant to the material covered in the class. The simulations #1 to #6 are part of preparation to the laboratory sessions and must be completed before the laboratory and obtained presented to the laboratory instructor. 1. AC Analysis The AC analysis allows us to see a frequency response or AC transfer function H(jω You) of a linear circuit. can imagine that a sinusoidal voltage source with amplitude 1 volt is applied to a specified node of a circuit (input) and that voltage and relative phase is measured at a different specified node (output) of the same circuit. The voltage ratio or voltage gain and relative phase shift between these two voltages depend on frequency applied. The gain (often expressed in decibels or dBs) and phase are plotted vs. frequency over the specified frequency range. Frequency often is displayed in logarithmic scale. In such scale distance between two frequencies, one 10 times larger than the other is constant irrespective of absolute frequency and is called a decade. Similarly, distance between two frequencies - one twice the other is constant irrespectively of absolute frequency and is called an octave. Such plots are called frequency responses (amplitude and phase) of a linear circuit. In electronic circuits we frequently encounter nonlinear elements such as transistors. For frequency response analysis (AC analysis) such elements are linearized prior to AC analysis. Any nonlinear circuit can be approximated by a linear circuit if the signal applied is sufficiently small. As an illustration let us consider a simple RC circuit shown in Figure T1. 10k 1 2

E1

0.5u

.MODEL E1 SIN (F=32 A=1 DC=0 PH=0 RS=1M RP=0 TAU=0 FS=0) Figure T1. RC Circuit The voltage source should be added but will not play a role in AC analysis. The output voltage phasor V(2) at node 2 is equivalent to H(jω), which is a complex quantity. To get the amplitude response, we need to plot magnitude of H(jω) or mag(V(2)) which is most frequently expressed in dB. This is reflected in the dialog box shown in Figure T2 that also includes phase response PH(V(@)). The

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial frequency range set is from 100 kHz to 1 Hz (if you think that this is a strange order, I agree)

100 F

1K

1-2

10K

Figure T2. Dialog Box The resulting plot in logarithmic frequency axis is shown in Figure T3 with the cursor. 0.00 8.00 --16.00 -24.00 -32.00 -40.00 110 20*log(mag(v(2))) 0.00 -18.00 -36.00 -54.00 -72.00 -90.00 110100 PH(V(2)) F Expression Left Right Delta Slope F 0.032K 10.000K 9.968K 1 20*log(mag(v(2))) -3.032 -49.943 -46.911 -4.706m Figure T3. The frequency response; amplitude and phase We can observe that the amplitude frequency response represents a low-pass filter that attenuates signal at higher frequencies. At a certain frequency the response reaches linear asymptote with slope of -20dB/decade. We also can see that a –3dB-point occurs at 32 Hz. This is consistent with so-called 3dB or corner frequency for RC circuit fc = 1/2π result can be verified in time domainRC. This by performing transient analysis for signal frequency at fc=32 Hz with set up as shown in dialog box in Figure T4.

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

1K

10K

ELEC 380 Electronic Circuits II - Tutorial

1-3

Figure T4 Dialog Box The results are shown in Figure T5 with cursor activated. We can see that the output waveform - v(2) has reduced amplitude to 0.707 volts, which corresponds to 3 dB attenuation as expected. Note also a phase shift between waveforms. 1.00

0.60

0.20

-0.20

-0.60

60m

80m

100m

-1.00 0m 20m 40m v(1) v(2) T Expression Left Right Delta Slope T 42.984m 100.000m 57.016m 1 v 1 0.705 0.951 0.246 4.318 v(2) 0.705 0.318 -0.387 -6.783 Figure T5 Time domain responses 2. Spectral Analysis Spectral analysis of a periodic waveform can be performed on time domain data x(t) using Fast Fourier Transform FFT(x) algorithm. You can think of FFT as a Fourier Series of an infinite duration periodic waveform made of infinite repetitions of the time domain waveform of duration T. The fundamental frequency of Fourier Series of such constructed waveform is equal to 1/T. This will determine the frequency resolution of spectral analysis based on FFT, that is ∆F=1/T. In order to obtain valid results using FFT it is important to place complete number of cycles of the waveform within the observation window T.

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial

FFT calculates complex numbers and often only its magnitude is of interest. Function MAG(FFT(x)) calculates the magnitude.

1-4

Let's illustrate these points using two sinusoidal waveforms f1=1000Hz with amplitude 1 and another at f2=2000Hz with amplitude 0.5 as shown in Figure T6

V1

10k V2 10k

.MODEL V1 SIN (F=1000 A=1 DC=0 PH=0 RS=1M RP=0 TAU=0 FS=0) .MODEL V2 SIN (F=2000 A=0.5 DC=0 PH=0 RS=1M RP=0 TAU=0 FS=0)

Figure T6 Two sinusoidal waveforms

The dialog box in Figure T7 leads to the results shown in Figure 8

Figure T7 Dialog Box

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial

1-5

Figure T8 Spectral representation of two harmonic signals The frequency points are separated by∆F = 100Hz as expected. Each frequency component is represented by only one point in the spectrum (triangular shape is due to the way the points are joined by lines) and two waveforms are fully resolved. The absolute amplitude of spectral components is related to sampling frequency of the time-domain waveforms – the higher the sampling rate, the larger the spectral amplitude. The relative amplitudes and frequency positions of the two spectral components are as expected. 3. Tolerances Value of parameters of any physical electronic component is given within certain limits defined by tolerances. For instance, set of resistors with tolerances 10% (or 10 % lot) means that an actual individual resistor will have a random value between +/- 10% of its nominal value. Simulation allows us to investigate finite tolerances effect on overall performance of circuit built using real components. Several simulations are to be performed and a random value of a component within specified tolerances is assigned at each run. This is so called Monte Carlo method (guess where the name came from?). For Worst Case option the parameter is assigned randomly but only at limits of its tolerances. For N parameters this gives 2^N possible combinations. To establish good confidence level, the number of simulations n > 2^N.

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial

As an illustration let's go back to the simple circuit from Figure T1 but assume that the resistor is from 10% lot. With this modification the circuit becomes as shown in Figure T9. 10k LOT=10% 1 2

1-6

E1 0.5u .MODEL E1 SIN (F=32 A=1 DC=0 PH=0 RS=1M RP=0 TAU=0 FS=0) Figure T9 RC Circuit with uncertain resistor value We will proceed to investigate its frequency response as in Figure T3. The dialog box for Monte Carlo analysis is shown in Figure T10 and the results are shown in Figure T11.

Figure T10 Dialog Box for Random Simulation n=10

Figure T11 Amplitude frequency response for n=10 simulations

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial

1-7

4. Temperature effects All real electronic elements change their parameters with temperature changes. This applies to passive elements like resistors as well as to active ones like transistors or Operational Amplifier. Simulation is an ideal and simple method to determine the effect of temperature on a circuit. Consider a simple voltage divider shown in Figure T12. R1 1 2 10R2.Define R1 100K TC=0.001 .Define R2 100K

Figure T12 Voltage divider circuit Here we use symbols for resistors that need to be defined. Nominal value for both resistors is 100 kohms but resistor R1 changes its value with temperature as determined by its temperature coefficient TC= 0.001. This coefficient specifies how much the resistance will change from its nominal value at nominal temperature for a one degree Centigrade of the difference between the nominal temperature (27 degrees) and the actual one. We will illustrate this by running a transient analysis with printout. The dialog box is shown in Figure T13.

Figure T13 Dialog box for temperature variation

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II - Tutorial

1-8

The simulation is run from temperatures –27 degrees to 27 degrees in steps of 27. The numerical results obtained are shown in Figure T14 Micro-Cap IV Transient Analysis Limits of Temperature Date 8/8/02 Time 10:21 PM Temperature= -27 Case= 1 T v(2) (uSec) (V) 0.000 5.139 0.200 5.139 0.400 5.139 0.600 5.139 0.800 5.139 1.000 5.139 Temperature= 0 Case= 1 T v(2) (uSec) (V) 0.000 5.068 0.200 5.068 0.400 5.068 0.600 5.068 0.800 5.068 1.000 5.068 Temperature= 27 Case= 1 T v(2) (uSec) (V) 0.000 5.000 0.200 5.000 0.400 5.000 0.600 5.000 0.800 5.000 1.000 5.000 Figure T 14 The temperature effects We can see that the divider functions properly only for the nominal temperature of 27 degrees but the voltage is higher for other temperatures. This is due to a lower resistance of R2 at lower temperatures.

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II — Simulation #1

2-1

SIMULATION #1 Small Signal Amplifiers This simulation is part of preparation to the Laboratory Session #1. 1. Design the CE amplifier shown in Figure 1-1 for biasing current IE=1mA and gain of 36 (31.1dB) at frequency 1kHz. Note that components values shown in Figure 1-1 are not unique. V c c 15

56k 910 Vo 1uF V s V i2N3904 Ve 10k MV1 1.5k 62uF

.MODEL MV1 SIN (F=1K A=5M DC=0 PH=0 RS=1M RP=0 TAU=0 FS=0) .MODEL 2N3904 NPN (BF=378.5 BR=2 IS=15.8478P CJC=3.62441P CJE=4.35493P RC=1.00539U VAF=101.811 TF=666.564P TR=173.154N MJC=300M VJC=770.477M MJE=403.042M VJE=1 NF=1.34506 ISE=61.1468P ISC=0.00155473F IKF=14.2815M IKR=35.709 NE=2.02174 RE=1.10494 VTF=10 ITF=9.79838M XTF=499.979M )

Figure 1-1 CE Amplifier 2.Select the proper values for the ac source (10mVp-p, f=1kHz) and transistor (beta= BF= 150). 3. Set the proper simulation parameters fortransient analysis(see dialog box shown in Figure 1-2) and confirm the dc and ac conditions by simulation.

Figure 1-2 Box Dialog

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002

ELEC 380 Electronic Circuits II — Simulation #1

2-2

Note that under the Transient – Option menu the option of calculating the operating dc-point was selected. This allows us to see the waveforms in steady state. Shown in Figure 1-3 is a result: 5.00m 3.00m 1.00m -1.00m -3.00m -5.00m 0m Vs 14.25 14.17 14.09 14.01 13.93 13.85 0m Vo

1m

1m

2m T

3m

4m

4m

2m3m T TransientFigure 1-3 Analysis After running transient analysis select the “state variables” under Transient Analysis Menu. You can read numerical values of dc for all nodes: In this particular case we got:

5m

5m

VariablesFigure 1-4 State This feature is very convenient to verify the dc-analysis. Alternatively, you can select Node voltages and Node numbers as shown in Figure 1-5

ELEC 380 Tutorial and Simulations Adam ZielinskiAugust 2002