ABSTRACT - SIM University

advertisement
1
2
SIM UNIVERSITY
SCHOOL OF SCIENCE AND TECHNOLOGY
3
4
5
6
7
8
9
10
11
12
13
14
15
APPLICATION OF
MICRO-CONTROLLER
AND DAC IN A
WAVEFORM GENERATOR
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
1
STUDENT
: KOO HONG TAK (K0706388)
SUPERVISOR
: CHONG SIEW PING
PROJECT CODE : JAN09/BEHE/74
A project report submitted to SIM University
in partial fulfilment of the requirements for the degree of
Bachelor of Engineering in Electronics
28 NOV 2009
i
2
3
4
5
6
7
8
9
10
11
12
ABSTRACT
The author’s project involves the designed and implementation of the waveform generator with
the use microcontroller and Digital-to-Analog Converter(DAC). Different types of waveform
such as square, sine, triangular and DC can be generated with vary frequency and amplitude. The
report initially covers a brief introduction about the waveform generator, information about the
waveform generator available on the market and the analysis of relevant technologies. It then
proceeds to document the development of the waveform generator, in the hardware and software.
Finally, the report includes some suggestion for the improvement of the waveform generator.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
i
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ACKNOWLEDGEMENT
The author would like to thank the following people for their continued help, support and
guidance throughout this project. The work presented in this report would not been possible
without them:

Mr. Chong Siew Ping, author’s project supervisors from Singapore Polytechnic, for all
his immensely useful suggestions, ideas, and time. His encouragement, guidance and
advice were invaluable in keeping the project on track.

The author’s supervisor from Chartered Semiconductor Manufacturing Mrs. Neo Soh
Ping and Mrs Loh Sock Khim for their encouragement and guidance for the improve of
the project thesis.

The author’s friends Mr. Ang Wei Jie and Mr. Steven Tan Kok Meng for the sharing of
their knowledge and guidance for the improvement for this project throughout the
duration of this project.

Finally, author’s biggest thank you goes to his parents for their unwavering love,
guidance and support.
Words can never describe how grateful the author is to those mentioned above.
ii
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
TABLE OF CONTENTS
ABSTRACT
i
ACKNOWLEDGEMENT
ii
LISTS OF FIGURE
v
LIST OF TABLES
vii
CHAPTER ONE
INTRODUCTION
1
1.1
Project Background
1
1.2
Project Objective
1
1.3
Overall Project Objective
2
1.4
Proposed Approach
2
1.5
Skills Review
3
CHAPTER TWO
LITERATURE REVIEW
4
2.1
Waveform
4
2.2
Waveform Generator
5
2.3
Hardware and Software Overview
7
2.3.1
Hardware Overview
2.3.1.1 Microcontroller
2.3.2
7
7
2.3.1.2 Operational Amplifier
12
2.3.1.3 Digital-To-Analog Converter
21
Software Overview
26
2.3.2.1 Integrated Development Environment
26
2.3.2.2 Ways to Generate Waveform
27
CHAPTER THREE
DESIGN AND DEVELOPMENT
3.1
Architecture of Waveform Generator
32
32
iii
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
3.2
Software Architecture
36
CHAPTER FOUR
TESTING AND RESULTS
37
4.1
Hardware and Software Testing
37
4.2
Results
39
CHAPTER FIVE
PROBLEMS ENCOUNTERED AND SOLUTIONS
42
CHAPTER SIX
PROJECT PLANNING AND MANAGEMENT
43
CHAPTER SEVEN
CONCLUSION
44
7.1
Future Work
44
7.2
Summary
44
REFERENCES
46
APPENDIX A - Gantt Chart for Project Planning
49
APPENDIX B - Schematic Diagram
50
APPENDIX C - Software Flow Chart Structure
52
APPENDIX D - Test Program
54
APPENDIX E - Main Program Source Code
56
APPENDIX F – Test Results
62
APPENDIX G
– Prototype of Waveform Generator
67
191
iv
192
193
194
195
196
197
198
199
200
201
202
LIST OF FIGURES
Figure1: Proposed Waveform Generator Layout
2
Figure2: Proposed Software Flow Chart
3
Figure3: Periodic Waveform
5
Figure4: Example of Some Waveform Generator
6
Figure5: ICL8038 Connection for Waveform Generator
6
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
Figure6: System Block Diagram
7
Figure7: Basic Mircocontroller Architecture
8
Figure17: Summing Amplifier
20
226
Figure18: Output Signal of DAC
22
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Figure19: Output Signal of Samples-And-Holds
22
Figure20: 6-bit Binary-Weighted-Input DAC
23
Figure21: R-2R Ladder DAC
23
Figure22: Produce Waveform Using Counter and A LUT
28
Figure8: Standard Operational amplifier Symbol
13
Figure9: Equivalent Circuit Of An Op-Amp
16
Figure10: Open Loop Gain
17
Figure11: Positive Feedback Configuration
17
Figure12: Negative Feedback Configuration
17
Figure13: Virtual Ground with Negative Feedback
18
Figure14: Inverting Amplifier
19
Figure15: Non-inverting Amplifier
19
Figure16: Voltage Follower
20
Figure23: Adjust Peak Voltage by Using a Multiplier
29
Figure24: Adjust Peak Voltage by Using a Shift Register and Adder
30
Figure25: Number of Clock Ticks Before Increasing the Angle by One Degree
31
Figure26: Architecture of Waveform Generator
32
Figure27: Microcontroller Board
33
v
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Figure28: Digital-to-Analog Board
34
Figure29: Switch and LED Board
35
Figure30: PICkit2 Tool
35
Figure31: Message showed PICkit2 Detected and Ready for Use
38
Figure32: Message showed Programmed Process Success and Completed
38
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
vi
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
LIST OF TABLES
Table1: PIC18F2520 Features
11
Table2: Comparison for Ideal and Practical Op-amp
16
Table3: Sine Look-Up-Table (LUT)
28
Table4: Example of Some Digital Code Value
34
Table5: Square Wave Result
39
Table6: Triangular Wave Result
40
Table7: Triangular Wave Result
41
Table8: Project Task with Schedule
43
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
vii
INTRODUCTION
1.1 PROJECT BACKGROUND
Waveform generator is an electronics instrument that generates a periodic and nonperiodic electronics signal. Normally the output of the generator will be sine, square,
DC, sawtooth or triangular waveform which follow the well-defined mathematical
functions[1]. Waveform generator is normally used for designing, testing,
troubleshooting and repairing of electronic devices[2] in Research and
Development(R&D) stage or products on the market.
The waveform generator is also known as test signal generator or function generator.
It can be classified into two groups, general purpose waveform generator and special
purpose waveform generator[2].
There are two types of general purpose waveform generator, function generator and
Arbitrary Waveform Generators (AWGs). Function generator is an instrument that
used to generate some simple periodic function such as sine wave [1]. Arbitrary
waveform generators are a form of function or signal generator that is able to produce
an arbitrary waveform with different sets of value for various types of waveform
defined as a series of “waypoints”(specific voltage targets) at different timing[3][4].
The special purpose waveform generator include video signal generator and tone
generators. Video signal generator is used for television and video systems. The
output waveform of the television or video system that passes through this device is
predetermined to simulate faults or as an aid in parametric measurement[1]. As for the
tone generators, it is used to test audio-frequency equipment and performed signaling
by creating a suitable audio-frequency signal[5].
1.2 PROJECT OBJECTIVE
The project aims to design and develop a waveform generator using Microcontroller
and Digital-to-Analog Converter (DAC). The waveform generator should be able to
produce a continuous waveform such as sine wave, a square wave, a triangular wave
or a DC voltage on demand. As for the amplitude, it should be in the range of 1V to
5V and increase in the step of 1V. As for the frequency, it ranges from 100Hz to
3200Hz and increase in the step of 100Hz. Finally output waveform produced by the
DAC can be checked using an oscilloscope and then used as test signal.
1
1.3 OVERALL PROJECT OBJECTIVE
Technology is developing very fast and the needs of test equipment to isolate the fault
of the electronic equipment become very important. Waveform generator is a device
used to generate an electronic signal with specific known characteristics, thereby
enabling an engineer or technician to test and examine a circuit. In order to make the
troubleshooting process more easy and convenient so as to save cost, a
Microcontroller, Digital-to-Analog Converter (DAC) and other electronic components
is used to build a low cost waveform generator
1.4 PROPOSED APPROACH
Picture1 shows the block diagram of the proposed waveform generator. The circuit is
built with a microcontroller PIC18F2520. By using the microcontroller, different
waveforms can be generated. The circuit uses a Digital-to-Analog Converter to
convert the digital output of the microcontroller to analog circuit. The circuit uses 5
switches for user selections. One switch to select the required output waveform and
four switches to select the parameters required.
Figure1: Proposed Waveform Generator Layout
The waveform can be generated by selecting a suitable digital logic, equivalent to the
required analog output and to output it to the port for a required time. The frequency
of the output waveform can be made variable by changing a delay routine that is
called to execute while keeping the output logic constant.
2
Figure2: Proposed Software Flow Chart
1.5 SKILLS REVIEW
This project requires the knowledge on both hardware and software engineering and
the understanding of basic mathematic theory. Besides, other skills like information
gathering and research, soldering, time management and project management are very
important throughout the completion of this project.
Firstly the Time and Project management skills are two of the most important skills
required. This is because of the tight schedule to cope with the full time job and the
part time studies, which include 20 credit units besides of this Final Year Project.
Most of the time is spent on the research of information needed, especially in the
initial stage of the project overview to have a better understanding on how to select
the hardware component and their connection. After that, the soldering of the
electronics components together is also a challenging task since the connection for the
DAC board will be very complicated. Also the programming of the microcontroller
chip to get the desired output.
There is a new exploration to the use of the microcontroller. This is a new challenge
to me as I have no experience in the programming of the microcontroller and has not
been doing any programming things after I finish my diploma studies. This Project
work is being done according to a project schedule so that it can be completed and
meet the objective of the project.
3
LITERATURE REVIEW
2.1 WAVEFORM
Waveform means the shape and form of a signal. Example is the moving of a wave in
the solid, liquid or gaseous medium[6]. Normally waveform is represented in the
graph form by plotting the variation of a voltage or current over a period. There are
three common characteristics that can be found on all the waveform such as
Amplitude, Frequency and Period.

Period(T)
Is time taken for a waveform to repeat itself from start to finish with the unit
Second(s).

Frequency(f)
Is the number of times the waveform repeats itself within one second. It is the
reciprocal of the time period, (f=1/T) with the unit called Hertz (Hz).

Amplitude
Is the magnitude of the waveform measured in Volts(V) or Amperes(A).
Waveform can be divided into two groups, periodic or non-periodic waveform. A
periodic waveform is a function ƒ(x) of a real or complex variable is periodic with
period T if ƒ(x + T) = ƒ(x) for every value of x[7]. Examples of periodic waveform
are Sine, Square, Triangular and Sawtooth wave. Waveform that is not periodic is
called non-periodic waveform. Example is voice.
4
Figure3: Periodic Waveform
2.2 WAVEFORM GENERATOR
A Waveform Generator or Function Generator is a device or circuit that produces a
variety of different waveforms at a desired frequency. It can generate Sine wave,
Square wave, Triangular and Sawtooth waveform. Beside of that, it can also generate
other types of output waveforms.
On the market, there are many types of such instruments with a price range from
medium to very high, depending on their specifications. Examples of some of the
Waveform Generator manufactures are Agilent, Tektronix, Instek and Fluke.For the
waveform generator device, it consists of five main sections. One of them is analog
output section build up of one or more Digital-To-Analog Converters(DACs),
amplifier and reconstruction filters. A memory section used to store binary waveform
data temporarily before sending it to DAC. Bus section is the electrical interface to
the host computer to transfer commands to the Arbitrary Waveform Generator(AWG)
to set up the output speed and choice of filter. Clock section to generate clock signal
to determine the sample rate of DAC and provides internal bus synchronization. A
control section is to control the previous four sections and transfer the data from bus
to the onboard memory[8].
5
Figure4: Example of Some Waveform Generator
http://www.globaltestsupply.com/category.cfm?category_id=5&catSort=manufacturer&
resultsPage=2
Also, many of the off-shelf waveform generator IC's are available that can be used to
incorporate into a circuit that requires an auto-generated periodic waveform such as
ICL8038(Intersil), MAX038(Maxim) and XR8038A(Exar)[9]. Example, for ICL0830
IC is capable of generate sine, square and triangular waveform with only a few
numbers of external components. Its operating frequency range can be selected over
eight decades of frequency from 0.001KHz to 300KHz by correct external R-C
components[10].
Figure5: ICL8038 Connection for Waveform Generator
http://www.electronics-tutorials.ws/waveforms/waveforms.html
Electronic circuit can also used to create a simple function generator with a bistable
multivibrator or “flip-flop” controlled in time by a succession of clock pulses which
generates the square wave. Triangular waveform can be obtained by integrating the
square wave through the use of the operational amplifier integrator. The sine wave is
obtained by applying the triangular wave to a shaping circuit consisting of a
combination of resistors and diodes. Alternatively the sine wave can be generated
using sinusoidal oscillator. From the output, the square wave may be obtained by
amplication, limiting, and clipping of the sine wave. Then the triangular wave may be
obtained using an integrator[11].
6
2.3 HARDWARE AND SOFTWARE OVERVIEW
For this project, the waveform generator is built up of three boards, PIC18
Microcontroller board (act as a ‘brain’ to give instruction with an 8 bits digital
output), DAC board (to interpret the instruction and output a waveform in analogue
form) and a LED and Switch board(for indication and control of the output
waveform). So, the following section will discussed about the components and
software used.
Figure6: System Block Diagram
2.3.1 HARDWARE OVERVIEW
2.3.1.1 MICROCONTROLLER
A microcontroller(MCU) is a kind of miniature, low-cost computer or a single-chip
computer. The word Micro means the device is small and controller means that the
device maybe used to control an object, processes or even an events. Microcontroller
is used to control one or more tasks for a typical operation of a device or a system. It
is sometime being called as an embedded controller because the microcontroller and
its supporting circuits are normally built into or embedded in the devices they
intended to controller.
The microcontroller is built up of an 8/16/32-bit microprocessor(CPU). It consist of a
small amount of RAM(random access memory), ROM(read only memory),
programmable flash memory, parallel and serial I/O ports, timer, crystal oscillator,
watchdog and Analog to Digital (A/D) or Digital to Analog(D/A) conversion.
7
Figure7: Basic Mircocontroller Architecture
http://o.mneina.googlepages.com/what_is_microcontroller.htm
You can find microcontrollers being used in all kinds of device these days. Any
device that use for measurement, storage, controlling, calculation, or to displays
information, they are chances that a programmable microcontroller was being used.
Some example of the different usage of microcontroller is for engine control, and to
control additional systems function in the car such as car safety system. As for the
desktop computers, microcontroller is embedded inside the keyboards, modems,
printers, and other peripherals. In test and measure equipment such as the multimeter
and oscilloscope, microcontrollers make it easy to add features such as the ability to
store measurements, to create and store user routines, and to display messages and
waveforms. Consumer products that use microcontrollers include cell phone, cameras,
video recorders, washing machine, oven and etc.
TYPES OF MICROCONTROLLER
In order to meet the different demands, many types of microcontroller are invented.
Some common types of microcontroller architectures will be discussed.
 ARM- developed by ARM Limited. Dominate the mobile and consumer
electronics market because of their power saving features[12]. Used
extensively in consumer electronics such as PDAs, cell phone, iPods, handheld game consoles and computer peripherals such as router and hard drive.
According to research on year 2007, about 98% of a billion cell phones sold
each year use at least one ARM processor[12].

MSP430- microcontroller family from Texas Instuments. Designed to meet
the demand of low cost and low power consumption embedded
applications[13]. It is applicable for utility metering, wireless RF, or batterypowered applications. However due to some limitations, this device is
8
prevented from being used in more complex embedded systems. For this
MSP430, it does not include an external memory bus. As a result can used an
on-chip memory size of up to 256 KB Flash and 16 KB RAM which might
be too small for applications that require large buffers or data tables[13].

MIPS- Microprocessor without Interlocked Pipeline Stages(MIPS) is a
reduced instruction set computer(RISC) microprocessor architecture that
further developed by MIPS Technologies. With this architecture, all
instructions are able to complete in one cycle. It allowed the pipeline to be
run at much higher speeds and is responsible for much of the processor’s
speed (there was no need for induced delays). The disadvantage is that it
eliminates many useful instructions such as multiply and divide[14]. Being
used in telecommunications, video arcade games and home video game
consoles[15]. Sony Playstation PSX and Sony Playstation Portable(PSP) are
worked based on the MIPS architecture.

PIC- a family of Harvard architecture microcontroller developed by
Microchip Technology. The name PIC initially refer to ‘Peripheral Interface
Controller’ Due to low cost, wide availability, large user base, extensive
collection of application notes and reprogramming with flash memory, the
PICs microcontroller are very popular among the developers and hobbyists.
In February 2008, Microchip announced a shipment of 6 billion PIC
processors[16].
OVERVIEW OF PIC18 FAMILY OF MICROCONTROLLERS
The PIC18 microcontroller family provides in 18- to 80-pin packages that are both
socket and software upwardly compatible to the PIC16 family. Popular peripherals
such as Master Synchronous Serial Port(MSSP), Enhanced Serial Communication
Interface(ESCI), Capture/Compare/PWM(CCP) modules, flexible 8- and 16-bit
timers, Parallel Slave Port(PSP) module, 10-bit Analog-to-Digital Converter(ADC),
Watchdog Timer(WDT), Power-on Reset(POR) and Control Area Network(CAN)
2.0B Active for the maximum flexible solution are included in the PIC18 family.
Most PIC18 microcontroller will provide FLASH program memory range from 8K to
128K bytes and data RAM range from 256K to 4K bytes. It operating range is from
2.0 to 5.5 volts, at a speed from DC to 40 MHz. Optimized for high-level languages
like ANSI C, the PIC18 family offers a highly flexible solution for complex
embedded applications[17].
9
High Performance RISC CPU

77 instruction

C-language friendly architecture

16-bit wide instructions, 8-bit wide data path

Priority levels for interrupts

8 x 8 Single Cycle Hardware Multiplier
Peripheral Features

Up to four external interrupt pins

Up to three 16-bit timer/counters




Up to two 8-bit timer/counters with 8-bit period register (time-base for
PWM)
Secondary LP oscillator clock option - Timer1
Max. PWM frequency at 8-bit resolution = 156 kHz and 10-bit resolution =
39 kHz
Up to 2 Addressable USART modules(ESCI) which Supports interrupt on
Address bit
Analog Features

10-bit Analog-to-Digital Converter module(A/D) with a fast sampling rate

and up to 16 channels input multiplexor
Comparators
Special Microcontroller Features

Watchdog Timer(WDT) with its own on-chip RC oscillator for reliable
operation

Programmable code protection

In-Circuit Serial Programming(ICSP) using two pins
FEATURES OF THE PIC18F2520 MICROCONTROLLERS
PIC18F2520 is a 28–Pin Enhanced Flash microcontroller with 10-Bit A/D and
nanoWatt Technology. With high computational performance at a low price, addition
of high-endurance Enhanced Flash program memory and other design enhancements
make this microcontroller choice for many high-performance and power sensitive
applications.
10
Features
Operating Frequency
Program Memory (Bytes)
Program Memory (Instructions)
Data Memory (Bytes)
Data EEPROM Memory (Bytes)
Interrupt Sources
I/O ports
Timers
PIC18F2520
DC-40Mhz
32768
16384
1536
256
19
Port A, B, C, (E)
4
Table1: PIC18F2520 Features
NANOWATT TECHNOLOGY
Some feature has been incorporate in PIC18F2520 that can significantly reduce power
consumption during operation. This includes Alternate Run Modes, Multiple Idle
Modes, On-the-Fly Mode Switching and Low Consumption in Key Modules. For
Alternate Run Modes, the power consumption can significantly reduce about 90% by
clocking the controller from the Timer1 source or the internal oscillator block. When
the Multiple Idle Modes was activated, the controller can also run while the CPU is
disabled but the peripherals still active. This reduces the power to as little as 4% of
normal operation requirements. As for the On-the-Fly Mode Switching, the power
managed modes are called up by user code during operation, allowing the user to
incorporate power-saving ideas into their software applications design. Low
Consumption in Key Modules, The power requirements for both Timer1 and the
Watchdog Timer are minimized.
MULTIPLE OSCILLATOR OPTIONS AND FEATURES
Ten different oscillator options are available which provide users a wide range of
choices in developing application hardware. These include 4 Crystal modes by using
either crystals or ceramic resonators. As for the Two External Clock mode and Two
External RC Oscillator mode, it offered an option of using two pins(oscillator input
and a divide-by-4 clock output) or one pin(oscillator input, with the second pin being
assigned as general I/O port). With an internal oscillator block, it provides an 8MHz
clock and an INTRC source(about 31KHz), as well as a range of 6 user-selectable
clock frequencies, between 125KHz to 4MHz, for a total of 8 clock frequencies. This
option frees the two oscillator pins for use as additional general purpose I/O.
A Phase Lock Loop(PLL) frequency multiplier, available to both the High-Speed
Crystal and Internal Oscillator modes, which allows clock speeds of up to 40MHz.
11
Used with the internal oscillator, the PLL gives users a complete selection of clock
speeds, from 31KHz to 32MHz without using an external crystal or clock circuit.
SPECIAL FEATURES


Memory Endurance- Flash cells for both program memory and data
EEPROM are rated to last for many thousands of erase/write cycles(up to
100,000 for program memory and 1,000,000 for EEPROM). Data retention
without refresh is conservatively estimated to be greater than 40 years.
Extended Instruction Set: An optional extension to the PIC18 instruction
set, which adds 8 new instructions and an Indexed Addressing mode. This
extension, enabled as a device configuration option, has been specifically
designed to optimize re-entrant application code originally developed in
high-level languages, such as C.

Enhanced Addressable USART: This serial communication module is
capable of standard RS-232 operation and provides support for the LIN bus
protocol. Other enhancements include automatic baud rate detection and a
16-bit Baud Rate Generator for improved resolution. When the
microcontroller is using the internal oscillator block, the EUSART provides
stable operation for applications that talk to the outside world without using
an external crystal(or its accompanying power requirement).

10-Bit A/D Converter: This module incorporates programmable acquisition
time, allowing for a channel to be selected and a conversion to be initiated
without waiting for a sampling period and thus, reducing code overhead.
2.3.1.2 OPERATIONAL AMPLIFIER
In the early stage of operational amplifier(Op-amp) development, it was used to
performed mathematical operation in the analog computer. This operation include
addition, subtraction, integration and differentiation, hence the term operation came
about. Since an operational amplifier is a very high gain differential amplifier with
input impedance and low output impedance, its applications are amplitude and
polarity change, oscillator, filter and many types of instrumentation circuits. Due to
the characteristic of its input and output impedance, Op-amp stages can be easily
cascaded without much loading effect.
OPERATIONAL AMPLIFIER BASIC
12
Operational amplifier is a solid-state device capable of sensing and amplifying DC
and AC inputs signal. Three basic circuits are included in the Op-amp, and there are a
high-input impedance differential amplifier, a high-gain voltage amplifier and lowimpedance output amplifier. Positive and negative power supply is supplied to the
Op-amp so that it allows the output voltage to swing positive and negative with
respect to ground. Some new Op-amp design techniques have enabled some newer
Op-amps to require only on supply voltage.
SYMBOL AND TERMINALS
Figure8: Standard Operational amplifier Symbol
http://www.markallen.com/teaching/images/electronics/opamp_block.jpg
The standard Op-amp is showed in Picture8, where
 +input = non-inverting input
 -input = inverting input
 Output = output
 +Vss = positive power supply
 -Vss = negative power supply
It has two input terminal and one output terminal. The input is a differential amplifier
stage. One of the inputs is inverting in characteristic and the other is non-inverting. A
typical Op-amp requires two supply voltages, one positive and other negative. Some
new Op-amp design techniques have enabled some newer Op-amps to require only on
supply voltage.
IMPORTANT OPERATIONAL AMPLIFIER PARAMETERS

Gain of Amplifier(Op-Amp Gain)
The maximum voltage gain obtained from an Op-amp is its open-loop
voltage gain ( AOL ). The typical value of AOL is about equal or greater than
13
10000. Well designed Op-Amp can achieve a open-loop gain in the range of
hundreds of thousands.

Differential Voltage Gain ( Ad )
The heart of the Op-amp is the differential amplifier. It amplifies the
difference between the two inputs and attenuates any common signals at the
inputs. The output level depends on the gain of the amplifier, the polarity
relationship between the two input voltages and the supply voltage.
Vout = Ad ( V  V )
the input signal is applied to the non-inverting input port (with inverting
input at ground), which results in an output having the same polarity as the
applied input signal. The input signal is applied to the inverting input port,
the output then being the opposite in phase to the applied signal.
By applying two identical signals to both terminals of Op-amp, its output is
ideally zero. When a differential input Vd is applied between the two input
terminals, the amplified output will be in the same phase with that applied
between the non-inverting and inverting inputs.

Common-mode Voltage Gain
When the same input signals are applied to both inputs, common-mode
operation results. Ideally, these signals cancel each other, resulting in 0V
output. Practically, a small output signal will result. A common signal
element due to the two inputs can be defined as the average of the two
signals.
1
Vc  (V  V )
2
Vo  AcVc

Common Mode Rejection Ration(CMRR)
Since any signal applied to Op-amp in general have both in-phase and out-ofphase components, the resulting output can be expressed as
Vo  Ad (V  V ) 
1
As (V  V )
2
14
Where Ad is the differential voltage gain and As is the common-mode
voltage gain.
CMRR is defined as the ration of the differential voltage to the commonmode voltage gain.
CMRR |
Ad
| (no unit)
Ac
CMRR measure the amplifier ability to reject common mode voltage gain.
As the value of CMRR increases, the Op-amp ability to reject common-mode
signal improves. The value of CMRR can be also expressed in logarithmic
terms as
CMRR(log)  20log10 |
Ad
| dB
Ac
Example,
CMRR 
Ad 200000

 800000@118.06dB
Ac
0.25
Meaning of the figure 800000 is that if the amplitude of the differential input
signal and the common-mode noise are equal, the desired signal will appear
on the output 800000 times greater in amplitude than the noise.

Supply Voltage
The supply voltage does not only power the Op-Amp for its operations, they
also determine the limits of the output voltage swing. The output voltage
level will be always lower than the supply voltage, +Vss and –Vss,
regardless of the gain of the amplifier. In fact, the magnitude of the
maximum output voltage is always less than that of the supply voltages,
typically in between one to two volt.

Input Bias Current
The input bias current is the average DC biasing current drawn by the two
inputs of the Op-amp. The input bias current is
IB 
I B1  I B 2
when Vo  0V
2
15
Op-amp will not function if either of its input is open as there will be no
input bias current path for the differential amplifier to work.
THE IDEAL OPERATIONAL AMPLIFIER
The equivalent circuit of an Op-amp is shown in Figure9. The characteristic of a
practical amplifier are very high voltage gain, very high input impedance and very
low output impedance.
Figure9: Equivalent Circuit Of An Op-Amp
http://en.wikipedia.org/wiki/Operational_amplifier
The ideal Op-amp that we hope to achieve is to have an infinite voltage gain and
infinite bandwidth. It also has infinite input impedance (open), so that it does not load
the driving source. Finally, it has zero output impedance.
Characteristic
Ideal Op-amp
Practical Op-amp (741)[18]
Voltage Gain
Infinity
200000
Input Impedance
Infinity
2MΩ
Output Impedance
0Ω
75Ω
Table2: Comparison for Ideal and Practical Op-amp
WAYS TO CONFIGURE OPERATIONAL AMPLIFIER

Open-loop Gain of an Operational Amplifier
The open-loop voltage gain is the gain of the operation amplifier without any
external feedback network from the output terminal to the input terminal. The
open loop gain in the internal gain of the device and represents the ration of
output voltage. It is normally used as comparator.
16
Figure10: Open Loop Gain
http://www.allaboutcircuits.com/worksheets/opamp2.html

Positive/Negative Feedback Configuration
Positive/Negative feedback is a process whereby a portion of the output
voltage of an amplifier is return to the input with a phase angle that opposes
the input signal. As for the positive feedback(Figure11), the output voltage is
connected to the non-inverting input. Normally the positive feedback
configuration is used as a waveform generator and it is a unstable circuit. As
for the negative feedback(Figure12), the output voltage is connected to the
inverting input to improve the stability of the circuit. Normally the negative
feedback configuration is used as an amplifier.
Figure11: Positive Feedback Configuration
http://www.allaboutcircuits.com/vol_3/chpt_8/12.html
Figure12: Negative Feedback Configuration
http://www.allaboutcircuits.com/vol_3/chpt_8/4.html

Virtual Ground
17
The closed-loop voltage is for an entire amplifier configuration consisting of
the operational amplifier and an external negative feedback circuit that
connects the output to the inverting input. The closed-loop gain is determined
by the external component values. The closed-loop gain can be precisely
controlled by external component values.
As the amplifier has very high input impedance, almost no current could
flows through Rin to the ground. Since no current flows, there is no voltage
drop across Rin. Hence the potential at the V almost equal to V which is
ground potential 0V. But V is not directly connected to the ground therefore
not truly ground potential. Thus, the negative input terminal V is said to be
virtually grounded.
Figure13: Virtual Ground with Negative Feedback
http://en.wikipedia.org/wiki/Virtual_ground
SOME COMMON OPERATIONAL AMPLIFIER CIRCUITS

Inverting Amplifier
Virtual ground concept states that with negative feedback, the two inputs are
virtually at the same voltage potential, even though there is no direct
connection between the inputs. For the inverting amplifier shown in
Picture13, the inverting input V is at the potential of 0V since V is
grounded, as V = V (virtually).
The output voltage of the inverting amplifier is 180 degree phase shifted
from the input voltage. The closed loop gain ( ACL ) of the amplifier is
determined by the values of resistors R f and Rin .
18
ACL  
Rf
Rin
Zin = R in (because V- is a virtual ground)
Figure14: Inverting Amplifier
http://en.wikipedia.org/wiki/Op-amp_inverting_amplifier#Inverting_amplifier

Non-inverting Amplifier
The non-inverting amplifier has high input impedance and low output
impedance. The input impedance is almost equivalent to the input impedance
of the Op-amp. It is useful for matching high impedance source to low
impedance load. It does not provide phase shift of 180 degree between input
and output signal.
ACL  1 
Rf
Rin
Zin  
Figure15: Non-inverting Amplifier
http://en.wikipedia.org/wiki/Op-amp_inverting_amplifier#Inverting_amplifier

Voltage Follower
The voltage follower configuration is a special case of non-inverting
amplifier where all of the output voltage is fed back to the inverting
19
input(Figure16). The voltage at the output is exactly the same as input
voltage.
ACL 
Vout
1
Vin
Zin = (realistically, the differential input impedance of the op-amp itself)
Figure16: Voltage Follower
http://en.wikipedia.org/wiki/Op-amp_inverting_amplifier#Inverting_amplifier

Summing Amplifier
The summing amplifier provides a means of algebraically summing voltages,
each multiplied by a constant-gain factor determined by the values of the
resistors.
Vo   R f (
V1 V2 V3


)
R1 R2 R31
Figure17: Summing Amplifier
http://www.allaboutcircuits.com/vol_3/chpt_8/8.html
FEATURES OF THE HA17741 OPERATIONAL AMPLIFIER
20
The HA17741 Op-amp are general purpose operational amplifier (frequency
compensated) which feature improved performance over industry standards. This Opamp is an internal phase compensation high-performance operational amplifier which
is suitable for use in a wide range of applications in the test and control fields. It give
a voltage gain of 106dB (typically) and a wide output amplitude of ±13V (typically)
when RL≥2kΩ. It also come with the shorted output protection to protect the Op-amp
in case anything happen. The adjustable offset voltage and internal phase
compensation also make this Op-amp better as compare with other company Op-amp.
Some other application that can be achieve using this IC Op-amp are Astable
Multivibrator, Monostable Multivibrator, Bistable Multivibrator, Wien Bridge Sine
Wave Oscillator, Quadrature Oscillator, Triangular Wave Generator and Sawtooth
Waveform Generator[19].
2.3.1.3 DIGITAL-TO-ANALOG CONVERTER
Digital-to-Analog converter (DAC) is a device for converting an input signal in the
discrete states to the analog signal at the output. Mostly, the input signal is
representing a parallel binary number and output signal is represented at the voltage
or current form[20]. Such a device is needed as an interface between a digital
component and analog component.
The output value of the DAC is proportional to the product of the digital input value
and the reference. In many applications, the reference input voltage is fixed and the
output value will be a fixed portion comparing to the digital input. However, in some
applications, the reference voltage and digital input can vary. Normally we called this
DAC as the multiplying DAC. The reason we use this kind of configuration is to
impart a digital controlled scale factor or “gain” to an analog input signal applied at
the reference terminal.
BASIC OPERATION OF DIGITAL-TO-ANALOG CONVERTER
The basic function of DAC is to convert a finite-precision numbers(usually fixedpoint binary numbers) into a continuously varying physical quantity, usually an
analog electrical voltage[21].
For the idea case, the output of the DAC should be a sequence of impulses(Figure18).
Then a samples and holds the impulse constant until the next impulse is received and
converted into a voltage(Figure19), followed by a low-pass(reconstruction) filter to
remove the unwanted high frequency components to smooth out the DAC output.
21
Figure18: Output Signal of DAC
http://www.answers.com/topic/digital-to-analog-converter
Figure19: Output Signal of Samples-And-Holds
http://www.answers.com/topic/digital-to-analog-converter
DIGITAL-TO-ANALOG CONVERSION METHOD
There are many types of DAC conversion methods such as Pulse Width Modulator
(PWM), Delta-Sigma DAC, Thermometer coded DAC and Hybrid DAC. However,
the most common types of DAC are Binary-Weighted-Input DAC and R-2R Ladder
DAC.
For Binary-Weighted-Input DAC(Figure20), it used a resistor network with resistance
values that represents the binary weights of the input bits of the digital codes[22]. One
of the disadvantages of this type of DAC is the number of different resistor values that
required. For example, a 8-bit converter requires four resistors, ranging from some
value of R to 128R in binary-weighted steps. This range of resistor requires tolerances
of one part in 16 one part in 255 (less than 0.5%) to accurately convert the input,
making this type of DAC very difficult for mass production[22].
22
Figure20: 6-bit Binary-Weighted-Input DAC
http://www.allaboutcircuits.com/vol_4/chpt_13/2.html
For R-2R Ladder DAC(Figure21), it is similar to the Binary-Weighted-Input DAC but
uses a repeating cascaded structure of resistor values R and 2R[22]. Since this method
only needs two resistor values, it overcomes one of the problems faced in BinaryWeighted-Input DAC. However, due to the increase of large RC-constants for each
added R-2R link, the performance will be slow down.
Figure21: R-2R Ladder DAC
http://www.allaboutcircuits.com/vol_4/chpt_13/2.html
PERFORMANCE CHARACTERISTICS OF DIGITAL-TO-ANALOG
CONVERTER
The performance of the DAC will be discussed below[23].
 Resolution
The resolution of the DAC is the reciprocal of the number of discrete steps in
the output. This is normally depends of the number of input bits selected. It
can also be expressed as the number of output levels the DAC can reproduce.
Example, a 8-bit DAC will have a resolution of one part
in 28  1 (one part in 255) .
23

Accuracy
The accuracy of the DAC is derived from comparing the output of a DAC with
the expected output. It express the full scale or maximum output voltage in
term of the percentage.

Settling time
Settling time for a DAC is to determine the time taken to settle within the
limits of a defined error band of its final value when there is a change in the
input.

Monotonicity
For a monotonic DAC, it does not take any reverse steps when it is sequenced
over its entire range of inputs bits. It is a very important characteristic to
consider when the DAC is used as a low frequency signal source or as a
digitally programmable trim element[20].

Linearity
Is an error deviation from the ideal straight-line output of a DAC. They is a
special case of offset error, in which the amount of output voltage when the
inputs bits are all zeros.
DIGITAL-TO-ANALOG CONVETER APPLICATIONS

Audio
With the development of the technology, voice/audio can be process and store
in the digital form. Most of the modern audio signals are stored in the digital
form such as in the compact discs (CDs) and MP3s. In order to retrieve the
digital information of the audio, it must be converted into the analog signal so
that it can be heard through speaker. DACs are therefore can be found in audio
player such as the CD player and MP3 player. A good DAC is crucial to highfidelity music playback and it can be found in most of the high-end Hi-Fi
system. The similar DAC can be found the digital speaker such as USB
speaker and sound card of the Personal Computer (PC)[20].
24

Video
The Video signal can also be stored in the digital form. In order to display in
on the analog monitor, it must be converted from the digital form to analog
form. As of 2007, analog inputs are more commonly used than digital.
However, with the popularity of the Digital Visual Interface (DVI) and HighDefinition Multimedia Interface (HDMI) connection, the DAC is incorporated
in any digital video player with analog outputs[20].
FEATURES OF THE DAC0830 DIGITAL-TO–ANALOG CONVERTER
The DAC0830 is a 8-bituP compatible and double-buffered DAC. It comes with an
advanced CMOS/Si-Cr 8-bit multiplying DAC designed to interface directly with the
8080, 8048, 8085, Z80®, and other popular microprocessors. With the deposited
silicon-chromium R-2R resistor ladder network, it is able to divide the reference
current and provides the circuit with excellent temperature tracking characteristics
(0.05% of Full Scale Range maximum linearity error over temperature). CMOS
current switches and control logic are employed in DAC0830 to achieve low power
consumption and low output leakage current errors. Special circuitry provides TTL
logic input voltage level compatibility. Double buffering allows these DACs to output
a voltage corresponding to one digital word while holding the next digital word. This
permits the simultaneous updating of any number of DACs[24].
Some other features of the DAC0830 are that it can performed single/double-buffered
or flow-through digital data inputs. It can be easily interchange and pin compatible
with 12-bit DAC1230 series for further development. It has a linearity specified with
zero and full scale adjusts only which is not best for straight line fit. It is able to works
with ±10V reference-full 4-quadrant multiplication and can be used in voltage
switching mode. The performance characteristic of this DAC0830 is that it have a
current settling time of 1us, a 8-bit resolution, a linearity of 8, 9 or 10 bits (guaranteed
over temperature), power dissipation of 20mW and a single power supply from the
range of 5V to 15 V depends on the application[24].
25
2.3.2 SOFTWARE OVERVIEW
2.3.2.1 INTEGRATED DEVELOPMENT ENVIRONMENT (IDE)
An integrated development environment/integrated design environment/ integrated
debugging environment (IDE) is software application program that provides
comprehensive facilities to computer programmers in a software programming
environment[25]. Normally for IDE, it has been packaged as an application program.
A source code editor, a compiler and/or an interpreter, build automation tools and a
debugger are included in the IDE. For IDE, it gives a software programmer a userfriendly framework for many programming languages like Visual Basic (VB) and
Java[26].
FEATURES OF THE MPLAB INTEGRATED DEVELOPMENT
ENVIRONMENT (IDE)
MPLAB Integrated Development Environment(IDE) is a free, integrated GNU
Compiler Collection(GCC) toolset for the development of embedded applications
employing Microchip's PIC and dsPIC microcontrollers[27][28]. MPLAB IDE runs as
a 32-bit application on Microsoft Windows, a host of free software components for
fast application development and super-charged debugging is included for
programmer. Also it serves as a single, unified graphical user interface for additional
Microchip and third party software and hardware development tools. MPLAB IDE
can support Assembly and C programming language. However, MPLAB IDE does
not support Linux, Unix and Macintosh based Operating System (OS)[28].
It also features flexible customizable programmer’s text editor include fully integrated
debugging , tabbed editor, context sensitive colour highlighting for assembly and C
code, and graphical project manager. Besides that, the simple and powerful source
level debugging features such as auto alignment of breakpoints after source code
modification, mouse-over variable inspection and watch variables, structures and
array. There are some free components for programmer’s text editor and full featured
debugger available such as MPLAB SIM for high speed software simulator, MPASM
and MPLINK for debugging. Some built in support for hardware and add-on
components are available such as MPLAB C Compilers, PICKit2 and PICkit3 Debug
Express[28].
26
FEATURES OF THE MPLAB C COMPILER
The MPLAB C Compiler(MPLAB C18) is a full-featured ANSI compliant C
compiler. It allows source level debugging with MPLAB’s software and hardware
debug engines. Projects, compiler switches and linker customizations can be
controlled completely within MPLAB IDE to provide a full graphical front end for
when using this compiler. Text errors in source code and breakpoints instantly switch
to corresponding lines in the proper file, and watch windows show data structures
with defined data types, including floating point, arrays and structures[29].
Some features of this MPLAB C Compiler are that it is integrated with MPLAB IDE
easy-to-use project management and source-level debugging, able to generate
relocatable object modules for enhanced code reuse, strong support of inline assembly
when total control is necessary, extensive library support such as string manipulation
and math libraries, full user-level control over data and code memory allocation,
support 16 and 24 bit pointers memory model, MPLIB allows easy use of included
libraries and for user created libraries and supports new PIC18F extended mode
instructions[29].
FEATURES OF THE PICKIT2 MICROCONTROLLER PROGRAMMER
WITH IN-CIRCUIT SERIAL PROGRAMMING(ICSP)
The PICkit2 Development Programmer/Debugger is a low-cost development tool with
an easy to use interface for programming and debugging the Microchip
microcontroller. It support the PIC10F, PIC12F, PIC16F, PIC18F, PIC24 dsPIC30
and dsPIC33 series of microcontroller With Microchip’s powerful MPLAB IDE, the
PICkit2 enables in-circuit debugging and has the Debug Express Capable. In-CircuitDebugging runs, halts and single steps the program while the PIC microcontroller is
embedded in the application. When halted at a breakpoint, the file registers can be
examined and modified[29][30].
2.3.2.2 WAYS TO GENERATE A WAVEFORM
Any waveform can be produced a simple circuit(Picture21) connected as below by a
counter (“Angle”) and a look-up-table (“LUT”).
27
Reset
Clk
Angle
Loop
Angle
LUT
Waveform
Figure22: Produce Waveform Using Counter and A LUT
The table below showed an example of Sine wave look-up-table(Table3). In order to
generate the sine waveform, the Vout of all angles from 0 degree until 360 degree has
to be calculated. Digital Code, the correlation between the Digital Input/Digital Code
and the Analog Output (Vout) will then be calculated using the equation given in the
DAC datasheet. Example the DAC will produce 1V if the input Digital Code is 154
when is Sine(90). This value can be calculated by using Equation1. The “LUT” can
also be used to generate Cosine waveform as well.
Angle Vout=Sine(Angle) Digital Code=Sine
0
0
128
….
45
0.7071
146
….
90
1
154
….
359
-0.0154
Equation1: Vout=Vref X (Digital Code-128)/128
Table3: Sine Look-Up-Table (LUT)
When the “Clk” is being triggered, the counter will produces an angle value start from
0 to 359 and then repeat itself, while the look-up-table produces the corresponding
Digital Code value to the angle.
Also, the waveform generator should have the capability to generate a waveform with
different peak voltage level and frequency. There are some ways to adjust the voltage
such as the use of multiplier, store different set of LUT values and the used of shift
register and an adder.
VARYING PEAK VOLTAGE BY A MULTIPLIER
28
One of the easiest way is to use a multiplier as showed below(Figure23). The output
of the multiplier is then connected to the DAC. However, a lot of logic gates are
required to implement a multiplier.
Waveform Generated,
1.0Sin(θ)
Output Waveform,
ASin(θ)
Multiplier
Peak Voltage, A
Figure23: Adjust Peak Voltage by Using a Multiplier
VARYING PEAK VOLTAGE BY MULTIPLE LUT’S
The other way is by storing different set of LUT’s values for Sine or Cosine. A
multiplexer is needed to select the correct set of LUT table values to uses. Many logic
gates are required to make this method work.
VARYING PEAK VOLTAGE BY SHIFTING AND ADDITION
With the used of shift register and adder(Picture23), the peak voltage can be adjust by
storing only the 4.0 sine/cosine LUT value. In many computer languages include
instructions to ‘shift right’ and ‘shift left’ the data in a register, effectively dividing by
two or multiplying by two for each place shifted[31]. Example, the ‘shift right’ of
4.0Sine(θ) to generate 2.0Sine(θ), 1.0Sine(θ) and 0.5Sine(θ). So the other sine waves
can be produced by adding two or more of these values.
4.0Sin(θ)
ASin(θ)
2.0Sin(θ)
Adder
Shift Registers
1.0Sin(θ)
0.5Sin(θ)
Peak Voltage, A
29
Figure24: Adjust Peak Voltage by Using a Shift Register and Adder
VARYING THE FREQUENCY OF THE WAVEFORM
To vary the frequency of the waveform, some important things have to take note,
frequency of the crystal and step size of the LUT.
Let’s consider a 1KHz sine wave to be generated.
Frequency, f=1KHz
Crystal’s frequency, of=20MHz
Crystal’s period=1/fo=50ns(assume equal to X)
Period, T=1ms
Time for each degree, Td=T/360=1ms/360
So the crystal must tick Td/X=1ms/(360x50ns)=55.56 times for the sine wave to
advance 1 degree. In other words, the next LUT value will only sent to DAC after the
crystal tick about 56 times. The number of crystal clock ticks to make one degree for
different frequency can be computed using the same calculation.
To produce the sine wave for different frequencies, the following method is used.



A Roll Over Counter is used to count from 0 to (Max-1) and then repeat.
Every time a roll over occur, a pulse is produced at Clk, advancing Angle by
one degree.
Max depends on Freq, the frequency selected. Example, Max=56 for
Freq=1kHz, as calculated.
Angle
Sine
Reset
Angle_Loop
Sine_LUT
Clock(20MHz)
Freq
Roll Over
Counter
Clk
Figure25: Number of Clock Ticks Before Increasing the Angle by One Degree
30
DESIGN AND DEVELOPMENT
3.1 ARCHITECTURE OF WAVEFORM GENERATOR
Figure26: Architecture of Waveform Generator
For this project, is being divided into two categories: hardware and software. For the
hardware portion, it consists of four circuitries: the Microcontroller, the Digital-toAnalog Converter (DAC), the Switch and the LED display.
For the microcontroller circuitry, the microcontroller is the brain of the waveform
generator. It serve to interpret instructions given and know what to do for the inputs
and outputs. Example, when the ‘Amplitude’ push button is being pressed, the
microcontroller must output a different waveform amplitude and display the
amplitude value using the LED display.
For the Digital-to-Analog Converter (DAC) circuit, it main purpose is to convert the
digital signal received from the Microcontroller and convert it into the digital signal.
As for the switch circuit, it is used for controlling the output waveform. When the
button is being pressed, one high level signal will send to the input port of the
microcontroller. Then the microcontroller will change the output signal according to
the program written.
For the LED display circuit, it is used to display information related to the waveform.
This includes the amplitude and frequency value. The LED display value will change
according to the waveform display.
31

Microcontroller Circuit
On the microcontroller board, it consists of PIC18F2520 microcontroller, 5V
voltage regulator, push button, LEDs and other electronic components. The
power supply can either get from the DC power supply or using the PICkit2. If
the DC power supply is used, it will pass through a voltage regulator to step
down to a constant 5V. The two LEDs are used as an indicator for the power
supply and Master Clear.
For PIC18F2520 microcontroller, the Port A, B and C will be used as the
general purpose I/O operations. PortA[RA0:RA7] is used by the LED display
circuit. PortB[RB0:RB4] is assigned for the Switch circuit. For the
PortC[RC0:RC7], it is connected to the DAC circuit. For more information,
please refer to Appendix B.
Figure27: Microcontroller Board

Digital-to-Analog Converter (DAC) Circuit
The Digital-to-Analog Converter (DAC) circuit, it consists of the DAC0830,
HA17741, connectors and some other electronic components. The Digital
Input[DI0:DI7] port is connected to the PortC of the microcontroller. The DC
power supply of 5V, ±13V and ground will connect to the connector. As for
the with the two Op-Amp IC connect in ‘Bipolar Output Voltage with a Fixed
Reference’ mode. This gives sign significance to the MSB of the digital input
word and allows two-quadrant multiplication of the reference voltage. The
polarity of the reference can also be reversed to full 4-quadrant multiplication
with the relation Vout  Vref (
DigitalCode  128
) . The output of the second Op128
amp is connected to the BNC connector and the intended waveform can be
32
tapped from here. For more information regarding the connection, please refer
to Appendix B. For more information about the DAC, please refer to data
sheet for DAC0830 which can be found at REFERENCES[24].
Digital Code
0
64
128
192
255
DC Value
-5.0000
-2.5000
0.0000
2.5000
4.9609
Table4: Example of Some Digital Code Value
Figure28: Digital-to-Analog Converter Board

Switch and LED Circuit
For the switch and the LED circuits, it consists of Push Button (PB), LEDs
and other electronic components. The five PBs are connected to the PortB of
the microcontroller. The five PBs are used to input the signal to the
Microcontroller. 2 switches is used to control the frequency, another 2
switches used to control the amplitude and the last switch to select types of
waveform. As for the LEDs, it is connected to the PortA. It consists of 8
LEDs. It is used to display the ‘amplitude’ and ‘frequency’ value. This two
circuit is actually build on the same board so the user can easily get the
information on the waveform display. For more information, please refer to
Appendix B.
33
Figure29: Switch and LED Board

Microcontroller and the PICkit2 Microcontroller Programmer with In-Circuit
Serial Programming
During the process of downloading the source code into the microcontroller, it
required the used of the PICkit2 microcontroller programmer. The serial port
of the microcontroller programmer is connected to the programming head on
the microcontroller board, while the other USB cable is used to link the
microcontroller programmer with the computer. First check on the ‘On’ under
the VDD PICkit2 section and select 5V on the PICkit2 programmer software.
The clicking on the ‘Connect’ under the Programmer option. It will start a
debug session and initialize the communication for the target hardware.
Follow by the ‘Program’ under the Programmer option. Then the program start
the downloading of the executable program process into the PIC18F2520.
Figure30: PICkit2 Tools
34
3.2 SOFTWARE ALGORITHM
The square wave is generated by toggle the amplitude value. The frequency of the
signal is varied by putting a delay command after the data was output. The amplitude
is calculated using the below formula.
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic1)
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic0) .
The triangular waveform is achieved by linearly increase the output digital word[32].
Once the output 8-bit digital word has reached the peak voltage level, a linear
decreasing order logic level combination was output to the DAC. The frequency of
the signal is varied by putting a delay command after the data was output. The
amplitude is calculated using the
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic1)
formula.
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic0)
The sine waveform is generated using the sine formula provided in the C Library.
However the formula has to convert to radian mode first.
A sin(2* pi * f * t )(deg ree)  A sin(t /180* pi)( rad ) . Each time the value is calculated
and sent to the DAC. And again the frequency of the signal can be change by
changing the delay that is used every time a digital logic is output to the DAC. The
amplitude is calculated using the
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic1)
DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic0)
then multiply with the output value from sine formula.
For the DC waveform, the amplitude is calculated and the value was send to the DAC
for processing. DigitalCode  128*Vout / Vref  127  128*Vout / 5  127( Logic1) .
For more information regarding the programming flow, please refer to Appendix C.
35
TESTING AND RESULTS
4.1 HARDWARE AND SOFTWARE TESTING
During the process of designing the hardware and testing, I faced some problem for
both hardware and software. So, to make the work more efficient, some of the
circuitries were tested on the breadboard first, before mounted together. Some testing
was done to confirm the proper function of the circuit.

Testing of the Microcontroller Board
The LED and Switch circuit were first connected on the breadboard according
to the schematic. Then the LED circuit with 8 LEDs was connected to the Port
A and Switch circuit with 8 Push Buttons (PB) was connected to the Port B. A
program was written and program into the PIC18F2520. If any one of the PB
was pressed, a corresponding LED will LED light up. It is used to test for the
input test for the function of the Port A and Port B. Each LED was light up
according to the PB that was being pressed. This program will use for Port A,
Port B and Port C vice-versa as Input and Output. For more information
regarding the test program, please refer to Appendix D.

Testing of the Digital-to-Analog Converter(DAC) Board
The Microcontroller board was first connected to the DAC board which was
built on the breadboard. A program was written to test for the output
waveform of the DAC board. The Port C of the Microcontroller was
connected the Digital Input[DI0:DI7] port of the DAC0830. A simple program
to generate the square wave was programmed into the PIC18F2520. A square
wave was observed from the oscilloscope at the output of the DAC board. For
more information regarding the test program, please refer to Appendix D

Testing Voltage Regulator(LM7005)
When the 9V power adaptor is connected to the Voltage Regulator, Digital
Multimeter (DMM) was used to check for the voltage. A 5V was displayed on
the Digital Multimeter.
36

Testing of the PICkit2 Microcontroller Programmer
During the process of testing the PICkit2 microcontroller, the PICkit2 must
first connect to the computer using the USB cable. Then the programmer
connector of the microcontroller programmer was connected to the
programming head of the microcontroller board. First check on the ‘On’ under
the VDD PICkit2 section and select 5V on the PICkit2 programmer software.
Then in the MPLAB IDE program, clicked on the ‘Connect’ under the
Programmer option. A succeed message will popped out to show the detected
of the PIC18F2520 and the PICkit2 programmer. Then under the programmer
section, click on ‘Program’ to program the source code into the PIC18F2520.
A succeed message will popped out to show the programming was successes.
Figure31: Message showed PICkit2 Detected and Ready for Use
Figure32: Message showed Programmed Process Success and Completed
37
4.2 RESULTS
Pressing the ‘Waveform’ button, the waveform was able to change and it display
in the sequence of Square, Triangular, Sine and DC waveform. After the DC
waveform, the sequence will restart again. When repeating the testing cycle, the
result will remain the same.
SQUARE WAVE
Table5: Square Wave Result
Pressing the ‘Frequency Down’ or ‘Frequency Up’ button, the square waveform
was able to increase and decrease at the same frequency value but not at the fixed
frequency steps. This could be due to the internal oscillator frequency timing is
not accurate. By pressing the ‘Amplitude Down’ or ‘Amplitude Up’ button, the
amplitude was able to increase and decrease in the fixed step size of 1V from 1V
to 5V and the default voltage value is 5V. Whenever the amplitude reaches 1V or
5V, the amplitude will remain unchanged. The frequency will remain the same
when the amplitude changes and vice-versa. When repeating the testing cycle, the
result will remain the same as showed in the table. For more information please
refer to Appendix F.
38
TRIANGULAR WAVE
Table6: Triangular Wave Result
Pressing the ‘Frequency Down’ or ‘Frequency Up’ button, the triangular
waveform was able to increase and decrease at the same frequency value but not
at the fixed frequency steps. This could be due to the internal oscillator frequency
timing is not accurate. Also, by pressing the ‘Amplitude Down’ or ‘Amplitude
Up’ button, the amplitude was able to increase and decrease in the fixed step size
of 1V from 1V to 5V and the default voltage value is 5V. Whenever the amplitude
reaches 1V or 5V, the amplitude will remain unchanged. The frequency will
change when the amplitude change. This could be the formula use to calculate the
triangular waveform is not so well define. When repeating the testing cycle, the
result will remain the same as showed in the table. For more information please
refer to Appendix F.
39
SINE WAVE
Table7: Triangular Wave Result
Pressing the ‘Frequency Down’ or ‘Frequency Up’ button, the sine waveform was
unable to increase and decrease as it will only display frequency value of 8.93Hz.
This could be due to the time taken for the program to calculate the sine equation.
However, by pressing the ‘Amplitude Down’ or ‘Amplitude Up’ button, the
amplitude was able to increase and decrease in the fixed step size of 1V from 1V
to 5V and the default voltage value is 5V. Whenever the amplitude reaches 1V or
5V, the amplitude will remain unchanged. The frequency will remain the same
when the amplitude changes. When repeating the testing cycle, the result will
remain the same as showed in the table. For more information please refer to
Appendix F.
DC WAVE
When pressing the ‘Amplitude Down’ or ‘Amplitude Up’ buttons, the amplitude
was able to increase and decrease in the fixed step size of 1V from 1V to 5V and
the default voltage value is 5V. Whenever the amplitude reaches 1V or 5V, the
amplitude will remain unchanged. For more information please refer to Appendix
F.
40
PROBLEMS ENCOUNTERED AND SOLUTIONS
Problem1:
Missing of the linker file “18f2520.lkr” inside the MCC18 folder.
Solution1:
After reinstall the program again and again, the problem did not solve. So asked for
the “lkr” folder from my friend and able to find the linker file “18f2520.lkr”.
Problem2:
Unable to get the negative voltage after programmed for generate a negative voltage.
Solution2:
A Digital Multimeter(DMM) was used to check for the power supply connected to the
Op-Amps. The -13V power supply connected to one of the Op-Amps was not
soldered together. So, soldering was performed. Checking on the oscilloscope and the
negative voltage waveform was observed.
Problem3:
Unable to get the sine wave using the after programming using the Sine function
provided in the C library.
Solution3:
Just pumped in the different value for sine wave from 0 to 360 degree. Able to see the
sine wave. So suspect could be due to the wrong variable declaration. After declared
the variable used in the Sine function into the integer type, the problem solved.
41
6. PROJECT PLANNING AND MANAGEMENT
The project will be carried out in seven phases as follows:
Phase1: Data and component procurement
Phase2: Hardware construction
Phase3: Software and algorithms
Phase4: Testing
Phase5: Further development(if time permit)
Phase6: Writing final report
Phase7: Presentation preparation
TASK NAME
1- Information search
2- Analyse information
3- Collect components from supervisor
4- Writing initial report
5- Schematic design finalise boards layout
6- DAC board construction
7- LED indicator and switch board construction
8- Testing of individual board
9- Testing of integrated hardware
10- Final hardware troubleshooting
11- Simple program to test the DAC boards
12- DC waveform algorithm
13- Sine waveform algorithm
14- Square waveform algorithm
15- Triangular waveform algorithm
16- Integration of all programs
17- Debugging after integration
18- Full functionality check
19- Monitor and correct the output waveform
21- Writing Final Report
22- Presentation Preparation
START
23-Feb
23-Feb
20-Feb
15-Feb
2-Apr
30-Apr
22-May
30-May
8-Jun
17-Jun
22-May
5-Jun
5-Jun
8-Jul
10-Aug
24-Aug
16-Sep
14-Sep
4-Oct
1-Oct
2-Nov
FINISH
30-Apr
30-Apr
28-Feb
28-Feb
29-Apr
21-May
29-May
17-Jun
30-Jun
5-Jul
3-Jun
12-Jun
3-Jul
3-Aug
20-Aug
15-Sep
6-Oct
21-Oct
1-Nov
9-Nov
28-Nov
DURATION
67
67
9
14
28
22
8
19
23
19
13
8
29
29
11
21
21
39
29
40
27
Table8: Project Task with Schedule
7. CONCLUSION
42
7.1 FUTURE WORK

Since the sine wave can only generate one frequency, it could be due to the
longer computational timing for the sine wave equation. So, maybe can try to
limit the number of digits involve in the calculation to shorter the processing
time.

Because of the limitation of the built in internal oscillator frequency, the
output waveform frequency is very low. In order to increase it, an external
oscillator is needed and this can make the delay timing more accurate
compare to the internal oscillator.
 In order to make the display the amplitude, frequency and type of the
frequency more clearly, the LCD display should be employed. Since the
current connection for the PORTA is designated to display amplitude and
frequency, it can be easily fit into the LCD port. Also, the design of the PCB
board can be perform to include the Microcontroller, DAC, LED and Switch
circuit combine with a LCD display to make the waveform generator more
presentable and user friendly.
7.2 SUMMARY
Generally in this project, it provides me a lot of knowledge and exposure to the
hardware and software. It also gives me a chance to have hands on experience on how
to manage a project and to pick up more skills.
The major part of this project is to design and develop a waveform generator, that the
frequency, amplitude and waveform can be varied. With the little experience of the
hardware, I faced a difficulty in the selection of the components and deciding on the
connection of the electronics circuit. Also, I have no experience in the programming
of the microcontroller, which made me have to start from the basic to learn how to
program a microcontroller.
I have spent times on research and communicate with people from different forum to
help on the programming of the waveform generator. I also discussed with my friends
who have the experience in the microcontroller programming. As for the choice of the
43
hardware components, I have approached my project supervisor and some of my
friends who work in the related industry.
I believed that this project was not very success but the main objectives were met. I
am able to generate different types of waveform, the amplitude of the waveform can
vary accordingly and the frequency of the triangular and square can be vary even
though the frequency cannot increase in the fixed step size. During these 10 months, I
had picked up many valuable skills and knowledge. The years I spent at UniSIM had
been tested and I had learnt how to solve problems will more confident and improved
on my project management skill. Also, the report writing and oral presentation skill
will benefit me for my future career and life. By and large, this is really a worthy
experience to go through to make my life more excited and valuable.
44
REFERENCES
[1] "Function generator: Definition from Answers.com." Answers.com - Online
Dictionary, Encyclopedia and much more. 10 Feb. 2009
<http://www.answers.com/topic/function-generator>.
[2] "Signal generator -." Wikipedia, the free encyclopedia. 10 Feb. 2009
<http://en.wikipedia.org/wiki/Signal_generator>.
[3] "Arbitrary Waveform Generator (AWG) :: Radio-Electronics.Com." RadioElectronics.Com :: Radio and electronics tutorials, news and information. 11 Feb.
2009 <http://www.radio-electronics.com/info/t_and_m/generators/awg-arbitrarywaveform-generator.php>.
[4] "Arbitrary waveform generator -." Wikipedia, the free encyclopedia. 10 Feb. 2009
<http://en.wikipedia.org/wiki/Arbitrary_waveform_generator>.
[5] "Tone generator: Definition from Answers.com." Answers.com - Online
Dictionary, Encyclopedia and much more. 11 Feb. 2009
<http://www.answers.com/tone%20generator>.
[6] "Waveform". 5 Oct. 2009 <http://en.wikipedia.org/wiki/Waveform>.
[7] "Periodic function". 7 Oct. 2009 <http://www.answers.com/topic/periodicfunction>.
[8] "Waveform Generator". 8 Oct. 2009 <http://www.strategictest.com/eng/Learn/Waveform-Generator>.
[9] "Waveform / Signal / Function Generator IC's". 10 Oct. 2009
<http://www.siliconfareast.com/waveform-gen.htm>.
[10] "Signals and Waveforms". 5 Oct. 2009 <http://www.electronicstutorials.ws/waveforms/waveforms.html>.
[11] "Function generator". 10 Oct. 2009 <http://www.answers.com/topic/functiongenerator>.
45
[12] "ARM architecture -." Wikipedia, the free encyclopedia. 17 Feb. 2009
<http://en.wikipedia.org/wiki/ARM_architecture>.
[13] "TI MSP430 -." Wikipedia, the free encyclopedia. 17 Feb. 2009
<http://en.wikipedia.org/wiki/TI_MSP430>.
[14] "MIPS". 1 Oct. 2009 <http://www.langens.eu/tim/ea/mips/mipsverslag.pdf>
[15] "MIPS architecture -." Wikipedia, the free encyclopedia. 17 Feb. 2009
<http://en.wikipedia.org/wiki/MIPS_architecture>.
[16] "PIC microcontroller -." Wikipedia, the free encyclopedia. 17 Feb. 2009
<http://en.wikipedia.org/wiki/PIC_microcontroller>.
[17] "PIC18 Microcontroller Family". 1 Oct. 2009 <
http://lis.epfl.ch/contest/flying07/docs/resources/PIC%2018XXXX.pdf>.
[18] "LM741 Operatioanl Amplifier". 4 Oct. 2009
<http://www.national.com/ds/LM/LM741.pdf>.
[19] "HA17741/PS". 4 Oct. 2009 <http://datasheet.digchip.com/740/740-3-044879A17741PS.pdf>.
[20] "Digital-to-analog conversion: Definition from Answers.com." Answers.com Online Dictionary, Encyclopedia and much more. 11 Feb. 2009
<http://www.answers.com/topic/digital-to-analog-converter>.
[21] "Digital-to-analog converter -." Wikipedia, the free encyclopedia. 12 Feb. 2009
<http://en.wikipedia.org/wiki/Digital-to-analog_converter>.
[22] "The R/2nR DAC : DIGITAL-ANALOG CONVERSION." All About Circuits :
Free Electric Circuits Textbooks. 16 Feb. 2009
<http://www.allaboutcircuits.com/vol_4/chpt_13/2.html>.
[23] .Floyd, Thomas. 8th ed. Prentice Hall.
46
[24] "DAC0830 - 8-bit Microprocessor Compatible, Double-Buffered D/A
Converter". 4 Oct. 2009 <http://www.national.com/mpf/DA/DAC0830.html#General
Description>
[25] "Integrated development environment". 4 Oct. 2009
<http://en.wikipedia.org/wiki/Integrated_development_environment>.
[26] "integrated development environment". 4 Oct. 2009
<http://searchsoftwarequality.techtarget.com/sDefinition/0,,sid92_gci754848,00.html
>.
[27] "MPLAB". 4 Oct. 2009 <http://en.wikipedia.org/wiki/MPLAB>
[28] "MPLAB Integrated Development Environment ". 4 Oct. 2009
<http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=14
06&dDocName=en019469&part=SW007002>.
[29] "MPLAB C Compiler for PIC18 MCUs ". 5 Oct. 2009
<http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=14
06&dDocName=en010014>.
[30] "PICkit 2 Development Programmer/Debugger ". 5 Oct. 2009
<http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=14
06&dDocName=en023805&redirects=pickit2>
[31] "Shift Register-." Wikipedia, the free encyclopedia. 26 Feb. 2009
< http://en.wikipedia.org/wiki/Shift_register>
[32] "SINGLE-CHIP MICROCONTROLLER BASED ARBITRARY WAVEFORM
GENERATOR". 10 Oct. 2009
<http://www.kau.edu.sa/Files/320/Researches/47196_18725.pdf>.
47
APPENDIX A
GANTT CHART FOR PROJECT PLANNING
48
APPENDIX B
SCHEMATIC DIAGRAM
Microcontroller, Switch and LED Circuit Schematic
49
Digital-To-Analog Converter Schematic
50
APPENDIX C
SOFTWARE FLOWCHART STRUCTURE
Software Overall Flow Chart
Frequency Flow Chart
51
Amplitude Flow Chart
Waveform Selection Flow Chart
52
APPENDIX D
TEST PROGRAM
Microcontroller Board Test Program
#include "p18cxxx.h"
#include "delays.h"
#include "math.h"
void main (void)
{
TRISA = 0x00; //Port A as output port
TRISB = 0xFF; //Port B as output port
while(1)
{
if(PORTBbits.RB0 == 1)
{
PORTA = 0x01;
}
if(PORTBbits.RB1 == 1)
{
PORTA = 0x02;
}
if(PORTBbits.RB2 == 1)
{
PORTA = 0x04;
}
if(PORTBbits.RB3 == 1)
{
PORTA = 0x08;
}
if(PORTBbits.RB4 == 1)
{
PORTA = 0x10;
}
if(PORTBbits.RB5 == 1)
{
PORTA = 0x20;
}
if(PORTBbits.RB6 == 1)
{
PORTA = 0x40;
}
if(PORTBbits.RB7 == 1)
{
PORTA = 0x80;
}
}
}
53
Digital-To-Analog Board Test Program
#include "p18cxxx.h"
#include "delays.h"
#include "math.h"
void main (void)
{
TRISA = 0x00; //Port A as output port
TRISB = 0xFF; //Port B as input port
TRISC = 0x00; //Port C as output port
while(1)
{
for(i = 0; i <= 360; i++) //square wave
{
PORTC = 255; // +5V
Delay10KTCYx(1);
PORTC = 0; // -5V
Delay10KTCYx(1);
}
}
}
54
APPENDIX E
MAIN PROGRAM SOURCE CODE
#include "p18cxxx.h"
#include "delays.h"
#include "math.h"
//#pragma config OSC = INTIO67 // use internal oscillator and bits 6 & 7 of PORTA can be
used as IO pins
#define PI 3.14159
void main (void)
{
int i,SW = 1,N,M,j,Amplitude = 0x05,Frequency,multiply = 1; //SW default type of
waveform, Amplitude default Amplitude value
float Amp = 5.0,Freq = 10.0; //4.0
OSCTUNE = 0x008F; //
OSCCON = 0x0077; //8MHz internal oscillator
ADCON1 = 0x1F; //set all the port to digital I/O
TRISA = 0x00; //set PortA as output port
TRISB = 0x1F; //set the Port5{D4:D0} as input port
TRISC = 0x00; //set PortC as output port
PORTA = 0x00;
N = (int)(128.0+(127.0*Amp)/5.0); //amplitude +5V
M = (int)(128.0-(127.0*Amp)/5.0); //amplitude -5V
Delay10TCYx(10);
while(1)
{
if(PORTBbits.RB4 == 1)//change waveform
{
Delay10TCYx(1);
if (PORTBbits.RB4 != 1)
break;
if(SW == 0x04) //
SW = 0x01;
55
else
SW = SW + 0x01;
Delay10TCYx(20);
while(PORTBbits.RB4);
}
if(PORTBbits.RB3 == 1)//change amplitude to increase
{
Delay10TCYx(1);
if (PORTBbits.RB3 != 1)
break;
if(Amp == 5.0)
Amp = 5.0;
else
Amp = Amp + 1.0;
Amplitude = (int)Amp;
N = (int)(128.0+(127.0*Amp)/5.0);
M = (int)(128.0-(127.0*Amp)/5.0);
Delay10TCYx(20);
while(PORTBbits.RB3);
}
if(PORTBbits.RB2 == 1)//change amplitude to decrease
{
Delay10TCYx(1);
if (PORTBbits.RB2 != 1)
break;
if(Amp == 1.0)
Amp = 1.0;
else
Amp = Amp - 1.0;
Amplitude = (int)Amp;
N = (int)(128.0+(127.0*Amp)/5.0);
56
M = (int)(128.0-(127.0*Amp)/5.0);
Delay10TCYx(20);
while(PORTBbits.RB2);
}
if(PORTBbits.RB1 == 1)//change frequency to increase
{
Delay10TCYx(1);
if (PORTBbits.RB1 != 1)
break;
if(multiply == 10) //120.0
multiply = 10;
//Freq = 200.0;
else
multiply = multiply + 1;
//Freq = Freq + 20.0;
Frequency = (int)Freq;
Delay10TCYx(10);
while(PORTBbits.RB1);
}
if(PORTBbits.RB0 == 1)//change frequency to decrease
{
Delay10TCYx(1);
if (PORTBbits.RB0 != 1)
break;
if(multiply == 1)
multiply = 1;
else
multiply = multiply - 1;
Frequency = (int)Freq;
Delay10TCYx(10);
while(PORTBbits.RB0);
57
}
switch(SW)
{
case 0x01:
for(i = 0; i <= 360; i=i+10) //square wave
{
if(i<180)
{
PORTC = M; // Amplitude value
}
else
{
PORTC = N; // Amplitude value
}
Delay10TCYx(Freq*multiply);
}
break;
case 0x02:
for(i = M; i <= N; i = i + 10) // triangular wave
{
PORTC = i;
Delay10TCYx(Freq*multiply); // delay depends on freq
}
for(i = N; i >= M; i = i - 10)
{
PORTC = i;
Delay10TCYx(Freq*multiply); // delay depends on freq
}
break;
case 0x03:
for (i = 0; i <= 360; i= i+10) //sine wave
{
PORTC = (int)((127.0*Amp*sin(i/180.0*PI))/5.0+128.0);//typecasting
Delay10TCYx(Freq*multiply);
58
}
break;
default :
PORTC = N;
break;
}
switch(Amplitude)//led for amplitude
{
case 0x01: //1V amplitude
PORTA = 0x01;
break;
case 0x02: //2V amplitude
PORTA = 0x02;
break;
case 0x03: //3V amplitude
PORTA = 0x03;
break;
case 0x04: //4V amplitude
PORTA = 0x04;
break;
case 0x05: //5V amplitude
PORTA = 0x05;
break;
}
switch(Frequency) //to display the frequency value
{
case 0x01:
PORTA |= 0x08;
break;
59
case 0x02:
PORTA |= 0x10;
break;
case 0x03:
PORTA |= 0x18;
break;
case 0x04:
PORTA |= 0x20;
break;
case 0x05:
PORTA |= 0x28;
break;
case 0x06:
PORTA |= 0x30;
break;
case 0x07:
PORTA |= 0x31;
break;
case 0x08:
PORTA |= 0x40;
break;
}
}
}
60
APPENDIX F
AMPLITUDE TESTING RESULT
Square Waveform at Different Amplitude
Triangular Waveform at Different Amplitude
61
Sine Waveform at Different Amplitude
DC Waveform at Different Amplitude
62
FREQUENCY TESTING RESULT
Square Waveform at Different Frequency
63
Triangular Waveform at Different Frequency
64
Sine Waveform at Frequency of 8.93Hz
65
APPENDIX F
PROTOTYPE OF WAVEFORM GENERATOR
66
Download