Manuals, Timing, Ham Radio, Test Equipment

Help keep this site free:
(More Info)
        

Electronics 102 - Lesson 2

Back to Electronics 102

Circuit Simulation

In order to demonstrate how transistors work and see the effects of components values, the common practice used to be to head for the lab with a box full of components, a soldering iron or a prototype board and some test equipment such as a signal generator, one or more power supplies and an oscilloscope.

While extremely instructive and interesting, it is not always easy to go to the lab, the test equipment may not be available or not capable of the particular tests we want to do, and it may be difficult or impractical to see the effects of extreme conditions such as extreme temperatures or extreme supply voltages. Also the choice of parts may be limited, so it may be impossible to verify the operation of a circuit when component values are at the edge of their specifications.

For these reasons, and since the appearance of affordable personal computers, engineers and designers have been relying on simulation software running on a personal computer to simulate and optimize the operation of their designs before building the actual hardware.

Since this is an on-line class, we will be using a circuit simulation software in this and the following chapters.

Spice Simulation Software

SPICE is a general-purpose circuit simulation program for nonlinear dc, nonlinear transient, and linear ac analyses. Circuits may contain resistors, capacitors, inductors, mutual inductors, independent voltage and current sources, several types of dependent sources, transmission lines, switches, and the five most common semiconductor devices: diodes, Bipolar Junction Transistors (BJTs), Junction Field Effect Transistors (JFETs), Metal-Semiconductor Field Effect Transistors (MESFETs), and Metal Oxide Semiconductor Field Effect Transistors (MOSFETs.)

SPICE originates from the EECS Department of the University of California at Berkeley, http://bwrc.eecs.berkeley.edu/

Spice is the oldest (updated regularly) and best known circuit simulation software. It is essentially free (check the link above for details) and the basic engine has been used as the basis of many commercial software implementations that provide convenient front-end, schematic capture, printing tools and libraries of parts.

While we could be using the Berkeley SPICE package, we will instead use another free version designed by a semi-conductor company, Linear Technology, called SwitcherCAD (c). Log on to the download page of the company web site, download and install the software before continuing the course.

SwitcherCAD is copyright of Linear Technology.

The SwitcherCAD software is intended to facilitate the application of products designed and manufactured by Linear Technology, but the tool is not limited to Linear Technology's products. The company is to be commended for making such a useful tool available for free.

Create your first Spice circuit

This is going to be your first schematic. This is called a "common emitter amplifier stage".

Start the program, then click File->New schematic.

Click on the integrated circuit symbol (tool tip = Component )

A selection window pops up. Locate and select "npn" and click OK. The symbol for an NPN transistor shows up. Move it to the right side of the page about half way up and click the mouse. Then, press Escape because we will only need one transistor at this point.

Once the transistor is placed on the schematic, we need to select a part number. Right-click on the transistor and click "Pick New Transistor" in the popup window. The first selection is 2N2222, which is one of the most popular small signal transistors ever made. It will be fine for this example. Click OK. Please note that the transistor has a "reference designator" of Q1, and a "part number" of 2N2222. Do not confuse the two. You will quickly become familiar with this terminology.

Note: If you make a mistake, it is easy to click on the "Cut" tool (the scissors ) and remove the components you do not need.

Click on the resistor symbol , then move the mouse so that the resistor is just above the collector terminal of the transistor (the top connection) and click the mouse button. The program will drop a resistor on the schematic and the cursor will give you the opportunity to drop more resistors until you press the Escape key.

By default, the resistor is vertical (so to speak) and that will be the collector resistor on our schematic. To create the base resistor, we need to select the Rotate tool on the toolbar.

Click on the Rotate symbol () then move the resistor close to the base terminal of the transistor and click the mouse. Press Escape to turn off the resistor tool.

Right click on the resistor near the collector (should be R1) and in the Resistance box, enter "1000". Click OK.

Do the same thing with R2, but with a value of "470".

Repeat the process with the Voltage Source symbol (click on Component, then select "voltage"). Place two voltage sources approximately as they are shown on the sample schematic above. Make sure the first one you click is higher up on the page so that it is V1.

Right-click on Source V1 (should be the top one) and enter a DC value of "12". Click OK.

Right-click on V2 then click "Advanced". In the advanced settings window, select SINE and enter the following values:

  • DC offset: 0.73
  • Amplitude: 0.02
  • Freq: 1k

Click OK.

Note: The amplitude value for an AC source in SwitcherCAD is the peak voltage. The total peak-to-peak voltage is therefore 2 x 20mV, or 40mV.

Finally, place three ground symbols , near the emitter of the transistor, and near the bottom terminal of the two voltage sources.

Now, you are ready to string wire to connect all the components.

Click on the "Wire" symbol and connect all the parts as shown on the sample schematic above. Place a short piece of wire from the collector of the transistor going to the right. It is not needed to make a connection, but it will be used later to place a Label Net.

The last step is to name a few connections to make it easy to view the simulation results.

Click on the "Label Net" symbol , enter "Collector" and place it at the end of the free wire going to the collector. Create another Label Net for the Source V2 (call it "Source"). You can also name the base of the transistor: "Base".

 

Simulate!!!

You are now ready to run your first simulation.

Click Simulate->Run or click the small runner icon on the toolbar ("Run" ). The first time, the simulation menu will appear.

SwitcherCAD can run a number of different simulations, Transient, AC Analysis, DC sweep, Noise, DC Transfer and DC operating point. DC operating point is typically run automatically before other simulations, we will study what it does later. For now, select Transient analysis and enter a value of "5m" (for 5 milli seconds, or 0.005 second) in Stop Time. Click OK.

The next window lets you pick which voltage in the circuit you want to see. You can select the Label Net points (such as "collector", or "source"), which is why we gave them names, or you can select voltages or current through various components. For now, let's select the collector voltage "V(collector)" and click OK.

The computer performs the simulation and if all goes well, the collector voltage waveform will appear at the top of the screen. Here is what I got:

It should be a reasonably smooth looking sinusoidal waveform. Move the mouse cursor on top of the minimum and maximum of the waveform and note the cursor values. They should indicate that the output voltage has a minimum of about 2V and a maximum of about 7.2V. So the peak to peak output voltage is about 7.2 - 2 = 5.2 V p-p. Since the input voltage is 40mV (0.04 V) p-p, the voltage gain of this circuit is 5.2/0.04 = 130. Not too bad for a circuit that has a single transistor and two resistors (we typically do not count the voltage sources, two in this case, as components.

Notice that the mouse cursor changes shape when you move it near a conductor on the schematic. It may look like a voltage probe (the red probe with a spiky test point), or a current probe (the black instrument with an arrow indication the current direction.)

Notice that if you click the voltage probe on a net, the waveform at that point is displayed, in addition to the previous waveform. So, if you click on the base of the transistor, you will see an almost completely flat blue line around 0.7V. Now right-click on the green "V(collector)" label at the top of the waveform display. This will open a window. Select "Delete this trace" and click OK. The trace disappears, now click on "Run". The simulation will re run, but now the blue trace uses the full screen, so you can measure the actual base voltage with good precision..

Try to do that with other voltage and current waveforms to get familiar with the program.

 

Analysis of operation.

In this circuit, the transistor is biased so that it draws some current all the time. During its operation, we do not intend for the current to drop to zero (cut-off) or to reach the maximum available through the load resistor R1 (saturation). Either circumstance would cause clipping and distortion. So we can say that this is a Class A amplifier.

If we wanted to build something like a microphone preamplifier to drive a power audio amplifier, we would need such a Class A amplifier to minimize distortion. Since this circuit is being operated in Class A, it would be easy to think it is just fine and our job is done.

Typical microphones deliver voltages in the millivolt range while most power amplifiers expect input voltages in the 100s of millivolts to a volt or so. Under the conditions of the simulation, this simple amplifier does just that.

Well, it is not so easy. Actually, it is rarely that easy, even though in some cases, we can make some tasks pretty easy. But where would be the fun with that?

There are a few problems with this circuit. Here are some of them:

  • Bias sensitivity.
    The voltage source V2, which would represent the microphone, is set to provide a 0.73 V DC offset in addition to the 20mV peak AC voltage. Microphones typically do not provide a 0.73 V DC offset, and the microphones that do provide an offset do not guaranty how precise or stable that offset is over time or temperature.

    To see the effect of an unstable offset voltage in the source V2, right-click on V2 and change the offset to 0.75 V. Then click the "Run" icon again.

    Whoah! the waveform now has severe distortion. We call it "clipped". Increasing the offset from 0.73 to 0.75 VDC was sufficient to completely saturate the transistor during the time the input signal is maximum.

    Exercise: Find out how low you can set the DC offset before the waveform is clipped in the other direction.

    Let's reset the offset to 0.73 and click "Run" again to go back to the original, "good" simulation result.

  • Temperature sensitivity.
    Let's use SPICE to show us the effect of temperature. Click on the "Text" icon . A window pops up. Enter the following in the text box: ".STEP TEMP LIST 25 50 75" (do not omit the dot at the beginning) and click "SPICE Directive" then click OK. Place the text somewhere on the schematic sheet.

    This directive instructs SPICE to step the temperature through a list of values: 25, 50 and 75 degree C, and plot the results of the simulation at each temperature. Click "Run" again.

    Now, there are 3 plots on the screen. The green plot looks a lot like the original simulation, except that the voltages are a little higher. That's because the default temperature for SPICE is 30 degrees C, where the first plot is run at 25 degrees C.

    However, the other plots are severely distorted, the red plot (75 degrees) does not show any waveform, just a flat line.

    The reason for this is that the base threshold voltage (the voltage at which the base starts conducting current) changes by about -1.8 mV/degree, so if the bias voltage (0.73V in our simulation) is not reduced when temperature increases, the transistor finds itself harder and harder driven, up to the point where it is saturated.

    Exercise: Verify how much the DC offset voltage in source V2 should be changed to provide linear operation (no clipping) at 75 degrees.

     

  • Transistor characteristic sensitivity.
    Right click on the transistor and select 2N3055. Click OK. Right-click on the .STEP directive on the schematic and select "Comment" in the window to turn off the temperature stepping. Then click "Run" again. Notice that while the waveform looks somewhat sinusoidal, the levels vary between 55 mVand 58 mV or so. SPICE has automatically re scaled the waveform to fill the screen, but the output waveform is actually completely saturated and the transistor provides less output voltage than we feed into it.

     

  • Changing class of operation.
    Exercise: reduce the DC offset of the source V2 to zero in order to bias the amplifier in class B. You will not get any output because you need to increase the AC drive voltage in order to be able to actually generate base current, so progressively increase the Amplitude setting of source V2 until you get an output signal. You may have to go to 0.7V before seeing much. Observe the effect of the drive amplitude on the output waveform and the clipping that takes place.

Conclusion of this lesson

  • We used SPICE to simulate a simple amplifier under varying conditions that would not be very easy to simulate in the lab.
  • This circuit was simple, and under limited conditions it might work, but it would not be very useful as a microphone preamplifier in a real life environment.

In the next lessons, we will see how we can use simple techniques and SPICE to make the circuit work better.