You are on page 1of 194

SCHOOL OF ENGINEERING

DEPARTMENT OF ELECTRICAL, ELECTRONIC AND COMPUTER ENGINEERING

STUDY MANUAL

MEASUREMENTS AND COMPUTER MODELLING EMR100


MODULE WEB SITE ADDRESS:
http://phobos.ee.up.ac.za/~subjects/news.php?course=EMR100

Compiled by:
Mr Saurabh Sinha & Mr David Buys
Translated by:
Teaching Assistants, 2004/2005
Date of last revision:
14 May 2005
Copyright reserved

TABLE OF CONTENTS
ORGANISATIONAL COMPONENT
Page
1. GENERAL PREMISE AND EDUCATIONAL APPROACH.............................................. 2
2. LECTURERS, VENUES AND CONSULTING HOURS..................................................... 2
3. STUDY MATERIALS AND PURCHASES ......................................................................... 5
4. LEARNING ACTIVITIES..................................................................................................... 5
5. RULES OF ASSESSMENT................................................................................................... 5
6. GENERAL ............................................................................................................................. 5
STUDY COMPONENT/APPENDICES
A

ECSA REQUIREMENTS .................................................................................................. 6

PART-1: REAL LABORATORY ...................................................................................... 8

PART-2: MATLAB & SIMULINK ................................................................................... 108

PART-3: INTRODUCTION TO ELVIS ............................................................................ 135

MATLAB & LINEAR SYSTEMS..................................................................................... 171

ORGANISATIONAL COMPONENT
1.

GENERAL PREMISE AND EDUCATIONAL APPROACH

A typical engineering design cycle incorporates either/both simulation (virtual laboratory) and actual laboratory
implementation. The approach of this course will be to introduce basic laboratory equipments, fundamental electronic
components, and some software simulation (mathematical/MATLAB modelling) tools. Software-hardware interfacing
is an important aspect in most electronic systems today. Global trends are towards design automation and eventual
automation of electronic system level design (Co Wang, Co-founder, Axis Systems, Special Speaker: Design &
Automation Conference 1-6 June 2003, Anaheim, California, USA). To illustrate the latter, LabView & SIMULINK
will be used. The measurements and computer modelling is a mandatory course for all first year undergraduate students in
Electrical, Electronic & Computer Engineering. Students are encouraged to compare and understand
similarities/differences in the real and virtual laboratory experimentation components of the course.
In terms of the educational policy of the University, it is accepted that "a student should undergo an academic-scientific
moulding to be able later in professional context to function as an independent engineer and to contribute to the creative
development of the chosen profession . . . in effect it refers to a purposeful and pro-active educational approach which
brings with it a change in emphasis from the traditional lecturer-centred teaching approach to a more dynamic studentcentred learning approach." (A new approach, Tukkie-onderrig, Vol. 1(2), 1986). A syllabus for this module has
accordingly been developed as worded in this study manual.

2.

LECTURERS, VENUES AND CONSULTING HOURS


Name
Building Name and
Room Number
CEFIM 2-11.1
Chief Lecturer/Coordinator Saurabh
{Presenter}
Sinha
(SS)
Research Assistant (0)
Jannes
CEFIM 2-13
Venter
(Alternative Coordinator)
{Presenter}
Research Assistant (1)
Ashraf
CEFIM 2-12
Sheri
Teaching Assistant (1)
Cobus
ENG I 15-14
Vlok
Teaching Assistant (2)
Martin
ENG I 13-26
Grobler
Teaching Assistant (3)
Johan
ENG I 13-26
du Toit
Teaching Assistant (4)
Maritte
ENG II 4-50
{Presenter}
Conning
Teaching Assistant (5)
Francois
ENG I 15-19
{Presenter}
Maasdorp
Teaching Assistant (6)
Stefan
ENG II 2-13
van der Merwe
Teaching Assistant (7)
Andr
ENG I 13-26
Mcdonald
Teaching Assistant (8)
Lakshmi
ENG I 13-26
Nair
Sindhu
ENG I 13-16
Teaching Assistant (9)
{Presenter}
Samuel

Telephone No.
and E-mail Address
(012) 420-2950
saurabh.sinha@eng.up.ac.za
(012) 420-3648
pjventer@ieee.org
(012) 420-2983
sheri@eng.up.ac.za
(012) 420-2201
cobus.vlok@up.ac.za
(012) 420-5388
martin.grobler@up.ac.za
(012) 420-5388
jdutoit@up.ac.za
(012) 420-3604
mariette.conning@up.ac.za
(012) 420-3129
francois.maasdorp@up.ac.za
(012) 420-5915
stefan.vandermerwe@up.ac.za
(012) 420-5388
andre.mcdonald@up.ac.za
(012) 420-5388
lakshmi.nair@up.ac.za
(012) 420-2068
sindhu.samuel@up.ac.za

Teaching Assistant (10)

Brian
ENG I 15-14
(012) 420-2201
Salmon
salmon.brian@up.ac.za
Teaching Assistant (11)
Gerhard
ENG II 2-21
(012) 420-5912
Steyn
gerhard.steyn@up.ac.za
Teaching Assistant (12)
Michal
ENG 1 13-26
(012) 420-5388
{Presenter}
Steyn
michal.steyn@up.ac.za
Instructor (0)
David
CEFIM 1-14
(012) 420-3136
Buys
david.buys@eng.up.ac.za
Instructor (1)
Henry
ENG II 1-43
(012) 420-3501
OKennedy
hokenne@postino.up.ac.za
Instructor (2)
Johan
ENG II 3-67
(012) 420-2430
Mienie
johan.mienie@eng.up.ac.za
Instructor (3)
Lukas
Compact Range 1-6 (012) 420-3629
Naude
lukas.naude@eng.up.ac.za
Instructor (4)
Pieter
ENG II 3-67
(012) 420-5789/3928
{Presenter}
Strydom
pieter.strydom@eng.up.ac.za
Secretary (Coordinator)
Mrs Tilla
CEFIM 2-4
(012) 420-3794
Loubser
tilla.loubser@eng.up.ac.za
*Note: On the following page, the following abbreviations are used:
TA (Teaching Assistant), Instructor (I) & RA (Research Assistant)
Consulting hours:
Hours for consultation of the Lecturer, Teaching assistants & Instructors will be announced at the beginning of the course,
and will also be displayed on their office doors, as well as the module webpage.
Students may consult the lecturer, teaching assistant and research assistant only during the consulting hours as indicated,
or by appointment. This policy also holds before tests and examinations. In other words, the lecturer, teaching assistant
and the research assistant will only be available during their normal consulting hours on the day before a test or
examination. This policy aims to encourage students to plan their work and to work continuously.

Lecture times and lecture rooms


Due to a large number of registered students and diversity of resources required for this course, the following rotational
sessions will be followed:
Real Laboratory
Virtual Laboratory
Programme
27 June 29 June
Part-3 (Appendix D)
Part-1 (Appendix B)
Part-2 (Appendix C)
Introduction to laboratory
Mathematical
CAEC (Computer aided
Course run-time:
instruments and electronic
modelling
education centre)
08h00-16h00
components
MATLAB and
ELVIS & LabView
SIMULINK
Lunch (not included)

12h20-13h45

Engineering II: 2-37


Engineering II: Labs B & C
[Group size: 91]
Presenter:
RA (0) (Assisted by TA (5))

Engineering I: 1-1
NWII: Computer labs
[Group size: 91]
Presenter:
SS (Assisted by TA (12))

In the laboratory***:

Computer labs (NW II):

CAEC

27 June: I (0 & 1), TA (1, 2, & 3) & RA (1)


28 June: I (0 & 1), TA (1, 2, & 3) & RA (1)
29 June: I (0 & 1), TA (1, 2, & 3) & RA (1)

27 June: TA (6, 10 & 11)


28 June: TA (6, 10 & 11)
29 June: TA (6, 10 & 11)

27 June: I (4) & TA (7, 8 & 9)


28 June: I (4) & TA (7, 8 & 9)
29 June: I (4) & TA (7, 8 & 9)

27 June: Group A*
28 June: Group B*
29 June: Group C*
Programme
30 June - 1 July

Group D* [Group size: 124]

Course run-time:
08h00-16h00

Group E* [Group size: 123]

Lunch (not included)

12h20-13h45

27 June: Group B*
28 June: Group C*
29 June: Group A*

Engineering I: 1-4
Engineering II: CAEC
[Group size: 73]
Presenter(s):
TA (4) & I (4)

27 June: Group C*
28 June: Group A*
29 June: Group B*

30 June - Part 1 (Appendix B (continued)) Laboratory Exercises


Venue: Eng I 1-1 (later, Labs B & C (Eng II))
Presenter: TA (5) (Assisted by RA (0)), Instructors: (0** & 2); TA (Labs): (1, 2, 3 & 10)
30 June - Part 2 MATLAB Exercises in Signal processing (Appendix E)
Venue: Eng 1 1-4 (later, NWII Labs)
Presenter: TA (12) (Assisted by TA (9)) & TA (Labs) (6, 7, 8 & 11)

Group D* [Group size: 124]


1 July - Part 2 MATLAB Exercises in Signal processing (Appendix E)
Venue: Eng 1 1-4 (later, NWII Labs)
Presenter: TA (12) (Assisted by TA (9)) & TA (Labs) (6, 7, 8 & 11)
Group E * [Group size: 123]
1 July Part 1 (Appendix B (continued)) Laboratory Exercises
Venue: Eng 1 1-1 (later, Labs B & C (Eng II))
Presenter: TA (5) (Assisted by RA (0)), Instructors: (0** & 3) & TA (Labs): (1, 2, 3 & 10)

*** Some instructors will not be available (as per ancillary examination invigilation time-tables)
** On 30 June 1 July, D Buys will be present as/if necessary, i.e. he will be partially available only.

*Group allocations (for students) are detailed on the course web-site (click on the link: study manual.)

3.

STUDY MATERIALS AND PURCHASES

Relevant study material is part of Appendix B-E. Additional study materials may be used/handed out (at the discretion of
the chief lecturer, teaching assistant, and/or presenters) during the course. Such study materials will also be available on
the module web site. Equipment manuals used during the course may not be taken out of the laboratory. Students are
referred to Appendix B for additional laboratory material (protoboard & cables) that is required.

4.

LEARNING ACTIVITIES

4.1

Contact time and learning hours

Number of lectures per week: 5 days (08h00-16h00) [27 June 2005-1 July 2005]
Laboratory work: Four experiments of five-six hours each day
4.2

Lectures

Lectures are presented in a style of co-operative and student-centred learning. Clarification and explanation of the subject
matter and concepts are given during the lectures. Students are advised not to take comprehensive notes during lectures.
The time should rather be used more effectively by concentrating on the lecturing and by active participation in
discussions. All the relevant study material is adequately referenced and is available on the module web site.
4.3

Laboratory work

See appendix B - E.

5.

RULES OF ASSESSMENT

Also see the examination regulations in the Year Books of the Faculty of Engineering, Built Environment and Information
Technology (Part 1: Engineering).
The following marking allocation will be used for assessment:
Part 1 (2 days)
Part 2 (2 days)
Part 3 (1 day)

Real laboratory exercises (Lab-book): 40 % (Appendix B)


Virtual laboratory exercises (Matlab): 40 % (Appendix C (30 %) & E (10 %))
Virtual laboratory exercises (ELVIS): 20 % (Appendix D)

The required exercises to be completed are provided on the module web-site (upon login)
Kindly note that this module has a strict attendance requirement. Attendance registers will be circulated at various times
of the module students must ensure that if they are not available (for instance, due to an ancillary examination) they
provide relevant documentation:
a) if such documentation is available electronically, please email the course co-ordinator directly, or
b) if such documentation is available in traditional (paper) form, please provide the documentation to
Mrs Tilla Loubser (CEFIM 2-4) Please ensure that your details (student number & name) clearly appears on such
documentation. Ms Loubser will scan/electronically forward such documentation to the course co-ordinator. It is
the candidates duty to ensure his/her name appears on such an attendance register. All relevant details relating to
the document must be very clear (in language)
Please note that it is the personal preference of the course co-ordinator to not handle paper/traditional correspondence
methods.
Please note that the final results (for this module) will be provided at the end of November, 2005 (as EMR100 is a year
course.) Results are available via the Faculty only (i.e. Level 6 of the Engineering Tower.) Results will appear on student
online within 24 working hours of release by the Faculty. This is anticipated by the 25th of November 2005.

6.

GENERAL

Grievance procedures and academic dishonesty


Refer to the EEC Guide.
Absence from certain scheduled activities
Since this is an attendance course, students are not allowed to miss any session of the course. Special cases may be
discussed (in writing) with Saurabh Sinha (Email is preferred: s.sinha@eng.up.ac.za) If permission to write any special
report is granted the language & formatting style is to be as in Appendix C of this study manual.
Posting of official notices
The announcement page on the module web site will be used for this purpose. Students must visit the site on two distinguished
occasions at least twice a week.

EXIT-LEVEL OUTCOMES FOR ENGINEERING BACHELOR'S DEGREES


(Excerpt from ECSA Document No. PE-61: Standards for Accredited University Bachelor's Degrees)

Required Outcomes:
The required outcomes of an accredited university bachelor's degree in engineering are defined in Sections 2.1 to 2.10.
2.1 Engineering Problem Solving
The B.Eng./B.Sc.(Eng.) graduate is competent to
Identify, assess, formulate and solve convergent and divergent engineering problems creatively and innovatively.
2.2 Application of fundamental and specialist knowledge
The B.Eng./B.Sc.(Eng.) graduate is competent to
Apply knowledge of mathematics, basic science and engineering sciences from first principles to solve engineering
problems, involving the following performances:
1. Bring mathematical, numerical analysis and statistical knowledge and methods to bear on engineering problems by
using an appropriate mix of:
a) Formal analysis and modelling of engineering components, systems or processes;
b) Communicating concepts, ideas and theories with the aid of mathematics;
c) Reasoning about and conceptualising engineering components, systems or processes using mathematical
concepts;
d) Dealing with uncertainty and risk through the use of probability and statistics.
2. Use physical laws and knowledge of the physical world as a foundation for the engineering sciences and the
solution of engineering problems by an appropriate mix of:
a) Formal analysis and modelling of engineering components, systems or processes using principles and
knowledge of the basic sciences;
b) Reasoning about and conceptualising engineering problems, components, systems or processes using
principles of the basic sciences.
3. Use the techniques, principles and laws of engineering science at a fundamental level and in at least one specialist
area to:
a) identify and solve open-ended engineering problems;
b) identify and pursue engineering applications;
c) work across engineering disciplinary boundaries through cross-disciplinary literacy and shared fundamental
knowledge.
2.3 Engineering Design and Synthesis
The B.Eng./B.Sc.(Eng.) graduate is competent to
Perform creative, procedural and nonprocedural design and synthesis of components, systems, works, products or
processes, involving the performances:
1. identify and formulate the design problem to satisfy user needs, applicable standards, codes of practice and
legislation;
2. plan and manage the design process: focus on important issues, recognise and deal with constraints;

3. acquire and evaluate the requisite knowledge, information and resources: apply correct principles, evaluate and use
design tools;
4. perform design tasks including analysis, quantitative modelling and optimisation;
5. evaluate alternatives and preferred solution: exercise judgement, test implementability and perform technoeconomic analyses;
6. assess impacts and benefits of the design: social, legal, health, safety, and environmental
7. communicate the design logic and information.
2.4 Investigations, experiments and data analysis
The B.Eng./B.Sc.(Eng.) graduate is competent to
1. Apply research methods.
2. Plan and conduct investigations and experiments using appropriate equipment.
3. Analyse, interpret and derive information from data.
2.5 Engineering methods, skills, tools and information technology
The B.Eng./B.Sc.(Eng.) graduate is competent to
1. Use appropriate engineering methods, skills and tools and assess the results they yield.
2. Use computer packages for computation, modelling, simulation, and information handling, involving:
a) assessment of the applicability and limitations of the package;
b) proper application and operation of the package;
c) critical testing and assessment of the end-results produced by the package.
3. Use computers and networks and information infrastructures for accessing, processing, managing, and storing
information to enhance personal productivity and teamwork.
4. Create computer applications as required by the discipline.
5. Bring basic techniques and knowledge to bear on engineering practice from economics, business management, and
health, safety and environmental protection.
2.6 Professional and General Communication
The B.Eng./B.Sc.(Eng.) graduate is competent to
1. Communicate effectively, both orally and in writing, with engineering audiences and the community at large, using
appropriate structure, style and graphical support;
2. Apply methods of providing information for use by others involved in engineering activity.
2.7 Impact of engineering activity on society and the environment
The B.Eng./B.Sc.(Eng.) graduate is critically aware of:
1. The impact of engineering activity on society and the environment.
2. The need to bring into engineering analysis and design considerations of:
a) the impact of technology on society;
b) the personal, social, cultural values and requirements of those affected by engineering activity.
2.8 Team and multidisciplinary working
The B.Eng./B.Sc.(Eng.) graduate is competent to
Work effectively as an individual, in teams and in multidisciplinary environments showing leadership and performing
critical functions.
2.9 Lifelong Learning
The B.Eng./B.Sc.(Eng.) graduate understands
1. The requirements to maintain continued competence and to keep abreast of up-to-date tools and techniques;
and is competent to
Engage in lifelong learning through well-developed learning skills.
2.10 Professional ethics and practice
The B.Eng./B.Sc.(Eng.) graduate is critically aware of
1. The need to act professionally and ethically and to take responsibility within own limits of competence;
and is competent to
2. Exercise judgement commensurate with knowledge and experience.

REAL LABORATORY
1. Practicum guide
The guidelines and information below refer only to practicals done in the Department of
Electrical, Electronic and Computer Engineering, but the compulsory laboratory note
book (item 5) may also be used for practicals in other Departments if this is not contrary
to the custom in other Departments.
1.1

Protoboard /breadboard and Cables

From the first to the fourth year, every student is expected to provide their own cables
and proto-board. Students are expected to buy their own proto-boards. Cables can be
bought from Miss Marie Pretorius, in Room 1-24, Engineering II Building. The
prescribed cables are:
3 x BNC to crocodile clips,
5 x Banana plug to crocodile clips,
1 x Banana plug to banana plug.
The price of the cables is R160-00 per set.
To acquire a set of cables from the department, students are requested to pay the
indicated amount into account number E1204-5391 at Client Services in the Human
Science Building. Upon presentation of the receipt, a set of cables can be obtained from
Miss Marie Pretorius in the above office. Cables must be obtained prior to the first
practicum in the lab. Without it, students will not be allowed to work in the laboratory.
1.2 General laboratory rules
In the laboratory, students should behave in accordance with the following general rules
that are also displayed on the walls in the laboratories:
(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
(i)
(j)

Take note of the "prohibited" signs in the laboratory.


After use, resistors and capacitors must be returned to their designated trays.
Components that had been distributed must be handed in at the end of the practical.
Connecting wire must also be returned.
Soldering irons without proper stands are prohibited.
Benches must be switched off at the end of the practical.
Chairs must be returned after use.
Tidy bench after use.
Defective equipment must be noted in designated fault books in the laboratory.
Students, who do not heed the above rules, could be prohibited from using the
laboratory again.

3.

After-hours access to laboratories

(a)

Students may obtain access to laboratories after hours by having their student cards
activated by Mr OKennedy, in Room 1-43, Engineering II Building.
Students may gain access to the laboratories only by using their own cards.
Only one person at a time may enter the laboratory through the booth.
Any deviation from the above rules may lead to students forfeiting the privilege of
using the laboratories.

(b)
(c)
(d)
4.

Indemnity of the University against claims. You will be expected to sign an


indemnity form, which will indemnify the University against any claims that might
arise from injuries or damage as a result of any incident that may occur in the
laboratories.

5.

Laboratory Notebooks

5.1

Introduction
Suggestions are made for the keeping of laboratory notes in terms of both legal
requirements, as well as to serve for the preparation of reports. Furthermore, such
notes also provide information, which can be used for the later traceability of
procedures in great detail. The information below specifies the format and
principles for the notebook and its use.
Although, students are not required to keep a laboratory notebook for EMR100, it is
recommended.

5.2 The laboratory note book and its format:


(a)

(b)
(c)

(d)
(e)

You MUST have a hardcover A4 sized laboratory notebook with bound pages. As
this notebook will in future be used for all practical work in the Department of
Electrical, Electronic and Computer Engineering, it is recommended that a thick
notebook with about 250 to 300 pages (125-150 sheets) be used.
All notes must be kept in ink. The reason is that black ink usually copies better
than other colours, and is more permanent than pencil.
All pages are to be sequentially numbered from beginning to end, preferably at the
top center, or alternatively left and right on opposite pages, in such a way that the
page number is clearly legible. All pages are normally numbered from 1 with odd
numbers to the right and even numbers to the left. The first inside page on the right
is page 1. It is recommended that the first four pages be used for the table of
contents and cross-references.
The title of each experiment as well as the date must appear at the head of the page.
The date must be unambiguous, for example, 3 Sep. '99 or 3 September 1999.
Under no circumstances should you use 3/7/99, or 7/3/99, or anything similar.
The name or names of the persons undertaking a task or performing an experiment
must be written immediately below the title.

(f)
(g)
(h)

If you have made a mistake, draw a single line neatly through the mistake. What
has been written must still be legible. You will be surprised how often such a small
item can jog your memory and lead to more productive work.
You must sign your name at the end of every set of notes for a specific lecture. It is
also a good habit to write the date immediately below your name. This procedure is
therefore regarded as a compulsory requirement.
Unused open space must be clearly 'cancelled' using a large Z or X. Nothing may
be written in this area at a later stage.

5.3 Evaluation

(a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
(i)

You will not be evaluated on the basis of handwriting, or style of note keeping,
other than as noted below. Please note the following:
Is the format of the notebook as specified, with page numbers, table of contents,
etc? Are the notes written in black ink?
Are the notes readable? Are all numbers and symbols clear and unambiguous?
Is the table of contents up to date?
Has each set of notes for a given day been signed along with an unambiguous date?
Does each task, experiment, etc. have a descriptive title, and date together with all
the information of the participants?
Are the notes written in the first person? Is it clear who did what?
Is the work adequately described so that another person can understand it easily
without further discussions with the author?
Have you made a note of the number of the workbench used, along with models
and numbers of relevant equipment?
Have you tried to put your own thoughts in the notes - no loose pieces of paper? In
other words, do you try to "think" in the notebook?

5.4 Summaries and Comment


The purpose of keeping notes is to encourage you as a future engineer to establish a good
habit, which will benefit you for the rest of your life. The notes you make at meetings and
in the laboratory can be of considerable value to a future employer and in your career.
Indeed, the notes serve as a working record of what happened and can be used for the
preparation of reports.
No additional time or homework is involved in the notes. The notes for a particular
assignment or experiment should be written in full immediately after completion,
otherwise the whole objective is missed. Therefore, there can be no question of writing
down the notes later on.

10

2.

Lab Safety

Acquaint yourself with the location of the following safety items within the lab.
a)
fire extinguisher
b)
first aid kit
c)
telephone and emergency numbers : Make sure that you have handy emergency
phone numbers to call for assistance if necessary. The extension for emergencies is
2310 or (012) 420 2310. If any safety questions arise, consult the lab instructor or
staff for guidance and instructions. The 24 hour crisis service line is
0800 00 64 28 (Toll free).
Observing proper safety precautions is important when working in the laboratory to
prevent injuries to yourself or others. The most common hazard is the electric shock
which can be fatal if one is not careful.
A.
Electric shock
Shock is caused by passing an electric current through the human body. The severity
depends mainly on the amount of current and is less a function of the applied voltage.
The threshold of electric shock is about 1 mA which usually gives an unpleasant tingling.
For currents above 10 mA, severe muscle pain occurs and the victim can't let go of the
conductor due to muscle spasm. Current between 100 mA and 200 mA (50 Hz AC)
causes ventricular fibrillation of the heart and is most likely to be lethal.
What is the voltage required for a fatal current to flow? This depends on the skin
resistance. Wet skin can have a resistance as low as 150 Ohm and dry skin may have a
resistance of 15 k ohm. Arms and legs have a resistance of about 100 Ohm and the trunk
200 Ohm.
This implies that 220 V can cause about 160 mA to flow in the body if the skin is wet and
thus be fatal. In addition skin resistance falls quickly at the point of contact, so it is
important to break the contact as quickly as possible to prevent the current from rising to
lethal levels.
Here are several safety precautions one should follow all the time:
B.

Equipment grounding

Grounding is very important. Improper grounding can be the source of errors, noise and a
lot of trouble.
Electric instruments and appliances have equipment cases that are electrically insulated
from the wires that carry the power. The isolation is provided by the insulation of the
wires as shown in figure A below. However, if the wire insulation gets damaged and
makes contact to the case, the case will be at the high voltage supplied by the wires. If the
user touches the instrument he or she will feel the high voltage. If, while standing on a

11

wet floor, a user simultaneously comes in contact with the instrument case and a pipe or
faucet connected to ground, a sizable current can flow through him or her, as shown in
Figure B. However, if the case is connected to the ground by use of a third (ground) wire,
the current will flow from the hot wire directly to the ground and bypass the user as
illustrated in figure C.

Equipment with a three wire cord is thus much safer to use. The ground wire (3rd wire)
which is connected to metal case, is also connected to the earth ground (usually a pipe or
bar in the ground) through the wall plug outlet.
C.
(a)
(b)
(c)
(d)
(e)

(f)

Safety Precautions
Do not work alone while working with high voltages or if you are using
electrically operated machinery like a drill.
Never leave high voltages on when you are not present.
Keep one hand in your pocket when probing high voltage circuits or
discharging capacitors.
Make sure all high voltage connections are adequately taped or otherwise
insulated to prevent accidental contact by you or neighboring students.
After switching power off, discharge any capacitors that were in the circuit.
Do not trust supposedly discharged capacitors. Certain types of capacitors can
build up a residual charge after being discharged. Use a shorting bar across the
capacitor, and keep it connected until ready for use.
If you use electrolytic capacitors, do not:
i)
put excessive voltage across them
ii)
put ac across them
iii)
connect them in reverse polarity.

12

(g)
(h)
(i)
(j)
(k)
(l)

(m)

Take extreme care using tools that can cause short circuits if accidental
contact is made to other circuit elements. Only tools with insulated handles
should be used.
If a person comes in contact with a high voltage, immediately shut off power.
Do not attempt to remove a person in contact with a high voltage unless you
are insulated from them.
In the event of an electrical fire do not use water. The lab fire extinguishers
are specifically charged for electrical fires. Vacate the lab and close the door.
Do not breath toxic smoke or fumes. Ring the fire alarm, if one is available.
Check wire current carrying capacity if you will be using high currents. The
lab power wiring can only handle 15 Amperes continuously.
Make sure your leads are rated to withstand the voltages you are using. This
includes instrument leads. Common wire insulation is rated for 600 Volts.
Avoid simultaneous touching of any metal chassis used as an enclosure for
your circuits and any pipes in the laboratory that may make contact with the
earth, such as a water pipe. Use a floating voltmeter to measure the voltage
from ground to the chassis to see if a hazardous potential difference exists.
Make sure that the lab instruments are at ground potential by using the ground
terminal supplied on the instrument.

13

3.

Basic Measurement

Alessandro Volta

Sir Charles Wheatstone

THERE IS NO RULE AGAINST ENJOYING THE EMR 100 LAB EXPERIENCE!


3.1

Breadboard / Prototype board


The figure below shows a typical protboard (GL-12N 172x65mm)

Components and wire links can be pushed into any of the holes. Inside the prototype
board, metal channels with springy contacts make connections with the components. The
metal channels are arranged in rows, as indicated below:

14

Some prototype boards have an easily removed base which lets you see this arrangement.
On each side of the board, there are two long channels connecting from top to bottom. In
the centre of the board, there is a gap, and on either side there are short channels, each
corresponding to a horizontal group of five holes.
What connections are needed to make a circuit? First, you need to connect a power
supply. The ground connection is made to one of the strips of holes on the left hand side
of the board. Connecting leads with BLACK-coloured insulation are used. The positive
end of the power supply is connected to the right hand side of the prototype board, using
leads with RED-coloured insulation.

15

3.2
What is the purpose of a resistors?
Resistors limit current. In a typical application, a resistor is connected in series with an
LED:

Enough current flows to make the LED light up, but not so much that the LED are
damaged. Later in this chapter, you will find out how to calculate a suitable value for this
resistor.
The 'box' symbol for a fixed resistor is popular in the UK and Europe. A 'zig-zag' symbol
is used in America and Japan:

Both symbols are commonly interchangeably used in South Africa.


Resistors are used with transducers to make sensor subsystems. Transducers are
electronic components, which convert energy from one form into another, where one of
the forms of energy is electrical. A light dependent resistor, or LDR, is an example of
an input transducer. Changes in the brightness of the light shining onto the surface of
the LDR result in changes in its resistance. As will be explained later, an input transducer
is most often connected along with a resistor to make a circuit called a potential divider.
In this case, the output of the potential divider will be a voltage signal, which reflects
changes in illumination.
Microphones and switches are input transducers. Output transducers include
loudspeakers, filament lamps and LEDs.

16

In other circuits, resistors are used to direct current flow to particular parts of the circuit,
or may be used to determine the voltage gain of an amplifier. Resistors are used with
capacitors to introduce time delays.
Most electronic circuits require resistors to make them work properly and it is obviously
important to find out something about the different types of resistors available, and to be
able to choose the correct resistor value, in , K, or M, for a particular application.
3.3

Fixed value resistors

The diagram shows the construction of a carbon film resistor:

During manufacture, a thin film of carbon is deposited onto a small ceramic rod. The
resistive coating is spiraled away in an automatic machine until the resistance between
the two ends of the rod is as close as possible to the correct value. Metal leads and end
caps are added, the resistor is covered with an insulating coating and finally painted with
colored bands to indicate the resistor value.
Carbon film resistors are cheap and easily available, with values within 10% or 5% of
their marked, or 'nominal' value. Metal film and metal oxide resistors are made in a
similar way, but can be made more accurately to within 2% or 1% of their nominal
value. There are some differences in performance between these resistor types, but none,
which affect their use in simple circuits.
Winding thin wire onto a ceramic rod makes wire wound resistors. They can be
made extremely accurately for use in multimeters, oscilloscopes and other measuring
equipment. Some types of wire wound resistors can pass large currents without
overheating and are used in power supplies and other high current circuits.

17

3.4

Colour code

How can the value of a resistor be worked out from the colours of the bands? Each
colour represents a number according to the following scheme:
Number

Colour

Black

brown

red

orange

yellow

green

blue

violet

grey

white

The first band on a resistor is interpreted as the FIRST DIGIT of the resistor value. For
the resistor shown below, the first band is yellow, so the first digit is 4:

The second band gives the SECOND DIGIT. This is a violet band, making the second
digit 7. The third band is called the MULTIPLIER and is not interpreted in quite the same
way. The multiplier tells you how many naughts you should write after the digits you
already have. A red band tells you to add 2 naughts. The value of this resistor is therefore
4700 ohms, that is, 4700, or 4.7k. Work through this example again to confirm that
you understand how to apply the colour code given by the first three bands.

18

The remaining band is called the TOLERANCE band. This indicates the percentage
accuracy of the resistor value. Most carbon film resistors have a gold-coloured tolerance
band, indicating that the actual resistance value is with + or - 5% of the nominal value.
Other tolerance colours are:
Tolerance Colour
1%

brown

2%

red

5%

gold

10%

silver

When you want to read off a resistor value, look for the tolerance band, usually gold, and
hold the resistor with the tolerance band at its right hand end. Reading resistor values
quickly and accurately isn't difficult, but it does take practice!
3.5

More about colour codes

The colour code as explained above allows you to interpret the values of any resistor
from 100 upwards. How does the code work for values less than 100 ? Here is the
code for 12:
Brown, red, black
The multiplier colour black represents the number 0 and tells you that no naughts should
be added to the first two digits, representing 1 and 2.
What would be the colour code for 47? The answer is:
yellow, violet, black
Using this method for indicating values between 10 and 100 means that all resistor
values require the same number of bands.
For values between 1 and 10 , the multiplier colour is changed to gold. For example,
the colours:
brown, black, gold
indicate a 1 resistor, while the colours:
red, red, gold
refer to a 2.2 resistor.

19

Metal film resistors, manufactured to 1 or 2% tolerance, often use a code consisting of


four coloured bands instead of three. The code works in the same way, with the first three
bands interpreted as digits and the fourth band as the multiplier. For example, a 1 metal
film resistor has the bands:
brown, black, black, brown (+brown or red for tolerance)
while a 56 metal film resistor has the bands:
green, blue, black, red
It is worth pointing out that the multiplier for metal film resistors with values from 1
upwards is brown (rather than red, as in the three colour system), while the multiplier for
10 upwards is red (instead of orange).
You are likely to use low value resistors and metal film resistors on some occasions and it
is useful to know how to read their codes. However, most of the resistors you use in
building electronic circuits will be carbon film types with values indicated using the three
band colour code. It is this system which you should master first.
3.6

E12 and E24 values

If you have any experience of building circuits, you will have noticed that resistors
commonly have values such as 2.2E, 3.3E, or 4.7E and are not available in equally
spaced values 2E, 3E, 4E, 5E and so on. Manufacturers don't produce values like these why not? The answer is partly to do with the fact that resistors are manufactured to a
percentage accuracy. Look at the table below which shows the values of the E12 and E24
series:
E12 series
10% tolerance

E24 series
5% tolerance

10

10
11

12

12
13

15

15
16

18

18
20

22

22
24

27

27
30

20

E12 series
10% tolerance

E24 series
5% tolerance

33

33
36

39

39
43

47

47
51

56

56
62

68

68
75

82

82
91

Resistors are made in multiples of these values, for example, 1.2 , 12 , 120 ,
1.2 k, 12 k, 120 k and so on.
Consider 100 and 120, adjacent values in the E12 range. 10% of 100 is 10 while
10% of 120 is 12. A resistor marked as 100 could have any value from 90 to
110, while a resistor marked as 120 might have an actual resistance from 108 to
132. The ranges of possible values overlap, but only slightly.
Further up the E12 range, a resistor marked as 680 might have and actual resistance of
up to 680+68=748, while a resistor marked as 820 might have a resistance as low as
820-82=738. Again, the ranges of possible values just overlap.
The E12 and E24 ranges are designed to cover the entire resistance range with the
minimum overlap between values. This means that, when you replace one resistor with
another marked as a higher value, its actual resistance is almost certain to be larger.
From a practical point of view, all that matters is for you to know that carbon film
resistors are available in multiples of the E12 and E24 values. Very often, having
calculated the resistance value you want for a particular application, you will need to
choose the nearest value from the E12 or E24 range.

21

3.7

Gustav Robert Kirchhoff

Born March 12, 1824, Knigsberg, Prussia [now Kaliningrad, Russia] died Oct. 17, 1887, Berlin,
Germany

Kirchhoff was one of the foremost physicists of the 19th century and is remembered as
one of the founders of the science of spectroscopy. He is also known for Kirchhoff's laws,
formulated in 1845 while he was still a student, which refer to the currents and
electromotive forces in electrical networks.
Kirchhoff's Current Law.
Stated another way
No matter how many paths into and out of a single point all the current leaving that point
must equal the current arriving at that point. Kirchhoff's circuit rules named after
Gustav Robert Kirchhofft are two statements about multi-loop electric circuits that
embody the laws of conservation of electric charge and energy and that are used to
determine the value of the electric current in each branch of the circuit.
Kirchoff's Current Law
The first rule, the junction theorem, states that the sum of the currents into a specific
junction in the circuit equals the sum of the currents out of the same junction. Electric
charge is conserved: it does not suddenly appear or disappear; it does not pile up at one
point and thin out at another.

22

Kirchhoff's Voltage Law


The second rule, the loop equation, states that around each loop in an electric circuit the
sum of the emf 's (electromotive forces, or voltages, of energy sources such as batteries
and generators) is equal to the sum of the potential drops, or voltages across each of the
resistances, in the same loop. All the energy imparted by the energy sources to the
charged particles that carry the current is just equivalent to that lost by the charge carriers
in useful work and heat dissipation around each loop of the circuit.

The algebraic sum of the voltages around any closed path is zero.

Stated another way


The voltage drops around any closed loop must equal the applied voltages.

When voltages are opposing as seen at the right, the difference is the voltage applied to
the circuit. In this case 4 volts must be dropped by the resistors to equal the applied
voltage.
3.8

Wheatstone Bridge

Sir Charles Wheatstone was a talented and versatile scientist. He invented the concertina,
experimented with stereoscopic photography and invented the stereoscope and played an
important part in the early development of telegraph communications. He didn't claim to
have invented the circuit named after him, but was among the first to exploit the circuit
effectively in making resistance measurements.
So, what is a Wheatstone bridge? This is the circuit:

23

It is obvious that the circuit consists of two voltage dividers. Suppose RX is an unknown
resistor value. RC is adjusted until Vout from the second voltage divider is equal to Vout
from the voltage divider containing RX . When the Vout values are equal, the bridge is said
to be balanced. The balance point can be detected by connecting either a voltmeter or an
ammeter across the output terminals. Both sorts of meter give a zero reading when
balance is achieved.
In a balanced circuit, the ratio RX / RA is equal to the ratio RB / RC . Rearranging:

In other words, if the values of RA , RB and RC are known, it is easy to calculate RX . In


Wheatstone bridge instruments, RA and RB were fixed and RC was adjusted on a sliding
scale in such a way that the value of RX could be read off directly.
Today, Wheatstone bridge circuits are not usually used to measure resistance values, but
they are used in designing sensor circuits.
A variometer is an instrument used in gliders to detect changes in air pressure due to
sudden changes in altitude. The variometer alerts the glider pilot to updrafts or thermals.
By circling within a thermal the pilot can gain height and keep flying for longer.

24

One type of variometer uses thermistors to monitor pressure changes:

Altitude changes cause pressure changes, which produce airflow. A heating element in
the flow passage heats air, which arrives at different temperatures at a thermistor sensor
upstream and downstream of the heating element depending on the rate of airflow.
The thermistor sensors are part of a Wheatstone bridge:

When the instrument is first set up, the preset resistor is adjusted for zero output. The
advantage of the Wheatstone bridge is that only temperature differences between the two
sensors will put the bridge out of balance. Cold or warm weather conditions affect both
sensors equally. Air flow into or out of the reference chamber has the opposite effect on
the two sensors: one will be heated by the air stream, while the other is cooled. As a
result, the output changes by more than it would if there was just a single sensor device.
By the way, Wheatstone bridge circuits are supposed to be difficult to understand. The
circuit is usually drawn as a diamond:

25

It's less obvious that you should be thinking about two voltage dividers, but once you
know, the action of the circuit is easy to follow.
Due to their outstanding sensitivity, Wheatstone Bridge Circuits are very advantageous
for the measurement of resistance, inductance, and capacitance. Wheatstone bridges are
widely used for strain measurements. A Quarter Bridge Wheatstone bridge is shown
below:

It consists of 4 resistors arranged in a diamond orientation. An input DC voltage, or


excitation voltage, is applied between the top and bottom of the diamond and the output
voltage is measured across the middle. When the output voltage is zero, the bridge is said
to be balanced. One or more of the legs of the bridge may be a resistive transducer, such
as a strain gage. The other legs of the bridge are simply completion resistors with
resistance equal to that of the strain gage(s). As the resistance of one of the legs changes,
by a change in strain from a resistive strain gage for example, the previously balanced
bridge is now unbalanced. This unbalance causes a voltage to appear across the middle of

26

the bridge. This induced voltage may be measured with a voltmeter or the resistor in the
opposite leg may be adjusted to rebalance the bridge. In either case the change in
resistance that caused the induced voltage may be measured and converted to obtain the
engineering units of strain.
3.9

Current limiting

You are now ready to calculate a value for the resistor used in series with an LED. Look
at the circuit diagram:

A typical LED requires a current of 10 mA and has a voltage of 2 V across it when it is


working. The power supply for the circuit is 9 V. What is the voltage across resistor R1?
The answer is 9-2=7 V. (The voltages across components in series must add up to the
power supply voltage.)
You now have two bits of information about R1: the current flowing is 10 mA, and the
voltage across R1 is 7 V. To calculate the resistance value, use the formula:

Substitute values for V and I:

Look out! The formula works with the fundamental units of resistance, voltage and
current, that is, ohms, volts and amps. In this case, 10 mA had to be converted into amps,
0.01 A, before substitution.
If a value for current in mA is substituted, the resistance value is given in K:

27

The calculated value for R1 is 700 . What are the nearest E12/E24 values? Resistors of
680, 750 and 820 are available. 680 is the obvious choice. This would allow a
current slightly greater than 10 mA to flow. Most LEDs are undamaged by currents of up
to 20 mA, so this is fine. What is the colour code for a 680 resistor?
Resistors in series and parallel
In a series circuit, the current flowing is the same at all points. The circuit diagram shows
two resistors connected in series with a 6 V power supply:

Resistors in series
It doesn't matter where in the circuit the current is measured, the result will be the same.
The total resistance is given by:

Rtotal = R1 R2
In this circuit, Rtotal=1+1=2 k. What will be the current flowing? The formula is:

Substituting:
mA

I=

V
6
=
= 3 mA
R 2k

Notice that the current value is in mA when the resistor value is substituted in k.
The same current, 3 mA, flows through each of the two resistors. What is the voltage
across R1? The formula is:
V = IR

28

Substituting:

What will be the voltage across R2? This will also be 3V. It is important to point out that
the sum of the voltages across the two resistors is equal to the power supply voltage.
The next circuit shows two resistors connected in parallel to a 6V power supply:

Resistors in parallel
Parallel circuits always provide alternative pathways for current flow. The total resistance
is calculated from:

Rtotal =

R1 R2
R1 + R2

This is called the product over sum formula and works for any two resistors in parallel.
An alternative formula is:

1
Rtotal

1
1
+
R1 R2

This formula can be extended to work for more than two resistors in parallel, but lends
itself less easily to mental arithmetic. Both formulae are correct.

29

The current can be calculated from:

I=

V
6
=
= 12 mA
R 0.5k

How does this current compare with the current for the series circuit? It's more. This is
sensible. Connecting resistors in parallel provides alternative pathways and makes it
easier for current to flow. How much current flows through each resistor? Because they
have equal values, the current divides, with 6mA flowing through R1, and 6mA through
R2.
To complete the picture, the voltage across R1 can be calculated as:

V = IR = 6 mA 1 k = 6 V
This is the same as the power supply voltage. The top end of R1 is connected to the
positive terminal of the battery, while the bottom end of R1 is connected to the negative
terminal of the battery. With no other components in the way, it follows that the voltage
across R1 must be 6V. What is the voltage across R2? By the same reasoning, this is also
6V. When components are connected in parallel, the voltage across them is the same.
Here is a slightly more complex circuit, with both series and parallel parts:

Circuit with series and parallel resistors


To find the overall resistance, the first step is to calculate the resistance of the parallel
elements. You already know that the combined resistance of two 1K resistors in parallel
is 0.5 K, so the total resistance in the circuit is 1+0.5=1.5. The power supply current
is:

I=

6
V
=
= 4 mA
R 1.5k

30

This is the current which flows through R1. How much current will flow through R2?
Since there are two equally easy pathways, 2mA will flow through R2, and 2mA through
R3.
The voltage across R1 is given by:

V = 4 mA 1 k = 4 V
This leaves 2V across R2 and R3, as confirmed by the calculation for R2:

V = 2 mA 1 k = 2 V
Again, the sum of the voltages around the circuit is equal to the power supply voltage.
Check through this section carefully. A clear understanding of the concepts involved will
help tremendously.
3.10

Power rating

When current flows through a resistance, electrical energy is converted into heat. This is
obvious in an electric torch where the lamp filament heats up and glows white hot.
Although the result may be less evident or imperceptible, exactly the same process of
energy conversion goes on when current flows through any electronic component.
The power output of a lamp, resistor, or other component, is defined as the rate of change
of electrical energy to heat, light, or some other form of energy. Power is measured in
watts, W, or milliwatts, mW, and can be calculated from:
P = VI where P is power.
What is the power output of a resistor when the voltage across it is 6V, and the current
flowing through it is 100
mA?
0.6W of heat are generated in this resistor. To prevent overheating, it must be possible for
heat to be lost, or dissipated, to the surroundings at the same rate.
A resistor's ability to lose heat depends to a large extent upon its surface area. A small
resistor with a limited surface area cannot dissipate (=lose) heat quickly and is likely to
overheat if large currents are passed. Larger resistors dissipate heat more effectively.

31

Look at the diagram below which shows resistors of different sizes:

The standard size of carbon film resistor used in most circuits has a power rating of
0.5W. This means that a resistor of this size can lose heat at a maximum rate of 0.5W. In
the example above, the calculated rate of heat loss was 0.6W, so that a resistor with a
higher power rating, 1W or 2 W, would be needed. Some resistors are designed to pass
very large currents and are cased in aluminium with fins to increase surface area and
promote heat loss.
Input and signal processing subsystems in electronic circuits rarely involve large currents,
but power rating should be considered when circuits drive output transducers, such as
lamps, LEDs, and loudspeakers.

32

3.11

Voltage divider

What is a voltage divider?


The diagram below shows a light dependent resistor, or LDR, together with its circuit
symbol:

The light-sensitive part of the LDR is a wavy track of cadmium sulphide. Light energy
triggers the release of extra charge carriers in this material, so that its resistance falls as
the level of illumination increases.
A light sensor uses an LDR as part of a voltage divider.
The essential circuit of a voltage divider, also called a potential divider, is:

As you can see, two resistors are connected in series. With Vin, which is often the power
supply voltage, connected above Rtop.
The output voltage Vout is the voltage across Rbottom and is given by:

33

It may help you to remember that Rbottom appears on the top line of the formula because
Vout is measured across Rbottom.
This is an extremely useful formula which you should learn thoroughly
What happens if one of the resistors in the voltage divider is replaced by an LDR? In the
circuit below, Rtop is a 10
resistor, and an LDR is used as Rbottom:
Suppose the LDR has a resistance of 500
shade (these values are reasonable).

, 0.5

, in bright light, and 200

in the

When the LDR is in the light, Vout will be:

In the shade, Vout will be:

In other words, this circuit gives a LOW voltage when the LDR is in the light, and a
HIGH voltage when the LDR is in the shade. The voltage divider circuit gives an output

34

voltage, which changes with illumination. A sensor subsystem which functions like this
could be thought of as a 'dark sensor' and could be used to control lighting circuits,
which are switched on automatically in the evening. Perhaps this does not seem terribly
exciting, but almost every sensor circuit you can think of uses a voltage divider. There's
just no other way to make sensor subsystems work.
Here is the voltage divider built with the LDR in place of Rtop:

What effect does this have on Vout?


The action of the circuit is reversed. That is, Vout becomes HIGH when the LDR is in the
light, and LOW when the LDR is in the shade. Substitute the appropriate values in the
voltage divider formula to convince yourself that this is true.
3.12

Temperature sensors

A temperature-sensitive resistor is called a thermistor. There are several different types:

35

The resistance of most common types of thermistor decreases as the temperature rises.
They are called negative temperature coefficient, or ntc, thermistors. Note the -t next
to the circuit symbol. A typical ntc thermistor is made using semiconductor metal oxide
materials. (Semiconductors have resistance properties midway between those of
conductors and insulators.) As the temperature rises, more charge carriers become
available and the resistance falls. Although less often used, it is possible to manufacture
positive temperature coefficient, or PTC, thermistors. These are made of different
materials and show an increase in resistance with temperature. How could you make a
sensor circuit for use in a fire alarm? You want a circuit, which will deliver a HIGH
voltage when hot conditions are detected. You need a voltage divider with the ntc
thermistor in the Rtop position:

How could you make a sensor circuit to detect temperatures less than 4C to warn
motorists that there may be ice on the road? You want a circuit, which will give a HIGH
voltage in cold conditions. You need a voltage divider with the thermistor in place of
Rbottom:

This last application raises an important question: How do you know what value of Vout
you are going to get at 4C?

36

4.

Capacitor

4.1

What Exactly Is A Capacitor?

First the history to understand where the 'capacitor' or condensor came from and how it
was developed. In 1745 a new physics and mathematics professor at the
University of Leyden (spelled Leiden in modern Dutch), Pieter van
Musschenbroek (1692 - 1791) and his assistants Allmand and Cunaeus
from the Netherlands invented the 'capacitor' (electro-statice charge or
capacitance actually) but did not know it at first. His condenser was called
the 'Leyden Jar' (pronounced: LY'duhn) and named so by Abbe Nollet.
This Leyden jar consisted of a narrow-necked glass jar coated over part of its inner and
outer surfaces with a conductive metallic substance; a conducting rod or wire passes
through as insulating stopper (cork) in the neck of the jar and contacts the inner foil layer,
which is separated from the outer layer by the glass wall. The Leyden jar was one of the
first devices used to store an electric charge. If the inner layers of foil and outer layers of
foil are then connected by a conductor, their opposite charges will cause a spark that
discharges the jar. van Musschenbroek's very first 'condenser' was nothing more than a
beer glass!
By modern standards, the Leyden jar is inefficient. It is rarely used except in exciting
laboratory demonstrations of capacitance, and exiting they are! Benjamin Franklin was
acquainted with the Leyden Jar experiments also so he decided to test his ideas that
'charge' could also be caused by thunder and lightning. Franklin tested his theories, in
Philadelphia in June 1752, via his now famous
'Electrical Fluid Theory' to prove that lightning
was an electrical phenomenon. What he did was
fly a kite, which had a metal tip. The kite was
tied with wet conducting thin hemp cord and at
the end he attached a metal key to which a nonconducting silk string was attached which he
held in his hand; when he held his knuckles near
the key he could draw sparks from it. Although
his experiment was completed successfully and
the results as he had calculated before, the next couple people after him who tried the
hazardous experiment were killed by lightning strikes. Franklin was extremely lucky with
his hazardous experiments. We believe there is some sort of "time-line" in which
inventions are invented 'no matter what'.

37

A similar device was invented independently by Ewald Georg von Kleist, Dean of the
Kamin Cathedral in Pomerania, at about the same time (October 1745), but these facts
were not published immediately at that particular time. As a matter of fact, Van
Musschebroek announced his discovery in January, 1746. However, a letter dated
February 4, 1745 appearing in Philosophical Transactions suggests that the jar existed in
Van Musschenbroek's laboratory almost a year before that date. There is still some
residual controversy about this but the generally held opinion is: "Trembley, the editor, or
the composter of the letter in PT either misdated the letter, or failed to translate properly
into the new style (NS). Until 1752 the English began their legal year on March 25 so
that, roughly speaking, their dates where a year behind continental ones for the first
quarter of every continental year. This makes sense because there would be no reason for
Van Musschenbroek and his staff to delay announcing for 11 months, especial given the
potential claim to prior discovery by Von Kleist.
Look at the picture at the left; the worlds
first illustration of the working of a
Leyden Jar, by Abbe Jean-Antoine
Nollet!
Trembley's letter is fascinating as it is
one of the earliest first-hand accounts of
this new discovery. He happened to be in
Holland about the time of the discovery
and his letter was the first word to
England of the marvelous new jar.
Georg von Kleist tried using an
electrostatic generator to place a charge
on an iron nail inside a small glass
bottle. Again later in 1745, a lawyer by
the name of Anreas Cunaeus who
frequently visited one the laboratories at
the University of Leiden, was trying to
electrify water. He used a chain hanging
into a flask of water, and brought the end
of the chain into contact with an
electrostatic generator. In both cases, after disconnecting the generator, the experimenter
touched the metal nail or chain inside the flask with one hand while the other hand still
surrounded the outside of the container, and got zapped with an electric shock as a result.
But Van Musschenbroek and Von Kleist were certainly not the only ones playing with
static discharge or electromagnetism. The Greeks, by means of Greek philosopher Thales
of Miletus, had already determined that fact in around 600 BC by charging up Lodestone
with a piece of amber and a sheeps skin. Lodestone (sometimes called incorrectly
Loadstone) was used in ancient times for navigation at sea. Another Greek philosopher,

38

Theophrastus, stated that this power is possessed by other substances about three
centuries later.
The first scientific study of electrical and magnetic phenomena, however, did not appear
until AD 1600, when the researches of the English physician William Gilbert were
published. Gilbert was the first to apply the term electric (Greek electron, "amber") to the
force that such substances exert after rubbing. He also distinguished between magnetic
and electric action.

Capacitors are funny things, creating enormous problems when troubleshooting for a
fault and are absolutely necessary for almost every electronic circuit. They come in a
variety of sizes, shapes, models, or if you so desire they can be manufactured by your
specifications. They also come in a variety of materials, to name a few: Aluminum foil,
Polypropylene, Polyester (Mylar), Polystyrene, Polycarbonate, Kraft Paper, Mica, Teflon,
Epoxy, Oil-filled, Electrolyte, Tantalum, and the list goes on. Latest product (in research)
is Niobium. The value of a capacitor can vary from a fraction of a pico-Farad to more
than a million Farad ( means 'micro'). Voltage levels can range from a couple to a
substantial couple hundred thousand volts. The largest capacitor in my own collection is
150.000 F at 10Volts. A big sucker measuring about 10 x 5 inches! Does it still work?
You bet! It will still zap the soles of your shoes... I use it on occasion to recondition
shorted NiCad batteries which I use for my Radio Control gear.
The basic unit of capacitance is the Farad. Clumsy and not very practical to work with,
capacitance is usually measured in microFarads, abbreviated F, or picoFarads (pF). The
unit Farad is used in converting formulas and other calculations. A F (microFarad) is on
millionth of a Farad (10-6 F) and a pF picoFarad is onemillionth of a microFarad (10-12 F).
What exactly is a 'Capacitor'? A capacitor is a device that
stores an electrical charge or energy on it's plates. These
plates (see Fig. 1), a positive and a negative plate, are placed very close together with an
insulator in between to prevent the plates from touching each other. A capacitor can carry

39

a voltage equal to the battery or input voltage. Usually a capacitor has more than two
plates depending on the capacitance or dielectric type.
The 'Charge' is called the amount of stored electricity on the plates, or actually the
electric field between theses plates, and is proportional to the applied voltage and
capacitor's 'capacitance'.
The Formula to calculate the amount of capacitance is Q = C * V where:

Q = Charge in Coulombs

Capacitance in Farads

V = Voltage in Volts
There is also something else involved when there is 'charge', something stored called
'Energy'.
The formula to calculate the amount of energy is: W = V2 * C / 2 where:

W = Energy in Joules

V = Voltage in Volts

C = Capacitance in Farads
Charge a capacitor. Put a voltage on the legs of the capacitor and wait till current stops
flowing. It goes very fast. Do NOT exceed the capacitor's working breakdown voltage or,
in case of an electrolytic capacitor, it will explode. The break down voltage is the voltage
that when exceeded will cause the dielectric (insulator) inside the capacitor to break
down and conduct. If that happens the results can be catastrophic. And in case of a
polarized capacitor, watch the orientation of the positive and negative poles. A healthy,
good quality capacitor (disconnected) can hold a charge for a long time. From seconds to
several hours and some for several days depending on its size.
Capacitors are used as:
(a)

(b)

(c)

(d)

dc blocking devices - a capacitor will pass ac or rf but not dc. That is often the
function of coupling capacitors in circuits. The coupling capacitor will pass our
required signal but block the dc supply from the previous stage e.g. .001 uF (1000
pF or 1N0).
supply by-pass capacitor - a capacitor used to pass ac or rf. Examples include bypass of a dc supply to an emitter bypass capacitor. When used on a dc supply line
the capacitor shunts (shorts) to ground any unwanted ac or rf to avoid
contamination of our supply e.g. 0.1 uF (100,000 pF or 100N).
reservoir by-pass capacitor - Used in the output of a dc rectifier to smooth out the
power line ac pulses and as a reservoir between the charging pulses. Think of it as a
big water storage tank. This is where you have the high value capacitors e.g. 10,000
uF / 63V. (10,000U)
emitter by-pass capacitor - In the case of an emitter by-pass our transistor may, as
one example, be considered as two distinct models. One under dc conditions which
sets up how we want the transistor to operate and another under ac or rf conditions

40

e.g. as an amplifier. In this case our emitter by-pass capacitor merely makes any
emitter resistor invisible for ac or rf purposes typical values might range from 2.2
uF down to 0.1 uF. (2U2 down to 100N).
4.2

Capacitor Codes

How to read all those different codes, it is not as difficult as it appears to be. Except for
the electrolytic and large types of capacitors, which usually have the value printed on
them like 470F 25V or something, most of the smaller caps have two or three numbers
printed on them, some with one or two letters added to that value. Check out the little
table below.
Have a look at Fig. 2 and Fig. 3. As you can see it all looks very simple. If a capacitor is
marked like this 105, it just means 10+5zeros = 10 + 00000 = 1.000.000pF = 1000 nF = 1
F. And that's exactly the way you write it too. Value is in pF (PicoFarads). The letters
added to the value is the tolerance and in some cases a second letter is the temperature
coeficient mostly only used in military applications, so basically industrial stuff.

So, for example, it you have a ceramic capacitor with 474J printed on it, it means:
47+4zeros = 470000 = 470.000pF, J=5% tolerance. (470.000pF = 470nF = 0.47F) The
only major thing to get used to is to recognize if the code is F nF, or pF.
Other capacitors may just have 0.1 or 0.01 printed on them. If so, this means a value in
F. Thus 0.1 means just 0.1 F. If you want this value in nanoFarads just move the
comma three places to the right which makes it 100nF.
But the average hobbyist uses only a couple of types like the common electrolytic and
ceramic capacitors and depending on the application, a more temperature stable type like
metal-film or polypropylene.

41

The larger the plate area and the smaller the area between the plates, the larger the
capacitance. Which also depends on the type of insulating material between the plates
which is the smallest with air. (You see this type of capacitor sometimes in high-voltage
circuits and are called 'spark-caps'.) Replacing the air space with an insulator will
increase the capacitance many times over. The capacitance ratio using an insulator
material is called Dielectric Constant while the insulator material itself is called just
Dielectric. Using the table in Fig. 4, if a Polystyrene dielectric is used instead of air, the
capacitance will be increased 2.60 times.

Look below for a more detailed explanation for the most commonly used caps.

42

Electrolytic - Made of electrolyte, basically conductive


salt in solvent. Aluminum electrodes are used by using
a thin oxidation membrane. Most common type,
polarised capacitor. Applications: Ripple filters, timing
circuits. Cheap, readily available, good for storage of charge (energy). Not
very accurate, marginal electrical properties, leakage, drifting, not suitable
for use in hf circuits, available in very small or very large values in F.
They WILL explode if the rated working voltage is exceeded or polarity is
reversed, so be careful. When you use this type capacitor in one of your
projects, the rule-of-thumb is to choose one which is twice the supply
voltage. Example, if your supply power is 12 volt you would choose a
24volt (25V) type. This type has come a long way and characteristics have
constantly improved over the years. It is and always will be an all-time
favorite; unless something better comes along to replace it. But I don't
think so for this decade; polarized capacitors are heavily used in almost
every kind of equipment and consumer electronics.

43

Tantalum - Made of Tantalum Pentoxide. They are electrolytic capacitors


but used with a material called tantalum for the electrodes. Superior to
electrolytic capacitors, excellent temperature and frequency characteristics.
When tantalum powder is baked in order to solidify it, a crack forms inside.
An electric charge can be stored on this crack. Like electrolytics, tantalums
are polarized so watch the '+' and '-' indicators. Mostly used in analog signal
systems because of the lack of current-spike-noise. Small size fits
anywhere, reliable, most common values readily available. Expensive, easily damaged by
spikes, large values exists but may be hard to obtain. Largest in my own collection is
220F/35V, beige color.
Super Capacitors - The Electric Double Layer capacitor is a
real miracle piece of work. Capacitance is 0.47 Farad (470,000
F). Despite the large capacitance value, its physical
dimensions are relatively small. It has a diameter of 21 mm
(almost an inch) and a height of 11 mm (1/2 inch). Like other
electrolytics the super capacitor is also polarized so exercise
caution in regards to the break-down voltage. Care must be
taken when using this capacitor. It has such large capacitance
that, without precautions, it would destroy part of a powersupply such as the bridge
rectifier, volt regulators, or whatever because of the huge inrush current at charge. For a
brief moment, this capacitor acts like a short circuit when the capacitor is charged.
Protection circuitry is a must for this type.
Polyester Film - This capacitor uses a thin polyester film as a dielectric. Not as
high a tolerance as polypropylene, but cheap, temperature stable, readily
available, widely used. Tolerance is approx 5% to 10%. Can be quite large
depending on capacity or rated voltage and so may not be suitable for all
applications.
Polypropylene - Mainly used when a higher tolerance is needed then
polyester caps can offer. This polypropylene film is the dielectric.Very little
change in capacitance when these capacitors are used in applications within
frequency range 100KHz. Tolerance is about 1%. Very small values are
available .

Polystyrene - Polystyrene is used as a dielectric. Constructed like a coil


inside so not suitable for high frequency applications. Well used in filter
circuits or timing applications using a couple hundred KHz or less.
Electrodes may be redish of color because of copper leaf used or silver
when aluminum foil is used for electrodes.

44

Metalized Polyester Film - Dielectric made of Metal-Oxide. Good


quality, low drift, temperature stable. Because the electrodes are thin
they can be made very small. Good all-round capacitor.

Epoxy - Manufactured using epoxy based polymers as dielectric. Widely


available, stable, cheap. Can be quite large depending on capacity or rated
voltage and so may not be suitable for all applications.

Ceramic - Constructed with materials such as titanium acid barium for


dielectric. Internally these capacitors are not constructed as a coil, so
they are well suited for use in high frequency applications. Typically
used to by-pass high frequency signals to ground. They are shaped like a
disk, available in very small capacitance values and very small sizes.
Together with the electrolytics the most widely available and used capacitor around.
Comes in very small size and value, very cheap, reliable. Subject to drifting depending on
ambient temperature. NPO types are the temperature stable types. They are identified by
a black stripe on top.
Multilayer Ceramic - Dielectric is made up of many layers. Small in
size, very good temperature stability, excellent frequency stable
characteristics. Used in applications to filter or bypass the high
frequency to ground. They don't have a polarity. *Multilayer caps suffer from high-Q
internal (parallel) resonances - generally in the VHF range. The CK05 style 0.1F/50V
caps for example resonate around 30MHz. The effect of this resonance is effectively no
apparent capacitance near the resonant frequency. As with all ceramic capacitors, be
careful bending the legs or spreading them apart to close to the disc body or they may get
damaged.
Silver-Mica - Mica is used as a dielectric. Used in resonance circuits,
frequency filters, and military RF applications.Highly stable, good
temperature coefficient, excellent for endurance because of their frequency
characteristics, no large values, high voltage types available, can be
expensive but worth the extra dimes.
Adjustable Capacitors - Also called trimmer capacitors or variable
capacitors. It uses ceramic or plastic as a dielectric.Most of them
are color coded to easily recognize their tunable size. The ceramic
type has the value printed on them. Colors are: yellow (5pF), blue
(7pF), white (10pF), green (30pF), brown (60pf). There are a
couple more colors like red, beige, and purple which are not listed here. Anyways, you
get the idea...

45

Tuning or 'air-core' capacitors.


They use the
surrounding air as a dielectric. I have seen these
variable capacitor types of incredible dimensions,
especially the older ones. Amazing it all worked.
Mostly used in radio and radar equipment. This type
usually have more (air) capacitors combined (ganged)
and so when the adjustment axel is turned, the capacitance of all of them changes
simultaneously. The one on the right has a polyester film as a dielectric constant and
combines two independant capacitors plus included is a trimmer cap, one for each side.

A selection of high voltage capacitors

46

4.3

Combining Capacitors & Formula's:

Is it possible to combine capacitors to get to a certain value like we do with resistors?


Certainly! Check below how go about it.
Capacitors in Parallel
Capacitors connected in parallel, which is the
most desirable, have their capacitance added
together, which is just the opposite of parallel
resistors. It is an excellent way of increasing the
total storage capacity of an electric charge:
Ctotal = C1 + C2 + C3
Keep in mind that only the total capacitance changes, not the supplied voltage. Every
single capacitor will see the same voltage, no matter what. Be careful not to exceed the
specified voltage on the capacitors when combining them all with different voltage
ratings, or they may explode. Example: say you have three capacitors with voltages of
16V, 25V, and 50V. The voltage must not exceed the lowest voltage, in this case the 16V
one. As a matter of fact, and a rule-of-thumb, always choose a capacitor which is twice
the supplied input voltage. Example: If the input voltage is 12V you would select a 24V
type (in real life 25V).
Capacitors in Series:
Again, just the opposite way of calculating resistors. Multiple capacitors
connected in series with each other will have the total capacitance lower
than the lowest single value capacitor in that circuit. Not the preferred
method but acceptable.
For a regular two capacitor series combo use this simple formula:

If you have two identical capacitors in series the formula is simplicity itself:
microFarads (F)

nanoFarads (nF)

picoFarads (pF)

0.000001F

= 0.001nF

= 1pF

0.00001F

= 0.01nF

= 10pF

0.0001F

= 0.1nF

= 100pF

0.001F

= 1nF

= 1000pF

0.01F

= 10nF

= 10,000pF

47

0.1F

= 100nF

= 100,000pF

1F

= 1000nF

= 1,000,000pF

10F

= 10,000nF

= 10,000,000pF

100F

= 100,000nF

= 100,000,000pF

Table 1
Capacitance Conversion
Capacitor Identification Codes
There are no international agreements in place to standardise capacitor identification.
Most plastic film types (Figure1) have printed values and are normally in microfarads or
if the symbol is n, nanofarads. Working voltage is easily identified. Tolerances are upper
case letters: M = 20%, K = 10%, J = 5%, H = 2.5% and F = 1pF.

A more difficult scheme is shown in Figure 2 with examples. The unit is picofarads and
the third number is a multiplier. A capacitor coded 474K63 means 47 10000 pF which
is equivalent to 470000 pF or 0.47 microfarads. K indicates 10% tolerance. 50, 63 and
100 are working volts.

Figure 2

48

Ceramic disk capacitors have many marking schemes. Capacitance, tolerance, working
voltage and temperature coefficient may be found. See Figure 3. Capacitance values are
given as number without any identification as to units. (uF, nF, pF) Whole numbers
usually indicate pF and decimal numbers such as 0.1 or 0.47 are microfarads. Odd
looking numbers such as 473 is the previously explained system and means 47 nF.

Figure 3

Figure 4

Figure 4 shows some other miscellaneous schemes.

49

5. Diodes
There are many different kinds of diodes. On these two pages I show circuits
applications using the small signal diodes, the rectifier diodes and the zener
diodes.
Small signal diodes are used to transform low current AC to DC, detect
(demodulate) radio signals, multiply voltages, perform logic and a few other
functions. A diode will not conduct until the forward voltage reaches a certain
threshold point. For a silicon diode this voltage is about 0.6 volts and slightly less
for a germanium diode.
Power rectifier diodes are functionally identical to the signal diodes and can
handle much more current. Some are very large to absorb excess heat and may
require a heat sink.
Zener diodes are designed to have a specific reverse voltage breakdown. It means
that they can function like a switch. They also can be very large to absorb heat
and may require a heat sink.

The Zener diode needs a current limiting resistor (Rs) to maintain its voltage regulating
point. The zener current is constant regardless of load.

5.1

Light Emitting Diodes

A Light Emitting Diode is commonly called LED. The light emitted by an LED
has a narrow wavelength as compared to an incandescent lamp which contains
many wavelengths. When an LED begins to conduct, the voltage increases
gradually while the current increases rapidly. Too much current will overheat the
LED and eventually destroy it. The light emitted by an LED is directly
proportional to current through the LED. The light output from an overheated
LED will soon decrease and the LED may be damaged.
The forward voltage and wavelength of an LED are directly related, so, it is not
always possible to substitute a different LED without changing the voltage and
current. Many different materials are used to make various LEDs. Below is a table
50

showing the general description of wavelength and voltage operation for some
LEDs.
Wavelength (nm) Voltage Wavelength (nm) Voltage
565 (green)

2.2 - 3.0 690 (red)

2.2 - 3.0

590 (yellow)

2.2 - 3.0 880 (infrared)

2.2 - 2.5

615 (orange)

1.8 - 2.7 900 (infrared)

1.2 - 1.6

640 (red)

1.6 - 2.0 940 (infrared)

1.3 - 1.7

In all applications, LEDs specified operating current limit must be respected for
longevity and I have found that operating LEDs at their current limit does not
significantly produce more brilliance than at 50% of their current rating and
ensure long operating life for most LEDs. Having said that, I must point out that
for some infrared LED types, reducing the operating current may also affect a
specified detecting range.
Circuit no-1 below shows the formula and procedure to find the proper resistance
value to be used to limit the operating current for all LED types, including
infrared.

Connecting several LEDs in series can be used but I strongly do not recommend
it. Regardless of good current calculation and voltage regulation one or more
LEDs are bound to fail as an open circuit which can be a real pain trouble
shooting to find and replace the bad LEDs. If one or more LEDs fail as a short
than other LEDs in the string may well be destroyed by excess current load, an
expensive proposition.

51

6.

The history of Analogue meters

Weston Model 151 Voltmeter

1913

Weston Model 355 Frequency Meter

1900

Westinghousetype SX Ammeter
1913

An analogue meter moves a needle along a scale. Switched range analogue multimeters
are very cheap but are difficult for beginners to read accurately, especially on resistance
scales. The meter movement is delicate and dropping the meter is likely to damage it!
Each type of meter has its advantages. Used as a voltmeter, a digital meter is usually
better because its resistance is much higher, 1 M or 10 M, compared to 200 for a
analogue multimeter on a similar range. On the other hand, it is easier to follow a slowly
changing voltage by watching the needle on an analogue display.
Used as an ammeter, an analogue multimeter has a very low resistance and is very
sensitive, with scales down to 50 A. More expensive digital multimeters can equal or
better this performance.
Most modern multimeters are digital and traditional analogue types are destined to
become obsolete.
6.1

Using a multimeter

The practical work introduces you to using a multimeter to make measurements from
circuits. Once you are able to test circuits, you will understand better how they work and
be able to locate and correct faults.
What do meters measure?
A meter is a measuring instrument. An ammeter measures current, a voltmeter measures
the potential difference (voltage) between two points, and an ohmmeter measures
resistance. A multimeter combines these functions, and possibly some additional ones as
well, into a single instrument.
Before going in to detail about multimeters, it is important for you to have a clear idea of
how meters are connected into circuits. Diagrams A and B below show a circuit before
and after connecting an ammeter:

52

Diagram A

Diagram B

To measure current, the circuit must be broken to allow the ampmeter to be connected in
series
Ammeters must have a LOW resistance. Think about the changes you would have to
make to a practical circuit in order to include the ammeter. To start with, you need to
break the circuit so that the ammeter can be connected in series. All the current flowing
in the circuit must pass through the ammeter. Meters are not supposed to alter the
behaviour of the circuit, or at least not significantly, and it follows that an ammeter must
have a very LOW resistance.
Diagram C shows the same circuit after connecting a voltmeter:

Diagram C
To measure potential difference (voltage), the circuit is not changed. The voltmeter is
connected in parallel. Voltmeters must have a HIGH resistance.
This time, you do not need to break the circuit. The voltmeter is connected in parallel
between the two points where the measurement is to be made. Since the voltmeter
53

provides a parallel pathway, it should take as little current as possible. In other words, a
voltmeter should have a very HIGH resistance.
Which measurement technique do you think will be the more useful? In fact, voltage
measurements are used much more often than current measurements.
The processing of electronic signals is usually thought of in voltage terms. It is an added
advantage that a voltage measurement is easier to make. The original circuit does not
need to be changed. Often, simply touching them to the points of interest connects the
meter probes.
An ohmmeter does not function with a circuit connected to a power supply. If you want
to measure the resistance of a particular component, you must take it out of the circuit
altogether and test it separately, as shown in diagram D:

Diagram D
To measure resistance, the component must be removed from the circuit altogether.
Ohmmeters work by passing a current through the component being tested.
Ohmmeters work by passing a small current through the component and measuring the
voltage produced. If you try this with the component connected into a circuit with a
power supply, the most likely result is that the meter will be damaged. Most multimeters
have a fuse to help protect against misuse.
6.2

Digital multimeters

Multimeters are designed and mass-produced for electronics engineers. Even the simplest
and cheapest types may include features, which you are not likely to use. Digital meters
give an output in numbers, usually on a liquid crystal display.

54

The picture below shows switched range multimeters:

Switched range multimeters


The central knob has lots of positions and you must choose which one is appropriate for
the measurement you want to make. If the meter is switched to 20 V DC, for example,
then 20 V is the maximum voltage which can be measured, This is sometimes called
20 V fsd, where fsd is short for full scale deflection.
For circuits with power supplies of up to 20 V, which includes all the circuits you, are
likely to build, the 20 V DC voltage range is the most useful. DC ranges are indicated by
on the meter. Sometimes, you will want to measure smaller voltages, and in this
case, the 2 V or 200 mV ranges are used.

55

What does DC mean? DC means direct current. In any circuit, which operates from a
steady voltage source, such as a battery, current flow is always in the same direction.
Every constructional project described in Design Electronics works in this way.
AC means alternating current. In an electric lamp connected to the domestic mains
electricity, current flows first one way, then the other. That is, the current reverses, or
alternates, in direction. With SA mains, the current reverses 50 times per second.

For safety reasons, you must NEVER connect a multimeters to the mains supply.
, on your multimeters.
You are not at all likely to use the AC ranges, indicated by
An alternative style of multimeters is the auto ranging multimeters:

Auto ranging multimeter

56

The central knob has fewer positions and all you need to do is to switch it to the quantity
you want to measure. Once switched to V, the meter automatically adjusts its range to
give a meaningful reading, and the display includes the unit of measurement, V or mV.
This type of meter is more expensive, but obviously much easier to use.
Where are the two-meter probes connected? The black lead is always connected into the
socket marked COM, short for COMMON. The red lead is connected into the socket
labeled V mA. The 10A socket is very rarely used.

57

7.

Introducing signals

Heinrich Hertz

Joseph Fourier

Voltage/time, V/t, graphs to describe the characteristics of different types of signals.


The Practical introduces the oscilloscope, a key instrument for measuring and displaying
V/t graphs.
In electronic circuits things happen. Voltage/time, V/t, graphs provide a useful method of
describing the changes which take place.

The diagram above shows the V/t graph, which represents a DC signal:
This is a horizontal line a constant distance above the X-axis. In many circuits, fixed DC
levels are maintained along power supply rails, or as reference levels with which other
signals can be compared.

58

Compare this graph with the V/t graphs for several types of alternating, or AC, signals:

As you can see, the voltage levels change with time and alternate between positive values
(above the X-axis) and negative values (below the X-axis). Signals with repeated shapes
are called waveforms and include sine waves, square waves, triangular waves and saw
tooth waves. A distinguishing feature of alternating waves is that equal areas are
enclosed above and below the X-axis.
7.1

Sine waves

A sine wave has the same shape as the graph of the sine function used in trigonometry.
Rotating electrical machines such as dynamos and power station turbines produce sine
waves and electrical energy is transmitted to the consumer in this form. In electronics,
sine waves are among the most useful of all signals in testing circuits and analyzing
system performance.

59

Look at the sine wave in more detail:

The terms defined below are needed to describe sine waves and other waveforms
precisely:
7.2

Period: T: The period is the time taken for one complete cycle of a repeating
waveform. The period is often thought of as the time interval between peaks, but
can be measured between any two corresponding points in successive cycles.

7.3

Frequency: f: This is the number of cycles completed per second. He measurement


unit for frequency is the hertz, Hz. 1 Hz = 1 cycle per second. If you know the
period, the frequency of the signal can be calculated from:

Conversely, the period is given by:

Signals you are likely to use vary in frequency from about 0.1 Hz, through values in
kilohertz, kHz (thousands of cycles per second) to values in megahertz, MHz (millions
of cycles per second). Gigahertz, GHZ
7.4

Amplitude: In electronics, the amplitude, or height, of a sine wave is measured in


three different ways. The peak amplitude, Vp, is measured from the X-axis, 0 V, to
the top of a peak, or to the bottom of a trough. (In physics 'amplitude' usually refers
to peak amplitude.) The peak-to-peak amplitude, Vpp, is measured between the
maximum positive and negative values. In practical terms, this is often the easier
measurement to make. It's value is exactly twice Vp.

60

Although peak and peak-to-peak values are easily determined, it is often more useful to
know the root mean square, or rms amplitude of the wave, where:

or
And:
Or

What is rms amplitude and why is it important?


The rms amplitude is the DC voltage, which will deliver the same average power as
the AC signal.
To understand this, think about two lamps connected to alternative power supplies:

The brightness of the lamp illuminated from the AC supply looks constant but the current
flowing in the lamp is changing all the time and alternates in direction, flowing first one
way and then the other. There is no current flowing at the instant that the AC signal
crosses the X-axis. What you see is the average brightness produced by the AC signal.
The second lamp is illuminated from a DC supply and its brightness really is constant
because the current flowing is always the same. It is obviously possible to adjust the
voltage of the DC supply until the two lamps are equally bright. When this happens, the
DC supply is providing the same average power as the AC supply. At this point, the DC
voltage is equal to the Vrms value for the AC signal.
A bit of mathematics is needed to explain why the equivalent DC value is called the root
mean square value know about this. What is important at this stage is to remember that
the AC signal and its rms equivalent provide the same average power.

61

7.5

Phase: It is sometimes useful to divide a sine wave into degrees, , as follows:

Remember that rotating electrical machines generates sine waves. A complete 360 turn
of the voltage generator corresponds to one cycle of the sine wave. Therefore 180
corresponds to a half turn, 90 to a quarter turn and so on. Using this method, any point
on the sine wave graph can be identified by a particular number of degrees through the
cycle.
If two sine waves have the same frequency and occur at the same time, they are said to be
in phase:

On the other hand, if the two waves occur at different times, they are said to be out of
phase. When this happens, the difference in phase can be measured in degrees, and is
called the phase angle, . As you can see, the two waves in part B are a quarter cycle out
of phase, so the phase angle = 90.

62

7.6

Listening to waves

It can be helpful in understanding what is meant by 'frequency' and 'amplitude' to


compare the sounds produced when different waves are played through a loudspeaker.
Not all frequencies are audible. The hi-fi range is defined as from 20 Hz to 20 kHz,
approximately the same as the range of frequencies, which can normally be detected. As
you get older, you will find it more and more difficult to hear higher frequencies.
Experience suggests that, by the time you are able to afford a decent hi-fi system, you
will probably be unable to fully appreciate its performance.
The pitch of a musical note is the same as its frequency.
The intensity or loudness of a musical note is the same as its amplitude.
Your ears are particularly sensitive to sounds in the middle range, from about 500 Hz to
2 kHz, corresponding with the range of frequencies found in human speech. Telephone
systems have a poor high frequency performance but do work effectively in this middle
range. When you design an alarm system with an audible output, it is important to keep
the frequency of the alarm sounds within this middle range. The graphs below show
waveforms of different frequency and amplitude.

63

These sine wave signals produce a 'pure' sounding tone. If the amplitude is increased, the
sound is louder. If the frequency is increased, the pitch of the sound is higher.

64

Other shapes of signal generate sounds with the same fundamental pitch, but can sound
different. Compare the sine wave sounds with square signals at 500 Hz and 1 kHz:

The square wave sound is harsher because the signal contains additional frequencies
which are multiples of the fundamental frequency. These additional frequencies are
called harmonics. Sounds from different musical instruments are distinguished by their
harmonic content.

65

7.8

Making waves

Sine waves can be mixed with DC signals, or with other sine waves to produce new
waveforms. Here is one example of a complex waveform:

'Complex' doesn't mean difficult to understand. A waveform like this can be thought of as
consisting of a DC component with a superimposed AC component. It is quite easy to
separate these two components using a capacitor, as will be explained in Chapter 5.
More dramatic results are obtained by mixing a sine wave of a particular frequency with
exact multiples of the same frequency, in other words, by adding harmonics to the
fundamental frequency. The V/t graphs below show what happens when a sine wave is
mixed with its 3rd harmonic (3 times the fundamental frequency) at reduced amplitude,
and subsequently with its 5th and 7th harmonics:

66

As you can see, as more odd harmonics are added, the waveform begins to look more and
more like a square wave.
This surprising result illustrates a general principle first formulated by the French
mathematician Joseph Fourier, namely that any complex waveform can be built up from a
pure sine waves plus particular harmonics of the fundamental frequency. Square waves,
triangular waves and sawtooth waves can all be produced in this way.
7.9

Other signals

This part of the Chapter outlines the other types of signal you are going to meet. Circuits
which generate these signals are versatile building blocks and many practical examples
are given later in Design Electronics.
7.10 Square waves: Like sine waves, square waves are described in terms of period,
frequency and amplitude:

Peak amplitude, Vp, and peak-to-peak amplitude, Vpp, are measured as you might expect.
However, the rms amplitude, Vrms, is greater than that of a sine wave. Remember that the
rms amplitude is the DC voltage which will deliver the same power as the signal. If a
square wave supply is connected across a lamp, the current flows first one way and then
the other. The current switches direction but its magnitude remains the same. In other
words, the square wave delivers its maximum power throughout the cycle so that Vrms is
equal to Vp. (If this is confusing, don't worry, the rms amplitude of a square wave is not
something you need to think about very often.)
Although a square wave may change very rapidly from its minimum to maximum
voltage, this change cannot be instantaneous. The rise time of the signal is defined as the
time taken for the voltage to change from 10% to 90% of its maximum value. Rise times
are usually very short, with durations measured in nanoseconds (1ns = 10-9s), or
microseconds (1s = 10-6s), as indicated in the graph.

67

7.11 Pulse waveforms: Pulse waveforms look similar to square waves, except that all
the action takes place above the X-axis. At the beginning of a pulse, the voltage
changes suddenly from a LOW level, close to the X-axis, to a HIGH level, usually
close to the power supply voltage:

Sometimes, the 'frequency' of a pulse waveform is referred to as its repetition rate. As


you would expect, this means the number of cycles per second, measured in hertz, Hz.
The HIGH time of the pulse waveform is called the mark, while the LOW time is called
the space. The mark and space do not need to be of equal duration. The mark space
ratio is given by:

A mark space ratio = 1.0 means that the HIGH and LOW times are equal, while a mark
space ratio = 0.5 indicates that the HIGH time is half as long as the LOW time:

A mark space ratio of 3.0 corresponds to a longer HIGH time, in this case, three times as
long as the space.

68

Another way of describing the same types of waveform uses the duty cycle, where:

When the duty cycle is less than 50%, the HIGH time is shorter than the LOW time, and
so on.
A subsystem which produces a continuous series of pulses is called an astable. Section 8
describes pulse waveforms in more detail and explains how to build a variety of astable
circuits. As you will discover, it is useful to be able to change the duration of the pulse to
suit particular applications. Other pulse-producing subsystems include monostables and
bistables, Section 8.
7.13 Ramps: A voltage ramp is a steadily increasing or decreasing voltage, as shown
below:

The ramp rate is measured in units of volts per second, V/s. Such changes cannot
continue indefinitely, but stop when the voltage reaches a saturation level, usually close
to the power supply voltage.
7.14 Triangular and sawtooth waves: These waveforms consist of alternate positivegoing and negative-going ramps. In a triangular wave, the rate of voltage change is
equal during the two parts of each cycle, while in a sawtooth wave, the rates of
change are unequal. Sawtooth generator circuits are an essential building block in
oscilloscope and television systems.
7.15 Audio signals: As already mentioned, sound frequencies which can be detected by
the human ear vary from a lower limit of around 20 Hz to an upper limit of about
20 kHz. A sound wave amplified and played through a loudspeaker gives a pure
audio tone. Audio signals like speech or music consist of many different
frequencies. Sometimes it is possible to see a dominant frequency in the V/t graph
of a musical signal, but it is clear that other frequencies are present.

69

7.16 Noise: A noise signal consists of a mixture of frequencies with random amplitudes:

70

Noise can originate in various ways. For example, heat energy increase the random
motion of electrons and results in the generation of thermal noise in all components,
although some components are 'noisier' than others. Additional sources of noise include
radio signals, which are detected and amplified by many circuits, not just by radio
receivers. Interference is caused by the switching of mains appliances, and 'spikes' and
'glitches' are caused by rapid changes in current and voltage elsewhere in an electronic
system.
Designers try to eliminate or reduce noise in most circuits, but special noise generators
are used in electronic music synthesizers and for other musical effects.

71

8.

Oscilloscope

Practical introduces the oscilloscope, a key instrument for measuring and displaying V/t
graphs.
An oscilloscope is easily the most useful instrument available for testing circuits because
it allows you to see the signals at different points in the circuit. The best way of
investigating an electronic system is to monitor signals at the input and output of each
system block, checking that each block is operating as expected and is correctly linked to
the next? With a little practice, you will be able to find and correct faults quickly and
accurately.
An oscilloscope is an impressive piece of equipment and is very expensive. Handle it
whit care!!
How does an oscilloscope work?
An outline explanation of how an oscilloscope works can be given using the block
diagram shown below:
Like a television screen, the screen of an oscilloscope consists of a cathode ray tube.
Although the size and shape are different, the operating principle is the same. Inside the
tube is a vacuum. The electron beam emitted by the heated cathode at the rear end of the
tube is accelerated and focused by one or more anodes, and strikes the front of the tube,
producing a bright spot on the phosphorescent screen.
The electron beam is bent, or deflected, by voltages applied to two sets of plates fixed in
the tube. The horizontal deflection plates, or X-plates produce side-to-side movement. As
you can see, they are linked to a system block called the time base. This produces a saw
tooth waveform. During the rising phase of the saw tooth, the spot is driven at a uniform
rate from left to right across the front of the screen. During the falling phase, the electron
beam returns rapidly from right to left, but the spot is 'blanked out' so that nothing
appears on the screen.
In this way, the time base generates the X-axis of the V/t graph.
The slope of the rising phase varies with the frequency of the saw tooth and can be
adjusted, using the TIME/DIV control, to change the scale of the X-axis. Dividing the
oscilloscope screen into squares allows the horizontal scale to be expressed in seconds,
milliseconds or microseconds per division (s/DIV, ms/DIV, s/DIV). Alternatively, if the
squares are 1 cm apart, the scale may be given as s/cm, ms/cm or s/cm.
The signal to be displayed is connected to the input. The AC/DC switch is usually kept in
the DC position (switch closed) so that there is a direct connection to the Y-amplifier. In
the AC position (switch open) a capacitor is placed in the signal path. As will be
explained in Chapter 5, the capacitor blocks DC signals but allows AC signals to pass.

72

The Y-amplifier is linked in turn to a pair of Y-plates so that it provides the Y-axis of the
V/t graph. The overall gain of the Y-amplifier can be adjusted, using the VOLTS/DIV
control, so that the resulting display is neither too small nor too large, but fits the screen
and can be seen clearly. The vertical scale is usually given in V/DIV or mV/DIV.
The trigger circuit is used to delay the time base waveform so that the same section of the
input signal is displayed on the screen each time the spot moves across. The effect of this
is to give a stable picture on the oscilloscope screen, making it easier to measure and
interpret the signal.
Changing the scales of the X-axis and Y-axis allows many different signals to be
displayed. Sometimes, it is also useful to be able to change the positions of the axes. This
is possible using the X-POS and Y-POS controls. For example, with no signal applied,
the normal trace is a straight line across the center of the screen. Adjusting Y-POS allows
the zero level on the Y-axis to be changed, moving the whole trace up or down on the
screen to give an effective display of signals like pulse waveforms which do not alternate
between positive and negative values.

The diagram shows Faced with an instrument like this, students typically respond either
by twiddling every knob and pressing every button in sight, or by adopting a glazed
expression. Neither approach is especially helpful. Following the systematic description
below will give you a clear idea of what an oscilloscope is and what it can do.
The function of an oscilloscope is extremely simple: it draws a V/t graph, a graph of
voltage against time, voltage on the vertical or Y-axis, and time on the horizontal or Xaxis.

73

As you can see, the screen of this oscilloscope has 8 squares or divisions on the vertical
axis, and 10 squares or divisions on the horizontal axis. Usually, these squares are 1cm in
each direction:

Many of the controls of the oscilloscope allow you to change the vertical or horizontal
scales of the V/t graph, so that you can display a clear picture of the signal you want to
investigate. 'Dual trace' oscilloscopes display two V/t graphs at the same time, so that
simultaneous signals from different parts of an electronic system can be compared.
The oscilloscope has a built in source of signals, which allow you to check that the
oscilloscope is working properly. A connection to the input of channel 1, CH 1, of the
oscilloscope can be made using a special connector called a BNC plug, as shown below:

74

The diagram shows a lead with a BNC plug at one end and crocodile clips at the other.
When the crocodile clip from the red wire is clipped to the lower metal terminal, a 2 V
square wave is connected to the input of CH 1.
Adjust VOLTS/DIV and TIME/DIV until you obtain a clear picture of the 2 V signals,
which should look like this:
The diagram shows Faced with an instrument like this, students typically respond either
by twiddling every knob and pressing every button in sight, or by adopting a glazed
expression. Neither approach is especially helpful. Following the systematic description
below will give you a clear idea of what an oscilloscope is and what it can do.
The function of an oscilloscope is extremely simple: it draws a V/t graph, a graph of
voltage against time, voltage on the vertical or Y-axis, and time on the horizontal or Xaxis.
As you can see, the screen of this oscilloscope has 8 squares or divisions on the vertical
axis, and 10 squares or divisions on the horizontal axis. Usually, these squares are 1 cm
in each direction:
Check on the effect of Y-POS 1 and X-POS:
75

What do these controls do?


Y-POS 1 moves the whole trace vertically up and down on the screen, while X-POS
moves the whole trace from side to side on the screen. These controls are useful because
the trace can be moved so that more of the picture appears on the screen, or to make
measurements easier using the grid, which covers the screen.
You have now learned about and used the most important controls on the oscilloscope.
You know that the function of an oscilloscope is to draw a V/t graph. You know how to
put all the controls into their 'normal' positions, so that a trace should appear when the
oscilloscope is switched on. You know how the change the horizontal scale of the V/t
graphs, how to change the vertical scale, and how to connect and display a signal.
What is needed now is practice so that all of these controls become familiar.
The function generator has a push button controls for On/Off switching and for selecting
sine, square, or triangular wave shapes. Most often the 600 outputs is used. This can be
connected to the CH 1 input of the oscilloscope using a BNC-BNC lead, as follows:

76

Switch the function generator on and adjust the output level to produce a visible signal on
the oscilloscope screen. Adjust TIME/DIV and VOLTS/DIV to obtain a clear display and
investigate the effects of pressing the waveform shape buttons.
Once the crocodile clip corresponding to the black lead has been connected to 0 V, it can
be ignored. This leaves the test probe which can be connected to any point in the circuit
to monitor the signals present.

77

8.

555 TIMER

8.1

Introduction

As electronic designs get bigger, it becomes difficult to build the complete circuit. So we
will use prebuilt circuits that come in packages. This prebuilt circuit is called an IC. IC
stands for Integrated Circuit. An IC has many transistors inside it that are connected
together to form a circuit. Metal pins are connected to the circuit and the circuit is stuck
into a piece of plastic or ceramic so that the metal pins are sticking out of the side. These
pins allow you to connect other devices to the circuit inside. We can buy simple ICs that
have several inverter circuits like the one we built in the LED and Transistor tutorial or
we can buy complex ICs like a Pentium Processor.
The IC Time Machine and was also the very first and only commercial timer ic
available. It provided circuit designers and hobby tinkerers with a relatively cheap, stable,
and user-friendly integrated circuit for both monostable and astable applications. Since
this device was first made commercially available, a myrad of novel and unique circuits
have been developed and presented in several trade, professional, and hobby publications.
The past ten years some manufacturers stopped making these timers because of
competition or other reasons. Yet other companies, like NTE (a subdivision of Philips)
picked up where some left off.
This primer is about this fantastic timer which is after 30 years still very popular and used
in many schematics. Although these days the CMOS version of this IC, like the Motorola
MC1455, is mostly used, the regular type is still available, however there have been
many improvements and variations in the circuitry. But all types are pin-for-pin plug
compatible. Myself, every time I see this 555 timer used in advanced and high-tech
electronic circuits, I'm amazed. It is just incredible.
In this tutorial I will show you what exactly the 555 timer is and how to properly use it by
itself or in combination with other solid
state devices without the requirement of
an engineering degree. This timer uses a
maze of transistors, diodes and resistors
an d for this complex reason I will use a
more simplified (but accurate) block
diagram to explain the internal
organizations of the 555. So, lets start
slowly and build it up from there.
The first type-number, in Table 1 on the
left, represents the type which was/is
preferred for military applications which
have somewhat improved electrical and
thermal characteristics over their
commercial counterparts, but also a bit

78

more expensive, and usually metal-can or ceramic casing. This is analogous to the 7400
series convention for TTL integrated circuits.

The 555, in fig. 1 and fig. 2 above, come in two packages, either the round metal-can
called the 'T' package or the more familiar 8-pin DIP 'V' package. About 20-years ago the
metal-can type was pretty much the standard (SE/NE types). The 556 timer is a dual 555
version and comes in a 14-pin DIP package, the 558 is a quad version with four 555's
also in a 14 pin DIP case.

Inside the 555 timer, at fig. 3, are the equivalent of over 20 transistors, 15 resistors, and 2
diodes, depending of the manufacturer. The equivalent circuit, in block diagram,
providing the functions of control, triggering, level sensing or comparison, discharge, and
power output. Some of the more attractive features of the 555 timer are: Supply voltage
79

between 4.5 and 18 volt, supply current 3 to 6 mA, and a Rise/Fall time of 100 nSec. It
can also withstand quite a bit of abuse.
The Threshold current determine the maximum value of Ra + Rb. For 15 volt operation
the maximum total resistance for R (Ra +Rb) is 20 Mega-ohm.
The supply current, when the output is 'high', is typically 1 milli-amp (mA) or less. The
initial monostable timing accuracy is typically within 1% of its calculated value, and
exhibits negligble (0.1%/V) drift with supply voltage. Thus longterm supply variations
can be ignored, and the
temperature variation is only
50ppm/C (0.005%/C).
All IC timers rely upon an
external capacitor to determine
the off-on time intervals of the
output pulses. As you recall from
your study of basic electronics, it
takes a finite period of time for a
capacitor (C) to charge or
discharge through a resistor (R).
Those times are clearly defined
and can be calculated given the
values
of
resistance
and
capacitance.
The basic RC charging circuit is
shown in fig. 4. Assume that the
capacitor is initially discharged.
When the switch is closed, the capacitor begins to charge through the resistor. The
voltage across the capacitor rises from zero up to the value of the applied DC voltage.
The charge curve for the circuit is shown in fig. 6. The time that it takes for the capacitor
to charge to 63.7% of the applied voltage is known as the time constant (t). That time can
be calculated with the simple expression:
t=RXC
Assume a resistor value of 1 MegaOhm and a capacitor value of 1uF (micro-Farad). The
time constant in that case is:
t = 1,000,000 X 0.000001 = 1 second
Assume further that the applied voltage is 6 volts. That means that it will take one time
constant for the voltage across the capacitor to reach 63.2% of the applied voltage.
Therefore, the capacitor charges to approximately 3.8 volts in one second.

80

Fig. 4-1, Change in the input pulse frequency allows completion of the timing cycle. As a
general rule, the monostable 'ON' time is set approximately 1/3 longer than the expected
time between triggering pulses. Such a circuit is also known as a 'Missing Pulse detector

Looking at the curve in fig. 6. you can see that it takes approximately 5 complete time
constants for the capacitor to charge to almost the applied voltage. It would take about 5
seconds for the voltage on the capacitor to rise to approximately the full 6-volts.

8.2

Definition of Pin Functions:

Pin 1 (Ground): The ground (or common) pin is the most-negative supply potential of
the device, which is normally connected to circuit common when operated from positive
supply voltages.
Pin 2 (Trigger): This pin is the input to the lower comparator and is used to set the
latch, which in turn causes the output to go high. This is the beginning of the timing
sequence in monostable operation. Triggering is accomplished by taking the pin from
above to below a voltage level of 1/3 V+ (or, in general, one-half the voltage appearing at
pin 5). The action of the trigger input is level-sensitive, allowing slow rate-of-change
waveforms, as well as pulses, to be used as trigger sources.
One precaution that should be observed with the trigger input signal is that it must not
remain lower than 1/3 V+ for a period of time longer than the timing cycle. If this is
allowed to happen, the timer will retrigger itself upon termination of the first output
pulse. Thus, when the timer is driven in the monostable mode with input pulses longer
than the desired output pulse width, the input trigger should effectively be shortened by
differentiation.
The minimum-allowable pulse width for triggering is somewhat dependent upon pulse
level, but in general if it is greater than the 1S (micro-Second), triggering will be
reliable.
A second precaution with respect to the trigger input concerns storage time in the lower
comparator. This portion of the circuit can exhibit normal turn-off delays of several
microseconds after triggering; that is, the latch can still have a trigger input for this period
of time after the trigger pulse. In practice, this means the minimum monostable output

81

pulse width should be in the order of 10uS to prevent possible double triggering due to
this effect.
The voltage range that can safely be applied to the trigger pin is between V+ and ground.
A dc current, termed the trigger current, must also flow from this terminal into the
external circuit. This current is typically 500nA (nano-amp) and will define the upper
limit of resistance allowable from pin 2 to ground. For an astable configuration operating
at V+ = 5 volts, this resistance is 3 Mega-ohm; it can be greater for higher V+ levels.
Pin 3 (Output): The output of the 555 comes from a high-current totem-pole stage made
up of transistors Q20 - Q24. Transistors Q21 and Q22 provide drive for source-type
loads, and their Darlington connection provides a high-state output voltage about 1.7
volts less than the V+ supply level used. Transistor Q24 provides current-sinking
capability for low-state loads referred to V+ (such as typical TTL inputs). Transistor Q24
has a low saturation voltage, which allows it to interface directly, with good noise
margin, when driving current-sinking logic. Exact output saturation levels vary markedly
with supply voltage, however, for both high and low states. At a V+ of 5 volts, for
instance, the low state Vce(sat) is typically 0.25 volts at 5 mA. Operating at 15 volts,
however, it can sink 100mA if an output-low voltage level of 2 volts is allowable (power
dissipation should be considered in such a case, of course). High-state level is typically
3.3 volts at V+ = 5 volts; 13.3 volts at V+ = 15 volts. Both the rise and fall times of the
output waveform are quite fast, typical switching times being 100nS.
The state of the output pin will always reflect the inverse of the logic state of the latch,
and this fact may be seen by examining Fig. 3. Since the latch itself is not directly
accessible, this relationship may be best explained in terms of latch-input trigger
conditions. To trigger the output to a high condition, the trigger input is momentarily
taken from a higher to a lower level. [see "Pin 2 - Trigger"]. This causes the latch to be
set and the output to go high. Actuation of the lower comparator is the only manner in
which the output can be placed in the high state. The output can be returned to a low state
by causing the threshold to go from a lower to a higher level [see "Pin 6 - Threshold"],
which resets the latch. The output can also be made to go low by taking the reset to a low
state near ground [see "Pin 4 - Reset"].
Pin 4 (Reset): This pin is also used to reset the latch and return the ouput to a low state.
The reset voltage threshold level is 0.7 volt, and a sink current of 0.1mA from this pin is
required to reset the device. These levels are relatively independent of operating V+
level; thus the reset input is TTL compatible for any supply voltage.
The reset input is an overriding function; that is, it will force the output to a low state
regardless of the state of either of the other inputs. It may thus be used to terminate an
output pulse prematurely, to gate oscillations from "on" to "off", etc. Delay time from
reset to output is typically on the order of 0.5 uS, and the minumum reset pulse width is
0.5 uS. Neither of these figures is guaranteed, however, and may vary from one
manufacturer to another. When not used, it is recommended that the reset input be tied to
V+ to avoid any possibility of false resetting.

82

Pin 5 (Control Voltage): This pin allows direct access to the 2/3 V+ voltage-divider
point, the reference level for the upper comparator. It also allows indirect access to the
lower comparator, as there is a 2:1 divider (R8 - R9) from this point to the lowercomparator reference input, Q13. Use of this terminal is the option of the user, but it does
allow extreme flexibility by permitting modification of the timing period, resetting of the
comparator, etc.
When the 555 timer is used in a voltage-controlled mode, its voltage-controlled operation
ranges from about 1 volt less than V+ down to within 2 volts of ground (although this is
not guaranteed). Voltages can be safely applied outside these limits, but they should be
confined within the limits of V+ and ground for reliability.
In the event the control-voltage pin is not used, it is recommended that it be bypassed
with a capacitor of about 0.01uF (10nF) for immunity to noise, since it is a comparator
input.
Pin 6 (Threshold): Pin 6 is one input to the upper comparator (the other being pin 5)
and is used to reset the latch, which causes the output to go low.
Resetting via this terminal is accomplished by taking the terminal from below to above a
voltage level of 2/3 V+ (the normal voltage on pin 5). The action of the threshold pin is
level sensitive, allowing slow rate-of-change waveforms.
The voltage range that can safely be applied to the threshold pin is between V+ and
ground. A dc current, termed the threshold current, must also flow into this terminal from
the external circuit. This current is typically 100nA, and will define the upper limit of
total resistance allowable from pin 6 to V+. For either timing configuration operating at
V+ = 5 volts, this resistance is 16 Mega-ohm.
Pin 7 (Discharge): This pin is the open collector of an npn transistor (Q14), the emitter
of which goes to ground. The conduction state of this transistor is identical in timing to
that of the output stage. It is "on" (low resistance to ground) when the output is low and
"off" (high resistance to ground) when the output is high.
In both the monostable and astable time modes, this transistor switch is used to clamp the
appropriate nodes of the timing network to ground. Saturation voltage is typically below
100mV (milli-Volt) for currents of 5 mA or less, and off-state leakage is about 20nA
(these parameters are not specified by all manufacturers, however).
Maximum collector current is internally limited by design, thereby removing restrictions
on capacitor size due to peak pulse-current discharge. In certain applications, this open
collector output can be used as an auxiliary output terminal, with current-sinking
capability similar to the output (pin 3).

Pin 8 (V +): The V+ pin (also referred to as Vcc) is the positive supply voltage terminal
of the 555 timer IC. Supply-voltage operating range for the 555 is +4.5 volts (minimum)

83

to +16 volts (maximum), and it is specified for operation between +5 volts and + 15
volts. The device will operate essentially the same over this range of voltages without
change in timing period. Actually, the most significant operational difference is the
output drive capability, which increases for both current and voltage range as the supply
voltage is increased. Sensitivity of time interval to supply voltage change is low, typically
0.1% per volt.

Try the simple 555 testing-circuit of Fig. 5. to get you going, and test all your 555 timer
ic's. I build several for friends and family. I bring my own tester to ham-fests and what
not to instantly do a check and see if they are oscillating. Or use as a trouble shooter in
555 based circuits. This tester will quickly tell you if the timer is functional or not.
Although not foolproof, it will tell if the 555 is shorted or oscillating. If both Led's are
flashing the timer is most likely in good working order. If one or both Led's are either off
or on solid the timer is defective.

The capacitor slows down as it charges, and in actual fact never reaches the full supply
voltage. That being the case, the maximum charge it receives in the timing circuit (66.6%
of the supply voltage) is a little over the charge received after a time constant 63.2%)

84

.
The capacitor slows down as it discharges, and never quite reaches the ground potential.
That means the minimum voltage it operates at must be greater than zero. Timing circuit
is 63.2% of the supply voltage.

The discharge of a capacitor also takes time and we can shorten the amount of time by
decreasing resistance (R) to the flow of current.
Operating Modes: The 555 timer has two basic operational modes: one shot and astable.
In the one-shot mode, the 555 acts like a monostable multivibrator. A monostable is said
to have a single stable state--that is the off state. Whenever it is triggered by an input
pulse, the monostable switches to its temporary state. It remains in that state for a period
of time determined by an RC network. It then returns to its stable state. In other words,
the monostable circuit generates a single pulse of a fixed time duration each time it
receives and input trigger pulse. Thus the name one-shot. One-shot multivibrators are
used for turning some circuit or external component on or off for a specific length of
time. It is also used to generate delays. When multiple one-shots are cascaded, a variety
of sequential timing pulses can be generated. Those pulses will allow you to time and
sequence a number of related operations.
The other basic operational mode of the 555 is as and astable multivibrator. An astable
multivibrator is simply and oscillator. The astable multivibrator generates a continuous
stream of rectangular off-on pulses that switch between two voltage levels. The
frequency of the pulses and their duty cycle are dependent upon the RC network values.

85

Notice how the monostable continues to output its pulse regardless of the inputs swing
back up. That is because the output is only triggered by the input pulse, the output
actually depends on the capacitor charge.
8.3

Monostable Mode

The 555 in fig. 9a is shown here in it's utmost basic mode of operation; as a triggered
monostable. One immediate observation is the extreme simplicity of this circuit. Only
two components to make up a timer, a capacitor and a resistor. And for noise immunity
maybe a capacitor on pin 5. Due to the internal latching mechanism of the 555, the timer
will always time-out once triggered, regardless of any subsequent noise (such as bounce)
on the input trigger (pin 2). This is a great asset in interfacing the 555 with noisy sources.
Just in case you don't know what 'bounce' is: bounce is a type of fast, short term noise
caused by a switch, relay, etc. and then picked up by the input pin.
The trigger input is initially high (about 1/3 of +V). When a negative-going trigger pulse
is applied to the trigger input (see fig. 9a), the threshold on the lower comparator is
exceeded. The lower comparator, therefore, sets the flip-flop. That causes T1 to cut off,
acting as an open circuit. The setting of the flip-flop also causes a positive-going output
level which is the beginning of the output timing pulse.
The capacitor now begins to charge through the external resistor. As soon as the charge
on the capacitor equal 2/3 of the supply voltage, the upper comparator triggers and resets
the control flip-flop. That terminates the output pulse which switches back to zero. At this
time, T1 again conducts thereby discharging the capacitor. If a negative-going pulse is
applied to the reset input while the output pulse is high, it will be terminated immediately
as that pulse will reset the flip-flop.
Whenever a trigger pulse is applied to the input, the 555 will generate its single-duration
output pulse. Depending upon the values of external resistance and capacitance used, the
output timing pulse may be adjusted from approximately one millisecond to as high as on
hundred seconds. For time intervals less than approximately 1-millisecond, it is
recommended that standard logic one-shots designed for narrow pulses be used instead of
a 555 timer. IC timers are normally used where long output pulses are required. In this
applicaton, the duration of the output pulse in seconds is approximately equal to:

T = 1.1 x R x C (in seconds)


86

The output pulse width is defined by the above formula and with relatively few restrictions, timing components R(t) and C(t) can have a wide range of values. There is actually
no theoretical upper limit on T (output pulse width), only practical ones. The lower limit
is 10uS. You may consider the range of T to be 10uS to infinity, bounded only by R and
C limits. Special R(t) and C(t) techniques allow for timing periods of days, weeks, and
even months if so desired.
However, a reasonable lower limit for R(t) is in the order of about 10Kilo ohm, mainly
from the standpoint of power economy. (Although R(t) can be lower that 10K without
harm, there is no need for this from the standpoint of achieving a short pulse width.) A
practical minimum for C(t) is about 95pF; below this the stray effects of capacitance
become noticeable, limiting accuracy and predictability. Since it is obvious that the
product of these two minimums yields a T that is less the 10uS, there is much flexibility
in the selection of R(t) and C(t). Usually C(t) is selected first to minimize size (and
expense); then R(t) is chosen.
The upper limit for R(t) is in the order of about 15 Mega ohm but should be less than this
if all the accuracy of which the 555 is capacle is to be achieved. The absolute upper limit
of R(t) is determined by the threshold current plus the discharge leakage when the
operating voltage is +5 volt. For example, with a threshold plus leakage current of
120nA, this gives a maximum value of 14M for R(t) (very optimistic value). Also, if the
C(t) leakage current is such that the sum of the threshold current and the leakage current
is in excess of 120 nA the circuit will never time-out because the upper threshold voltage
will not be reached. Therefore, it is good practice to select a value for R(t) so that, with a
voltage drop of 1/3 V+ across it, the value should be 100 times more, if practical.
So, it should be obvious that the real limit to be placed on C(t) is its leakage, not it's
capacitance value, since larger-value capacitors have higher leakages as a fact of life.
Low-leakage types, like tantalum or NPO, are available and preferred for long timing
periods. Sometimes input trigger source conditions can exist that will necessitate some
type of signal conditioning to ensure compatibility with the triggering requirements of the
555. This can be achieved by adding another capacitor, one or two resistors and a small
signal diode to the input to form a pulse differentiator to shorten the input trigger pulse to
a width less than 10uS (in general, less than T). Their values and criterion are not critical;
the main one is that the width of the resulting differentiated pulse (after C) should be less
than the desired output pulse for the period of time it is below the 1/3 V+ trigger level.
There are several different types of 555 timers. The LM555 from National is the most
common one these days, in my opinion. The Exar XR-L555 timer is a micropower
version of the standard 555 offering a direct, pin-for-pin (also called plug-compatible)
substitute device with an advantage of a lower power operation. It is capable of operation
of a wider range of possitive supply voltage from as low as 2.7volt minimum up to 18
volts maximum. At a supply voltage of +5V, the L555 will typically dissipate of about
900 microwatts, making it ideally suitable for battery operated circuits. The internal
schematic of the L555 is very much similar to the standard 555 but with additional

87

features like 'current spiking' filtering, lower output drive capability, higher nodal
impedances, and better noise reduction system.
Intersil's ICM7555 model is a low-power, general purpose CMOS design version of the
standard 555, also with a direct pin-for-pin compatibility with the regular 555. It's
advantages are very low timing/bias currents, low power-dissipation operation and an
even wider voltage supply range of as low as 2.0 volts to 18 volts. At 5 volts the 7555
will dissipate about 400 microwatts, making it also very suitable for battery operation.
The internal schematic of the 7555 (not shown) is however totally different from the
normal 555 version because of the different design process with CMOS technology. It
has much higher input impedances than the standard bipolar transistors used. The CMOS
version removes essentially any timing component restraints related to timer bias
currents, allowing resistances as high as practical to be used.
This very versatile version should be considered where a wide range of timing is desired,
as well as low power operation and low current sync'ing appears to be important in the
particular design.
A couple years after Intersil, Texas Instruments came on the market with another CMOS
variation called the LINCMOS (LINear CMOS) or Turbo 555. In general, different
manufacturers for the CMOS 555's reduced the current from 10mA to 100A while the
supply voltage minimum was reduced to about 2 volts, making it an ideal type for 3v
applications. The CMOS version is the choice for battery powered circuits. However, the
negative side for the CMOS 555's is the reduced output current, both for sync and source,
but this problem can be solved by adding a amplifier transistor on the output if so
required. For comparison, the regular 555 can easily deliver a 200mA output versus 5 to
50mA for the 7555. On the workbench the regular 555 reached a limited output
frequency of 180Khz while the 7555 easily surpassed the 1.1Mhz mark and the TLC555
stopped at about 2.4Mhz. Components used were 1% Resistors and low-leakage
capacitors, supply voltage used was 10volt.
Some of the less desirable properties of the regular 555 are high supply current, high
trigger current, double output transitions, and inability to run with very low supply
voltages. These problems have been remedied in a collection of CMOS successors.

88

A caution about the regular 555 timer chips; the 555, along with some other timer ic's,
generates a big (about 150mA) supply current glitch during each output transition. Be
sure to use a hefty bypass capacitor over the power connections near the timer chip. And
even so, the 555 may have a tendency to generate double output transitions.

Astable operation: Figure 9b shows the 555 connected as an astable multivibrator. Both
the trigger and threshold inputs (pins 2 and 6) to the two comparators are connected
together and to the external capacitor. The capacitor charges toward the supply voltage
through the two resistors, R1 and R2. The discharge pin (7) connected to the internal
transistor is connected to the junction of those two resistors.
When power is first applied to the circuit, the capacitor will be uncharged, therefore, both
the trigger and threshold inputs will be near zero volts (see Fig. 10). The lower
comparator sets the control flip-flop causing the output to switch high. That also turns off
transistor T1. That allows the capacitor to begin charging through R1 and R2. As soon as
the charge on the capacitor reaches 2/3 of the supply voltage, the upper comparator will
trigger causing the flip-flop to reset. That causes the output to switch low. Transistor T1
also conducts. The effect of T1 conducting causes resistor R2 to be connected across the
external capacitor. Resistor R2 is effectively connected to ground through internal
transistor T1. The result of that is that the capacitor now begins to discharge through R2.
The only difference between the single 555, dual 556, and quad 558 (both 14-pin types),
is the common power rail. For the rest everything remains the same as the single version,
8-pin 555.

89

As soon as the voltage across the capacitor reaches 1/3 of the supply voltage, the lower
comparator is triggered. That again causes the control flip-flop to set and the output to go
high. Transistor T1 cuts off and again the capacitor begins to charge. That cycle
continues to repeat with the capacitor alternately charging and discharging, as the
comparators cause the flip-flop to be repeatedly set and reset. The resulting output is a
continuous stream of rectangular pulses.
The frequency of operation of the astable circuit is dependent upon the values of R1, R2,
and C. The frequency can be calculated with the formula:

f = 1/(.693 x C x (R1 + 2 x R2))


The Frequency f is in Hz, R1 and R2 are in ohms, and C is in farads.
The time duration between pulses is known as the 'period', and usually designated with a
't'. The pulse is on for t1 seconds, then off for t2 seconds. The total period (t) is t1 + t2
(see fig. 10).
That time interval is related to the frequency by the familiar relationship:

f = 1/t
or
t = 1/f
The time intervals for the on and off portions of the output depend upon the values of R1
and R2. The ratio of the time duration when the output pulse is high to the total period is
known as the duty-cycle. The duty-cycle can be calculated with the formula:

D = t1/t = (R1 + R2) / (R1 + 2R2)


You can calculate t1 and t2 times with the formulas below:

t1 = .693(R1+R2)C
t2 = .693 x R2 x C
90

The 555, when connected as shown in Fig. 9b, can produce duty-cycles in the range of
approximately 55 to 95%. A duty-cycle of 80% means that the output pulse is on or high
for 80% of the total period. The duty-cycle can be adjusted by varying the values of R1
and R2.
8.4

Applications

There are literally thousands of different ways that the 555 can be used in electronic
circuits. In almost every case, however, the basic circuit is either a one-shot or an astable.
The application usually requires a specific pulse time duration, operation frequency, and
duty-cycle. Additional components may have to be connected to the 555 to interface the
device to external circuits or devices.
In the remainder of this experiment, you will build both the one-shot and astable circuits
and learn about some of the different kinds of applications that can be implemented see
lab book. Furthermore, the last page of this document contains 555 examples, which you
can build, and experiment with.

91

9.

OPERATIONAL AMPLIFIER

What exactly is an OPerational AMPlifier? Let's define what that component is and
look at the parameters of this amazing device. An operational amplifier IC is a solidstate integrated circuit that uses external feedback to control its functions. It is one of
the most versatile devices in all of electronics.
The term 'op-amp' was originally used to describe a chain of high performance dc
amplifiers that was used as a basis for the analog type computers of long ago. The
very high gain op-amp IC's our days uses external feedback networks to control
responses. The op-amp without any external devices is called 'open-loop' mode,
refering actually to the so-called 'ideal' operational amplifier with infinite open-loop
gain, input resistance, bandwidth and a zero output resistance. However, in practice
no op-amp can meet these ideal characteristics. And as you will see, a little later on,
there is no such thing as an ideal op-amp. Since the LM741/NE741/A741 Op-Amps
are the most popular one, this tutorial is direct associated with this particular type.
Nowadays the 741 is a frequency compensated device and although still widely used,
the Bi-polar types are low-noise and replacing the old-style op-amps.
Let's go back in time a bit and see how this device was developed. The term
"operational amplifier" goes all the way back to about 1943 where this name was
mentioned in a paper written by John R. Ragazzinni with the title "Analysis of
Problems in Dynamics" and also covered the work of technical aid George A.
Philbrick. The paper, which was defined to the work of the U.S. National Defense
Research Council (1940), was published by the IRE in May 1947 and is considered a
classic in electronics. It was around 1947 that the Operational Amplifier concepts
were originally advanced. The very first series of modular solid-state op-amps were
introduced by Burr-Brown Research Corporation and G.A. Philbrick Researches Inc.
in 1962. The op-amp has been a workhorse of linear systems ever since.
At the left you see a picture
of a K2-W tubes general
purpose computing OpAmp from George A.
Philbrick Researches. This
type was first introduced in
1952, more than a decade
before the first transistorized version. The op-amp
is shown with and without
its bakelite shell. What a
beauty! The first solid-state
monolithic
op-amp,
designed by Bob Widlar,
offered to the public in
1963 was the A702
manufactured by Fairchild Semiconductors but it had very weird supply voltages such
as +12 and -6 volts and had a tendency to burn out when it was temporarily shorted.
Despite all these little shortcomings this device was the best in its day. It contained

92

just nine transistors and sold for about $300.00 US which limited the sales to the
Military and Aerospace consumers.
In 1965 the next major change was introduced in op-amp design by Bob Widlar with
the A709 from Fairchild Semiconductor. It had higher gain, a larger bandwidth,
lower input current, and a more user-friendly supply voltage requirement of
approximately +/- 15 Volt DC. The tremendous success of the 709 was associated
with high production demands causing rapid and steep price reductions. This
particular op-amp, introduced at about $70, was the first to break the $10 barrier and
again not much later the $5 barrier. By 1969, op-amps were selling for around $2.
The outrageous success of the A709 emboldened Bob Widlar to request a significant
enhancement in his compensation. When his request was denied by his boss, Charles
Sporck, Widlar left Fairchild in 1966 to join the young National Semiconductor.
Ironically, one year later, Sporck became president of National Semiconductors and
so again becoming Widlar's boss. However, this time Sporck had to accept Widlar's
compensation package, which allowed Bob Widlar to retire in 1970 just before his
30th birthday. Widlar worked briefly in 1980 for Linear Technology and continued to
produce designs for National Semiconductors on a consulting basis for the rest of his
life.
Under the brilliant guidance and futuristic view again of Bob Widlar, National
Semiconductor decided to jump on the bandwagen with the release of a more versatile
op-amp version in the form of the LM101 in 1967. It had a an increased gain (up to
160K) and operation range. One of the nicest features of the LM101 was 'short-circuit'
protection, and simplified frequency compensation. This was accomplished by placing
an external capacitor across selected connection pins. The first op-amp to provide this
internally was the hybrid LH101, which was basically a LM101 with a capacitor in a
single package.
But Fairchild was not done yet. It introduced in May 1968 an internally compensated
op-amp called the A741. However, the differences between their LM101 and the
A741 were very slight. Frequency compensation is accomplished using an 'on-chip'
capacitor. Offset null is accomplished by adjustment of currents in input stage
emitters. On the LM101, Offset is achieved by adjusting current in input stage
collectors.
In December 1968, an improved version of the LM101, the LM101A, was devised.
This device provided better input control over the temperature and lower Offset
currents.
National Semiconductor introduced the LM107, which had the frequency
compensation capacitor built into the silicon chip. The LM107 came out at the same
time as the LM101A.
In 1968, Fairchild Semiconductor issued the A748. The device had essentially the
same performance characteristics as the A741. The difference was external
frequency compensation.

93

The first multiple op amp device was Raytheon Semiconductor's RC4558 in 1974.
Characteristics of this new device are similar to the A741 except that the latter uses
NPN input transistors. Later in that same year, the LM324 quad op amp from National
Semiconductor became public to the delight of manufacturing industry and hobbyist
alike. It is similar in characteristics in comparison with the A741 in speed and input
current. The LM324 is especially useful for low-power consumption. The beauty of
this chip, according to some engineers, is its single-power-supply requirement.
Now the snowball was rolling. The first FET input op amp was the CA3130 made by
RCA. With this addition to the op-amp family, extremely low input currents were
achieved. Its power can be supplied by a +5 to +15vdc single supply system. A
beautiful piece of work this CA3130.
In July 1975, National Semiconductor came out with the J-FET type LF355. This was
the first device created using ion implantation in an op amp.
Texas Instruments introduced the TL084 op amp in October 1976. It is a quad JFET
input op amp; it also is an ion-implant JFET. Low bias current and high speed are two
of its beautiful attributes.
In dated sequence, the op-amp developed like this: 1963-A702, 1965-A709, 1967LM101/LH101, 1968-A741, 1974-RC4558/LM324, 1975-CA3130/LF355, and in
1976 the TL084... wow! Most of the mentioned op-amps have of course been replaced
over time, keeping the same model number, with cleaner and low-noise types.
Meaning, the cutting laser of the early 60's was not of the same quality and as narrow
as the 70's or the 80's, etc. Other companies like RCA discontinued their
semiconductor line all together.
Today, and since that month in 1976, the types of op amps have increased almost
daily. We now enjoy a variety of op amps that will provide the user essentially with
anything s/he needs, such as high common-mode rejection, low-input current
frequency compensation, cmos, and short-circuit protection. All a designer has to do
is expressing his needs and is then supplied with the correct type. Op-Amps are
continually being improved, especially in the low-noise areas.

Shown in Fig.1 at the right are op-amp symbols as used today. The one on the right is
an older way of drawing it but still used in books like the ARRL (American Radio
Relay Leaque) and older schematics. It is common practice to omit the power supply
connections as they are implied.
Absolute Maximum Parameters:
Maximum means that the op-amp can safely tolerate the maximum ratings as given in
the data section of such op-amp without the possibility of destroying it. The A741 is
a high performance operational amplifier with high open loop gain, internal

94

compensation, high common mode range and exceptional temperature stability. The
A741 is short-circuit protected and allows for nulling of the offset voltage. The
A741 is Manufactured by Fairchild Semiconductor.

Supply Voltage (+/-Vs): The maximum voltage (positive and negative) that can be
safely used to feed the op-amp.
Dissipation (Pd): The maximum power the op-amp is able to dissipate, by specified
ambient temperature (500mW @ 80 C).
Differential Input Voltage (Vid): This is the maximum voltage that can be applied
across the + and - inputs.
Input Voltage (Vicm): The maximum input voltage that can be simultaneously applied
between both input and ground also referred to as the common-mode voltage. In
general, the maximum voltage is equal to the supply voltage.
Operating Temperature (Ta): This is the ambient temperature range for which the
op-amp will operate within the manufacutre's specifications. Note that the military
grade version (A741)has a wider temperature range than the commercial, or
hobbyist, grade version (A741C).
Output Short-Circuit Duration: This is the amount of time that an op-amp's ouput
can be short-circuited to either supply voltage.
Summed-up Features:

Internal Frequency Compensation

Short Circuit Protection

Offset voltage null capability

Excellent temperature stability

High input voltage range

NO latch-up
Input Parameters:
1.
Input Offset Voltage (Voi)
This is the voltage that must be applied to one of the input pins to give a zero
output voltage. Remember, for an ideal op-amp, output offset voltage is zero!
95

2. Input Bias Current (Ib)


This is the average of the currents flowing into both inputs. Ideally, the two
input bias currents are equal.
3. Input Offset Current (Ios)
This is the difference of the two input bias currents when the output voltage is
zero.
4. Input Voltage Range (Vcm)
The range of the common-mode input voltage (i.e. the voltage common to
both inputs and ground).
5. Input Resistance (Zi)
The resistance 'looking-in' at either input with the remaining input grounded.
Output Parameters:

The resistance seen 'looking into' the op-amp's output.


1. Output Resistance (Zoi)
2. Output Short-Circuit Current (Iosc)
This is the maximum output current that the op-amp can deliver to a load.
3. Output Voltage Swing (Vo max)
Depending on what the load resistance is, this is the maximum 'peak' output
voltage that the op-amp can supply without saturation or clipping.
Dynamic Parameters:
1. Open-Loop Voltage Gain (Aol)
The output to input voltage ratio of the op-amp without external feedback.
2. Large-Signal Voltage Gain
This is the ratio of the maximum voltage swing to the charge in the input
voltage required to drive the ouput from zero to a specified voltage (e.g. 10
volts).
96

3. Slew Rate (SR)


The time rate of change of the ouput voltage with the op-amp circuit having a
voltage gain of unity (1.0).
Other Parameters:
1. Supply Current
This is the current that the op-amp will draw from the power supply.
2. Common-Mode Rejection Ratio (CMRR)
A measure of the ability of the op-amp' to reject signals that are
simultaneously present at both inputs. It is the ratio of the common-mode input
voltage to the generated output voltage, usually expressed in decibels (dB).
3. Channel Seperation
Whenever there is more than one op-amp in a single package, like the 747 opamp, a certain amount of "crosstalk" will be present. That is, a signal applied
to the input of one section of a dual op-amp will produce a finite output signal
in the remaining section, even though there is no input signal applied to the
unused section.
Open-Loop Gain & Frequency:

Unlike the ideal op-amp (Fig. 5-1), the op-amp that is used in more realistic circuits
today, does not have infinite gain and bandwidth. Look at Open-loop gain in Fig. 4
above, it is graphed for a type 741 op-amp as a function of frequency. At very low
frequencies, the open-loop gain of an op-amp is constant, but starts to taper off at
about 6Hz or so at a rate of -6dB/octave or -20dB/decade (an octave is a doubling in
frequency, and a decade is a ten-fold increase in frequency). This decrease continues
until the gain is unity, or 0 dB. The frequency at which the gain is unity is called the
unity gain frequency or fT. Maybe the first factor in the consideration of a specific opamp is its "gain-bandwidth product" or GBP. For the response curve of Fig. 4, the
product of the open-loop gain and frequency is a constant at any point on the curve,
so that: GBP = AolBW
Graphically, the bandwidth is the point at which the closed-loop gain curve intersects
the open-loop curve, as shown in Fig. 5 for a family of closed-loop gains. For a more
practical design situation, the actual design of an op-amp circuit should be
approximately 1/10 to 1/20 of the open-loop gain at a given frequency. This ensures
97

that the op-amp will function properly without distortion. As an example, using the
response in Fig. 4, the closed-loop gain at 10Khz should be about 5 to 10, since the
open-loop gain is 100 (40dB). One additional parameter is worth mentioning, the
Transient Response, or rise time is the time that it takes for the output signal to go
from 10% to 90% of its final value when a step-function pulse is used as an input
signal, and is specified under close-loop condistions. From electronic circuit theory,
the rise time is related to the bandwidth of the op-amp by the relation: BW = 0.35 / rise
time

Open-Loop Gain:
Lets have a look how the 'ideal' amplifier would look like in Fig. 5-1. The search for
an ideal amplifier is, of course, a futile exercise. The characteristics of the operational
amplifier are good enough, however, to allow us to treat it as ideal. Below are some
amplifier properties that make this so. (Please realize that these ratings are next to
impossible to achieve).

1.
2.
3.
4.
5.
6.

Gaininfinite
Input impedanceinfinite
Output impedancezero
Bandwidthinfinite
Voltage out--zero (when voltages into each other are equal)
Current entering the amp at either terminal--extremely small

The "operation" refered to mathematical operations, such as addition, integration, etc.


An exact equivalent of the ideal Op-Amp is called a "nullor" and it is composed of
new elements -- the nullator and the norator. The input to the opamp is the nullator
(i.e. no voltage or current), while the ouput is the norator (i.e. any voltage or current).
These two components give the device its ideal characteristics.
Power Supply:
In general op-amps are designed to be powered from a dual or bipolar voltage supply
which is typically in the range of +5V to +15Vdc with respect to ground, and another
supply voltage of -5V to -15Vdc with respect to ground, as shown in Fig. 7. Although
in certain cases an op-amp, like the LM3900 and called a 'Norton Op-Amp', may be
powered from a single supply voltage.

98

Electrical Ratings:
Electrical characteristics for op-amps are usually specified for a certain (given) supply
voltage and ambient temperature. Also, other factors may play an important role such
as certain load and/or source resistance. In general, all parameters have a typical
minimum/maximum value in most cases.

Fig. 6 - The two most common types are shown in the diagram on the right.
Depending on the application, the 8-pin version is used the most, worldwide.
Actually, there is a third type in the form of a metal-can but is obsolete and, by my
knowledge, no longer used. I have two of these metal-can types and keep them as a
'gone-by' memory.
Definition of 741-pin functions: (Refer to the internal 741 schematic of Fig. 3)
Pin 1 (Offset Null): Offset nulling, see Fig. 11. Since the op-amp is the differential
type, input offset voltage must be controlled so as to minimize offset. Offset voltage is
nulled by application of a voltage of opposite polarity to the offset. An offset nulladjustment potentiometer may be used to compensate for offset voltage. The nulloffset potentiometer also compensates for irregularities in the operational amplifier
manufacturing process which may cause an offset. Consequently, the null
potentiometer is recommended for critical applications. See 'Offset Null Adjustment'
for method.
Pin 2 (Inverted Input): All input signals at this pin will be inverted at output pin 6.
Pins 2 and 3 are very important (obviously) to get the correct input signals or the op
amp can not do its work.
Pin 3 (Non-Inverted Input): All input signals at this pin will be processed normally
without invertion. The rest is the same as pin 2.
Pin 4 (-V): The V- pin (also referred to as Vss) is the negative supply voltage
terminal. Supply-voltage operating range for the 741 is -4.5 volts (minimum) to -18
volts (max), and it is specified for operation between -5 and -15 Vdc. The device will
operate essentially the same over this range of voltages without change in timing
period. Sensitivity of time interval to supply voltage change is low, typically 0.1% per
volt. (Note: Do not confuse the -V with ground).
Pin 5 (Offset Null): See pin 1, and Fig. 11.
Pin 6 (Output): Output signal's polarity will be the oposite of the input's when this
signal is applied to the op-amp's inverting input. For example, a sine-wave at the
inverting input will output a square-wave in the case of an inverting comparator
circuit.
99

Pin 7 (posV): The V+ pin (also referred to as Vcc) is the positive supply voltage
terminal of the 741 Op-Amp IC. Supply-voltage operating range for the 741 is +4.5
volts (minimum) to +18 volts (maximum), and it is specified for operation between +5
and +15 Vdc. The device will operate essentially the same over this range of voltages
without change in timing period. Actually, the most significant operational difference
is the output drive capability, which increases for both current and voltage range as
the supply voltage is increased. Sensitivity of time interval to supply voltage change is
low, typically 0.1% per volt.
Pin 8 (N/C): The 'N/C' stands for 'Not Connected'. There is no other explanation.
There is nothing connected to this pin, it is just there to make it a standard 8-pin
package.

Experiments: You are given the opportunity to play with and analyze experiments to
demonstrate the principles, concepts, and applications of a couple of these basic
configured op-amps. If you have already a dual-voltage power supply
(positive/negative), that would make things alot easier for you. If not, build this Dual
Volt Powersupply listed at the bottom of the page to get you started. This power
supply has two non-adjustable voltages; +12Vdc and -12Vdc. However, in general, a
very simple and cheap power supply can be rigged up with two 9 Volt alkaline
batteries and does the job in most, if not all, cases. Personally I like to approach a
project more professionally and build the dual 12 volt powersupply. Nice project 'inbetween' while learning op-amps.
Bread Board Modules: A bread board module, or just 'breadboard', is a board
manufactured of plastic with a couple 100 tiny holes with tiny sockets in them
connected electrically together and in the center of the breadboard a grove to hold a
plastic panel for leds, pots and switches. They measure about 6 by 2 inches and come
in white, gray and blue. The blue kind is called 'BimBoard' and made in the UK. I
purchased mine back in 1980 from ElectroSonic in Toronto Canada and its still
working fine. The gray and white models are manufactured in the U.S. and Canada.
They all work. Radio Shack and the European Tandy are both selling their own
version and they work fine too. The Bread Board Design System is also available, if
you can afford it, and would be preferred if you intend to do a lot more experimenting
in the future. This system contains everything you need already build-in, like the
powersupply, jacks, switches, leds, function generator and lots more goodies. Kindah
nice to have everything in one place.
100

The Norton Op-Amp:

It is not my intention to confuse you with a different type of op-amp so I will just
mention a couple of points about this op-amp. The Norton op-amp, or currentdifferencing amplifier, is designed to operate from a single ended supply. Wow, that
is truly fantastic. You can use a voltage anywhere from +4V to a whopping +36V!
The Norton op-amp referred to here is the LM3900 and is the best known type made
by National Semiconductor. This chip contains four op-amps in a single 14-pin
package. The picture in Fig. 8-b below shows the symbol for the Norton op-amp. As
you may notice it is somewhat different than the normal op-amp symbol. Fig. 8-c
shows the major parameters of relevance between the 741 and the 3900 op-amps.

The Peak Detector


The peak detector is a circuit that "remembers" the peak value of a signal. As shown
in Fig. 9-a, when a positive voltage is fed to the non-inverting input after the capacitor
has been momentarily shorted (reset), the output voltage of the op-amp forward biases
the diode and charges up the capacitor. This charging last until the inverting and noninverting inputs are at the same voltage, which is equal to the input voltage. When the
no inverting input voltage exceeds the voltage at the inverting input, which is also the
voltage across the capacitor, the capacitor will charge up to the new peak value.

101

Consequently, the capacitor voltage will always be equal to the greatest positive
voltage applied to the no inverting input.
Once charged, the time that the peak detector "remembers" this peak value is typically
several minutes and depends on the impedance of the load that is connected to the
circuit. Consequently, the capacitor will slowly discharge towards zero. To minimize
this rate of discharge, a voltage follower can be used to buffer the detector's output
from any external load, as shown in Fig. 9-b. Momentarily shorting the capacitor to
ground will immediately set the output to zero.
The Comparator

A 'comparator' is circuit that compares an input voltage with a reference voltage. The
ouput of the comparator then indicates whether the input signal is either above or
below the reference voltage. As shown for the basic circuit in Fig. 9-c(1) , the output
voltage approaches the positive supply voltage when the input signal is slightly
greater than the reference voltage, Vref. When the input is slightly less than the
reference, the op-amp's output approaches the negative supply voltage. Consequently,
the exact threshold is dominated by the op-amp's input offset voltage, which should be
nulled out. Fig. 9-c(2) shows a Led indicator which input is connected to the output
Vout of the comparator.

102

Fig. 9-d(left) The output polarity of the op-amp switches from positive to negative, it
is inconvenient to keep reversing the voltmeter leads to keep polarity correct. One
way to overcome that problem is to use an indicator light to tell the output state. The
circuit show on the left uses a transistor to switch a led on or off depending on the
comparator's output state. When the op-amp output is 8.5 volts, the transistor switches
on the led via the 220 ohm current-limiting resistor.
When the output is -8.5 volts the transistor is cut-off turning off the led. Transistor
choice is not critical; it can be any common type NPN device. Any type of silicon
diode will protect the transistor. Fig. 9-e(right). The output on pin 6 switches
(repeatedly) from positive to negative and so either bias Q1 (NPN) or Q2 (PNP and
activates RL which is the resistive load. Just a basic circuit to show you what exactly a
'Boosted-Output' circuit does.
The Instrumentation Amplifier
There are many types of op-amps who are designed for a specific purpose like the
Instrumentation Amplifier from Burr-Brown.(see Fig. 10) In this example we are
talking about the 3660J type. It can be used in both balanced and unbalanced systems,
like a Wheatstone Bridge circuit. This does not mean in any way that the instrumentation amp cannot be used for other applications, on the contrary, it is in many a case
preferred because of the unique parameters of this device.

Keep this in mind as a rule-of-thumb:


An operational amplifier circuit will not work at all unless:
1. External feedback limits the gain or desired responce to a design value.
2. 2. Both inputs have direct-current return path to ground of a similar reference.
3. 3. The input frequencies and required gain are well within the performance
limitations of the op-amp used.
Offset Null Adjustment Procedure for the A741:
Offset null adjustments differ with the application (e.i. Inverting or Non-Inverting
Amplifier). Offset-null potentiometers are not placed on design schematics as they
would detract from a design. For practice, perform the following Offset Null
adjustment if you wish:

103

1.
2.
3.
4.
5.

Adjust the 10K potentiometer to its center position.


Connect the photometer outside leads between pins 1 and 5 of the op-amp.
Make sure that the power is applied to the design application.
Connect the wiper of the photometer to the negative supply voltage.
Ensure that input signals are zero or null and that pins 2 and 3 have a dc return
to ground.
6. 5. Measure the output with a dc meter and obtain zero null by adjusting the
potentiometer.
This is just one method and recommended nulling procedure for the A741 type
op-amp. Always look for, and follow the particular procedure as specified by that
chip manufacturer. Procedures may become obsolete or updated and changed
when improved op-amp versions come on the market.
Planning Your Prototype or Experiment:
Planning the layout of your experiments could be important, especially with large
circuits. Use this [lay-out sheet] to plan your components layout on the bread
board, if you wish. Remove every component and all wires from previous
experiments.
Important: Before starting to insert components into the breadboard, make sure
all power and signal connections are removed and the power source disconnected.
And if required, take the glue/dirt of the components' legs before inserting them
into the sockets, it is very hard if not impossible to get it cleaned out.
A couple circuit examples:
Below are a couple circuit examples you can play and experiment with to
understand the working of a 741 op-amp hands on. If you are serious about
electronics I strongly recommend buying a book or two about Op-Amps for your
experimenting pleasures.
Fig. 12 - Light Sensor
This is a really nice circuit to play with. When there is NO light falling on the
sensor, the relay closes. When light falls on the LDR, the relay opens. To reverse
the situation just exchange LDR and R1. Example uses for this circuit: Darkroom, Automatic door-lock, closet, Shed Alarm, etc.

104

Fig. 14 - 12V Battery Monitor


The 100 Kilo-ohm trimmer pot controls the set point of this circuit to a 'high' point
like 12.5 or something, so adjust it to the point you wish the LED to light up. To
monitor a 'low' point, and have the led light up when the battery has drained to a
certain point, connect the led (via the 330 ohm resistor) to ground (in the blueboxed area). The led is the high-brightness or ultra-bright type for maximum
visibility. The trimpot in the schematic is a 10-turn type for better accuracy, but
basically any type will do.
Fig. 15 - Low Power Amplifier
This is a simple low power amplifier with a single power supply. The Rx resistor
+ the resistance of the speaker should equal 1000 ohm. Example: speaker is 150
ohm. Rx is 1000 - 150 = 850 ohm. Closest available value is 860 ohm. I know
what your thinking; what about the 30 volt? Isnt the max 15-volt? Yes, but
positive and negative they combine 30 volt.

Below is the Dual Volt Power Supply to power the op-amps. Check the output
voltages when you are done. You may lower the 220F caps to 100F if need be.
105

106

10.

Reverences and Resource:


1.

JB McCormack, RK Morrow, HF Bare, RJ Burns, and JL Rasmussen, "The


Complementary Roles of Laboratory Notebooks and Laboratory Reports,"
IEEE Trans. Educe., Vol. 34, pp.133-137, 1991.
2. "The Radio Amateur Handbook" (ARRL).
3. "The Capacitor Book". by Cletus J. Kaiser., C.J. Publishing. ISBN: 09628525-3-8
4. "Active Filter Cookbook", by Don Lancaster, 1975, by Howard W. Sams &
CO., Publisher SAMS, ISBN: 0-672-21168-8
5. "CDA--The New Current Differencing Amplifier", by W.G. Jung, June 1973,
Popular Electronics, pp. 61-66.
6. "Design of OP-AMP Circuits With Experiments", H.M Berlin, 1987, Howard
W. Sams & Co., Inc. Publisher SAMS. ISBN: 0-672-21537-3
"IC Op-Amp Cookbook", by W.G. Jung, 1974, by Howard W. Sams & CO.,
Publisher SAMS.
7. "Introductory Experiments in Digital Electronics", by H.M.Berlin (Book
1&2), Howard W. Sams & Co., Inc. Publisher SAMS.
8. "Logic & Memory Experiments using TTL Integrated Circuits", by
H.M.Berlin (Book 1&2), Howard W. Sams & Co., Inc. Publisher SAMS.
9. "Operational Amplifiers--Design and Applications", by G.E.Tobey,
J.G.Graeme, and L.P.Huelsman, 1971. Publisher McGraw-Hill.
10. "The Design of Active Filters, with Experiments", by H.M.Berlin, 1974.
Howard W. Sams & Co., Inc. Publisher SAMS.
11. "Understanding IC Operational Amplifiers", by R. Melen and H. Garland,
1971. Reston Publishing Co., Publisher RESTON.
12. "The Art of Electronics", by Horowitz and Hill, 1989, 2nd edition (3rd?),
Cambridge University Press, ISBN: 0-521-37095-7.
The following business names, mentioned are Trade Marked and protected under
International Copyright Law
1. ECG, Fairchild Semiconductor, Howard W. Sams & CO. Publishing,
McGraw-Hill publishing, National Semiconductor, NTE, Philips, Raytheon
Semiconductors, RCA, Reston Publishing, Texas Instruments,
2. Some excerpts and graphics are used from SAMS Book "Design of Op-Amp
Circuits With Experiments" written by Howard

107

SCHOOL OF ENGINEERING, BUILT


ENVIRONMENT & INFORMATION
TECHNOOLOGY
DEPARTMENT OF ELECTRICAL, ELECTRONIC &
COMPUTER ENGINEERING
MEASUREMENTS AND COMPUTER MODELLING EMR100
GROUP: ELECTRONICS AND MICROELECTRONICS

Saurabh Sinha
Version 1.01
Copyright reserved, University of Pretoria
1

This guide can be downloaded from http://eerc.up.ac.za/~elk220/netcourse/files/EMR100/matlab.pdf

108

ELECTRONICS AND MICROELECTRONICS


Carl Emily Fuchs Institute for Micro-Electronics (CEFIM)

Director: Prof M du Plessis


Visit: http://www.up.ac.za/academic/ee/profiles/duplessis.html
: monuko.du.plessis@eng.up.ac.za
: (012) 420-2952
CEFIM has been active in the field of microelectronics research and specialist training for
the last 21 years. The research and postgraduate program is mainly in the field of integrated
circuit design, especially the design of analogue signal processors in CMOS technology.
The simulation and modelling of circuits, devices and processing technologies are also
investigated. The application of semiconductors as opto-electronic devices and radio
frequency (RF) devices play an important role in the activities at CEFIM.
In the fields of microelectronics, photonics and related areas, CEFIM's mission is to:

- provide expert human resources for South Africa, and


- do research.
These goals are attained by:

- training undergraduate students


- (analogue & digital design mixed signal design),
- developing a postgraduate programme which includes both research and
training,
- creating facilities for research promoting links between and co-operation
with local organizations that work in the same field,
- promoting co-operative agreements and liasing with institutions in other
countries by means of overseas trips, postdoctoral studies, and lecturer's
sabbatical leave,
- being a leading source of specialized human resources in these fields, &
- creating research facilities for new fields of research in microelectronics,
RF and photonics.
International contact in microelectronics is vital and the CEFIM lecturers & students often
participate at international conferences and overseas experts visit the CEFIM facility
regularly.
CEFIM ONLINE: http://www.ee.up.ac.za/ee/cgi-bin/ee/Cefim/cefim.html

TABLE OF CONTENTS
1. Introduction
1.1 Basic outline
1.2 MATLAB integration into electronics

111
111
111

2. Assignment 1
2.1 Solution of simple linear & non-linear circuits
2.2.1 General background
2.2.2 Technical background: Kirchoffs laws
2.3 MATLAB functions involved
2.4.1 MATLAB example linear circuits
2.4.2 MATALB example non-linear circuits
2.5.1 Exercise 1 linear circuits
2.5.2 Exercise 2 non-linear circuits

113
113
113
113
114
114
117
118
119

3. Assignment 2
3.1 Solution of simple linear & non-linear circuits
3.2.1 General background on how-to-use SIMULINK
3.2.2 General technical background
3.3 MATLAB functions involved
3.4.1 MATLAB example time domain analysis
3.4.2 MATALB example frequency domain analysis
3.5 Exercise linear circuits

120
120
120
124
125
125
126
127

4. References

128

5. Student feedback

129

1
110

1. INTRODUCTION
1.1 MATLAB & ENGINEERING
MATLAB, developed by MathWorks Inc. 1, is a software
package for high performance numerical computation
and visualization. The combination of analysis
capabilities, flexibility, reliability, and powerful graphics
makes MATLAB one of the premier software packages
for Electrical, Electronic & Computer Engineers.

1.2 BASIC OUTLINE


Creative problem solving

Problem definition
Idea generation, brainstorming, and teamwork
Creative evaluation, judgment, and critical thinking
Creative evaluation needs to be coupled with critical thinking to select the best possible
solution. This is not always easy, and hence mathematical modelling is done, to test
mathematical feasibility of the design (on a systems level). Subsystems can be likewise tested
and evaluated. Although approximate "first-cut" circuit designs can often be made by hand, an
exact analysis of circuit behaviour is often required, before hardware implementation, this is
often mathematically cumbersome; hence tools such as MATLAB & SIMULINK help
facilitate this.

Solution implementation
Figure 0.
The figure shows how MATLAB & SIMULINK fits into the creative problem solving.
The basic outline is taken from Lumsdaine & Lumsdaine, [1].

1.3 MATLAB INTEGRATION INTO ELECTRONICS


This guide consists of two assignments requiring MATLAB that will enable one to become
familiar with using MATLAB for Engineering calculations, simulations and graphical
display.

Visit The MathWorks home at http://www.mathworks.com

Electrical, Electronic and Computer Engineering

Introduction

MATLAB & Engineering

MATLAB provides an interactive environment with hundreds of reliable and accurate


built-in mathematical functions. These functions provide solutions to a broad range of
mathematical problems including matrix algebra, complex arithmetic, linear systems,
differential equations, signal processing, optimization, non-linear systems, and many other
types of scientific computations. The most important feature of MATLAB is its
programming capability, which is very easy to learn and to use, and which allows userdeveloped functions. It also allows access to Fortran algorithms and C codes by means of
external interfaces. There are several optional toolboxes written for special applications
such as signal processing, control systems design, system identification (SID), statistics,
neural networks, fuzzy logic, symbolic computations, and others. The first assignment will
focus on the use of some of these toolboxes for electronic and microelectronic applications.
MATLAB has been enhanced by the very powerful SIMULINK program. SIMULINK is a
graphical mouse-driven program for the simulation of dynamic systems. SIMULINK
enables students to simulate linear, as well as non-linear, systems easily and efficiently.
The following section describes the use of MATLAB and is designed to give a quick
familiarization with some of the commands and capabilities of MATLAB. The second
assignment will focus on the use of SIMULINK for electronic and microelectronic
applications.

1.4 COURSE ARTICULATION


EBN121: Circuits
WTW158: Calculus
Differentiation & integration

FSK116: Physics
Practical: Graphical introduction

ENV110: Innovation
Creative problem solving

E
M
R
1
0
0

Computer literacy, FTP, etc

E & E

Basic graphics literacy

Matric: Physical science and


mathematics

FSK126: Physics
Basic electric circuits intro.

WTW161: Linear algebra


Matrix intro., Cramers method, etc

EBN210: Adv. circuits


RLC networks

EIT111: Info. tech.


EGA 110: Eng. graphics

Kirchhoffs laws, Thvenin Eq., etc.

ELK220: Elec. components


Intro. to diodes

WTW263: Numerical methods

Feedback

Input courses

Newtons method

ELI/ESL220: Signal/Linear systems


Bode plots

EBB320: Control systems


System level mod. & simulation

Output courses
Figure 1.
The figure shows how this guide (and the two assignments) contributes to your previous
courses (Input courses) as well as future courses (Output courses). Note, that the
references, [1-9] are mostly the official prescribed textbooks that have been (and will
possibly be) used for the courses. Many of the courses (in future) will approach the subject
matter depicted in the figure, from a more fundamental perspective, this guide provides an
alternative computer technique to solve many of these future problems that is
encountered not only during the Engineering studies, but also thereafter, in your career as
an Electrical, Electronic or Computer Engineer.
Electrical, Electronic and Computer Engineering

112

2. ASSIGNMENT ONE
2.1 SOLUTIONS OF SIMPLE LINEAR & NON-LINEAR CIRCUITS
2.2.1 GENERAL BACKGROUND ON HOW-TO-USE MATLAB
One of the most useful mathematical forms for modelling a system with multiple
describing equations is a matrix. In circuit analysis, matrix equations are used to describe
circuits with multiple node voltage equations or multiple mesh current equations. Tools
such as Cramers method (Theron, [2]) can be, then, be used to solve for the unknowns in
the matrix equation. The methods used to solve matrix equations quickly become unwieldy
when the matrix is larger than three-by-three.
The general steps for solving a circuit problem using MATLAB are as follows:
1. Write down the circuit equations that include the variables of interest in the circuit
problem.
2. Express the circuit equations in matrix form: x = Ay, where y is an n-dimensional
vector of independent variables, x is an m-dimensional vector of dependent
variables, and A is a n-by-m matrix that relates the independent and dependent
variables.
3. Use the MATLAB editor to construct a M-file that solves the matrix. The M-file
usually consists of three parts:
a. the input, which prompts the user to input specific values for the matrix
equation;
b. the solution, which specifies the MATLAB tools used to solve the matrix
equation; and
c. the result, which displays the numerical or graphical result of the solution.
4. Execute the M-file by typing its name at the MATLAB prompt.
2.2.2 TECHNICAL BACKGROUND: KIRCHHOFFS LAWS
The conservation of energy and conservation of charge when applied to electrical circuits
are known as Kirchhoff's laws (Nilsson & Riedel, [3]).
Conservation of energy - zero algebraic sum of the voltage drops, Vi around a closed
circuit loop (imaginary loop) (given in equation (1)).
(1)
Vi = 0
i

Conservation of charge - zero algebraic sum of the currents, ik flowing into a point (total
charge in, equals total charge out) (given in equation (2)).
(2)
ik = 0
k

When applying these laws to solve for circuit unknowns, one finds the following
definitions (based on the passive sign convention, (Nilsson & Riedel, [3])) useful:
an element is an impedance (resistance) or EMF (ideal voltage source or ideal
current source),
a node is a point where three or more current-carrying elements are connected,
a branch is one element or several in series connecting two adjacent nodes, and
an interior loop is a circuit loop not subdivided by a branch.
Electrical, Electronic and Computer Engineering

Assignment 1

Solution of simple linear & non-linear circuits

Using these definitions Kirchhoff's laws can be applied to a circuit to solve for the
unknown quantities.
The general procedure is:
define the currents and voltages on a diagram,
apply Kirchhoff's laws to loops and nodes,
write down a set of linear algebraic equations, and
solve for the unknowns (MATLAB).

2.3 MATLAB FUNCTIONS INVOLVED


fprintf, fzero, ezplot

Other functions: Defining and manipulation of matrices, e.g. using /, *, etc.


To get help on any of the functions, type in:
>> help <function> % replace <function> with the function name
>> help fprintf % example
Execution of the above help example command gives:
COUNT = FPRINTF(FID,FORMAT,A,...) formats the data in the real part of
matrix A (and in any additional matrix arguments), under control of the
specified FORMAT string, and writes it to the file associated with file
identifier FID. COUNT is the number of bytes successfully written. FID is
an integer file identifier obtained from FOPEN. It can also be 1 for
standard output (the screen) or 2 for standard error. If FID is omitted,
output goes to the screen

2.4.1 MATLAB EXAMPLE LINEAR CIRCUITS


In the following example (figure 2), the current, i1 is to be computed. Note that the single
value resistors have been chosen only for simplicity in real life applications, these are
often much larger.
1
1

ib
5
ic
2

1
1
240 V

i1

id
2

1
ia

ie
5

1
1
0

Figure 2.
The figure shows an example of a resistive network.
Electrical, Electronic and Computer Engineering

114

Assignment 1

Solution of simple linear & non-linear circuits

Kirchhoffs voltage law, as discussed in 2.2.2 is first used to evaluate the circuit. The
manner, in which this is applied, is often referred to as mesh current analysis. Currents in
each of the meshes are defined as in equations (3) (7).
240 = 4ia ib ic id ie
0 = -ia + 8 ib - ic
0 = -ia ib + 5ic - id
0 = -ia ic + 5id ie
0 = -ia id + 8ie

(3)
(4)
(5)
(6)
(7)

Since MATLAB requires these equations to be specified in the form of a matrix, the above
equations (3) (7) can be written as in equation (8).

240 4 1 1 1 1 i a
0 1 8 1 0
0 ib

0 = 1 1 5 1 0 ic

0 1 0 1 5 1 i d
0 1 0
0 1 8 i e
Furthermore: i1 = ic - id

(8)

(9)

MATLAB can solve this matrix equation interactively. The basic script is shown in
figure 3. This can be typed directly in the MATLAB Command window (or alternatively
saved as an M-file, and the M-file loaded, compiled and run).

% This example solves for the currents in the circuit shown


% in figure 2.
fprintf('The mesh current matrix is \n')
R = [ 4, -1, -1, -1, -1;
-1, 8, -1, 0, 0;
-1, -1, 5, -1, 0;
-1, 0, -1, 5, -1;
-1, 0, 0, -1, 8]
Vin = [ 240, 0, 0, 0, 0]';
fprintf('The voltage vector is\n')
V = Vin'
Iout = R\Vin;
fprintf('The mesh current vector is \n')
I = Iout'
I1 = Iout(3)-Iout(4);
fprintf('The current I1 is %3.2f \n', I1)
Figure 3.
The figure shows the MATLAB script used to solve the simple linear circuit of figure 2.
The typical output of figure 3 is shown in figure 4. It is, often, desirable to use generic
variables (R1, R2, R3, , R13) instead of numbers (1 , 2 , , etc). Assume that in
figure 2, the left most resistors are labelled (R1 down to R4), the ones thereafter (R5 down to
R9), and the ones on the extreme right (R10 down to R13). The voltage source is labelled V1.
Under the assumptions, figure 5 shows the script that can be used to solve the circuit. The
results of the script are shown in figure 6. Students may derive and see if they agree with
the given matrix (text form) in figure 5.
Electrical, Electronic and Computer Engineering

115

Assignment 1

The mesh current matrix is


R =
4
-1
-1
-1
-1
8
-1
0
-1
-1
5
-1
-1
0
-1
5
-1
0
0
-1

Solution of simple linear & non-linear circuits

-1
0
0
-1
8

The voltage vector is


V =
240
0
0
0
0
The mesh current vector is
I =
77.5000
12.5000
22.5000
22.5000
12.5000
The current I1 is -0.00
Figure 4.
The figure shows the result of the execution (run) of figure 3.
% This program reads component values for the circuit in
% figure 2, then computes the mesh currents
R = input('Input R values: [R1, ..., R13] ');
V = input('Input independent voltage, [V] ');
%
A = [ R(1)+R(2)+R(3)+R(4) , -R(1) , -R(2) , -R(3) , -R(4) ;
-R(1) , R(1)+R(5)+R(6)+R(10) , -R(6) , 0 , 0 ;
-R(2) , -R(6) , R(2)+R(6)+R(7)+R(11) , -R(7) , 0 ;
-R(3) , 0 , -R(7) , R(3)+R(7)+R(8)+R(12) , -R(8) ;
-R(4) , 0 , 0 , -R(8) , R(4)+R(8)+R(9)+R(13) ];
B = [ V(1) , 0, 0, 0, 0 ]';
%
fprintf('The mesh currents are \n')
i = A\B
fprintf('The current I1 is %3.2f \n', i(3)-i(4))
Figure 5.
The figure shows the MATLAB script used to solve the simple linear circuit of figure 2, if
the generic resistor variables were used. This code can be loaded from the web1, opened
(click on file & open) and run (press <F5>) in the M-file editor window.
Input R values: [R1, ..., R13] [2 2 2 2 2 2 2 2 2 20 5 5 20]
Input independent voltage, [V] 100
The mesh currents are
i =
15.0524
1.4398
3.6649
3.6649
1.4398
The current I1 is -0.00
Figure 6.
The figure shows the result of the execution (run) of figure 5. The values in bold and
italics are entered during the execution of the program.
1

Click here to download the code: http://eerc.up.ac.za/~elk220/netcourse/files/EMR100/figure5.m

Electrical, Electronic and Computer Engineering

116

Assignment 1

Solution of simple linear & non-linear circuits

2.4.2 MATLAB EXAMPLE NON-LINEAR CIRCUITS


Figure 7 illustrates a simple non-linear circuit.

10 k

vaD

R1

10 V

D1

V1
iD

Figure 7.
The figure illustrates a simple non-linear circuit. (Assume V1 > 0.)
This is a single loop circuit. Kirchhoffs laws always apply (whether the circuit is linear or
non-linear). Kirchhoffs loop (mesh) rule can be applied to obtain equation (10).
V1 = iDR1 + vD
(10)
The diode equation provides a mathematical model of the i-v characteristic of the diode.
This is given in equation (11) (Jaeger, [4]). Note the non-linear nature (exp) of this
equation.
qv
i D = I S exp D 1 ,
(11)
nkT
where IS: reverse saturation current of diode (A),
vD: voltage applied to diode (V),
q: electronic charge (1.6 10-19 C),
k: Boltzmanns constant (1.38 10-23 J/K),
T: absolute temperature (K), and
n: nonideality (some books refer to this as the ideality!) factor (dimenstionless).

Assume (for D1): IS = 10-13 A, T = 300 K, and n = 1.


Substituting the values depicted in figure 7, into equation (10) yields equation (12).
10 = iD (10000) + vD

(12)

It is required to determine the operating point (also called the quiescent, Q-point) of the
diode, i.e. the value of iD and vD. Substituting, equation (11) and the other numerical values
shown above into equation (12) yields equation (13).


1.6 10 19 v D
13

1 (10000) + v D
10 = 10 exp
(13)
23

(1) 1.38 10 (300)

(
(

)
)

This can be re-written as equation (14) to find the zero, i.e. value of vd that will satisfy
equation (13).


1.6 10 19 v D
1 (10000) + v D 10 = 0
10 13 exp
(14)
23

(1) 1.38 10 (300)

(
(

)
)

This can be solved on MATLAB by creating (file, new M-file), typing & running the code:
function xd=diode(vd)
xd=(((1e-13)*(exp((1.6e-19)*vd/(1*(1.38e-23)*(300)))-1)*10000+vd-10))

Figure 8.
The figure shows the function defintion in MATLAB to define equation (14).
Once the file2 is created, it must be run (hence, activated). Press <F5> to achieve this.
2

Click here to download the code: http://eerc.up.ac.za/~elk220/netcourse/files/EMR100/figure8.m

Electrical, Electronic and Computer Engineering

117

Assignment 1

Solution of simple linear & non-linear circuits

To solve for the solution, vD, type (in the MATLAB command window):
>> fzero('diode',1)
>> id=(1e-13)*(exp((1.6e-19)*ans/(1*(1.38e-23)*(300))))
Note: The 1 in the above equation means to numerically determine the solution(s) of the
equation near vD = 1. This is merely a guess, such guesses become more and more
educated with experience. Also, if a value that it is too far from the solution is entered,
then the fzero function fails to converge and reports an error in accordance. The fzero
function uses Newtons method (Mathews, [5]) to find the solution to the equation.
The above gives the solution: vD = 0.5942 V, id = 9.4058e-004 A
2.5.1 EXERCISE 1: LINEAR CIRCUIT
a

14

4
144 V
ia

16

V1

12
10 15
10

18

12
ib

ic

id

if

ie

b
Figure 9.
The figure shows the circuit configuration for exercise 1.
For the given circuit (figure 9), determine the following:
a) Write out six equations for each of the loops (meshes) as done in
equations (3) (7) of 2.4.1.
b) Write the equation derived in part (a) as a matrix (like in equation (8) of 2.4.)
c) Determine the current, ia (using MATLAB).
d) Determine the ratio of the voltage source, V1 to the current, ia. This gives a
resistance, called the Thvenin resistance, Rth. (This is one of the techniques used to
find the Thvenin resistance, i.e. determine the open circuit voltage, Vth = Voc = V1
and divide it by the current flowing through it, |ia|.) The Thvenin equivalent circuit
is drawn in figure 10 (a). Similar to the Thvenin equivalent (Nilsson & Riedel,
[3]), another equivalent is used, this is called the Norton equivalent (depicted in
figure 10 (b)).
Rth
a

ia

Vth
a

Rth
a

(a)

(b)
Figure 10.
The figure shows (a) the Thvenin equivalent circuit, and (b) the Norton equivalent
to the circuit configuration of figure 9.
e) Find the magnitude of the power delivered by the source. This can be computed by
taking the mere product of the current, ia and the source voltage value, V1. Note,
that from the law of conservation of power, the power delivered by the source is
equal to the power dissipated by the circuit (i.e. the sum of the power dissipated
over each resistor) (Nilsson & Riedel, [3]).
118
Electrical, Electronic and Computer Engineering

Assignment 1

Solution of simple linear & non-linear circuits

2.5.2 EXERCISE 2: NON-LINEAR CIRCUIT

Plot the diode i-v characteristic (equation (11)), using the numerical parameters given in
2.4.2. Plot this equation over a x-axis range of [0, 2] V.
Additionally:
Label the x-axis: Diode voltage (V), the y-axis, Diode current (A), and the
graph title as Diode i-v characteristic. Also, enable the grid.
Hint: The ezplot command can be used. An example of this is shown in figure 11. The
generated plot of figure 11 is depicted in figure 12.
% ezplot is part of the symbolic toolbox
>> syms x %define variables
>> ezplot('cos(x)', [0, pi])
>> grid on
>> xlabel('x-axis');
>> ylabel('y-axis');
>> title('Example of using ezplot');
Figure 11.
The figure shows the script used to show how the ezplot function could be used to generate
graphs/plots.

Figure 12.
The figure illustrates the plot generated by the script of figure 11.

Electrical, Electronic and Computer Engineering

119

Assignment 1

Electrical, Electronic and Computer Engineering

Solution of simple linear & non-linear circuits

120

3. ASSIGNMENT TWO
3.1 ELECTRONIC NETWORK TRANSFER FUNCTIONS (TFs)
3.2.1 GENERAL BACKGROUND ON HOW-TO-USE SIMULINK
SIMULINK includes a comprehensive block library of toolboxes for both linear and nonlinear analyses (Carlson, [6] & Nise, [7]). Models are hierarchical, which allow using both
top-down and bottom-up approaches. As SIMULINK is an integral part of MATLAB, it is
easy to switch back and forth during the analysis process and thus, the user may take full
advantage of features offered in both environments.
Starting SIMULINK
In MATLAB command window, type: >> SIMULINK (<press ENTER> to invoke.)
A SIMULINK Library Browser window should appear as shown in figure 13.

Figure 13.
The figure shows the SIMULINK Library browser window.
To see the content of the toolbox, click on the + sign at the beginning of each toolbox.
To start a model click on the New Document icon as shown in figure 14.
Click here
to start a
new model

Figure 14.
The figure shows how to start a model in SIMULINK.
Electrical, Electronic and Computer Engineering

Assignment 2

Electronic network transfer functions

A new window will appear on the screen. Models are constructed in this window. Also, in
this window, the constructed model is simulated. A screenshot of a typical working
(model) window looks like the one shown in figure 15.

Figure 15.
The figure shows how the SIMULINK working (model) window typically looks.
Now one may begin to construct a model. To become familiarized with the structure and
the environment of SIMULINK, it is encouraged to explore the toolboxes and scan their
contents. You may not know what they are all about but perhaps you could catch on the
organization of these toolboxes according to the category. For instant, you may see Control
System Toolbox to consist of the Linear Time Invariant (LTI) system library and the
MATLAB functions can be found under Function and Tables of the SIMULINK main
toolbox. A good way to learn SIMULINK (and MATLAB or computer programs/packages
in general) is to practice and explore. Making mistakes and know how to correct the
mistakes is also a way to learn. Don't be afraid to make mistakes as you go along.
A simple model is used here to introduce some basic features of SIMULINK. The
following steps describe how a simple model can be constructed.
STEP 1: CREATING BLOCKS - Open (Expand) the SIMULINK toolbox by clicking on
the + sign infront of the SIMULINK entry in the SIMULINK Library Browser. Further
expand Sources sub-library. You should see a Sine Wave entry in the list of sources as
shown in the screenshot depicted in figure 16.

Figure 16.
The figure shows the expanded list of sources in the SIMULINK library browser.
Electrical, Electronic and Computer Engineering

122

Assignment 2

Electronic network transfer functions

Mouse action: Click on the Sine Wave block to select and drag it to the model Window as
shown in figure 17.

Figure 17.
The figure shows how the Sine Wave component can be incorporated into the model
window.
Now a source of the model has been established. In similar fashion, create additional
blocks in your model window.
NOTE: It is advisable that one saves the model at some point earlier so that if the computer
crashes (running MATLAB under Linux OS is much more stable!) then not much time is
wasted in reconstructing the model. For example, save this model under a filename, such
as "simexample1". To save a model, go to the pull down File menu in the model window
and select Save As. An extension named ".mdl" will automatically be appended to the
filename (just enter the filename). SIMULINK will recognize files with .mdl extension as a
simulation model (similar to how MATLAB recognizes files with the extension .m as an
M-File).
Continue to build your model by adding more components (or blocks) to the model
window, for instance add a scope from Sinks library, an Integrator block from Continuous
library, and a Mux block from Signals & Systems library. Once all the blocks are dragged
over to the model window, the window looks like the one shown in figure 18.

Figure 18.
The figure shows the model window after more components have been added.
Electrical, Electronic and Computer Engineering

123

Assignment 2

Electronic network transfer functions

One may remove an undesired block by clicking on the block to turn it to the select
mode (with four squares at the corners) as in figure 19 and use the DEL key or keys
combination CTRL-X (control key and X key at the same time) to remove (or cut) the
block. For example, say the repeating pattern or sequence is to be used as the source
instead of sine wave. Simply select the Sine Wave block and press CTRL-X to cut-it-out,
and then do a click-n-drag on the Repeating Sequence block. This is achieved in figure 19.

Figure 19.
The figure shows typical modification of figure 18 (note that the source has been changed).
STEP 2: MAKING CONNECTIONS - To establish connections between the blocks,
simply move the cursor to the output port (represented by ">" sign at the right side of the
block) of a block (the cursor will become a cross "+" as you move the cursor over the input
or output port) and left-click (pressing the left mouse button) to begin a connection. With
the left mouse button depressed, drag the mouse to the input port of another block (output
port is represented by a ">" at the left side of the block). To branch a connection, use the
right mouse button in a similar fashion. A connected system is shown in figure 20.

Figure 20.
The figure shows the model window after connections are done. The figure is adapted from
Carlson, [6].
STEP 3: RUNNING SIMULATION
The simulation of the simple system of figure 20 can be run by clicking on the play button
(, alternatively, one may use key sequence CTRL-T, or choose Start submenu under
Simulation menu). The signal generated by the Repeating Sequence block will be
displayed on the Scope block. This signal will also be integrated (Larson et al., [8]) by the
Electrical, Electronic and Computer Engineering

124

Assignment 2

Electronic network transfer functions

Integrator block and be displayed simultaneously on the Scope block. Double click on the
Scope block to view the scope outputs. A typical display is shown in figure 21.

Figure 21.
The figure shows the output of figure 20.
Note that if the derivative (Larson et al., [8]) of the signal can be obtained using the
Derivative block instead of the Integrator block. The result would be as shown in figure 22.

Figure 22.
The figure shows the output of figure 20, if a derivative component was used instead of the
integrator component.
The above steps demonstrated some basic functions and structure of SIMULINK. It is
strongly recommended that one takes some time to explore the toolboxes and get familiar
with the parameters associated with each block. To view/edit the parameters, simply
double click on the block of interest.
Handling of Blocks and Lines
Table 1 describes the actions and the corresponding keystrokes or mouse operations
(Microsoft Windows versions).
Electrical, Electronic and Computer Engineering

125

Assignment 2

Electronic network transfer functions

Actions

Keystrokes or Mouse Actions

Copying a block from a


library

Drag the block to the model window with the left


button on the mouse OR select the COPY
(CTRL-C) and PASTE (CTRL-V) from EDIT menu.

Duplicating blocks in a
model

Hold down the CTRL key and select the block with the
left mouse drag the block to a new location.

Display block's parameters

Double click on the block

Flip a block

CTRL-F

Rotate a block (clockwise 90


CTRL-R
at each keystroke)
Changing blocks' names

Click on block's label and position the cursor to


desired place.

Disconnecting a block

Hold down the SHIFT key and drag the block to a new
location

Drawing a diagonal line

Hold down the SHIFT key while dragging the mouse


with the left button

Dividing a line

Move the cursor to the line to where you want to


create the vertex and use the left button on the mouse
to drag the line while holding down the SHIFT key
Table 1.
The table shows the actions and corresponding keystrokes (or mouse operations) for
effectively handling of blocks and lines.
Annotations
To add an annotation to the model, place the cursor at an unoccupied area in the model
window and double click on the left mouse button. A small rectangular area will appear
with a cursor prompting for the input. To delete an annotation, hold down the SHIFT key
while selecting the annotation, then press the DELETE or BACKSPACE key. One may
also change font type and colour from the FORMAT menu.
3.2.2 GENERAL TECHNICAL BACKGROUND: ELECTRONIC MODELLING
Equivalent circuits for the passive (assume that there is no internal source of energy)
linear electronic components: resistors, capacitors, and inductors will be discussed in this
. Table 2 summarizes the components and the relationships between the voltage, current,
charge, impedance and conductacne under zero initial conditions.

Table 2.
The table shows the voltage, current, voltage-charge, impedance & conductance
relationships for a capacitor, resistor and an inductor. The parameters in the dotted frame
box are used for modelling in SIMULINK. This table is taken from Nise, [7].
Electrical, Electronic and Computer Engineering

126

Assignment 2

Electronic network transfer functions

3.3 MATLAB FUNCTIONS INVOLVED


SIMULINK uses MATLAB functions in graphical mode. Hence, no functions are
explicitly defined here.
3.4.1 MATLAB EXAMPLE: TIME DOMAIN ANALYSIS
Determine the step response (i.e. if the (V(s) is a step function) of the RLC circuit.
sL 2 R
1
V(s)

1/(sC)
I(s)
0

Figure 23.
The figure shows a simple RLC network. Assume: R = 1 , L = 1 H and C = 1 F. Note,
that these values are not practical, but are used just for mathematical simplicity. After,
frequency translation (s = j2f = j) all the components have the units ohms, and hence
basic Kirchhoffs laws (as discussed in the first assignment) can be applied. The circuit
configuration is taken from Halliday et al., [9].
Kirchhoffs loop (mesh) rule gives equation (15).
V(s) = I(s) [sL + R + (1/sC)]
(15)
Substituting the values given in the caption of figure 23, equation (16) is obtained.
V(s) = I(s) [s + 1 + (1/s)]
(16)
Equation (16) can be alternatively written as equation (17). The RHS being called the
transfer function.
I (s )
s
= 2
(17)
V (s ) s + s + 1
This is modelled in figure 25.

Figure 25.
The figure shows the model of the circuit configuration shown1 in figure 23.

Scope1

Scope

Figure 26.
The figure shows the voltage & current output (respectively) generated from figure 23.
1

The SIMULINK file can be downloaded from http://eerc.up.ac.za/~elk220/netcourse/files/EMR100/fig25.mdl

Electrical, Electronic and Computer Engineering

127

Assignment 2

Electronic network transfer functions

3.4.2 MATLAB EXAMPLE: FREQUENCY DOMAIN ANALYSIS


A frequency sweep of a system-level design, like the one depicted in figure 23 is often
required. These are called Bode plots (Carlson, [6]), and show a variation of the magnitude
or phase variation of the transfer function as a function of frequency.
This example aims to generate the Bode plot of the circuit (equation (17)) in figure 23. The
script of figure 26, can be used to generate the required bode plots.

% An example of plotting a bode plot


num=[1 0];% 1*s + 0
den=[1 1 1]; %1*s^2 + 1*s + 1
Bode(tf(num,den));
Figure 26.
The figure shows the script used to generate the Bode plot of the circuit in figure 23.
Once the plot has been generated, basic properties can be changed, by right clicking on the
plot. This is shown in figure 27.

Right
Click

Figure 27.
The figure shows the Bode plot (generated by the script of figure 26) and property editor
window (to modify the title, fonts, axes labels, unit of plot, etc).

Electrical, Electronic and Computer Engineering

128

Assignment 2

Electronic network transfer functions

3.5 EXERCISE: TIME & FREQUENCY DOMAIN ANAYLSIS


R

1/sC
1

Vao(s)
sL

Vi(s)
I(s)

Figure 28.
The figure shows a simple RLC network. Assume: R = 1 , L = 1 H and C = 1 F. After,
frequency translation (s = j2f = j) all the components have the units ohms, and hence
basic Kirchhoffs laws (as discussed in 3.4.1) can be applied.
a) For the circuit, derive I(s) as a function of Vi(s) as in equation (15) and (16).
b) Write I(s) as a function of the denoted output voltage, Vo(s) and the impedance, sL.
c) Use the expressions, from (a) & (b) to write, Vo(s) as a function of Vi(s). This is the
system transfer function.
d) Model the system transfer function in SIMULINK (in MATLAB) as done in
figure 25. Save the SIMULINK file (as discussed in 3.2.1.)
e) Generate the response of the circuit to a ramp signal (as shown in figure 17, this is a
sub-library of the sources library of SIMULINK).
f) Generate (using MATLAB) the Bode plot of the transfer function derived in part
(c) as shown in figure 27. Modify the properties of the Bode plot, to display the
frequency, f in Hertz (Hz), rather than the angular frequency, in rad/sec (as per
default setting). Also, enable the grid on the plot.

Electrical, Electronic and Computer Engineering

129

4. REFERENCES
[1] E. Lumsdaine & M. Lumsdaine, Creative problem solving: Thinking skills for a
changing world, McGraw Hill, pp. 10-12, 1995.
[2] F. Theron, Linear algebra, University of Pretoria, p. 40, 1996.
[3] J.W. Nilsson & S. Riedel, Electric circuits, Addison-Wesley Pub. Co., New-York,
pp. 14-15, pp. 38-44, pp. 119-123 & pp. 136-140, 1996.
[4] R.C. Jaeger, Microelectronic circuit design, McGraw-Hill, Boston, pp. 53-54, 1997.
[5] J.H. Mathews, Numerical methods for mathematics, science and engineering,
Prentice Hall, p. 71, 1992.
[6] G.E. Carlson, Signal and linear system analysis with MATLAB, John Wiley and
Sons, New-York, p. 28 and pp. 228-244, 1998.
[7] N.S. Nise, Control systems engineering, John Wiley & Sons, New-York, p. 50, 2000.
[8] R.E. Larson, R.P. Hostetler, B.H. Edwards, Calculus with analytical geometry,
Houghton-Mifflin Company, Boston, p. 91 and p. 241, 1998.
[9] D. Halliday, R. Resnick & J. Walker, Fundamentals of physics, John Wiley and sons,
New York, pp. 776-800, 1996.

Electrical, Electronic and Computer Engineering

130

MEASUREMENTS AND COMPUTER MODELLING EMR100


GROUP: ELECTRONICS AND MICROELECTRONICS
EVALUATION WORKSHEET- ASSIGNMENT 1
Name:
Student number:
EXERCISE 1: LINEAR CIRCUIT
a
4
14

ia

10 15

16

V1

144 V

12

18
10

12
ib

ic

id

ie

if

b
Figure 9.
The figure shows the circuit configuration for exercise 1.
For the given circuit (figure 9), determine the following:
a) Write out six equations for each of the loops (meshes) as done in
equations (3) (7) of 2.4.1.

6
b) Write the equation derived in part (a) as a matrix (like in equation (8) of
2.4.)

2
c) Determine the current, ia (using MATLAB).
ia =

131

d) Determine the ratio of the voltage source, V1 to the current, ia. This gives a
resistance, called the Thvenin resistance, Rth. (This is one of the techniques
used to find the Thvenin resistance, i.e. determine the open circuit voltage,
Vth = Voc = V1 and divide it by the current flowing through it, |ia|.) The
Thvenin equivalent circuit is drawn in figure 10 (a). Similar to the Thvenin
equivalent (Nilsson & Riedel, [3]), another equivalent is used, this is called the
Norton equivalent (depicted in figure 10 (b)).
Rth
a

ia

Vth
a

Rth
a

(a)

(b)
Figure 10.
The figure shows (a) the Thvenin equivalent circuit, and (b) the Norton
equivalent to the circuit configuration of figure 7.
Rth =

e) Find the magnitude of the power delivered by the source. This can be
computed by taking the mere product of the current, ia and the source voltage
value, V1. Note, that from the law of conservation of power, the power
delivered by the source is equal to the power dissipated by the circuit (i.e. the
sum of the power dissipated over each resistor) (Nilsson & Riedel, [3]).
Pdelivered = Pdissipated =

15
EXERCISE 2: NON-LINEAR CIRCUIT
Plot the diode i-v characteristic (equation (11)), using the numerical parameters given
in 2.4.2. Plot this equation over a x-axis range of [0, 2] V.
Additionally: Label the x-axis: Diode voltage (V), the y-axis, Diode current (A),
and the graph title as Diode i-v characteristic. Also, enable the grid.
<Copy the graph from the MATLAB graph window, and paste it here>

132

MEASUREMENTS AND COMPUTER MODELLING EMR100


GROUP: ELECTRONICS AND MICROELECTRONICS
EVALUATION WORKSHEET- ASSIGNMENT 2
Name:
Student number:
EXERCISE: TIME & FREQUENCY DOMAIN ANALYSIS
R

1/sC
1

Va o(s)
sL

Vi(s)
I(s)

Figure 28.
The figure shows a simple RLC network. Assume: R = 1 , L = 1 H and C = 1 F.
After, frequency translation (s = j2f = j) all the components have the units ohms,
and hence basic Kirchoffs laws (as discussed in 3.4.1) can be applied.
a) For the circuit, derive I(s) as a function of Vi(s) as in equation (15) and (16).
2

b) Write I(s) as a function of the denoted output voltage, Vo(s) and the
impedance, sL.
1
c) Use the expressions, from (a) & (b) to write, Vo(s) as a function of Vi(s). This
is the system transfer function.
2
d) Model the system transfer function in SIMULINK (in MATLAB) as done in
figure 25. Save the SIMULINK file (as discussed in 3.2.1.) This file needs to
be submitted with this assignment (format of the filename: student#
e.g. 9806145). SIMULINK auto-attaches the <.mdl> extension. You may
copy the block diagram and paste it here from the SIMULINK Model editor.
2
e) Generate the response of the circuit to a ramp signal (as shown in figure 17,
this is a sub-library of the sources library of SIMULINK).
<Copy the graph from the MATLAB graph window, and paste it on the next page>
133

4
f) Generate the Bode plot (using MATLAB) of the transfer function derived in
part (c) as shown in figure 27. Modify the properties of the Bode plot, to
display the frequency, f in Hertz (Hz), rather than the angular frequency, in
rad/sec (as per default setting). Also, enable the grid on the plot.
<Copy the graphs from the MATLAB graph window, and paste it here>

4
15
FTP SUBMISSION
0. Download this report file from
http://eerc.up.ac.za/~elk220/netcourse/files/EMR100/report.doc
1. Complete the report (electronically).
2. Save As the file name to student#_surname.doc e.g. 9806145_SINHA.doc
3. The report (and the <.MDL> file from part (d) of Assignment 2) needs to be
uploaded:
EMR100 website Student Login Upload file
Note: This also evaluates your FTP abilities!
If you really have problems, the file may be submitted via electronic mail:
s.sinha@eng.up.ac.za and using the following subject line format:
[EMR100][EE]: Report student#_surname.doc
(For the latter (e-mail submission) you loose a mark!)
2
134

MEASUREMENTS AND COMPUTER MODELLING EMR100


GROUP: ELECTRONICS AND MICROELECTRONICS
STUDENT FEEDBACK
What did you learn?

I would like to hear more about?

Other comments?

Note: Theres marks allocated (!) to this page, so make sure you give both positive (as
well as any negative) feedback.
-Thank you.
3
Saurabh Sinha
[ s.sinha@eng.up.ac.za, : (012) 420-2950]

TOTAL (E & E): 40


135

Introduction to NI ELVIS

NI ELVIS Workspace Environment

136

NI ELVIS Workspace Environment


Professor Barry Paton
Dalhousie University

The NI ELVIS environment consists of the hardware workspace for


building circuits and interfacing experiments, and the NI ELVIS software.
The NI ELVIS software, all created in LabVIEW has two main types: the
soft front panel (SFP) instruments and LabVIEW APIs, which are just
additional LabVIEW VIs for custom control and access to the features of
the NI ELVIS benchtop workstation.

Goal
This lab introduces the NI ELVIS workstation to show how electronic
component properties can be measured. Circuits are then built on the
protoboard and later analyzed with the NI ELVIS software suite of
LabVIEW based soft front panels (SFP) or software instruments. In
addition, this experiment demonstrates the use of NI ELVIS within a
LabVIEW programming environment.

NI ELVIS Workspace Environment

137

Soft Front Panels (SFP) Used in this Lab


Digital Ohmmeter DMM[], Digital Capacitance meter DMM[C], and the
Digital Voltmeter DMM[V]

Components Used in this Lab


1.0 k resistor R1 (Brown, Black, Red)
2.2 k R2 (Red, Red, Red)
1.0 M resistor R3 (Brown, Black, Green)
1 F capacitor C

NI ELVIS Workspace Environment

138

Exercise 1

Measurement of Component Values


Connect two banana type leads to the DMM current inputs on the
workstation front panel. Connect the other ends to one of the resistors.
Launch NI ELVIS. After initializing, the suite of LabVIEW software
instruments pops up on the computer screen.

Select Digital Multimeter.

NI ELVIS Workspace Environment

139

The Digital Multimeter SFP can be used for a variety of operations. We


will use the notation DMM[X] to signify the X operation. Click on the
Ohm button [] to use the Digital Ohmmeter function DMM[].
Measure R1, R2, and R3. Using the capacitor button [ ], measure the
capacitor C with DMM[C] using the same leads. Fill in the following
table.
R1

_______

(1.0 k nominal)

R2

_______

(2.2 k nominal)

R3

_______

(1.0 M nominal)

C*

_______

(f)

(1 F nominal)

Note If you are using an electrolytic capacitor be sure to connect the + lead of the

capacitor to the DMM current +input and click on the electrolytic button of the DMM[C].
End of Exercise 1

NI ELVIS Workspace Environment

140

Exercise 2

Building a Voltage Divider Circuit on the NI ELVIS


Protoboard
Using the two resistors, R1 and R2, assemble the following circuit on the
NI ELVIS protoboard.

The input voltage Vo is connected to the [+5 V] pin socket and the
common to the NI ELVIS [Ground] pin socket. Connect the external leads
to the DMM voltage inputs (HI) and (LO) on the front panel of the
NI ELVIS workstation.
Note NI ELVIS has separate input leads for voltage and impedance/current

measurements.
Check your circuit and then apply power to the protoboard by switching
the Prototyping Board Power switch to the upper position. The three
power indicator LEDs +15V, 15V, and +5V should now be lit.

Note If any of these LEDS are OFF while the others are ON, the fuse for that power line

has probably blown. Refer to Appendix B of the NI ELVIS User Manual for fuse
replacement.

NI ELVIS Workspace Environment

141

Connect the DMM front panel leads to Vo and measure the input voltage
using the DMM[V].
Circuit theory tells us that the output voltage V1 should be R2/(R1+R2) *
Vo. Using the previous measured values for R1, R2, and Vo, calculate V1.
Then, use the DMM[V] to measure the actual voltage V1.
V1 (calculated) ________________ V1 (measured) ________________
How well does the measured value agree with your calculated value?
End of Exercise 2

NI ELVIS Workspace Environment

142

Exercise 3

Using the DMM to Measure Current


From Ohms law, the current I flowing in the above circuit is equal to
V1/R2. With the measured values of V1 and R2, calculate this current.
Next, do a direct measurement. Do this by moving the external leads to the
workstation front panel DMM (Current) inputs HI and LO. Connect the
other ends to the circuit as shown below.

Select the function DMM[A] and measure the current.


I (calculated) _______________

I (measured) ________________

How well does the measured value agree with your calculated value?
End of Exercise 3

NI ELVIS Workspace Environment

143

Exercise 4

Observing the Voltage Development of a RC Transient


Circuit
Build the RC transient circuit as shown below. It uses the voltage divider
circuit where R1 is now replaced with R3 (1 M resistor) and R2 is
replaced with the 1 F capacitor C. Move your front panel leads back to
the DMM(VOLTAGE) inputs and select DMM[V].

Note NI ELVIS version 1 has limited input impedance (1 M) for the DMM channel.

To read the correct voltage values, you will need to buffer the input voltage for this
measurement. Refer to the Limited Input Impedance Solution section for a simple
solution using a unity gain circuit using a FET Op Amp. This limitation will be remedied
in a future version. Also, notice that if you use the Analog Input channels of the DAQ
card as in Exercise 5, this is not a problem.
When you power up the circuit, the voltage across the capacitor will rise
exponentially. Turn on the power and watch the voltage change on the
DMM display. It takes about 5 seconds to reach the steady state value of

NI ELVIS Workspace Environment

144

Vo. When you power off the circuit, the voltage across the capacitor will
fall exponentially to 0 volts. Try it!
It would be interesting to view this transient effect on a plot of capacitor
voltage versus time.

Limited Input Impedance Solution


Using an FET Op Amp such as the LM356, build a unity gain circuit and
connect it as shown below. By connecting the output (pin 6) to the input
(pin 2), the gain of this circuit is set to 1. However, the + input impedance
on (pin 3) is now hundreds of megaohms and the ouput voltage (pin 6)
will faithfully follow the capacitor voltage allowing the DMM voltage
input to read the correct values.

This limitation will be corrected in future versions of NI ELVIS.


End of Exercise 4

NI ELVIS Workspace Environment

145

Exercise 5

Visualizing the RC Transient Circuit Voltage


Remove the + 5V power lead and replace it with a wire connected to the
Variable Power Supply socket pin VPS[+]. Connect the output voltage,
V1, to ACH0[+] and ACH0[].

Close the NI ELVIS software suite and launch LabVIEW.


From the Hands-On NI ELVIS VI Library, select RC Transient.vi.
This program uses LabVIEW APIs to turn the power supply ON for
5 seconds then OFF for 5 seconds while the voltage across the capacitor is
displayed on a LabVIEW chart.

NI ELVIS Workspace Environment

146

This type of square wave excitation dramatically shows the charging and
discharging characteristics of a simple RC circuit. The circuit time
constant is defined as the product of R3 and C.
From Kirchoffs laws it is easy to show that the charging voltage VC
across the capacitor is given by:
VC = V0 (1-exp(- t/))
and the discharge voltage VD is given by:
VD = V0 exp(- t/)
Can you extract the time constant from the measured chart?
Take a look at the LabVIEW diagram window to see how this program
works.

The VPS Initialization VI on the left starts NI ELVIS and selects the +
power supply. The next VI sets the output voltage on VPS+ to 5 volts.
Next, the first sequence measures 50 sequential voltage readings across
the capacitor at 1/10 of a second intervals. In the For Loop, the Analog
Input Multiple Point VI takes 100 readings at rate of 1000 samples per
second and passes the values to an array (thick orange line). The array is

NI ELVIS Workspace Environment

147

then passed to the Mean VI which returns the average value of the
100 readings. The average is then passed to the chart via a local variable
terminal (RC Charging and Discharging). The next sequence sets the
VPS+ voltage equal to 0 volts and then the last sequence measures another
50 averaged samples for the discharge cycle.
End of Exercise 5

Whats Cool!
This exercise has introduced the software instrument DMM and has shown
how the workstation front panel connectors can be used for the DMM
measurements.

However, one is not restricted to these 4 inputs as they are also present on
the protoboard strip sockets, labeled as:
Front Panel Workstation

Protoboard

DMM(voltage) HI

DMM2 Voltage +

DMM(voltage) LO

DMM2 Voltage

DMM(current) HI

DMM2 Current +

DMM(current) HI

DMM2 Current

Check it out.

NI ELVIS Workspace Environment

148

Digital Thermometer
Professor Barry Paton
Dalhousie University

A thermistor is a 2 wire device manufactured from a semiconductor


material. It has a nonlinear response curve and a negative temperature
coefficient. Thermistors make ideal sensors for measuring temperature
over a wide dynamic range and are also useful in temperature alarm
circuits.

Goal
This lab introduces the NI ELVIS variable power supply. It can be used
with the workstation front panel controls, with the virtual controls on your
computer screen or embedded inside a LabVIEW program. The VPS is
used to excite a 10 k thermistor in a voltage divider circuit. The voltage
measured across the thermistor is related to its resistance which in turn is
related to its temperature. This lab demonstrates how LabVIEW controls
and indicators together with NI ELVIS APIs are used to build a digital
thermometer.

Digital Thermometer

149

Soft Front Panels (SFP) Used in this Lab


Digital Ohmmeter (DMM[]) and the Digital Voltmeter (DMM[V]),
VPS APIs

Components Used in this Lab


10 k resistor R1 (Brown, Black, Orange)
10 k thermistor RT

Digital Thermometer

150

Exercise 1

Measurement of the Resistor Component Values


Launch NI ELVIS, select Digital Multimeter and click on the Ohms
button. First connect the 10 k resistor and then the thermistor and
measure their component values.
Fill in the following chart.
10 k resistor

_________________ Ohms

Thermistor

_________________ Ohms

Now place the thermistor between your finger tips to heat up the
thermistor and watch the resistance change. The fact that the resistance
decreases with increasing temperature (negative temperature coefficient)
is one of the key characteristics of a thermistor. Thermistors are
manufactured from semiconductor material whose resistivity depends
exponentially on ambient temperature and results in the following
nonlinear response. Compare the thermistor response with an RTD
(100 Platinum Resistance Temperature Device) shown below.
10 M

Resistance ()

1M

Thermistor
(2252 at 25 C)

100 k
10 k

RTD
(PT 100 )

1k
100

400

350

300

250

200

150

100

50

50

100

150

200

10

Temperature (C)

End of Exercise 1

Digital Thermometer

151

Exercise 2

Operating the Variable Power Supply


From the NI ELVIS Instrument Launcher, select Variable Power
Supplies. There are two controllable power supplies with NI ELVIS,
0 to 12 volts and 0 to +12 volts, each with a 500 mA current limit.

On the NI ELVIS workstation, slide the VPS+ switch to Manual.


Notice on the virtual VPS window how the controls are now grayed out
and can not be operated with the mouse. A green LED also signals the fact
that the VPS is in manual control. Only the front panel controls can
change the output voltage.
Connect the leads from [VPS+] and [Ground] sockets to the workstation
DMM voltage inputs.
Select DMM[V].
Rotate the manual VPS knob on the workstation and observe the voltage
change on the DMM[V].
Note The zero voltage position for VPS+ control is counter-clockwise (CCW) and for
VPS control is clockwise (CW).

Slide the workstation switch for VPS+ down (not Manual). You can now
use the virtual VPS controls on the computer screen. Click and drag the
virtual knob to change the output voltage. Notice the [RESET] button that
quickly resets the voltage back to zero. VPS works in a similar fashion,
only the output voltage is negative.
End of Exercise 2

Digital Thermometer

152

Exercise 3

A Thermistor Circuit for DAQ Operation


On the workstation protoboard, build a voltage divider circuit using the
10 k resistor and a thermistor. The input voltage is wired to [VPS+] and
[Ground] sockets. Measure the voltage across the thermistor with the
DMM[V] and workstation leads.

Figure 1 Thermistor Circuit

Make sure the workstation VPS+ knob is set CCW (zero volts position)
and the slide switch is set to Manual. Power up the protoboard and
observe the voltage levels on the DMM[V]. As you increase the voltage
from 0 to +5 volts, the voltage across the thermistor VT should increase to
about 2.5 volts. Reduce the power supply voltage to +3 volts.
Heat the thermistor with your finger tips and watch the voltage decrease.
We can now rearrange the standard voltage divider equation to calculate
the thermistor resistance.
RT = R1 * VT /(3 VT)
At an ambient temperature of 25 C, the resistance should be about 10 k.
Check it out!
This equation, called a scaling function, allows one to convert the
measured voltage into the thermistor resistance. VT can easily be measured
with the NI ELVIS DMM or within a LabVIEW program.

Digital Thermometer

153

In LabVIEW, the above scaling equation is coded as a subVI and looks


like the following:

End of Exercise 3

Digital Thermometer

154

Exercise 4

Calibration of the Thermistor


A typical thermistor response curve demonstrates the relationship between
device resistance and temperature. It is clear from this curve that a
thermistor has three characteristics: the temperature coefficient R/T is
negative, the response curve is nonlinear (exponential), and the resistance
varies over several decades (refer to the diagram in Exercise 1). A
calibration curve can be produced by fitting a mathematical equation to
the response curve. LabVIEW is rich in mathematical tools to fit such a
relationship. Once it is found, then the temperature can be calculated for
any resistance within the calibrated region. The following calibration VI is
typical for a thermistor and demonstrates how the LabVIEW formula node
can be used to evaluate mathematical equations.

End of Exercise 4

Digital Thermometer

155

Exercise 5

Building an NI ELVIS Virtual Digital Thermometer


The digital thermometer program turns on the VPS to power up the
thermistor circuit, then reads the voltage across the thermistor and
converts it into temperature. The basic program is a variation of the
Simple Variable Power Supply Application found in the NI ELVIS User
Manual, Figure 4-1. The Block Diagram is shown below.

NI ELVIS has the same Device Number (usually 1) as your DAQ card.
The NI ELVIS Initialization selects VPS Supply+. Then the voltage level
on the power supply is set with the VPS[Update] VI to + 3 volts.
Measurement, scaling, calibration, and display occur in sequence within
the While Loop. VoltsIn.vi measures the thermistor voltage.
Scaling.vi converts the measured voltage to resistance according the
scaling equation above. Convert R-T.vi uses a known calibration
equation to convert the thermistor resistance into temperature. Finally, the
temperature is displayed on the LabVIEW front panel in a variety of
formats.
The Wait function of 100 milliseconds ensures the voltage is sampled
every 1/10 of a second.
The digital thermometer continues running until the [Stop] button on the
front panel button is activated. When the loop ends, the supply reference is
closed and the VPS is set to zero volts.
From the Hands-On NI ELVIS VI Library, open Digital
Thermometer.vi.
Open up the program and sub VIs to view the program flow and see how
the subVIs, Read and Convert functions are coded.

Digital Thermometer

156

With the calibration file for your thermistor, you can generate the proper
subVI (Convert R->T) and use it to have a functioning digital
thermometer.
For those wishing to write their own program, you can use the DT
Template.vi (found in the Hands-On NI ELVIS VI Library) and
add your own programming style. You will find the VPS APIs in
FunctionsAll FunctionsInstrument I/OInstrument Drivers
NI ELVISVariable Power Supplies.

End of Exercise 5

Digital Thermometer

157

Exercise 6

Digital Thermometer with a Logging Feature


The simple digital thermometer program displays three indicators on the
front panel: a digital display, a meter, and a thermometer. Often only one
or two display formats are required. However, adding a logging feature
allows the temperature trend to be observed. In DT Logger.vi (found in
the Hands-On NI ELVIS VI Library), a chart on the front panel has been
added. This feature can be added as a single LabVIEW control (Waveform
Chart) on the front panel, found in the Controls/Graph menu.
From the Hands-On NI ELVIS VI Library, load and view the program DT
Logger.vi.
End of Exercise 6

Whats Cool!
NI ELVIS VPS can be used with WS front panel controls or Virtual
controls or within a LabVIEW program to build that special instrument.
There are many other features just wanting to be added to the digital
thermometer program. How about a [Hold/Update] button so you can
sample and hold the current value on a digital display. Later by toggling a
button, the temperature is updated. How about plotting T versus time and
you decide the reference temperature. Enjoy!

Digital Thermometer

158

AC Circuit Tools
Professor Barry Paton
Dalhousie University

Most electronic circuits are AC (alternating current) and our ability to


design good circuits depends on the tools to measure components,
measure impedance, and display circuit properties. With good tools and a
little circuit knowledge, one can tweak any circuit to give optimal
response.

Goal
This lab introduces the NI ELVIS tools for AC circuits: digital multimeter,
function generator, oscilloscope, impedance analyzer, and the Bode
analyzer.

AC Circuit Tools

159

Soft Front Panels (SFP) Used in this Lab


Digital Ohmmeter (DMM[]), Function Generator (FGEN), Oscilloscope
(OSC), Impedance Analyzer (IA), and the Bode Analyzer (BodeA).

Components Used in this Lab


1 k resistor R (Brown, Black, Red)
1 F capacitor C

AC Circuit Tools

160

Exercise 1

Measurement of the Circuit Component Values


Launch the NI ELVIS Instrument Launcher and select Digital
Multimeter. Use the DMM[] to measure the resistor R and then use
DMM[C] to measure the capacitor C.
Fill in the following chart.
Resistor

Capacitor C

_________________

(1k nominal)

_________________ F

(1 F nominal)

Close the DMM.


End of Exercise 1

AC Circuit Tools

161

Exercise 2

Measurement of Component and Circuit Impedance Z


For a resistor, the impedance is the same as the DC resistance. It can be
represented on a 2-D plot as a line along the X axis often called the real
component. For a capacitor, the impedance (or more specifically, the
reactance) XC is imaginary, depends on frequency and can be represented
as a line along the Y axis of a 2-D plot. It is called the imaginary
component. Mathematically, the reactance of a capacitor is represented by:
XC = 1/jC
where is the angular frequency (measured in radians/sec) and j is a
symbol used to represent an imaginary number. The impedance of a RC
circuit in series is the sum of these two components where R is the
resistive (real) component and XC is the reactive (imaginary) component.
Z = R + XC = R + 1/jC (Ohms)
This can also be represented as a phasor vector on a polar plot with:
Magnitude = (R2 + XC2)

and

Phase = tan-1 (XC / R)

A resistor has a phasor along the real (X) axis. A capacitor has a phasor
along the negative imaginary (Y) axis. Recall from complex algebra that
1/j = j.
Wouldnt it be great to visualize this phasor in real time?
Select Impedance Analyzer from the NI ELVIS Instrument Launcher
menu.

AC Circuit Tools

162

Connect leads from the front panel DMM (current) inputs to the 1 k
resistor. Verify that the phasor is along the real axis and the phase is zero.
Now connect the leads to the capacitor. Verify the phasor is along the
negative imaginary axis and the phase is 270 or 90 degrees. Adjust the
Measurement Frequency control box to observe that the reactance (length
of the phasor) gets smaller when you increase the frequency and larger
when you decrease the frequency. Now connect the leads across the
resistor and capacitor in series (be sure to verify the circuit is not
connected to ground). The circuit phasor has both a real and an imaginary
component. Change the frequency and watch the phasor move.
Adjust the frequency until the reactance component (X) is equal to the
resistance component (R). This is a special frequency value where the
phase is:
_______ degrees
The magnitude also has special meaning at this frequency or phase angle.
What is the magnitude of the phasor at this point?

Answer: R 2

Close the Impedance Analyzer.


End of Exercise 2

AC Circuit Tools

163

Exercise 3

Testing a RC Series Circuit with the Function Generator


and Oscilloscope
On the workstation protoboard, build a voltage divider circuit, with a 1 F
capacitor and a 1 k resistor. Connect the RC circuit inputs to [FGEN]
and [Ground] pin sockets.

The power supply for an AC circuit is often a function generator and we


will be using it to test our RC circuit. From the NI ELVIS Instrument
Launcher, select Function Generator.

AC Circuit Tools

164

The FGEN SFP has the usual controls for setting the Frequency by
decades (Course) and by Hertz (Fine), for selecting the waveform type
(Sine, Square, or Triangle) and for selecting the waveform amplitude. All
of these controls are also available on the workstation front panel as real
controls. They can be selected by sliding the workstation front panel
function generator switch to Manual. As with the Variable Power Supply,
manual control turns on the green LED display on the SFP and grays out
the virtual controls.
Note If you wish to add a DC offset to the AC signal, it is only available on the SFP

FGEN.
We will use the oscilloscope to analyze the voltage signals of the RC
circuit.

AC Circuit Tools

165

From the NI ELVIS Instrument Launcher, select Oscilloscope.

The oscilloscope SFP is similar to most oscilloscopes, but the NI ELVIS


oscilloscope can automatically connect inputs to a variety of sources.
Click on the CHANNEL A Source box and see the list.
BNC/Board CH A, ACH0, ACH1, ACH2, ACH5,
FGEN FUNC_OUT, FGEN SYNC_OUT, and DMM Voltage
Set the Source on Channel A, Source on Channel B, TRIGGER and
TIMEBASE inputs as shown above. This configuration allows the
oscilloscope to look at the output of the function generator on channel A,
the FGEN TTL synchronization signal (SYNC_OUT) on channel B and be
triggered with the SYNC_OUT signal. Make sure you have clicked on the
Run button of the FGEN SFP and on the OSC SFP. Play with the FGEN
controls (virtual or real) and observe the changes on the oscilloscope
window.
There are measurement options such as frequency, Amplitude P-P etc.
accessed by clicking on the MEAS buttons for either channel A or B.
Measurements show up at the bottom of the oscilloscope screen.
Even cursors for channel A or B can be activated for making amplitude
and time measurements.

AC Circuit Tools

166

Now connect the workstation BNC SCOPE input CH B to the 1 k


resistor.
Note You could also have used the channel B inputs on the protoboard pin sockets

labeled Oscilloscope CH B+ and CH B.


You will see the input signal as before on Channel A and the output signal
for our RC circuit on channel B. Trigger as before on the FGEN
SYNC_OUT and select a Sine wave on the FGEN. The ratio of the
amplitude on channel B to the amplitude on channel A defines the circuit
gain at a particular frequency. Since there is no amplifier in the circuit, the
gain will be less than one. By looking at different frequencies, you can get
a feel for the frequency characteristics of the RC passive filter circuit.
Challenge
Find the frequency for which the gain equals 1/2. On the oscilloscope
screen, measure the phase difference between the Channel A trace and
Channel B trace at this frequency.
Can you relate this phase measurement to the Phasor phase measurement
found with the Impedance Amplifier in Exercise 2?
Close the function generator and oscilloscope.
End of Exercise 3

AC Circuit Tools

167

Exercise 4

The Gain/Phase Bode Plot of the RC Circuit


A Bode plot defines in a very real graphical format the frequency
characteristics of an AC circuit. Amplitude response is plotted as the
circuit gain measured in decibels as a function of log frequency and the
Phase response is plotted as the phase difference between the input and
output signals on a linear scale as a function of log frequency.
From the NI ELVIS Instrument Launcher, select Bode Analyzer.
The Bode Analyzer allows one to scan over a range of frequencies; from a
start frequency to a stop frequency in steps of F. You can also set the
amplitude of the test sine wave. The Bode Analyzer uses the SFP function
generator to generate the test waveform. The FGEN output sockets must
be connected to your test circuit and also to ACH1. The output of the
circuit under test goes to ACH0. Further details can be found by clicking
on the [HELP] button on the lower right corner of the Bode Analyzer
window.
Re-build on the NI ELVIS protoboard the RC circuit, similar to the
following circuit and make connections as described above.

AC Circuit Tools

168

Verify your circuit is connected as above and click on the Run button.

Use the Display options to select the graphing format and the cursors to
read points off the frequency characteristic.
Note The frequency where the signal amplitude has fallen to 3 dB, is the same

frequency where the phase is 45 degrees.


End of Exercise 4

AC Circuit Tools

169

Whats Cool!
Both the Oscilloscope and Bode Analyzer SFPs have a Log button. When
activated the data presented on the graphs is written to a spreadsheet file
on your hard drive. You can now read this data for further analysis with
Excel, LabVIEW, DIAdem, or any other analysis or plotting program.

AC Circuit Tools

170

MATLAB & LINEAR SYSTEMS

171

MATLAB Tutorial
compiled by
F.R. Camisani-Calzolari and L. Staphorst
26/06/2003

This is a short tutorial to get you started with some of the basics of MATLAB.
Firstly, point to the Start tab at the bottom left of your screen, select Programs, then
MATLAB and then click on the MATLAB icon.
1. You will notice a statement such as:
To get started, type one of these commands: helpwin,
helpdesk, or demo.
Below this statement there will be a double greater than sign (""). This is the
MATLAB prompt. All command line calls are performed at the prompt

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 1/22

2. Try entering the following and then press enter ():


1+1
ans =
2

MATLAB gives the answer preceded by the abbreviation "ans".


3. Also try the following:

10*3
2/3
7-10

4. Variables can be assigned in MATLAB. Note that MATLAB is case sensitive.


Try the following:
a=3
b=-7.8
MATLAB has stored the value 3 in a and the value -7.8 in b.
5. Now call each of the variables from the prompt. For example:
a
a =
3

6. You can now perform calculations with the variables. Try the following:
a*b
a/b
c=a+b
In the last operations, the answer of a time b is stored in a new variable, c.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 2/22

7. Row and column vectors, as well as matrices may be specified by a variable or


just straight from the prompt.
Let's assign the following row vector x=[1 2.1 6.3]
x=[1 2.1 6.3]
x =
1.0000
2.1000

6.3000

or:
x=[1,2.1,6.3]
x =
1.0000
2.1000

6.3000

8. You can also define column vectors. Take a look at the following example:
y=[
4
-6
-3
]
y =

4
-6
-3

The same thing will happen if you type:


y=[4;-6;-3]
Thus, semicolons indicate new rows, commas indicate new columns.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 3/22

9. A transpose is taken by adding a "'" after the variable or statement:


y'
ans =
4
x'

-6

-3

ans =
1.0000
2.1000
6.3000

10. Note that a calculation on a vector or a matrix can be assigned to a new variable,
i.e:
c=y'
c =
4

-6

-3

11. Multiplication of matrices or vectors is also possible:


x*y
ans =
-27.5000

or:
y*x
ans =
4.0000
-6.0000
-3.0000

8.4000
-12.6000
-6.3000

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

25.2000
-37.8000
-18.9000

Page 4/22

12. Matrices can be defined similarly. Let's define the following matrix:
A=[
1.1 2 3
-6 7 1
4 3 -2
]
A =

1.1000
-6.0000
4.0000

2.0000
7.0000
3.0000

3.0000
1.0000
-2.0000

You would have gotten the same result by doing the following:
A=[[1.1,2,3];[-6,7,1];[4,3,-2]]
or with:
A=[1.1,2,3;-6,7,1;4,3,-2]
13. The inverse of a matrix can be determined in two ways. Either by function:
inv(A)
ans =
0.0984
0.0463
0.2664

-0.0753
0.0822
-0.0272

0.1100
0.1106
-0.1141

-0.0753
0.0822
-0.0272

0.1100
0.1106
-0.1141

or by an operator:
A^(-1)
ans =
0.0984
0.0463
0.2664

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 5/22

14. One can determine the dimensions of vectors and matrices as follows:
To determine the number of rows of a matrix or vector:
size(y,1)
ans =

To determine the number of columns of a matrix or vector:


size(x,2)
ans =
3

To determine the number of rows and columns of a matrix:


size(A)
ans =
3

which means that A is a 3x3 matrix.


15. The following statement gives the names of all the variables in memory:
who
Your variables are:
A
ans
x
a
c
y

Also:
whos
Name
A

Size
3x3

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Bytes
72

Class
double array
Page 6/22

a
ans
c
x
y

1x1
1x2
1x3
1x3
3x1

8
16
24
24
24

double
double
double
double
double

array
array
array
array
array

Grand total is 21 elements using 168 bytes

gives the sizes and dimensions of each of the variables.


16. One can extract elements from a matrix. The following statement extracts the
element in row 1 and column 1 of the A matrix:
A(1,1)
ans =
1.1000

The next statement extracts the element in row 2 and column 3:


A(2,3)
ans =

17. One can extract rows and columns from matrices and vectors:
A(2,:)
ans =
-6

The statement instructs MATLAB to display all elements in row two and all the
columns (:) of matrix A.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 7/22

18. Similarly, you can extract column vectors:


A(:,3)
ans =
3
1
-2

This instructs MATLAB to display all rows of column 3 of matrix A.


19. You can also get block matrices from other matrices:
A(1:2,2:3)
ans =
2
7

3
1

This instructs MATLAB to extract rows 1 to 2 and columns 2 to 3 from matrix A.


You could also assign the answer to a new matrix, e.g. B:
B=A(1:2,2:3)
B =

2
7

3
1

20. Press the up arrow ( ). What does it do?


21. Type a few characters of a previous statement and then press the up arrow.
B=
becomes:
B=A(1:2,2:3)
This is true for all previous statements.
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 8/22

22. Some special matrices:


C=zeros(2,4)
C =

0
0

0
0

0
0

0
0

gives a zero'd 2x4 C matrix.


D=ones(6,8)
D =

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

1
1
1
1
1
1

gives a 6x8 matrix filled with ones.


23. The semicolon ";" is used at the back of an operation when we do not want to see
the result, but still keep it stored in memory. Think of what the following
statement will do:
S=ones(300000,300000)
MATLAB will display the result of S. In this case it will take several hours to
display the result. One should rather execute the statement as follows:
S=ones(300000,300000);
S is still assigned the matrix, but S is not displayed.
24. One frequently needs to declare a vector of a series of numbers. For instance, in
signals we may be interested in a time vector which starts at zero, steps in 1 s and
ends at 10 seconds. This can be done in MATLAB by the following statement:

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 9/22

t=0:10
t =
9

0
10

25. Sometimes one doesn't want to use the default incremental value of 1, but rather
0.1, as an example. The following generates a vector starting at 0 and ending at 1
with 0.1 increments:
t=0:.1:1
t =
Columns 1 through 7
0
0.1000
0.5000
0.6000
Columns 8 through 11
0.7000
0.8000

0.2000
0.9000

0.3000

0.4000

1.0000

Also try t=1:-.1:0;


26. Typing help at the MATLAB prompt will generate a list of help categories
depending on your system. This is a useful feature, especially when installing
toolboxes or when you are unfamiliar with MATLAB. For instance:
help
HELP topics:
m-files\sid
MATLAB\general
MATLAB\ops
MATLAB\lang
MATLAB\elmat
MATLAB\elfun
MATLAB\specfun
MATLAB\matfun
MATLAB\datafun
MATLAB\polyfun
MATLAB\funfun
MATLAB\sparfun
MATLAB\graph2d
MATLAB\graph3d
MATLAB\specgraph
MATLAB\graphics

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

(No table of contents file)


General purpose commands.
Operators and special characters.
Programming language constructs.
Elementary matrices and matrix manipulation.
Elementary math functions.
Specialized math functions.
Matrix functions - numerical linear algebra.
Data analysis and Fourier transforms.
Interpolation and polynomials.
Function functions and ODE solvers.
Sparse matrices.
Two dimensional graphs.
Three dimensional graphs.
Specialized graphs.
Handle Graphics.
Page 10/22

MATLAB\uitools
MATLAB\strfun
MATLAB\iofun
MATLAB\timefun
MATLAB\datatypes
MATLAB\dde
MATLAB\demos
fuzzy\fuzzy
fuzzy\fuzdemos
toolbox\rtw
bin\nt
stateflow\stateflow
stateflow\sfdemos
simulink\simulink
simulink\blocks
simulink\simdemos
simulink\dee
toolbox\local
toolbox\control
toolbox\ident
toolbox\mpc
mpc\mpccmds
mpc\mpcdemos

Graphical user interface tools.


Character strings.
File input/output.
Time and dates.
Data types and structures.
Dynamic data exchange (DDE).
Examples and demonstrations.
Fuzzy Logic Toolbox.
Fuzzy Logic Toolbox Demos.
Real-Time Workshop
(No table of contents file)
Stateflow
(No table of contents file)
Simulink
Simulink block library.
Simulink demonstrations and samples.
Differential Equation Editor
Preferences.
Control System Toolbox.
System Identification Toolbox.
(No table of contents file)
Model Predictive Control Toolbox
Model Predictive Control Toolbox

For more help on directory/topic, type "help topic".

You can ascend further down and ask for:


help elfun
Elementary math functions.
Trigonometric.
sin
sinh
asin
asinh
cos
cosh
acos
acosh
tan
tanh
atan
atan2
atanh
sec
sech
asec
asech
csc
csch
-

Sine.
Hyperbolic sine.
Inverse sine.
Inverse hyperbolic sine.
Cosine.
Hyperbolic cosine.
Inverse cosine.
Inverse hyperbolic cosine.
Tangent.
Hyperbolic tangent.
Inverse tangent.
Four quadrant inverse tangent.
Inverse hyperbolic tangent.
Secant.
Hyperbolic secant.
Inverse secant.
Inverse hyperbolic secant.
Cosecant.
Hyperbolic cosecant.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 11/22

acsc
acsch
cot
coth
acot
acoth

Inverse cosecant.
Inverse hyperbolic cosecant.
Cotangent.
Hyperbolic cotangent.
Inverse cotangent.
Inverse hyperbolic cotangent.

Exponential.
exp
log
log10
log2
pow2
sqrt
nextpow2

Exponential.
Natural logarithm.
Common (base 10) logarithm.
Base 2 logarithm and dissect floating point number.
Base 2 power and scale floating point number.
Square root.
Next higher power of 2.

Complex.
abs
angle
conj
imag
real
unwrap
isreal
cplxpair

Absolute value.
Phase angle.
Complex conjugate.
Complex imaginary part.
Complex real part.
Unwrap phase angle.
True for real array.
Sort numbers into complex conjugate pairs.

Rounding and remainder.


fix
- Round towards zero.
floor
- Round towards minus infinity.
ceil
- Round towards plus infinity.
round
- Round towards nearest integer.
mod
- Modulus (signed remainder after division).
rem
- Remainder after division.
sign
- Signum.

You could then ask for individual help on a specific function:


help conv
CONV Convolution and polynomial multiplication.
C = CONV(A, B) convolves vectors A and B. The resulting
vector is length LENGTH(A)+LENGTH(B)-1.
If A and B are vectors of polynomial coefficients, convolving
them is equivalent to multiplying the two polynomials.
See also XCORR, DECONV, CONV2, FILTER, and CONVMTX in the
Signal Processing Toolbox.

27. If you are looking for a function that does something, but you do not know the
name of that function, you can use the lookfor command. For instance, let's
assume that we are looking for an FFT algorithm.
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 12/22

lookfor fft

FFT Discrete Fourier transform.


FFT2 Two-dimensional discrete Fourier Transform.
FFTN N-dimensional discrete Fourier Transform.
FFTSHIFT Shift DC component to center of spectrum.
IFFT Inverse discrete Fourier transform.
IFFT2 Two-dimensional inverse discrete Fourier transform.
IFFTN N-dimensional inverse discrete Fourier transform.
INTERPFT 1-D interpolation using FFT method.
FFTDEMO Demonstrate use of FFT for spectral analysis.
SFUNPSD an S-function which performs spectral analysis using ffts.
SFUNTF an S-function which performs transfer function analysis using
ffts.
fft.m: % Overload of fft() for uint8 inputs

MATLAB searches its database and gives the names of all files with matching
patterns.
28. Assume that we would like to determine the following expression:
t
y (t ) = sin 2 t = 0,0.1,0.2,,10s . To do this we would issue the following
5

statements in MATLAB:
t=0:.1:10;
y=sin(2*pi*t/5);
The vector y now contains the result of the expression.

29. One could now plot the data:


plot(y)
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 13/22

This gives a plot of the data as observations from 1 to 101 on the x-axis.

plot(t,y)
gives the data as a function of the time vector t.

plot(t,y,t,y,'o')
gives a plot with interpolated lines and "o"'s where the data is present.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 14/22

30. One can assign titles to the axis and to the figures.
xlabel('Time [s]')
ylabel('Voltage [V]')
title('Voltage as a function of time over R_1')

31. You can also generate a grid on the plot:


grid on
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 15/22

32. You can also zoom in or out of the graph.


zoom on

33. Many different types of graphs exist. Take a look at these two:
stem(t,y)
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 16/22

bar(t,y)

34. One can also plot 3-D graphs:


z=peaks(25);
surfl(z);
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 17/22

shading interp;
colormap(pink);

Or contour plots:

z=peaks(25);
contour(z,16);
colormap(jet)
colorbar

35. The hold function is used to hold the graph, i.e. nothing is cleared when the
next plot is rendered:
plot(t,y,t,y,'o')
hold
Current plot held
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 18/22

y2=cos(2*pi*t/5);
plot(t,y2)

Note that the same result would have occurred if we issued the command
plot(t,y,t,y,'o',t,y2)
36. Sometimes it can get very tedious to write code at the command prompt. One can
however overcome this in two ways: Either with script-files or m-files.
A script file is just a set of commands which is executed from a file rather than
the prompt. To generate a script file, point to File->New->M-File and click. A
new document opens in MATLAB's Editor/Debugger.
Enter in the new script file the following:
%This is a comment. Clear all variables.
clear
t=0:0.1:10;
%This is a comment. We are
%going to find the parabola and plot it.
y=t.^2 ;
plot(t,y,t,y,'.');
xlabel('Time [s]');
ylabel('Voltage [V]');
%End of script
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 19/22

Now, save the file as myscript.m. You can use any name, but be careful that it
does not clash with other functions or scripts. Execute the script as follows:
myscript

37. The user can also be prompted to enter values. See the script myscript2.m which
contain the following lines:
%Calculate the area of a triangle:
base=input('What is the length of the base of the
traingle');
height=input('What is the height of the traingle');
area=0.5*base*height
Now execute the script. You will be prompted to enter values and the answer will
then be given:
myscript2
What is the length of the base of the traingle? 10
What is the height of the traingle? 5
area =
25

38. One can also generate functions (true m-files) which take arguments and return
variables. For instance, lets assume that we want to generate a function which
takes the length and width of a rectangle and then calculates the area. Open the
MATLAB Editor/Debugger and enter these lines of text in that new file:
function A=rectangle_area(length,width)
%You may place comments anywhere
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 20/22

%Determine the are


A=length*width;
%The area will be returned in A
Now save the file as rectangle_area.m and excute it with lengths and widths of
your choice at the prompt. Let it return to any variable name you want:
the_area=rectangle_area(4,3)
the_area =
12

39. One could also return more that one variable. Let's assume we want our function
to return both the area and the circumference. We would modify our function as
follows:
function [A,C]=rectangle_area(length,width)
%You may place comments anywhere
%Determine the area
A=length*width;
%The area will be returned in A
C=2*length+2*width;
%The circumference will be returned in C
Execute the function at the prompt:
[the_area,the_circumference]=rectangle_area(4,3)
the_area =
12
the_circumference =
14

40. For loops and conditional statements are also possible in MATLAB functions.
Use the MATLAB Editor/Debugger and write the following function to determine
a factorial:
function total=findfactorial(x)
%Determine x! except when x=0;
total=1;
if x~=0,
for i=1:x,
Creation Date: 16/07/2001
Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 21/22

total=total*i;
end
end
Execute at the prompt.
findfactorial(3)
ans =
6
findfactorial(4)
ans =
24
findfactorial(5)
ans =
120
a=findfactorial(6)
a =
720
a=findfactorial(0)
a =
1

41. Directories command are also available: cd (change directory DOS), dir (DOS), ls
(UNIX) and pwd (UNIX) are all valid MATLAB commands. See what they do.
42. Storing variables: Experiment with the save and load commands in MATLAB.

Creation Date: 16/07/2001


Date Last Modified: 26/06/2003
Authors: F.R. Camisani-Calzolari and L. Staphorst
Title: MATLAB_Tutorial.doc

Page 22/22

You might also like