lab manual dr s. worrall autumn semester...
TRANSCRIPT
2ND Year Laboratories – Autumn
Lab Manual
Dr S. Worrall
Autumn Semester 2009/10
Department of Electronic Engineering
Second Year Laboratories Autumn Semester: 2009/10
2
Contents
1. GENERAL INSTRUCTIONS .................................................................................................................... 3
2. SAFETY IN 2ND
YEAR LABS ................................................................................................................... 6
3. ASSESSMENT ............................................................................................................................................. 8
4. SECOND YEAR LABORATORY PROJECT ....................................................................................... 10
5. LOCATION OF LABORATORIES ........................................................................................................ 13
6. EXPERIMENT A: PERL AND CGI PROGRAMMING ...................................................................... 14
7. EXPERIMENT B: ELECTRONIC MEASUREMENT OF AND E ................................................. 15
8. EXPERIMENT I1: LINEAR SYSTEMS AND FEEDBACK ................................................................ 20
9. EXPERIMENT I2: LINEAR SYSTEMS AND FEEDBACK ................................................................ 24
10. LABVIEW EXPERIMENT ...................................................................................................................... 32
11. EXPERIMENT M: POWER ELECTRONICS SIMULATIONS USING SPICE............................... 39
12. RUNNING EXCEED ON 2ND
YEAR LAB PC’S.................................................................................... 53
Second Year Laboratories Autumn Semester: 2009/10
3
Department of Electronic Engineering
Second Year Laboratory classes
1. General Instructions
Students are required to provide a minimum of stationery and equipment in order to carry out
experiments satisfactorily. The minimum requirements are provision of a laboratory logbook
with alternate pages of graph and lined paper (available from the university bookshop), a
calculator, and a mini tool kit consisting of at least wire cutters and strippers and a small
screwdriver. Any electrical items must be submitted to the laboratory technicians for testing
prior to use in the laboratory. All items should be obtained in advance of the first
experimental session.
Marking will normally be carried out by the demonstrators towards the end of the
experimental session, although occasionally it may be necessary to collect Lab books in order
to mark them. Work carried out as preparation for experiments will be marked upon arrival in
the laboratory. It is very important that you do the preparation work before the day of the each
experiment in order to be fully prepared for the day ahead.
Lab Groups
In the lab lectures, held on Monday in week 1, you will be given:
A list saying which lab group each student is in.
A lab timetable, which can be used in conjunction with your lab groups to find out
the experiment that you are doing in each week.
Experiments such as e and pi, and Linear Systems must be carried out by dividing yourselves
into teams of 2-3. You are free to select who you work with on each experiment, but you must
work with someone in your own lab group.
Under no circumstances may students change lab groups without express permission of the
laboratory organiser Dr Stewart Worrall. Doing so may result in a reduction of the awarded
mark for a given experiment or even a score of zero to be recorded. Wanting to work with a
friend is not a valid reason to change lab groups. Working with others is a valuable part of
your education as an engineer.
Furthermore, under no circumstances should students rearrange the dates of particular
experiments without the express permission of the laboratory organiser, Dr Worrall. Doing so
may again result in a reduction of the awarded mark for a given experiment or even a score of
zero being recorded.
The project work
More than half of the scheduled laboratory periods in the first semester are used for work on
your second year project. There is a choice of one of three different projects. You are
expected to form a project group of three to five people. Every member of each project group
Second Year Laboratories Autumn Semester: 2009/10
4
must attend all the project sessions scheduled for project work. A mark is given for attending
the labs, so make sure that your demonstrator has noted your presence. Otherwise you may
lose marks.
If you need to leave the labs for any reason (e.g. research in the library), you should ask the
academic in charge of that particular lab.
More Information
Please see the webpage:
http://info.ee.surrey.ac.uk/Teaching/Courses/ee2.laba/
Second Year Laboratories Autumn Semester: 2009/10
5
The Experiments
Second year lab experiments have been divided into subject streams. In the autumn semester
all students take the project and a further four weeks' worth of experiments. Students on the
“software/computing” (ECE) degree title streams take a two day LabVIEW experiment, a
one-day experiment on Perl and CGI, plus an experiment on calculating e and pi. Students on
“EE” degree titles take a lab on linear systems instead of the Perl and CGI experiment. The
matrix shows each experiment and the various pathways/streams.
AUTUMN SEMESTER
pathway
Instru
ctions
EE
EC
E
Med
ia E
ng
A PERL & CGI web X C X
B e and web C C X
LabVIEW X C X
I1 Linear Systems C X C
I2 Linear Systems C X X
Project (6 weeks) C C C
SPICE C C X
Digital Audio Synth. (2 weeks) X X C
Microphone Response X X C
C = compulsory
X = not available
Lab Lectures (Semester One):- Introduction, safety STW
Documentation & assessment STW
Errors and uncertainties NGE
Second Year Laboratories Autumn Semester: 2009/10
6
2. Safety in 2nd
Year Labs
READ THESE NOTES CAREFULLY
You should be aware that you are required to follow all university safety procedures, and
therefore it is your responsibility to know what they are. Prior to taking part in any laboratory
class, you are required to sign the “acknowledgement of hazards” form, associated with
second-year experiments. Any student failing to sign the form will not be permitted to begin
any laboratory class, and will score 0 for that experiment. The hazard form will be distributed
during the first week Lab lectures, and must be returned to Dr Worrall. It can be handed in to
the general office in BB Level 4, or without fail brought to the first lab session and handed in
right at the beginning of the class. A risk assessment has been made of each experiment and
the paperwork is held by the technicians in the second year laboratory. This is available for
students to read at any time, but must not be removed from the laboratory.
Types of hazard
There are certain known hazards associated with the experiments you will undertake. It is
important that you're aware of these hazards in order to minimise the risk of injury. The types
of hazards are categorised as follows:
Class A: use of terminals and stand-alone computers
Class B: low-voltage open wire experiments
Class C: open mains and high-voltage
Class D: three-phase electrical and rotating machines
Class E: hazardous materials and chemicals
Class F: chemical hazards and tools
Class G: radiation hazards such as microwaves, X-rays, or optical beams
All work must be supervised by an academic member of staff, but work involving hazards in
classes C, D, E and G are higher risk and must be closely supervised. In particular, all wiring
and instrumentation must be checked by an academic member of staff before power is turned
on.
Warning of specific hazards associated with particular experiments will be given in laboratory
lectures, and may also be included in laboratory manuals. Consequently, the laboratory
lectures are compulsory. Any student who has not attended the appropriate laboratory
lectures may be prevented from performing the experiment. In these circumstances the student
will score 0. There'll be no alternative opportunities to perform an experiment you have
missed.
Second Year Laboratories Autumn Semester: 2009/10
7
There are some general safety rules that must be followed at all times:
No student may work in the laboratory without the supervision of an academic
member of staff. At the end of the timetabled classes all students must leave
promptly and may not stay behind.
If in doubt about any equipment or procedure, ask for help.
Any incident involving any person or piece of equipment, however trivial, must be
reported immediately to a supervisor or technician.
Never run in laboratories under any circumstances
Turn soldering irons off when not in use, and keep cables, books, papers, clothes
well away from them
Be aware of the location of safety information and equipment such as fire
extinguishers, emergency meeting places, eye baths, emergency notices, etc.
Never block aisles or doorways with bags or equipment. Also, do not leave bags
and clothing on work benches where the equipment and tools and soldering irons
may cause an unnecessary hazard.
Do not eat or drink during laboratory classes. If you need food because, for
example, you are breaking a fast or you are diabetic, please simply ask a
demonstrator for permission to leave the laboratory briefly.
Laboratory class attendance
In order to pass each laboratory module, students must complete and achieve a pass grade in
each module (possibly via compensation). Note that missing an experiment cannot be excused
and it is extremely unlikely that we will be able to rearrange one except in exceptional
circumstances such as serious illness documented by a doctor's certificate. If an experiment
has been missed and not been rearranged for a valid reason, a score of zero will be recorded
for that experiment. Rearrangement of your lab timetable can only be done with the express
permission of Dr Worrall.
Working Hours are from 10.00 to 12.50 and 2.00 to 4.50.
Prompt arrival is required in case any announcements are made or hand-outs are distributed.
You are encouraged to leave promptly after 12.50 so that demonstrators can
have a lunch break; you cannot remain in the lab without supervision.
Second Year Laboratories Autumn Semester: 2009/10
8
3. Assessment
Laboratory assessment will normally be performed during each laboratory session. You will
be given a letter grade for each component of the assessment. The three components are
Preparation
Lab performance
Your preparation will be marked at the start of the session. You are required to write in your
lab book BEFORE THE LAB a summary of relevant theory, sample calculations, expected
results and any design work asked for in the experiment. Note that marks are not awarded for
simply copying theory from text books. You need to demonstrate understanding of the
experiment, and may be asked questions to check that you have understood what you have
written.
Your lab performance will be marked on your ability and your understanding, the effort you
make and the progress made on the experiment. Some experiments are quite lengthy and it is
not necessary to complete all parts in order to pass. However, the award of A or S level grades
is reserved for work demonstrating full understanding of the experiment and some use of
initiative. The lab performance mark will also be based upon the quality of your log book.
Your log book will be marked in terms of tidiness, quality of results, conclusions drawn1, and
proper documentation of the experimental set-up. You may be asked questions to check your
understanding of what you have done.
Additional hints and tips on preparing for some experiments will be posted online.
For each component the gradings are:-
S* Outstanding
S Excellent
A Very Good
B Good
C Satisfactory
D Pass
E Very Poor
F Equivalent to a 20% mark
The preferred mode of communication for important enquiries (e.g. notification of absence
due to illness, certified by a Doctor) is by e-mail :-
1 Conclusions are considered to be very important, and you will be awarded a low grade if you do not write any
conclusions or analysis of the results.
Second Year Laboratories Autumn Semester: 2009/10
9
Laboratory Log Books
An accurate and detailed record of what happened so that the experiment
could be exactly repeated by another person at a later date.
Part 1: Preparation
Date*
Summary of relevant theory*
Summary of experiment methodology*
Prediction of results based on theory*
Calculations using expected values
Description of what would be seen during experiment
Sketches of expected graphs
Sketches of expected oscilloscope waveforms
Diagrams of any circuits required for the experiment
Part 2: Experimental Work
Date*
List of equipment*
Serial numbers of equipment*
Any other relevant environmental parameters
Labelled diagram of set-up, showing connections (very valuable)
Note of what was done (method)*
Note of what went wrong and was changed*
Comments on method*
Comments on measured and calculated values
Comments on possible errors and uncertainties on measured values
Graphs: titled with labelled axes
Tables: titled with SI units
Conclusions on results, method, value of experiment* (what engineers actually get paid for)
Items marked “*” will probably be essential in all experiments. If these are missing it would
be difficult to call log book satisfactory
Note: you should use outline numbering throughout your log book.
R. Seebold
21st March 2002
Updated: S. Worrall
July 2008
Second Year Laboratories Autumn Semester: 2009/10
10
4. Second year laboratory project
4.1. Project Overview Each team must choose one of the following three projects, and you are expected to have
made a reasonable start in terms of project planning by the end of the first project day:-
1. Build a audio amplifier for a Walkman CD or cassette player to drive a pair of
small loudspeakers at an audible level from the headphone socket. The amplifier
should run on 3 AA batteries and use components available in the lab.
2. Build a battery-powered electronic doorbell which will play a tune at an audible
level. Use components available in the lab. Most often, a “PIC” Development
Board is programmed for this project.
A list of available components will be provided in the lab. You are not permitted to order
specialist components such as single chip FM radios and audio power amplifier modules. You
are only allowed to use two boxes, as supplied from the lab office. However, exceptions may
be made if you propose an interesting design. Contact Dr Worrall with details of your design
to discuss whether an exception is possible.
Each team will produce a design, the documentation package and the finished prototype. It is
expected that each group will organise itself so that the workload is partitioned fairly. Each
member of the group will be required to keep a project logbook in the form of a lab notebook
containing all work related to the project. These will be checked at regular intervals during the
project. The specific items of coursework which will be assessed are:-
1. Project specification
2. Project plan
3. Preliminary design
a. schematic diagrams
b. circuit descriptions
c. mechanical sketches
d. Spice simulations2
4. Documentation package
a. final schematic diagrams
b. printed circuit layout ( if applicable)
c. mechanical drawings
d. assembly drawings
e. parts list
f. test at specification
g. operating manual
5. Finished prototype
6. Presentation (EDPS Semester 2)
Items 1-4 should be kept as four separate reports, and should be made available for inspection
at the time of marking. Item 5, the finished prototype, will be inspected at the same time. Item
6, the presentation, will be marked in a separate session on the same day.
2 This applies mainly to the audio amplifier project, and not the doorbell project.
Second Year Laboratories Autumn Semester: 2009/10
11
There are six weeks of lab work dedicated to the project to, totalling 36 hours of lab time. A
7th week will be used for demonstrators to assess your project work and documentation.
4.2. Project Planning Remember that a team does not consist of one person doing the work and 4 watching, nor
does it consist of 5 people doing the same thing. Early in the project you should break the task
down into “workpackages” (e.g. electrical design; mechanical design; PCB layout;
specifications; testing; report writing) and ensure that each member of the team is busy
working at all times. A Gantt chart should be used to achieve this. An example is shown
below, in Figure 1. The example below was produced using Microsoft Visio which is freely
available to students via MSDNAA3.
ID
Task Name
(Person
Responsible)
Start Finish Duration
Sep 2008 Oct 2008 Nov 2008
7/9 14/9 21/9 28/9 5/10 12/10 19/10 26/10 2/11 9/11 16/11 23/11
1 2w19/09/200808/09/2008Plan Project (all)
2 4.8w16/10/200815/09/2008Task X (Bob)
3 2.4w06/10/200819/09/2008Task Y (Jack,
Anna)
4 4w20/10/200823/09/2008Task Z
(Muhammad)
5 3w04/11/200815/10/2008Task 5
6 2w24/10/200813/10/2008Task 6
7 1.8w31/10/200821/10/2008Task 7
8 2w13/11/200831/10/2008Task 8
9 3w25/11/200805/11/2008Testing
10 2w02/12/200819/11/2008Report Writing
Figure 1: Example Gantt chart for project planning.
The above is a SIMPLE example of the minimum level of planning you need. Real projects
need much more detailed plans, with milestones, critical reviews, deliverables, links between
work packages, etc.
4.3. Guidelines for Audio Amplifier Many different circuits can be found on the web and in books for audio amplifiers. However,
it is strongly recommended that you follow the guidelines set out here. They are intended to
help you design a circuit that you can understand and get working inside the six lab sessions
allocated to the project.
The first recommendation is that you consider the design, and construction of the circuit to be
made up of a number of stages. Examples of such stages are shown in Figure 2. Clearly, more
advanced circuits will give you better marks, but only if they work. By treating the amplifier
as a series of modules, it is possible to gradually upgrade the amplifier.
3 For details: http://info.eps.surrey.ac.uk/SCS/guides/msdnaa/
Second Year Laboratories Autumn Semester: 2009/10
12
The second recommendation is that you pick circuits that you understand. You may need to
adapt the example circuits that you find, so it is important to be able to understand how they
will work with slightly different components. Electronic Devices, by Floyd (621.381)
contains some useful example circuits. There are also some web links on ULearn. The
following are hints and tips for designing and building your circuit:
o Read about impedance matching.
o Read about different amplifier types, e.g. class A, class B.
o Consider a circuit involving op-amps for the pre-amp stage.
o Look for circuits involving transistors for the output stage.
o Take care when designing the tone controls. Simple designs are recommended that use
low pass and high pass filters.
o It should be possible to get the circuit working with 4.5V (e.g. 3 AA batteries), but
will probably work better with 5-6V. Extra credit will be given for getting it working
with lower voltages (e.g. fewer batteries).
Finally, make sure that you really know how the circuit works, as you may be asked questions
during the marking session. The idea of the project is that you learn more about electronic
circuits, rather than how to copy circuits from the Internet.
Bridge Amplifier
Pre-AmpOutput
Stage
Tone
Control
Output
Stage
(Inverted)
Pre-AmpOutput
Stage
Tone
ControlPre-Amp
Output
Stage
Figure 2: Example block diagrams for audio amplifier.
Updated November 2009.
S. Worrall.
(a) Simple audio amplifier.
(b) Simple audio amplifier with tone control.
(c) Simple audio amplifier with tone control and bridge amplifier.
Second Year Laboratories Autumn Semester: 2009/10
13
5. Location of Laboratories
All labs will be held in or near the main 2nd
year laboratory. If you cannot find your
experiment, then simply ask the academic in charge, or one of the lab technicians.
Figure 3: Location of main second year laboratories.
Main 2nd Year Lab
Tels lab
RF lab, power lab
Te
cn.
Stores
1st Year Lab
DJF
EW
S
SHOP
etc
BB building
Bridge to fourth floor (Elec Eng Reception)
Second Year Laboratories Autumn Semester: 2009/10
14
6. EXPERIMENT A: Perl and CGI programming
Lab Location: Main UG Labs
6.1. Quick Introduction to Perl: Perl and CGI form a powerfully combination, which is widely used in many current web
applications. However, Perl is not just a web based technology. It can be used for a wide
variety of applications, and is particularly strong at manipulating text. It has powerful features
that allow certain tasks to be performed simply, which are very difficult to perform using
other languages, such as C. Applications of Perl include interfacing with databases, scientific
calculations, and network programming.
In recent years Perl has lost ground to PHP4, for web-based development, in terms of
popularity. This is largely due to PHP‟s simplicity. However, the simplicity of PHP brings
with it limitations that make it unsuitable for more complex applications. Thus, the power of
Perl and the wide variety of modules available on the web, make it an important language.
6.2. Aim: This experiment sets out to teach the fundamentals of the computer language PERL and to get
the student to write a simple application using PERL to manipulate data returned from an
HTML form on a web server. The very basics of CGI (Common Gateway Interface)
programming will, therefore, be covered.
6.3. Preparation: Material to assist your preparation is provided on the web on the 2
nd year labs webpage:
http://info.ee.surrey.ac.uk/Teaching/Courses/ee2.laba/
You should make notes on the PERL language and make sure you know how to edit, compile
and execute a PERL program. There is a simple program to demonstrate this. You should
make the modifications to this program as instructed to gain some experience in the use of the
system.
6.4. Experimental Work: The experimental work is described on the webpage for 2
nd year laboratories.
Updated by S. Worrall, July 2008.
4 Perl and PHP have many similarities, so you will find it easy to learn PHP in future if you know Perl.
Second Year Laboratories Autumn Semester: 2009/10
15
7. Experiment B: Electronic measurement of and e Lab Location: Main UG Labs
Introduction This experiment aims to familiarise students with measurement techniques and the use of least
squares fitting for the treatment of experimental data. The values of and e are measured
experimentally using very simple circuits. Two methods for each are described. Items that
should be covered in the preparation are preceded by →.
Additional background material is provided on the Labs webpage.
7.1. Measurement of : first method
→ Show that the mean value, , of a half-wave rectified sine wave of amplitude Vo Volts
is
A straightforward method for measuring therefore, is to measure the peak and mean values
of a half-wave rectified sine wave and calculate the ratio , which should be close to .
Figure 4: (a) Calibration, (b) measurement of .
Experiment
You must use an analogue AVO meter for this part - why? (You need to explain this
rather carefully.)
Perform a simple calibration at d.c. as in Figure 4(a). Use a d.c. power supply to
generate 1V, say, as measured by the AVO (correctly zeroed and horizontal). Check
that the oscilloscope also reads 1V - if not, use the variable gain to adjust this.
Explain how this method of calibration will give the right value for , even if the
AVO reads wrongly by a constant factor.
What frequency are you going to set the signal generator to, and why?
Use the circuit of Figure 4(b) for several different values of (measured by the
oscilloscope) and (from the AVO).
Second Year Laboratories Autumn Semester: 2009/10
16
Find the ratio and average the values obtained to estimate .
7.2. Measurement of : second method Consider the one stage filter shown in Figure 5.
Figure 5: One stage filter.
→ Show, stating any assumptions that you make, that
(1)
Where f is the (linear) frequency of the input. How is τ defined?
According to equation (1), a plot of against will be a straight line of
gradient . The y-intercept of this line should be 1.
→ For a set of N data points show that the gradient m that minimises S, where
(2)
subject to the constraint that the y-intercept c = 1, is given by:
(3)
assuming the errors in x are much smaller than those in y. All the sums in (3) go from 1
to N.
It is also possible to calculate the standard error on m. It is given by:
(4)
Experiment
If your signal generator offers a choice of output impedance, which impedance will
you use and why?
Second Year Laboratories Autumn Semester: 2009/10
17
Choose values for R and C, measure them accurately and calculate τ; make sure you
include RS.
Using a DVM, measure vi and vo at 10-15 frequencies. Use a frequency counter to
measure f .
Plot against .
Use equations (2) and (3) to calculate S, the least squares gradient, and hence your
Use equation 4 to find the standard error on m.
Compare with the true value of and explain the sources of error.
7.3. Measurement of e: first method
Using the same circuit as before, but with square wave input, it is possible to plot an
exponential decay curve on the oscilloscope screen.
→ Show that if v(t) is a decaying exponential with time constant τ, then:
(5)
for all t.
Experiment
Set up the apparatus so that an exponential curve is displayed on the oscilloscope
screen. Choose the timebase, signal generator frequency and vertical positioning of
the trace appropriately.
The measurements are made much easier if τ is a whole number of divisions; decide
how you will achieve this. Can you rely on the output impedance of the signal
generator? If not, what can you do about it?
Measure and for at least 10 different values of t.
Calculate a value of e from equation (5) for each of these values of t. Find the mean,
the standard deviation σ, and the standard error on the mean, ( , where N is
the number of measurements), which is an estimate of the error on your
measurement of e. Tabulate your results.
Compare your results with the true value of e, 2.7182818.
7.4. Measurement of e: second method The exponential curve displayed on the oscilloscope in the previous experiment was of the
form:
(6)
where v(0) is the voltage at t = 0. From experimental measurements of v(t) at various times t,
it is possible to find the values of in the truncated series:
Second Year Laboratories Autumn Semester: 2009/10
18
(7)
using the method of least squares. In this case, there are 5 unknowns and the
arithmetic would be very tedious to carry out by hand. Hence, an Xmaple programme is
provided for carrying out the calculation for you (see last section).
→ Show that if v(t) is given approximately by equation (7), then
(8)
Experiment
Again, set up the apparatus so that an exponential curve is displayed on the
oscilloscope screen.
Measure v(t) for 10-15 different times t.
Tabulate v(t) and . Plot a graph of against t. Estimate error bars for
each point.
Using the provided Xmaple programme, calculate .
Using equation (8) estimate and hence e.
7.5. Help with Xmaple Xmaple is a large programme designed to perform algebraic calculations by computer. That
is, it can do symbolic operations, e.g. rather than just numerical
calculations. We use it in this experiment to solve the 5 linear equations that arise when
performing the least squares fit to the experimental exponential decay curve.
In order to use xmaple, log in to a Unix/Linux system (Linux PCs are available in the lab, or
see section 12 for help on how to log on to a Linux machine from a Windows PC). When you
have logged on, type: xmaple
After a short while an xmaple window will come up with a > prompt in it. You now have
three things to do:
1. Open a new document in “Worksheet” mode.
2. Load the xmaple programme I have written to do the calculations for you.
3. Type in your experimental data in the right form.
To load the program, type: read “/vol/examples/teaching/engmaths2/leastsqrs”;
in the xmaple window, followed by return. Xmaple will give you two warnings, which you
can ignore.
Your experimental data needs to be in the form of two lists called x and y. List x is the values
of t/τ at which you measured v. List y is the corresponding values of v(t)/v(0). Suppose you
had made the following measurements:
Second Year Laboratories Autumn Semester: 2009/10
19
t/τ 0 0.205 0.409 0.512 0.645
v(t)/v(0) 1 0.813 0.663 0.594 0.400
In order to define list x, type:
x := [0, 0.205, 0.409, 0.512, 0.645];
(return) and similarly for list y:
y := [1, 0.813, 0.663, 0.594, 0.400];
To perform the least squares fit for equation (7) to your data, type
lsf();
Xmaple will do the calculations and reply with the coefficients in the power series:
a0 = 1.000000
a1 = -0.527579
a2 = -4.027930
a3 = 12.928134
a4 = -11.86223
7.6. Extra work
Devise a method to measure 2 electronically. There are several ways you could do this.
Credit will be given for ingenuity. Could you extend your method to find, say, 5 ?
7.7. References Second year Engineering Maths notes, chapter 9: The method of Least Squares.
J.H.B.DEANE, MAY 2001.
Updated S. Worrall, N. Wright, July 2006.
Updated S. Worrall, November 2009
Second Year Laboratories Autumn Semester: 2009/10
20
8. EXPERIMENT I1: LINEAR SYSTEMS AND FEEDBACK
I1: FREQUENCY DOMAIN AND TIME DOMAIN
Lab Location: Main UG Labs
8.1. Aim
The aim of the first day of this two-day experiment is to study the frequency and time-domain
responses of first and second-order linear systems. This experiment supports material taught
in the Linear Systems Analysis and Analogue Electronics courses.
8.2. Preparation
Before coming to the laboratory you should carry out the following preparatory work.
Learn about asymptotic straight-line approximations for sketching frequency response:
magnitude and phase (Bode plots - see the Appendix).
Learn about first and second-order systems.
Learn about Laplace transform methods, in particular how the frequency response and
step response of a circuit are related.
For each of blocks B, C and D, showing important numerical values:
o Find the transfer function (as a function of s);
o Sketch a pole-zero diagram of the transfer function
o Sketch an asymptotic Bode plot (magnitude and phase) - Sketch the step
response (time domain)
See Figure 6 for details of the circuits used.
[Hint: For block B, it is quickest to use nodal analysis, making use of the fact that the circuit
contains a unity-gain amplifier.]
8.3. Equipment and materials
Pre-assembled PCB for Experiment I “Linear Systems”
Dc power supply, ±15V (dual/split rail)
Oscilloscope
Sine/square wave signal generator
Scaled log-linear graph paper
Calculator, 2mm patch leads, etc.
Second Year Laboratories Autumn Semester: 2009/10
21
8.4. Experimental Work
The experiment is concerned with circuit operation within the frequency range 10Hz to
10kHz.
Before commencing the experimental work, ensure the switches on the PCB are set up as
follows, with the board orientated so the text Experiment I “Linear Systems” is in the upper
left hand corner:
S 1 A to S 1 D all toggles to left hand position
S2A to S2D all toggles to left hand position
S2E toggle to right hand position
A-B, B-C both toggles to left hand position
C-I-D toggle to centre position.
Pot R2 - turn fully anti-clockwise
Block C (a first-order system)
Transfer your theoretical straight-line approximate bode plot (magnitude and phase)
to a sheet of the graph paper provided.
Measure the frequency response (magnitude and phase) and plot it on the same sheet
of graph paper as used above. (i.e. so the theoretical and measured results are
overlaid, remember to keep the scales for each axis the same, use a different colour
for each curve so they may be easily identified)
[Hint: It is quicker to take all of the gain measurements together, then all of the phase
measurements together. Measure at say three frequencies per decade in a 1-2-5 sequence, then
return to any interesting regions for a more detailed look]
Compare the theoretical and experimental plots. [Hint: high-frequency discrepancies
can be explained theoretically: think about the op amp's imperfections!]
From your experimental Bode plot, find the bandwidth of the circuit, i.e. the
frequency fB at which the gain is 3dB less than its low-frequency value. Calculate
the time constant from the relationship
Bf2
1
Compare this value of with the theoretical value from your preparatory analysis.
Observe the step response of the circuit by applying a square wave at a suitable
frequency. Measure the circuit‟s time constant and compare your value with the
theoretical prediction.
Measure the 10-to-90% rise time of the step response. For low-pass filters of any
order, a useful „rule of thumb‟ (with some theoretical basis) is:
Bandwidth × Rise Time = 0.35
How well do your results accord with this?
Second Year Laboratories Autumn Semester: 2009/10
22
Block D (another first-order system)
Transfer your theoretical straight-line approximate Bode plot (magnitude and phase)
to a new sheet of the graph paper provided.
Measure the frequency response (magnitude and phase) and plot it on the same
sheet. Compare the theoretical and experimental plots. In a single sentence, state the
action of this circuit.
Find the frequency at which the output lags the input by 90˚, and compare this with
the theoretical value from your preparatory analysis.
Observe the step response and hence find its time constant. Compare this with the
theoretical value from your preparatory analysis.
Block B (a second-order system)
Transfer your theoretical straight-line approximate Bode plot (magnitude and phase)
to a new sheet of the graph paper provided.
Measure the frequency response (magnitude and phase) and plot it on the same
sheet. Compare the theoretical and experimental plots.
Find experimentally the natural frequency nf [Hint: consider the phase angle.]
The gain at nf is theoretically ½ξ, where ξ; (zeta) is the damping factor. (You should
be able to verify this formula.) Hence find experimentally a value for the damping
factor ξ.
Measure the frequency mf at which the circuit has maximum gain. This frequency is
given theoretically by:
221nm ff
Hence find a second value for ξ.
Measure the 3dB bandwidth of the circuit.
Observe the step response by applying a square wave at a suitable frequency.
Measure the fractional overshoot h. (E.g. if the response peaks at 3V and settles to
2V, then h = (3 - 2)/2 =1/2) The damping factor is given theoretically by:
Using this formula, find a third value for ξ.
Compare your three measured values of ξ with the theoretical value derived from
your preparatory analysis.
Measure the 10% to 90% rise time of the step response. How well do your
measurements accord with the bandwidth-rise time rule?
Second Year Laboratories Autumn Semester: 2009/10
23
As best you can, find the frequency of the damped ringing. Compare it with the
theoretical value:
21nd ff
(Note that maxf and df differ from each other and from nf however, as ξ→ 0, both
maxf and df approach nf ).
Which method for finding ξ do you consider the best?
Second Year Laboratories Autumn Semester: 2009/10
24
9. EXPERIMENT I2: LINEAR SYSTEMS AND FEEDBACK
I2: CLOSING THE LOOP
Lab Location: Main UG Labs
9.1. Aim
The aim of the second part of this experiment is to support the material on feedback, control
and stability taught in the Linear Systems Analysis and Analogue Electronics courses.
9.2. Preparation
Before coming to the laboratory you should carry out the following preparatory work.
Analyse block A to find its operation. Plan an experiment to test your results.
Review your Part-I results for Blocks B, C and D.
Learn about feedback control systems; in particular, find out about the criteria for
stability of a feedback system, including the idea of gain and phase margins.
See Figure 6 for details of the circuit used.
9.3. Equipment and materials
Pre-assembled PCB for Experiment I “Linear Systems”
Dc power supply, ±15V (dual/split rail)
Oscilloscope
Sine/square wave signal generator
Scaled log-linear graph paper
Calculator, 2mm patch leads, etc.
9.4. Experimental Work
The experiment is concerned with circuit operation within the frequency range 10Hz to
10kHz.
Before commencing the experimental work, ensure the switches on the PCB are set up as
follows, with the board orientated so the text Experiment I “Linear Systems” is in the upper
left hand corner:
S 1 A to S 1 D all toggles to left hand position
S2A to S2D all toggles to left hand position
S2E toggle to right hand position
A-B, B-C both toggles to left hand position
C-I-D toggle to centre position.
Pot R2 - turn fully anti-clockwise
Second Year Laboratories Autumn Semester: 2009/10
25
Block A (a differential amplifier)
Operate switches S1A and S2A (so toggles are to the right) and ensure Pot R2 is turned fully
anti-clockwise. (So that Z1 = Z2 = 10kΩ)
(Note: The resistance of the potentiometer R2 can be checked by measuring the resistance
between the test point „TP1‟ and terminal „Output A‟. When measuring, for best results
ensure switches „S2A‟ and „A-B‟ are in the left hand position, further please ensure that the
power supply is disconnected from the board when making this measurement.)
With 1Z = 2Z = 10KΩ, check that Block A performs as you would expect from
theory, at a frequency of 1kHz. (Note: unused inputs should be properly terminated.)
Blocks B + C (a third-order system)
Ensure that switch „B-C‟ is closed (Toggle to the right) to connect block B to Block
C. From your Part-I experimental Bode plots, deduce the frequency at which the
total phase angle should be 180°.
Measure this frequency experimentally and compare it with your prediction. Also
measure the magnitude of the gain at this frequency.
System 1
Connect Blocks A, B and C as a negative feedback system (System 1), as shown in
Figure 6. To do this set the switches as follows:
S1A on (Toggle Right), SIB to SID off (Toggle Left), S2A on (Toggle Right), S2B
to S2D off (Toggle Left), S2E on (Toggle Right), Switches A-B and B-C both on
(Toggle Right), Switch C-I-D to position C (Toggle Left). Turn Pot R2 fully
clockwise initially for minimum resistance.
With these settings, 1Z = 10KΩ, and 2Z = R2=0Ω. (Value to be determined)
The loop gain depends on R2. Calculate the maximum value of R2 that will allow
stable operation. Predict the frequency of oscillation if R2 is increased slightly
beyond this value.
Adjust Resistor R2, accordingly, taking experimental measurements to confirm your
predictions. Explain why it is impossible in practice to obtain a steady, undistorted
sine wave with this simple oscillator circuit.
Note, the resistance of R2 can be measured using the following procedure:
Firstly, note the current positions of switches S2A and A-B. Next ensure switches
„S2A‟ and „A-B‟ are placed in the left hand position (Toggle Left). Now turn off,
and disconnect the power supply from the board. Once this has been done, you can
measure the resistance between the test point „TP1‟ and terminal „Output A‟ using a
suitable meter. Adjust R2 to obtain the desired resistance reading. When complete,
remove the meter connections, reconnect the board as before and return the switches
to their previous settings.
Reduce R2 to avoid oscillation, and measure the step response of the system.
Observe the effect of varying R2. Set R2 to a value that gives, in your judgement, a
satisfactory step response. In a unity-feedback control system such as this, the output
Second Year Laboratories Autumn Semester: 2009/10
26
is supposed to follow the input closely; compare the two waveforms to see how well
this is achieved.
Measure the value of R2 using the procedure given above and make a note of this
value.
Using your chosen value of R2, calculate the DC loop gain. Break the loop at an
appropriate point, and measure the DC (low frequency) loop gain and compare it to
the calculated value. Does the feedback system have sufficient loop gain for good
results?
In system 1, Block A is described as a proportional controller, because its output is
proportional to its differential input. In control terminology, blocks B & C form a
third-order plant. The only advantage of proportional control is its simplicity; a
major disadvantage is that the loop gain is usually low, to ensure stability. The result
is a large steady-state error and little improvement in dynamic performance.
Proportional control is therefore seldom used on its own.
System 2
Re-configure Block A by setting up the switches as follows:
SIC on (Toggle Right), S1A,S1B & SID off (Toggle Left), S2B, & S2C on (Toggle
Right), S2A & S2D off (Toggle Left), S2E on (Toggle Right), Switches A-B and B-
C both on (Toggle Right), Switch C-I-D to position C (Toggle Left).
With these settings, MZ 11 and uFMZ 1||12
Break the loop at an appropriate point, (see the hint below) and by measuring the
loop gain find the gain and phase margins of the system. How do they compare with
the commonly accepted values of 15dB and 50˚ for satisfactory stability?
[Hint: the loop can be broken at 3 different points by using either switch A-B, B-C
(Toggle Left to switch off so disconnecting blocks) or C-I-D (by putting into
position I). It's up to you to choose the correct one to use, consider the circuit as a
whole before deciding which to use. Note, Switch C-I-D determines which block's
output is applied to the feedback input on block A, this can be from either block C or
block D. the centre position (I) isolates the feedback input leaving it disconnected]
Reconnect the loop and measure the closed-loop system's step response, recording
the rise time and overshoot. How well does the output follow the input with this
controller? How well does the system obey the bandwidth-rise time rule of Part I?
What is the effect of changing nFMZ 470||12 ? Why?
Note: To change Z2 to 1MΩ||470nF, turn S2C off (Toggle Left) and turn on S2D
(Toggle Right)
This controller achieves system stability by brute force: it introduces a low-
frequency dominant pole that makes the system behave as if it were a very slow-
acting first-order system. With a dominant pole, the gain-bandwidth product of a
feedback system is almost constant. The advantage of a dominant-pole controller (a
practical approximation to an integral controller) is that it allows a higher DC gain
than a proportional controller, and hence smaller steady-state errors; its disadvantage
is that the system has a small bandwidth and hence responds slowly.
Second Year Laboratories Autumn Semester: 2009/10
27
System 3
Re-configure Block A by setting up the switches as follows:
S1B & SID on (Toggle Right), S1A,S1C off (Toggle Left), S2B & S2D on (Toggle
Right), S2A, S2C, & S2E off (Toggle Left), Switches A-B and B-C both on (Toggle
Right), Switch GI-D to position C (Toggle Left).
With these settings, and
5.6 Ω
(Makes for a very good controller, values optimized for this circuit)
Again, confirm by open-loop measurements that the system will be stable when the
loop is closed, recording the gain and phase margins, the DC gain, and the unity-
gain bandwidth.
Close the loop and check for stability. Measure the system‟s step response,
recording the rise time and overshoot. How well does the output follow the input
with this controller? How well does the system obey the bandwidth-rise time rule of
Part I?
Further work
An empirical relationship for the step response of a closed-loop system is:
Fractional overshoot (%) = 75 - Phase Margin (°)
Use your measured results for Systems 2 and 3, plus others obtained by your own
circuit modifications, to investigate how well the rule applies in this experimental
system.
Block D may be included in the loop by selecting position D for switch GI-D, as
shown by Figure 6. Assuming the values of Z1 and Z2 given for system 2, you
should be able to predict whether this new system will be stable or unstable. Check
your answer experimentally.
D.C. Hamill 30/7/93
Updated S. Worrall and N. Wright, July 2006
Text revised for new “Experiment I Linear Systems” breadboard developed by:
C.W. Murray, 2007
Appendix
Asymptotic Bode Plots
To ease sketching of gain and phase plots, asymptotic approximations are often used. The
following apply to poles, but can be adapted for zeros by reflecting the plots in the frequency
axis.
Second Year Laboratories Autumn Semester: 2009/10
28
Laplace Transform Techniques
The transfer function of a linear system is an s-domain description of the relation between its
input and output. For electrical circuits the most commonly used transfer function is the
voltage gain Vo/Vi. It can be found by letting the impedance of a resistor be R, a capacitor
1/sC and an inductor sL, and applying the rules of circuit analysis, e.g. Kirchhoff‟s laws.
Normally the transfer function is obtained in the form H(s) = N(s)/D(s), where N(s) and D(s)
(numerator and denominator) are polynomials in s, the Laplace-transform variable, or
„complex frequency‟.
An nth-degree polynomial has n roots, which may be real or complex; if complex, they come
in conjugate pairs. The roots may be found numerically or by factorisation. The roots of N(s)
are called the zeros of the transfer function, because substituting these values of s makes H(s)
= 0. The roots of D(s) are called poles; substituting these values makes H(s) = .
A pole-zero diagram can then be drawn by plotting the positions of poles and zeros in the
complex s-plane (writing js ), a pole being represented by x and a zero by O. With
the exception of the dc gain (i.e. the limit of H(s) as s→ 0), a pole-zero diagram presents all
the information of H(s), in a compact graphical form.
Second Year Laboratories Autumn Semester: 2009/10
29
The transfer function is a useful description of a linear system. It can give information about
both the frequency-domain and time-domain properties of the circuit. It is easy to extract the
frequency-domain information: just substitute js to get the frequency response .
This is in a complex form; for practical purposes the magnitude and the phase
can be found in the usual way.
It is rather more difficult to find time-domain characteristics such as the response to a unit
step. To get this, H(s) is multiplied by 1/s (the Laplace transform of a unit step) to get F(s)
and the inverse Laplace transform of F(s) is taken. To avoid tedious mathematics, standard
tables of Laplace transform pairs are usually consulted. The result is a function of time f(t),
which often contains exponentials and sinusoids. In analysing the systems in this experiment,
the following Laplace-transform pairs are of use:
Second Year Laboratories Autumn Semester: 2009/10
30
Figure 6: Linear Systems Experiment Circuit Blocks.
Second Year Laboratories Autumn Semester: 2009/10
31
Figure 7: Pre-assembled PCB Layout.
Second Year Laboratories Autumn Semester: 2009/10
32
10. LabVIEW Experiment Lab Location: Main Labs
LabVIEW by National Instruments is a graphical programming language. LabVIEW is most
widely used in automatic test equipment and measurement systems. It is extremely widely
used in industry. Almost every piece of test equipment has a GPIB interface. Drivers for
almost every such piece of test equipment are available in LabVIEW. As a result it is
extremely easy to build up surprisingly complicated programmes for controlling whole racks
of test equipment and even large systems.
The purpose of this experiment is to familiarise students with LabVIEW. You will only touch
the surface of its capabilities, since in one day it would not be practical to learn everything
about it. The vi you create will demonstrate the basic principles of the Fourier transform.
Your programme will generate a sine wave and its harmonics, and the user will be able to
tweak the amplitude of each harmonic and see the resulting waveform in real time.
10.1. PREPARATION 2 hours recommended
1. Read about LabVIEW and look at some example files - either on the web-site
(www.ni.com) or by running LabVIEW itself. You can download an evaluation copy
from the web site. Note that even if you can run LabVIEW “at home”, it is
COMPULSORY to attend the lab sessions to do the work. This ensures that all
students are assessed on their own work, not that of others. You can run LabVIEW
Version 8.0 from a university Linux terminal by typing: /vol/ee/teach/NIlabview/bin/labview80
2. Read about the basics of Fourier series; how is a square wave represented as the sum
of a fundamental and its harmonics? How do you calculate their relative amplitudes?
3. Read all the following instructions.
10.2. Experiment Step 1 Get basic familiarity with the LabVIEW environment:-
Programs are referred to as “vi”s, standing for virtual instruments. The vi‟s can, of course, be
nested so that one vi is used inside another: the sub-vi appears as a single icon with connector
terminals for the input and output of data.
There are two main windows in a vi. One is called the diagram. This is a graphical
representation of the program function. The second window is called the panel. This is the
user interface, and includes displays of results and input controls. Because LabVIEW is a
graphical language, it is not necessary to memorise detailed rules for syntax, etc. On the other
hand, a fairly simple equation may be quite tedious to enter into LabVIEW. However,
LabVIEW can be linked with Matlab scripts and Excel.
It is important to realise that there are a number of cursor modes. The hand-shaped cursor is
for entering data. The “+” or arrow cursor is for selecting, moving, deleting, etc. The cursor
Second Year Laboratories Autumn Semester: 2009/10
33
which looks like a spool of wire is for connecting up blocks on the diagram. The tools palette
can be used to toggle the cursor type. The tools palette can always be called up from the view
menu at the top of the screen.
The functions palette for the diagram window can be accessed by right-clicking in the
window, or from the window menu.
The controls palette for the panel window can be accessed by right-clicking in the window,
or from the window menu.
CREATE a vi which multiplies two user-input numbers together and
displays the result in a box:-
The user-input numbers are CONTROLS
The result can be shown using an INDICATOR
There are many ways to create this simple example. Here is the slow-but-clear method:-
1. In the PANEL window, right-click to call up the Controls palette, and select Modern -
Numeric – Numeric Control. This gives the user a box in which he can input one of
the numbers
2. Repeat (1) for the second user-input
3. In the PANEL window, select Modern - Numeric – Numeric Indicator from the
Controls palette. This gives a box to display the answer in.
3. Switch to the DIAGRAM window. The 3 items should be there; with the data cursor,
type in sensible names.
4. Right-click to call up the Functions palette, and select Programming - Numeric -
Multiply.
5. With the “connect wire” cursor, connect up the blocks
7. TEST the vi; select “run continuously” at the top of either window.
Second Year Laboratories Autumn Semester: 2009/10
34
Figure 8: Diagram Window, showing A x B note tools and functions palettes shown.
Figure 9: Panel Window, showing A x B with simple digital controls and indicator.
Second Year Laboratories Autumn Semester: 2009/10
35
10.3. Experiment Step 2 Create a simple sine wave on a graph:-
Open a new vi and move to the diagram window.
Firstly, create a for loop using Programming - Structures - For Loop.
You need to draw a box using the cursor, after selecting the command.
Insert the various numeric elements which build up the simple equation A cos t.
This can be done by using the I symbol of the loop to represent t, with some scaling: The FOR
loop is no different to any other language, that is for n = 1 to N, whatever is inside the box is
repeated. N is set by adding a Programming - Numeric - Numeric Constant item and
wiring it to the symbol for N. The “I” symbol inside the loop has an output terminal which
gives the value of n for each iteration.
Suppose then you set N=2000; the loop will create 2000 samples of the sine wave, BUT
LabVIEW works in radians, so they will be far too far apart in time. So, “n” should be
divided by say 100 to give a maximum of 20 radians (just over 3 cycles, for a nominal
frequency of one).
The frequency and amplitude can be set as user controls with the “connect wire” cursor by
right clicking in the diagram window near the desired terminal of the relevant numeric item
and choosing create-control. The controls then also appear on the panel window. Switch to
the panel window and observe these controls. Now insert a waveform graph in the panel
window by right-clicking to bring up the controls palette.
Go back to the diagram window. The sine wave samples from the loop have to be grouped to
form the graph. There are many ways of dealing with arrays and clusters of data. A simple
method here is to insert Programming – Cluster & Variant - Build Cluster Array. This,
and the graph, must be outside the loop structure, since it is building up all the individual
outputs from the loop. The cluster output can now be connected to the graph icon in the
diagram window. LabVIEW recognises any differences in data type and won't connect nodes
properly unless the data is consistent.
Complete the vi and run it using the “run continuously” command at the top left our
each window. Play with the frequency and amplitude controls and check that your vi
works.
In the panel window, try changing the controls to fancy knobs and sliders and change the
scales and ranges of everything. [Hint: try right clicking on everything to call up special
menus]. You have to stop the programme in order to alter the programme itself, but you can
change the scales of things like graphs whilst the programme is running.
Second Year Laboratories Autumn Semester: 2009/10
36
Figure 10: Example Panel for successful completion of Step 2.
10.4. Experiment Step 3 Make a sub-vi out of your sine-wave generator:-
Save your vi, then save it with a new name such as oscsub.vi.
Delete the build cluster array item and the waveform graph (you can only delete the graph in
the Panel window).
At the signal output, use the connect wire cursor and right-click on the output node to Create
- Indicator. LabVIEW then knows this is an output and adds the value as an item in the panel
window.
Now, you need to set the controls (ie the amplitude and frequency) and output signal to be
terminals using the connector pane. The connector pane is the small box at the top right
hand corner of the panel window. Right-click on it to set show connector. The icon will
change to a white box with sub boxes. Each sub box is an individual connector. When you
click on a sub box the cursor changes to wire mode, and you wire the connector to the control
or indicator that you want. Actually no wire appears, unlike in the diagram window, but the
terminals have label names. As each one is connected, the boxes are coloured-in to confirm
success.
Once you have the amplitude and frequency inputs and the signal output set as terminals, save
this sub-vi.
Now, open a new vi. Call up the sub-vi in the diagram window using functions-select a VI.
This is at the bottom left of the palette. Your previous vi now appears as a fixed block, with a
single icon and 3 terminals. Reconnect the amplitude and frequency controls, and put back the
cluster array builder and the waveform graph at the output. Check that this new hierarchical vi
works exactly as before. Save it.
Second Year Laboratories Autumn Semester: 2009/10
37
Figure 11: Diagram window for the hierarchical version of the sine generator.
10.5. Experiment Step 4 Use your sub-vi to create the Fourier series demonstrator:-
Now that you have the sine wave generator as a sub-vi, you can easily set up a number of
identical generators to generate a fundamental signal and its second, third, 4th and 5th , etc.
harmonics. Sum up the signals to display the overall waveform.
Create a nice user-interface on the PANEL, with knobs or sliders to tune each frequency
component.
See if you can create a square wave or triangle wave by varying the amplitudes. (TIPS: (1)
some amplitudes may have to be negative, (2) the number of samples might need more
thought, since you are going up in frequency, (3) if you only have cosine terms, you can only
get an EVEN function)
Second Year Laboratories Autumn Semester: 2009/10
38
Figure 12: Example square wave.
Once you have completed a VI which demonstrates the basic principles of the Fourier
series, with a reasonable user interface and display, you have completed the main part of
this lab with a SATISFACTORY grade (assuming full attendance and that it is your
own work).
To achieve a higher grade, you are invited to take the initiative and create something quite
impressive. Here are some examples of things which you could add to your program:-
1. Add a spectrum display to show the harmonics in the frequency domain
2. Add controls to allow sine or cosine terms for the harmonics for more flexibility
3. Implement a number of pre-defined waveforms such as a triangle wave, for which the
harmonic components are well-known
4. Re-do the vi completely using LabVIEW's own signal and/or function generators
5. Improve your user interface so that it provides a mini tutorial for the user
6. Convert your vi into a format which can be run stand-alone using either the LabVIEW
player or a Web browser.
IDR, version 1, Aug. 2003.
Updated S. Worrall, August 2007.
Second Year Laboratories Autumn Semester: 2009/10
39
11. EXPERIMENT M: POWER ELECTRONICS
SIMULATIONS USING SPICE Lab Location: Main Labs
11.1. Introduction
SPICE (Simulation Program with Integrated Circuit Emphasis) is software that can be used to
simulate electronic circuits on a PC. Any voltage or current waveform in your circuit can be
viewed and plotted. SPICE performs simulations to calculate the voltages and currents against
time (Transient Analysis) or against frequency (AC Analysis). Many SPICE implementations
also permit other types of analysis, such as DC, Sensitivity, Noise and Distortion.
SPICE was originally developed by researchers at the University of California, Berkeley
during the mid-70s. It was the arrival of the integrated circuit that created a need for a method
to test and tweak circuit designs before the expensive fabrication process.
SPICE is currently available from many vendors, who have added a variety of different
enhancements on to the original simulator, such as schematic drawing tools for the front end
and graphics post processors to plot the results. Over time, SPICE simulators and applications
have expanded to permit analysis of analogue and digital circuits, microwave devices, and
electromechanical systems.
SPICE is particularly useful in analogue and power electronics because it can numerically
solve the non-linear differential equations that govern this type of circuit. From the design
point of view, this means that analogue and power electronic circuits can be tested on a
computer before they are constructed. Thus minimising prototyping costs and providing a
useful insight into circuit operation. One of the most useful aspects of SPICE is the ability to
add imperfections to the circuit in order to provide an accurate representation of the practical
circuit being tested. Potential problems can then be identified and eliminated before the circuit
is built.
SPICE has proved to be very useful to 3rd
year project students, as it is more time and cost
efficient than prototyping. You may also find it helpful to simulate your lab project circuits to
identify any potential problems.
11.2. Aim
The aim of this experiment is to provide a basic understanding of SPICE. You will learn how
to interpret and create netlists to be used in SPICE simulations. You should also learn how to
analyse circuits. The experiment also reinforces knowledge about switched mode converters.
11.3. Preparation
It is important to carry out preparation in two areas: power electronics and SPICE. Note that
some of the answers to the preparation questions are contained in the experiment instructions.
Second Year Laboratories Autumn Semester: 2009/10
40
Power Electronics Preparation
Switch-Mode Power Supplies (SMPS) deliver power while wasting very little. The switch
state is toggled, from ON to OFF, to deliver pulses of current to the output. Very little power
is dissipated in the switch. This is an important feature, as conserving power is essential in
battery/portable device design.
Make notes on switched mode converters, mainly on the Buck converter. (A good source for
this is Power Electronics converters, applications and design by Mohan, Underland and
Robbins)
Answer the following questions in brief:-
1. What is the main difference between continuous and discontinuous mode operation?
2. What are the main advantages of switched mode converters?
3. What are the main disadvantages of switched mode converters?
4. With a Buck converter what is the basic difference between the input and output
voltages?
5. Express Duty factor in terms of the switch on time TON and the period TS.
6. What is Equivalent Series Resistance (ESR)?
SPICE Preparation
See ULearn for links to SPICE resources. It is strongly recommended that you use the version
of SPICE (DuSpice) specified on ULearn, as the experiment has been tested on this version.
There may be some minor compatibility issues with other SPICE software.
11.4. Buck Converter Background Material
The Buck Converter provides an output voltage that is smaller than the input voltage. It
consists of just a handful of components (see Figure 13). The current pulses are transformed
via the switch, SW1, into a constant voltage at the load. This experiment will examine some
voltage/current waveforms, and changes component values, so that you get a feel for each
component‟s role, and how to optimize the performance of the Buck Converter.
Second Year Laboratories Autumn Semester: 2009/10
41
VIN
VCTRL
RLC1
L1
D1
SW1
0
10
1 2 3 Vo
Figure 13: Circuit diagram for a Buck converter.
Buck Converter Basics
The Buck Converter operation can be understood by examining the two main states of
operation: SW1 ON and SW1 OFF.
SW1 ON: L1 delivers current to the load
With a voltage (VIN - Vo) across L1, the current rises linearly. The rise (in amps per second)
is given by:
VIN RLC1
L1SW1
0
1 2 3 Vo
I
+ VL -
Figure 14: Buck Converter when SW1 in ON.
L1‟s current changes are smoothed out by C1, to produce a stable voltage at Vo. C1 should be
big enough to ensure that Vo does not change significantly during one switching cycle. D1 is
reversed biased, meaning that it can be removed from the diagram for now.
SW1 OFF: L1 maintains current to the load
Second Year Laboratories Autumn Semester: 2009/10
42
Current falls linearly in L1, as its magnetic field collapses. The fall in current (amps per
second) is again determined by the voltage across L1 and its inductance:
RLC1
L1
D1
0
2 3 Vo
I
- VL +
-
VD
+
Figure 15: Effective Buck Converter circuit diagram when SW1 is OFF.
Although L1‟s current direction is the same, its voltage is reversed. When the applied voltage
is removed, following the change in state of the switch, L1 maintains its current flow by
reversing its voltage. When the voltage of L1 becomes negative, diode D1 switches on, which
provides a path for L1‟s current to flow.
Switching Frequency Vs Output Voltage
Voltage in a Buck Converter is typically controlled by using a Pulse-Width-Modulation
(PWM) signal to drive SW1. This implies that a pulse train is needed, which has the
following features:
o A switching period of TS
o An adjustable Pulse Width of TON, which is the time that SW1 is ON
o A Duty Cycle, S
ONT
TD
The desired output voltage can be obtained by adjusting the duty cycle. The pulse train is
typically in the range of 10‟s to 100‟s of kHz. The reasons why such high frequencies are
used are:
1. As frequency increases, the parts usually get smaller, lighter and cheaper, which is a
huge advantage for portable, battery powered devices. Large amounts of power can be
obtained from a small volume of components. This means that there is a high power
density (W/cm3).
2. The switching time causes a delay from input to output. Clearly, if the switching time,
Ts, is smaller, then the delay should be shorter. The delay becomes a problem when a
Buck Converter is used in a control loop. It can lead to effects such as overshoot,
ringing, or oscillation.
Second Year Laboratories Autumn Semester: 2009/10
43
The Simulation Challenge
Simulation and analysis of switch-mode supplies is challenging due to the different time
frames that need to be considered:
1. The short period of the pulse train turning SW1 ON and OFF (in μsec). This
simulation requires only a few switching cycles.
2. The longer response of LC components as they respond to input or load changes (in
msec). Thousands of cycles are needed to look at the overall response.
11.5. Experiment Part 1: Buck Converter Simulations
A netlist, buck_basic.cir, is provided, which represents the Buck Converter shown in
Figure 13. At this point, it is a good idea to cut out the netlist from page 52, and make
comments, briefly describing what each line does. This will help you learn some basic netlist
aspects.
Here are some of the less obvious points that may be useful when making your comments:
VCTRL generates a pulse train of period TS = 20μs and pulse-width TON = 5μs.
When VCTRL is 5V, SW1 drops to 0.01 Ω connecting 20V (VIN) to L1.
When VCTRL is 0V, SW1 changes to 1 MΩ, effectively disconnecting VIN from L1.
RL represents the load (analog/digital circuitry, motors, lights, etc.) powered by the
Buck Converter.
First Spice Run: Longer Overall Response
Run the simulation and take a look at Vo by plotting V(3). Use the graph to answer the
following questions:
1. How much overshoot occurs due to the LC components?
2. What voltage does the output settle to?
Vo could be expected to be related to VIN and D:
Add VCTRL to the plot by including trace V(10). Change its duty cycle by increasing or
decreasing TON from 5 μs to values like 2.5, 10 or 15 μs. To do this, change the 5US
parameter in the PULSE definition of VCTRL. Does the above equation predict Vo
accurately?
Finally, examine the current through L1. Can you explain what is happening in the plot?
Print the plots, and put them in your log book.
Second Year Laboratories Autumn Semester: 2009/10
44
Cycle By Cycle
Now it is time to look at the shorter term response. We need to look at only a few cycles of
the Buck Converter‟s operation, but we want to see the simulation results after a few hundred
cycles, when the supply has settled to a steady state. The Transient Analysis command caters
for this kind of requirement, as it lets you discard simulation results up to a specific delay
time. For example, this statement:
.TRAN 0.1US 840US 800US 0.1US
simulates the circuit up until 840μs, but discards the data before 800μs. The 40μs saved
represents two switching cycles. This statement is already included in the given netlist, but is
commented out. Uncomment the command and comment out the other .TRAN statement.
Set TON to 5μs and run a simulation of BUCK_BASIC.CIR. Plot Vo at V(3), VCTRL at V(10)
and in a separate plot window, view the inductor current, I(L1). You should see I(L1) rising
and falling as SW1 turns ON (VCTRL = 5 V) and SW1 turns OFF (VCTRL = 0 V).
Inductor Current
The next check on the circuit we can carry out is to examine the two different paths the
inductor current takes as it rises and falls. Open a new plot window and add SW1‟s current.
SW1‟s current should be the same as L1‟s current, but only when SW1 is ON. Then it drops
to 0 A. D1‟s current should initially be 0, then should equal L1‟s current when D1 turns ON.
Find D1‟s current, and plot it. Note that it may not be possible to plot it directly using Spice.
Finally take a look at the SW1‟s voltage at V(2). VSW1 should be VIN = 20V, and then it drops
to -0.3V as D1 (Schottky diode) turns ON, providing a pathway for L1‟s falling current.
Does L1‟s current rise and fall as expected? Check by first calculating the expected rise rate,
TI . Then calculate the total rise, ∆I, while SW1 is ON for 5μs.
Now, compare the expected rise against your plots. You might see a small difference between
the expected and actual values. Why is this?
What do you notice about the rise and fall of L1‟s current? This current change is called the
inductor ripple current, ΔI.
Find the average inductor current, Iave. This can be found either from the graph, or from the
Excel plot (go to the “tabelle” tab to find the raw data). Iave is important because this is the
current that gets delivered to the load RL. It can be calculated using:
L
oo
R
VI
Does Iave match Io? Now, suppose the demand for Io increases. What happens to the ripple and
average inductor current? Double Io by changing RL. Rerun the simulation and examine ΔI
Second Year Laboratories Autumn Semester: 2009/10
45
and Iave? What do you notice? Can you explain what is going on? Next, we‟ll discover how
the inductor ripple current plays a factor in the output ripple voltage.
Output Voltage Ripple
One of the most important aspects of the power supply, is the amount of voltage ripple, ΔVo,
that appears at the output. This voltage ripple is applied to anything driven by Vo, such as
transistors, speakers, motors, and IC‟s. Large values of ΔVo could cause unexpected
behaviour or poor performance from the components driven by the supply.
Set TON = 5μs and RL = 5Ω. Run a simulation from 800 to 840μs. Plot the output V(3) and
inductor current I(L1) in separate windows. How big is ΔVo? There should be about 160
mVp-p ripple at the output.
What if the design goal is less that 50 mVp-p of ripple? First, return the components to their
original values: L1 = 50 μH, C1 = 25 μF and RL = 5. Now change the component values to
achieve a ripple less than 50 mV p-p. You can use the following hints to help you adjust the
values. Find the best combination of values for optimum performance, and justify your
choices by explaining the trade-offs.
CAPACITOR - C1 For a given an inductor ripple current, C1 has the sole responsibility for absorbing ΔI to
minimize ΔVo. Try increasing C1 from 25 μF to a value like 50 or 100 μF. Has ΔVo reduced?
Note that you might have to extend the simulation delay from 800 to 1000 μs. Why do you
need to do this?
INDUCTOR - L1 ΔVo can also be reduced by decreasing ΔI. The equation:
tells us how ΔI can be made smaller. Try changing the inductor value to reduce the ripple.
Rerun the simulation. Did ΔVo shrink as expected?
What are the advantages and disadvantages of using very large inductors in the circuit?
SWITCHING TIME – TS The equation above shows us another ripple reducing parameter: ΔT. How can ΔT be reduced
without changing the output voltage, Vo? Rerun the simulation with the changed parameters.
Has ΔI shrunk as expected?
Why might faster switching times be a disadvantage?
Continuous Vs. Discontinuous Mode
Second Year Laboratories Autumn Semester: 2009/10
46
We‟ve previously seen current flowing continuously through L1. But there is also a mode
were the current goes to zero during the last portion of the switching cycle, called
discontinuous mode.
Table 1: Comparison of current through L1 for continuous and discontinuous mode of the Buck
Converter.
Continuous Mode – L1 has
2 states
Discontinuous Mode – L1
has 3 states
SW1 ON L1 current rises L1 current rises
SW1 OFF L1 current falls L1 current falls
L1 current falls to 0 Amps
We can change the netlist to see when L1‟s current goes to zero. First, set TON = 5μs, TS =
20μs and RL = 5Ω. Now run a SPICE simulation and plot the output V(3) and inductor
current I(L1). You should see ΔI, with Iave = 1A. Now reduce the load by raising RL to 10Ω.
Rerun the circuit. Comment on what happens to the following:
o The current in L1. What is the reason?
o Vo. Is SON TTVINVo still true? Raise RL to 20Ω and vary TON to find out.
Now, plot SW1‟s voltage, V(2), and inductor current, I(L), for the following two
configurations:
1. TON = 5μs, TS = 20μs, RL = 5Ω
2. TON = 5μs, TS = 20μs, RL = 10Ω
Comment on the differences that you see. Why do you think they occur? HINT: look at the
“non-ideal” parameters specified in the diode model.
Design Notes
It is usually recommended that supplies are run in continuous mode. There are two main
reasons for this:
1. The gain is stable. In continuous, Vo, can be approximately set using only VIN and the
duty cycle. However, in discontinuous mode, Vo depends on VIN, the duty cycle, L1,
RL, and TS.
2. For continuous and discontinuous modes, the frequency responses are different. This
means that a circuit optimized for use in continuous mode might respond significantly
differently in discontinuous mode.
For a given load, how should you ensure your supply is in continuous mode?
Capacitor ESR
We have previously used C1 to reduce ΔVo, which has worked successfully because an ideal
capacitor has been assumed. However, real capacitors behave as if there is a small resistor in
series with its capacitance, which is known as the Equivalent Series Resistance (ESR).
Change the C1 statement to the following two statements:
C1 3 4 25UF
RC1 4 0 0.5
Second Year Laboratories Autumn Semester: 2009/10
47
RC1 = 0.5Ω models the ESR of C1. Remember that with L1 = 50μH, C1 = 25μF and RL =
5Ω, we saw that ΔVo ≈ 160 mVp-p.
Run a simulation and plot the V(3) and I(L1). How big is ΔVo? The inductor ripple ΔI, is
normally absorbed by C1, but now flows through the ESR, adding to the voltage ripple. The
ripple can be predicted using the following equation:
Does this equation match what you see in the simulations?
What happens when you increase C1 to 50 or 100μF? Is the ripple reduced?
How can the voltage ripple be reduced? Carry out some simulations to demonstrate how you
can reduce the voltage ripple.
11.6. Experiment Part 2: Buck Converter Power Loss
VIN
VCTRL
RL
C1
L1
D1
SW1
0
10
1 2 3Vo
RL1
RC1
4
5
Figure 16: Buck Converter circuit with equivalent series resistors for L1 and C1 included.
One of the most important areas in Switch Mode Power Supply (SMPS) design is
minimization of the power lost. Ideally, all power should power should be delivered to the
load. However, non-ideal components introduce losses into the system. In this part of the
experiment, we will examine:
1. Where power is lost in the circuit.
2. How power loss can be minimized.
Second Year Laboratories Autumn Semester: 2009/10
48
3. How to evaluate the supply‟s power efficiency by comparing the average power
output versus average power input.
Second Year Laboratories Autumn Semester: 2009/10
49
Where Power is Lost
Most of the power in an SMPS goes to the load. However, the resistive and semiconductor
elements convert power into heat. Also, real world components have parasitic elements
modelled as resistance in series with their reactance. The table below summarises where these
losses occur, and how they can be plotted using SPICE.
Table 2: Summary of areas where power might be lost in a Buck Converter.
Power
Dissipating
Element
Comment Plotting Instantaneous
Power in SPICE
SW1 Power is lost while SW1 is ON
and current is flowing through L1.
Power is also lost while
transitioning between OFF and ON
states.
V(1,2)*I(SW1)5
RL1 Power is lost in the equivalent
series resistance of inductor L1.
V(3,4)*I(RL1)
RC1 Power is lost in the equivalent
series resistance (ESR) of
capacitor C1.
V(5)*I(RC1)
D1 Power is lost while SW1 is OFF
and D1 provides a path for L1‟s
current.
V(0,2)*I(D1)
Instantaneous power is variable, and it is therefore the average power that we are interested in.
Basic Buck Converter Set-up
1. Modify the Buck Converter netlist, so that it includes the ESR‟s for the capacitor and
the inductor.
2. Change the parameters, so that the switching supply runs at 50kHz (Ts = 20μs), Ton =
8.33μs for SW1, and the input VIN = 12V.
3. Change the simulation time parameters, so that you can look at just one cycle (20μs)
of operation after a 1000μs delay, allowing the supply to settle.
4. Run a SPICE simulation of your netlist, and plot the output at V(4). You should see
Vo ≈ 5 V, with a ripple ΔVo ≈ 300mVp-p.
SW1 Power Loss
To see how much power gets lost in SW1, plot SW1‟s instantaneous power:
V(1,2)*I(SW1). The plot shows units of Volts, but it is of course Watts. (Note that SW1 is
typically a MOSFET, but for simplicity, it is modelled here using a voltage controlled
switch.)
Note the power spikes in the instantaneous power plot. What causes these spikes?
5 Note that this is just an indication of how the power is calculated, rather than something that can be entered into
SPICE. For example, to plot V(1,2) in SPICE, type plot V(2)-V(1).
Second Year Laboratories Autumn Semester: 2009/10
50
What switch parameters could be changed to reduce the average power loss? Run SPICE
again after these parameters have been adjusted to show the reduction in power loss.
The parameters that you should have adjusted simulate selecting a MOSFET with different
specifications. So during the design of a SMPS, you might find the maximum requirements of
these parameters, and select the MOSFET based on those requirements.
Inductor And Capacitor Power Loss
Why would power be lost in the inductors and capacitors? Plot the instantaneous power
through the series resistances.
What are typical values for ESR in inductors and capacitors? Simulate ESR‟s at the extreme
ends of the typical values that you identified (i.e. smallest vs. largest) to show the difference
in power loss that might typically be seen without careful selection of components.
It should be noted that there is some power lost in the inductors core in real components that
is not modelled here.
D1 Power Loss
Although the Schottky diode used in this example has a lower ON voltage, 0.3V, compared
with the silicon diode, 0.7V, the power loss in the Schottky is still significant. Plot
V(0,2)*I(D1).
Compare the power lost in the diode to that lost in the switch, the inductor, and the capacitor.
Which is the most significant source of power loss?
A better diode is not available, which means that it is necessary to find an alternative to the
diode to reduce power loss further.
SYNCHRONOUS CONVERTER
In the Buck Converter, D1 acts as an automatic switch, which provides a current path for L1
when SW1 switches OFF. But, as shown in Figure 17, D1 can be replaced by an actual
switch. Because switches are low on resistance, they can reduce power loss during this part of
the switching cycle.
Remove D1 by commenting it out. Add SW2 to the netlist, and a corresponding model.
Remember SW2 should be ON when SW1 is OFF, and vice versa. You should now have a
netlist for the synchronous converter.
Run a new simulation, and plot a trace for SW2‟s power V(2)*I(SW2). Note that it may be
necessary to look at SW2‟s power in two plots: one where SW2 is OFF, and another where it
is ON. Is the power lost, lower than with D1?
Adding a switch changes the supply from a Buck Converter to a synchronous converter.
Although it is more complex, some battery powered applications may require this type of
converter to minimize the amount of power lost.
Second Year Laboratories Autumn Semester: 2009/10
51
VIN RL
C1
L1
SW1
0
1 2 3Vo
RL1
RC1
4
5SW2
Figure 17: Synchornous converter circuit diagram.
11.7. Final Conclusions
You should now have a feel for how a basic switch-mode power supply works, and how
SPICE can be used to experiment with different component values before building the actual
circuit. Make sure you write some conclusions, summarising what you have learnt in this
experiment. For example, what are the major issues that should be considered when designing
a SMPS.
July 2007.
S. Worrall.
N. Wright.
Second Year Laboratories Autumn Semester: 2009/10
52
11.8. Netlists
Buck_basic.cir
BUCK_BASIC.CIR - BASIC BUCK CONVERTER
*
* SWITCH DRIVER
VCTRL 10 0 PULSE(0V 5V 1NS 0.01US 0.01US 5US 20US)
R10 10 0 1MEG
*
* INPUT VOLTAGE
VIN 1 0 DC 20
*
* CONVERTER
SW1 1 2 10 0 SWI
D1 0 2 DSCH
L1 2 3 50UH
C1 3 0 25UF
*
* LOAD
RL 3 0 5
*
*
.MODEL SWI SW(VT=4.5V VH=0V RON=0.01 ROFF=1MEG)
.MODEL DSCH D( IS=0.0002 RS=0.05 CJO=5e-10 )
*
* ANALYSIS
.TRAN 1US 800US
*.TRAN 0.1US 840US 800US 0.1US
*
* VIEW RESULTS
.PLOT TRAN V(2) V(3)
.PROBE
.END
Second Year Laboratories Autumn Semester: 2009/10
53
12. Running Exceed on 2nd
Year Lab PC’s
12.1. Introduction This section describes how to bring up a unix/linux terminal window on the Windows PC‟s in
the main second year lab. This may be needed to complete the XMaple work included in the e
and π experiment.
12.2. Instructions 1. Run the XStart software, whose shortcut is featured on the desktop.
2. Select “Wizard…” on the Help menu.
3. Ensure that you use the settings shown in the following screenshots.
Second Year Laboratories Autumn Semester: 2009/10
54
4. Leave these next settings as they are.
5. Enter your username and password on the next screen
Second Year Laboratories Autumn Semester: 2009/10
55
6. Accept these settings
7. Click finish
Second Year Laboratories Autumn Semester: 2009/10
56
8. Click “Run!” on the menu bar.
9. If you get an error message box, such as the one below, click the “Send” button.
You should now see some terminal windows in which you should be able to run linux
software, such as xmaple.
S. Worrall, July 2006.