Sunteți pe pagina 1din 59

FUNCTION GENERATOR

XXXXXXXXXXXX

1XXXXXXX
Department of Electrical & Electronics Engineering

Sreenidhi Institute of Science & Technology

Yamnampet, Ghatkesar, Hyderabad – 501301.

2017-18
Department of Electrical & Electronics Engineering

Sreenidhi Institute of Science & Technology

(Autonomous)

CERTIFICATE

This is to certify that the project entitled “ FUNCTION GENERATOR” has


been carried out by the following students:

XXXXX - 1xxxxA0xxx

XXXXX - 1xxxxA0xxx

XXXXX - 1xxxxA0xxx

of III year, II semester B. Tech (Electrical & Electronics Engineering)


under our supervision during the year 2017-2018 in partial fulfillment of the
requirement for the award of Bachelor of Technology Degree in
Electrical & Electronics Engineering.

III
Internal guide:

UMADEVI APPADURAI

Assistant Professor

Electrical & Electronics Engg Dept.

Head of Department:

Dr. C. BHARGAVA,

Prof & Head,

Electrical & Electronics Engg Dept.

IV
ACKNOWLEDGEMENT

It is our privilege to express our sincerest regards to our


industrial project coordinator, Mr. Purna Chendar Rao, for his
valuable inputs, able guidance, encouragement, whole-hearted
cooperation and constructive criticism throughout the duration of
our Industrial project.

We deeply express our sincere thanks to our Head of Department


and Professor Dr. C. BHARGAVA for encouraging and allowing us
to present the project on the topic “Function Generator “at our
department premises.

We take this opportunity to thank all our lecturers who have


directly or indirectly helped our project. We pay our respects and
love to our parents and all other family members and friends for
their love and encouragement through out our career. Last but not
the least we express our thanks to our friends for their cooperation
and support.

V
ABSTRACT

A function generator is usually a piece of electronic test


equipment or software used to generate different types of electrical
waveforms over a wide range of frequencies. Some of the most common
waveforms produced by the function generator are the sine wave , square
wave, triangular wave and sawtooth shapes. These waveforms can be
either repetitive or single-shot (which requires an internal or external
trigger source). Integrated circuits used to generate waveforms may also
be described as function generator ICs.

In addition to producing sine waves, function generators may


typically produce other repetitive waveforms including sawtooth and
triangular waveforms, square waves, and pulses. Another feature
included on many function generators is the ability to add a DC offset.

VI
CONTENTS

CERTIFICATE………………………………………………………. i
ACKNOWLEDGEMENT…………………………………………… ii
ABSTRACT…………………………………………………………... iii

1 INTRODUCTION………………………………………………….. 1
1.1 Background…………………………………………………….
1.2 Wave generator architectures………………………………….
1.3 Aim……………………………………………………………..
2 SYSTEM OVERVIEW…………………………………………….. 2
2.1 Functions and outputs…………………………………………. 2
2.2 Modulation…………………………………………………….
3 HARDWARE………………………………………………………. 7
3.1 Power supply………………………………………………….. 7
3.1.1 Circuit Diagram…………………………………………. 7
3.1.2 Design…………………………………………………… 8
3.1.3 Wave forms……………………………………………… 9
3.2 AD9833 Board………………………………………………… 10

VII
3.2.1 Pin Diagram……………………………………………... 10
3.2.2 Circuit Diagram………………………………………….. 12
3.2.3 Working…………………………………………………. 13
3.2.4 Key Features…………………………………………….. 15
4 SOFTWARE……………………………………………………….. 18
4.1 Arduino……………………………………………………….. 18
4.2 AD9833……………………………………………………….. 21
4.3 Wave forms……………………………………………………. 24
5 CONCLUSION…………………………………………………….. 26
6 REFERENCE………………………………………………………. 26

VIII
1 INTRODUCTION

A function generator is a signal source that has the capability of


producing different types of waveforms as its output signal. The most
common output waveforms are sine-waves, triangular waves, square
waves, and sawtooth waves. The frequencies of such waveforms may be
adjusted from a fraction of a hertz to several hundred kHz.

Actually, the function generators are very versatile instruments as


they are capable of producing a wide variety of waveforms and
frequencies. In fact, each of the waveforms they generate is particularly
suitable for a different group of applications. The uses of sinusoidal
outputs and square-wave outputs have already been described in the
earlier Arts. The triangular-wave and sawtooth wave outputs of function
generators are commonly used for those applications which need a signal
that increases (or reduces) at a specific linear rate. They are also used in
driving sweep oscillators in oscilloscopes and the X-axis of X-Y
recorders.

1
1.1 Background

Many function generators are also capable of generating two


different waveforms simultaneously (from different output terminals, of
course). This can be a useful feature when two generated signals are
required for a particular application. For instance, by provid-ing a square
wave for linearity measurements in an audio-system, a simultaneous
sawtooth output may be used to drive the horizontal deflection amplifier
of an oscilloscope, providing a visual display of the measurement result.
For another example, a triangular-wave and a sine-wave of equal
frequencies can be produced simultaneously. If the zero crossings of
both the waves are made to occur at the same time, a linearly varying
waveform is available which can be started at the point of zero phase of
a sine-wave.

Today's electronic systems require many signal waveform shapes.


Common waveforms are the square wave, triangular wave, and
single pulse wave with fixed duration. Fixed duration pulses are
used in communication and control systems. Square waves are used
as a clock for digital systems. Triangular waves are used for
scanning an electron beam on a CRT screen, in precise time

2
measurements, and in time modulation. With the development of
modern technology, the function generator with independent control
of amplitude and frequency play an important role in applied
electronics, communications, instrumentation and signal processing
applications.

The function generator is a measurement equipment with


long history, it has been produced in 1920 .With the development of
communication technique and radar technique, in 1940, the function
generator used to test standard signal of various receiver appeared,
this improvement change the function generator from a qualitative
investigation testing instrument to a quantitative analysis measuring
instruments. At the same time, the pulse function generator to
measure the pulse circuit or modulate the pulse has been made. The
mechanical structure of the function generator is very complex in
early time, which led the slowly evolution of the function generator.
Till 1964, the first function generators with whole transistors were
created.

As a common used signal source, function generator is the


most extensive used of general instrument in the modern test area.
To research, production, testing and maintenance each electronic
components, units and the machine equipment, the signal source are
needed. It produces voltage signal and current signal with different

3
frequency and wave form, and added to the device or equipment
which being measured, then observe and measuring the output
response of the measured instrument to analyse and identify their
performance parameters. Function generator is the most basic and
widely used electronic instruments in electronic measurement field.

It has not only been applied in the domains of education,


scientific research, production and engineering, but also have some
advantages such as continuous phase transformation, frequency
stabilization and so on; it is useful in simulate various complex
signal and dynamic control the values, such as frequency, amplitude,
phase and wave form; the function generator can also communicate
with other equipments to constitute automatic test system (ATS), so
it can also applied in the domains of communication, ATS,
instrument and meter.

1.2 Wave generator architectures

In the modern field of electronic systems, wave generator can


be used as stand-alone signal sources or may be a part of integrated
sensing system for providing excitation and control. Tuning of
amplitude and frequency and independent control adds extra
flexibility to the system and required in many sensor based
integrated system applications like the micro-machined resistive and

4
capacitive sensors. In this part, different kinds of wave generator
and its applications will be introduced

1.2.1 Square-wave Generator

The square-wave generator with amplitude and frequency


tuning has been shown is Figure 1-1. Operational Transconductance
Amplifier (OTA) has been used in it. OTA-2 and OAT-3 along with
resistors R1 and R2 are configured as voltage amplifiers which are
connected in positive feedback, from a Schmitt trigger. OTA-1
along with the capacitor C forms an integrator which determines the
frequency of the square wave depending on its time constant.
OTA-4 with resistor R3 provides the out phase output of the
square-wave. The amplitude of the square-waves depends on the
bias currents of OTA-2 and OTA-4(Ib2 and Ib4) and also R1 and
R3.

5
Figure 1-1, Square-Wave and Clock Generator

1.2.2 Triangular/Square-Wave Generator

A triangular/square-wave generator in which the frequency


and amplitude of the square waveform can be independently and
linearly controlled by dc bias currents has been illustrated in Figure
1-2. Two voltage amplifiers (one is composed of OTA1 and R1 and
the other OTA2 and R2) connected in a positive-feedback manner
form a Schmitt trigger. OTA3 and the timing capacitor C form an
integrator. The frequency of the waveform is directly proportional
to the IB3, whereas the amplitude is directly proportional to the IB1.

6
Figure 1-2, The proposed Triangular/Square-Wave Generator

On the one hand, the application of the circuit to a current-controllable


saw-tooth waveform generator is also presented. On the other hand, it has a
wide range of applications in instrumentation and measurement systems.

1.2.3 Sinusoidal/Triangular/Square-wave generator

The Figure 1-3 shows a function generator, which can generator


sinusoidal, triangular and square wave. Operating principle: 555 timer and
some components constitute a multivibrator. C2 is a timing capacitor, its charge
circuit is R2→R3→RP→C2 and its discharge circuit is C2→RP→R3→Pin
7(discharge tube). Because R3 + RP >> R2, charge time constant approximately

7
equal to discharge time constant, pin 3 generate approximate symmetry square
wave. As component parameters in the Figure 1-3, its frequency is 1kHz, and it
can change the oscillator frequency to adjust potentiometer RP. Through R4
and C5 integrating circuit, generate triangle wave. The triangle wave pass
through R5 and C6 integrating circuit again, generate approximate symmetry
sine wave. C2 is power filter capacitor. The light-emitting diode VD is a power
light.

Figure 1-3, Diagram of a function generator

1.2.4 Arbitrary Waveform Generator

There are many kinds of methods of designing arbitrary waveform, and


they are based around digital techniques, but the two main categories always
fall into their design.

1.2.4.1 Arbitrary function generator

8
This type is based on the direct digital synthesis techniques (DDS) and
uses integrated circuits to be created relatively and for an economic price.

Figure 1-4 shows the operation of a direct digital synthesizer. It


operates by storing the points of a wave in digital format in a memory to
recall them to generate the wave. The points can be any form of repetitive
waveform, which is required. The rate of the DDS completes one wave decide
the frequency.

Figure 1-4, Block diagram of arbitrary function generator

Figure 1-5 shows the phase advances around the circle corresponds to
advances in the wave. From it, it can be obtain the faster we complete the
cycles, the higher we can achieve the frequency of the wave.

9
Figure1-5, Phase relationship for a signal

This arbitrary function generator has many advantages, such as digital


and sub-hertz frequency resolution. There is also some disadvantage, which
should also be taken into account. For example, it can generator any kinds of
wave, but the wave sequencing is not possible using DDS arbitrary function
generator.

1.2.4.2 Variable clock arbitrary waveform generator

The variable clock arbitrary waveform generator is more complex to


use and also more expensive, so it not may always be the most economic
instrument.

It uses variable frequency clocks to access points on a waveform stored


in RAM, and then convert into an analogue format. The number of that wave
points govern the clock frequency, which is the recetition frequency.
Furthermore the variable clock arbitrary waveform generator include several
techniques such as memory segmentation and sequencing whose function is to
improve the capabilities of this aribitrary generator. Its block diagram is
illustrated in Figure 1-6.

10
Figure1-6, Block digram of a variable clock arbitrary waveform generator

As amentioned, it is costly and more complicated set-up, but it also has


advantage such as it can produce the widest variation fo wavefroms of any
form of generator and also link several waveforms together within the
memory.Nowadays, the various function generators are produced by some
companies.

The Agilent and B&K precision are very famous companies in this
field. They build various function generators.

11
1.3 Aim

1.3.1 Original opinion

The original opinion is a programmable function generator, which can


obtain different kinds of waveform by using different binary input signals, but
our laboratory room cannot provide that components needed in the
programmable function generator, so the thesis work must need some change.
If Laboratory Equipment conditions permitted in the future, that is possible to
let this research better.

1.3.2 Final opinion

The main object of this thesis is to build a function generator which is


the breadboard circuit based on the operational amplifier and diodes,
capacitors, resistors and can achieve three kinds of common waveform. In this
paper, a new scheme is presented in which the frequency of the waveform can
be controlled by changing resistance and capacitance. First we will learn to
understand the working principle and architecture of sinusoidal –wave
generator, square-wave generator and triangular-wave generator, and then

12
simulation of a function generator will be created by Multisim. Finally
combine the three types of waveforms to build up a function generator.

In this paper, following this introductory section, its configuration and


principles of operations are given in the basic theory section. Some
experimental results and product model are presented in subsequent sections

2 SYSTEM OVERVIEW

2.1 Functions and outputs

The AD9833 generates sine waves and square waves at


frequencies up to 30.2 MHz, and triangle and ramp waveforms up to 100
kHz. The frequency resolution for all functions is 1 µHz. In addition to
the standard waveforms, the unit also provides a wideband (10 MHz)
white noise source.

Both the function output and a TTL SYNC output are available
through floating, front-panel BNC connectors. Both outputs have 50 Ω
output impedances and may be floated up to ±40 V relative to earth
ground. The amplitude of all function outputs is adjustable from 10
mVpp to 10 Vpp with 3-digit resolution, and can be displayed in Vp,

13
Vpp, Vrms or dBm. In addition, standard TTL and ECL output levels
can be selected.

Additional useful connectors are provided on the rear panel. A


trigger input is used to trigger arbitrary waveforms, modulation patterns,
sweeps and bursts, while a TTL trigger output is provided to allow
synchronization of external

Function generators are capable of producing a variety of repetitive


waveforms, generally from the list below:

 Sine wave: A function generator will normally have the


capability to produce a standard sine wave output. This is the
standard waveform that oscillates between two levels with a
standard sinusoidal shape.

14
The sinusoidal oscillator is one of the classical applications of op-amp
based active circuits. Canonic sinusoidal oscillators are designed with two
capacitors, four resistors, and only one op-amp [8], that is Wien-Bridge
Oscillator.

Canonic sinusoidal oscillator: Figure 2-1 shows a basic Wien-Bridge


Oscillator. It generates an oscillatory output signal without having any input
source and has widely applied in low frequency oscillating circuit. Uses two
RC networks connected to the positive terminal to form a frequency selective
feedback network and cause oscillations to occur. Amplifies the signal by the
two negative feedback resistors.

Figure 2-1, Basic Wien-Bridge Oscillator

15
Figure 2-2, Modification to the basic Wien-Bridge Oscillator

Frequency conversion: The analysis for Wien-Bridge Oscillator is shown


in Figure 2-6. It uses a feedback circuit consisting of a series RC circuit
connected with a parallel RC of the same component values producing a
phase delay or phase advance circuit depending upon the frequency. At the
resonant frequency ƒr the phase shift is 0o.

Figure 2-3, Analysis for Wien-Bridge Oscillator

16
 Square wave: A square wave is normally relatively easy for a
function generator to produce. It consists of a signal moving
directly between high and low levels.

Since the anode of the zener is connected to the inverting (-) input, it is
a virtual ground (≌ 0V). Therefore, when the output voltage reaches a
positive value equal to the zener voltage, it limits at that value, as illustrated
in Figure 2-7(a). When the output switches negative. The zener acts as a
regular diode and becomes forward-biased at 0.7 V, limiting the negative
output voltage to this value. As shown in part (b). Turning the zener around
limits the output voltage in the opposite direction.

17
Figure 2-4 Operation of a bounded comparator

Two zener diodes arranged as in Figure 2-8 limits the output voltage to
the zener voltage plus the forward voltage drop (0.7V) of the forward-biased
zener, both positively and negatively, as shown.

Figure 2-5, Double-bounded comparator

18
 Pulse: A pulse waveform is another type that can be
produced by a function generator. It is effectively the same as a
square wave, but with the mark space ratio very different to 1:1.

 Triangular wave: This form of signal produced by the


function generator linearly moves between a high and low point.

The integrator current: In Figure 2-9, the inverting input of the op-amp is at
virtual ground (0V), so the voltage across Ri equals Vin. Hence, the input
current is

Figure 2-6, Current in an integrator [9]

19
If Vin is a constant voltage, then Iin is also a constant because the
inverting input always remains at 0V, keeping a constant voltage across Ri.
Because of the very high input impedance of the op-amp, there is negligible
current at the inverting input. This makes all of the input current go through
the capacitor, as indicated in Figure 2-9

The capacitor voltage: Since Iin is constant, so is IC. The constant IC charges
the capacitor linearly and produces a linear voltage across C. The positive
side of the capacitor is held at 0 V by the virtual ground of the op-amp. The
voltage on the negative side of the capacitor, which is the op-amp output
voltage, decreases linearly from zero as the capacitor charges, as shown in
Figure 2-10.

Figure 2-7, Voltage in an integrator

The output voltage: Vout is the same as the voltage on the negative
side of the capacitor. When a constant positive input voltage in the

20
form of a step or pulse (a pulse has a constant amplitude when high)
is applied, the output ramp decreases negatively until the op-amp
saturates at its maximum negative level. This is indicated in Figure
2-11.

Figure 2-11, An op-amp integrator

Integrator is useful in triangular-wave oscillators as you will see in this paper.


In this section, a new scheme of RC-active Wien bridge oscillator is proposed,
whose oscillation frequency is quite independent on the time constants of the
op-amps used in the design, and is determined by passive components.

 Sawtooth wave: Again, this is a triangular waveform, but


with the rise edge of the waveform faster or slower than the fall,
making a form of shape similar to a sawtooth.

21
2.2 Modulation

The AD9833 offers a wide variety of modulation options. It contains


an internal modulation generator which can modulate any of its standard
waveforms except noise. The modulation waveform can be a sine, square,
triangle, ramp, or an arbitrary waveform. Modulation rates from 1 mHz to
10 kHz can be selected.The modulation generator can provide amplitude
modulation (AM), frequency modulation (FM), and phase modulation
(PM). When using AM, modulation depths of ±100 % can be selected
with 1 % resolution. Negative values of modulation correspond to Double
Sideband Suppressed Carrier (DSBSC) modulation. FM spans can be
selected with 1 µHz resolution, and phase modulation can be set between
0° and 7200° with 0.001° resolution.

22
Fig., 2.1

External Amplitude Modulation

In addition to the internal modulation generator, the output waveform


can be amplitude modulated by an external signal applied to the
rear-panel AM input. This input is always active even when other
modulation types are turned on.

Fig. 2.2

23
Burst Modulation

You can generate tone bursts of any output function except noise. In the
burst mode, the AD9833 will output an exact number of complete
waveform cycles after receiving a trigger. By adjusting the phase, you can
control where in the waveform the burst begins. While using the burst
mode, the maximum frequency for sine waves and square waves is 1
MHz, while triangles and ramps are limited to 100 kHz. Burst mode may
be used with arbitrary waveforms at any frequency.

Fig., 2.3
Frequency Sweeps

The AD9833 can frequency sweep any of its function outputs (except
noise). You can sweep up or down in frequency using linear or log
sweeps. Unlike conventional function generators, there are no annoying
discontinuities or band-switching artifacts when sweeping through
certain frequencies. The AD9833's DDS architecture inherently allows it
to perform smooth, phase-continuous sweeps over it's entire frequency
range.

24
Fig., 2.4

3 Hardware

There are two main parts regarding the hardware aspect of this
build: the power supply and the main PCB containing the function
generator IC and the microcontroller.

3.1 The Power Supply

3.1.1 Circuit Diagram

The main PCB will need two voltage rails: +12V and -12V. The
symmetrical supplies are needed for the final amplification of the signal.
A smaller +5V rail will be created directly on the main PCB by
regulating the +12V one; it is needed to power the microcontroller, the
AD9833, the function generator IC, and finally the 24MHz crystal
oscillator. Below you can find the schematic of the power supply board:

25
Fig., 3.1

3.1.2 Design

To obtain these voltages, a transformer will be used, from 230V


or 110V (depending on your region) to two 12V AC lines (on the
transformer it will usually be written something along the lines of
12V-0V-12V). An output current of 200mA is more than sufficient.

Remember that the output of a transformer is AC and we need


DC. For this, we will be using a simple rectifier bridge. This will change
the sinusoid into a positive signal. These usually come as standalone
components but you can alternatively use four general purpose diodes
such as 1N4001.

We will not be using it in the standard configuration as we want


a symmetrical output, so we will connect them as in the schematic above:
the ends of the transformer are connected to the rectifier, and the center
tap is connected to ground. To smooth out the output we will first use

26
two large capacitors, each 1000µF rated at 35V. Below you can find the
output waveforms for the power supply rails at various stages:

3.1.3 Waveforms

Fig., 3.2

In addition, to remove the ripple, two voltage regulators are used,


the classic LM7812 and its sibling the LM7912, which is used for
negative voltages. To top it off we add a 100µF capacitor and a 100nF
one, both rated at 25V, to each regulator IC output. We want this supply

27
to be as smooth as possible, as we will be using them to offset our final
output voltage, and any AC components will propagate to the output.

3.2 AD9833 Board


3.2.1 Pin Diagram

Fig. 3.3

Functional block diagram:

28
Fig. 3.4

Pin Description:

Pin No. Mnemonic Description


1 COMP DAC Bias Pin. This pin is used for decoupling the
DAC bias voltage.
2 VDD Positive Power Supply for the Analog and Digital
Interface Sections. The on-board 2.5 V regulator
is also supplied from VDD. VDD can have a value
from 2.3 V to 5.5 V. A 0.1 μF and a 10 μF
decoupling capacitor should be connected
between VDD and AGND
3 CAP/2-5V The digital circuitry operates from a 2.5 V power
supply. This 2.5 V is generated from VDD using
an on-board regulator when VDD exceeds 2.7 V.
The regulator requires a decoupling capacitor of
100 nF typicaL, which is connected from
CAP/2.5V to DGND. If VDD is less than or equal
to 2.7 V, CAP/2.5V should be tied directly to
VDD
4 DGND Digital Ground.
5 MCLK Digital Clock Input. DDS output frequencies are

29
expressed as a binary fraction of the frequency of
MCLK. This clock determines the output
frequency accuracy and phase noise
6 SDATA Serial Data Input. The 16-bit serial data
-word is applied to this input
7 SCLK Serial Clock Input. Data is clocked into the
AD9833 on each falling edge of SCLK
8 FSYNC Active Low Control Input. FSYNC is the frame
synchronization signal for the input data. When
FSYNC is taken low, the internal logic is
informed that a new word is being loaded into the
device
9 AGND Analog Ground
10 VOUT Voltage Output. The analog and digital output
from the AD9833 is available at this pin. An
external load resistor is not required because the
device has a 200 Ω resistor on-board.

3.2.2 Circuit Diagram

Let’s get to the main PCB. The LM1117-5V linear regulator is


used to create a +5V rail from the +12V supply. To keep everything
smooth, we add capacitors to both voltage input lines (+12V and -12V)
and the output of the voltage regulator.

30
Fig., 3.5

On the left side of the schematic, you will find an


ATMega328p-AU microcontroller, the same used on the Arduino Uno
but in an SMD package. To program the MCU, a 6-pin connector called
AVR-ISP is placed next to it. It has two pins for power (+5V and GND)
and four other pins for communication: MISO, MOSI, CLK, and
RESET.

3.2.3 Working

We will be using only one user input component, a rotary


encoder with an integrated switch. This will be our control element to
set the frequency, signal type, and other settings. The signals from the
rotary encoder are routed to two interrupt pins on the microcontroller,
PD2 and PD3 (D2 and D3 on the Uno), and the switch goes to an
available pin that can act as an input; I chose PD1 (D1 on the Uno). We

31
won’t be adding any pull-up resistors as we will be using the ones
integrated into the microcontroller.

Because mechanical contacts are not perfect, when we rotate


the encoder, instead of an ideal pulse, a jittery signal will appear, but
this can be easily fixed either by software or hardware using a capacitor.
For the integrated switch, we will use the software method, and for the
rotating contacts, two 100nF capacitors will be used.

A plain green LED is hooked up to pin PD7 (D7 on the Uno), for
debugging purposes or to display status. The display used is a simple
LCD with an HD44780 controller, which has 16 lines and two columns
and includes a backlight. To reduce the number of connecting wires, an
adapter board was used so that the only pins needed to control the LCD
are 2 for data over I2C and another 2 for power (+5V and GND). The
I2C lines on the microcontroller are on pins PC4 for SDA and PC5 for
SCL. On the Arduino Uno, these are named A4 and A5, respectively.

Finally, the last connection for the microcontroller is made


between it and the AD9833 integrated circuit. It uses a unidirectional
SPI bus, meaning that data can only flow in one direction, from the
MCU to the IC. The signals are MOSI (Master Out - Slave In), CLK
(Clock), and CS (Chip Select, called FSYNC on the AD9833). To
conclude the microcontroller portion, I should mention that decoupling
capacitors with a value of 100nF are needed for each power supply pin. .

32
Fig., 3.6
3.2.4 Key Features

It is a DDS type programmable waveform generator, so it takes a


clock signal with a maximum frequency of 25MHz (for this particular
IC), which it then divides based on a value passed by the
microcontroller (maximum 228) via the SPI bus, and using a 10-bit
DAC it outputs a waveform chosen by the microcontroller.

33
The output has a peak-to-peak value of 0.65V-0.038V (VOUT
maximum – VOUT minimum), and it has an offset of (0.65V-0.038V)/2.
This means that VOUT minimum is very close to 0V. One important
note is that the clock output (rectangular signal) has an amplitude of
2.5V, which is the voltage generated by the device's internal voltage
regulator.

A crystal oscillator is used to feed a 24MHz clock signal to the


master clock input of the AD9833. FSYNC, SCLK, and SDATA are
connected to the SPI bus of the microcontroller. Two decoupling
capacitors are used near the VDD pin, one with a value of 0.1µF and
another one with a value of 10µF. Another decoupling capacitor is
needed for the 2.5V internal voltage regulator; this is near the pin CAP
and has a value of 0.1µF. One more capacitor is needed between the
COMP and VDD pins for decoupling the DAC bias voltage; it has a
value of 10nF, as indicated by the datasheet.

Fig., 3.7

34
The output of the IC is fed into the non-inverting input of the
op-amp using a 1.3kΩ resistor. The trimmer POT1 (a variable resistor),
which has its side pins connected to -12V and +12V, has the sweeper
connected to a switch's input terminal to provide an offset voltage. The
other input terminal of the SPDT switch is wired directly to ground, and
the output terminal is connected to the non-inverting input of the
op-amp with another 1.3kΩ resistor. This configuration combined with a
50kΩ potentiometer allows us to have a variable gain between 1 and
approximately 20. This was computed using Millman’s theorem and the
fact that the op-amp keeps its inputs, V+ and V-, at the same voltage:

The offset voltage is set to -350mV using the trimmer POT1. When
the switch is in position 3 (R4 connected to ground), the output voltage
is the output of the IC, a signal with an amplitude of 350mV and an
offset of 350mV, multiplied by the gain set by the potentiometer POT2.

When the switch is in position 1 (R4 connected to the offset


voltage obtained by the trimmer POT1), the output is just as before
minus the offset voltage, essentially a signal with a 350mV amplitude
and no offset, multiplied by the gain.

With this configuration, the output voltage can either swing from
-7V to +7V or from 0V to what the op-amp is capable of (something
near +12V).

35
The offset voltage is set to VOUT minimum of the AD9833. This is
then multiplied by the gain, which can vary from 1 to 20.

Fig., 3.8
4 Software

With Multisim, you can optimize your circuit design performance


with powerful SPICE simulation and intuitive analyses. You can reduce
design errors, prototype faster, and improve productivity. Save prototype
iterations and optimize printed circuit board (PCB) designs earlier in the
design process by using the Multisim design approach. The Multisim
software has the ability to simulate function generator and help us collect
data.

36
The proposed design of the functiong generator is shown in Figure
3-2 by using Multisim software. The design contains three part like illustrated
in Figure 3-1, and that can obtain three kinds of waveform with different
frequency. The testing result will be shown in the results section.

Figure 3-2, The main circuit of functiong generator


To write the code that will be uploaded into the
microcontroller’s memory, we will be using the Arduino IDE. In the
following few paragraphs I will explain how to write a library for the
AD9833 and then the main piece of software that allows us to interface
the microcontroller with the AD9833, the LCD, and the rotary encoder.
The AD9833 has these so-called registers, which are basically memory
locations, into which we can put data, and based on these values the
integrated circuit changes its mode of operation; it chooses what
waveform to output, the phase, and the division factor. We will be

37
working with five registers: the control register; two phase registers,
PHASE0 and PHASE1; and two frequency registers, FREQ0 and
FREQ1.

4.1 Arduino

Arduino is an open-source hardware and software company,


project and user community that designs and manufactures single-board
microcontrollers and microcontroller kits for building digital devices
and interactive objects that can sense and control objects in the physical
and digital world. Its products are licensed under the GNU Lesser
General Public License (LGPL) or the GNU General Public License
(GPL), permitting the manufacture of Arduino boards and software
distribution by anyone. Arduino boards are available commercially in
preassembled form or as do-it-yourself (DIY) kits.

Arduino board designs use a variety of microprocessors and


controllers. The boards are equipped with sets of digital and analog
input/output (I/O) pins that may be interfaced to various expansion
boards or breadboards (shields) and other circuits. The boards feature
serial communications interfaces, including Universal Serial Bus (USB)
on some models, which are also used for loading programs from
personal computers.

The microcontrollers are typically programmed using a dialect


of features from the programming languages C and C++. In addition to

38
using traditional compiler toolchains, the Arduino project provides an
integrated development environment (IDE) based on the Processing
language project.

The Arduino project started in 2003 as a program for students at


the Interaction Design Institute Ivrea in Ivrea, Italy, aiming to provide a
low-cost and easy way for novices and professionals to create devices
that interact with their environment using sensors and actuators.
Common examples of such devices intended for beginner hobbyists
include simple robots, thermostats and motion detectors.

The Arduino integrated development environment (IDE) is a


cross-platform application (for Windows, macOS, Linux) that is written
in the programming language Java. It is used to write and upload
programs to Arduino board.

The source code for the IDE is released under the GNU General
Public License, version 2. The Arduino IDE supports the languages C
and C++ using special rules of code structuring. The Arduino IDE
supplies a software library from the Wiring project, which provides
many common input and output procedures. User-written code only
requires two basic functions, for starting the sketch and the main
program loop, that are compiled and linked with a program stub main()
into an executable cyclic executive program with the GNU toolchain,
also included with the IDE distribution. The Arduino IDE employs the
program avrdude to convert the executable code into a text file in

39
hexadecimal encoding that is loaded into the Arduino board by a loader
program in the board's firmware.

Pin Description:

Pin Category Pin Name Details


Vin: Input voltage to Arduino when using
an external power source.

5V: Regulated power supply used to


power microcontroller and other
Vin, 3.3V, 5V, components on the board.
Power
GND
3.3V: 3.3V supply generated by on-board
voltage regulator. Maximum current draw
is 50mA.

GND: ground pins.

40
Reset Reset Resets the microcontroller.
Used to provide analog input in the range
Analog Pins A0 – A5
of 0-5V
Input/Output Digital Pins 0 -
Can be used as input or output pins.
Pins 13
Used to receive and transmit TTL serial
Serial 0(Rx), 1(Tx)
data.
External
2, 3 To trigger an interrupt.
Interrupts
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM output.
10 (SS), 11
(MOSI), 12
SPI Used for SPI communication.
(MISO) and 13
(SCK)
Inbuilt LED 13 To turn on the inbuilt LED.
A4 (SDA), A5
TWI Used for TWI communication.
(SCA)
To provide reference voltage for input
AREF AREF
voltage.

Arduino Uno Technical Specifications:

Microcontroller ATmega328P – 8 bit AVR family microcontroller

Operating Voltage 5V

Recommended Input
7-12V
Voltage

41
Input Voltage Limits 6-20V

Analog Input Pins 6 (A0 – A5)

Digital I/O Pins 14 (Out of which 6 provide PWM output)

DC Current on I/O Pins 40 mA

DC Current on 3.3V Pin 50 mA

Flash Memory 32 KB (0.5 KB is used for Bootloader)

SRAM 2 KB

EEPROM 1 KB

Frequency (Clock Speed) 16 MHz

Pin Diagram:

42
Fig. 4.1

4.2 AD9833 Library

We will create two files, AD9833.cpp, the file that will contain
the source code, and AD9833.h, its header.

Inside the header, we specify the name of the class (AD9833)


and, just like a Russian nesting doll, inside it, variables and functions
that we will be calling to communicate with the waveform generator IC
and to change its parameters, such as the frequency and the type of
waveform.

43
These can be one of two types: public, which we can call from
outside the class methods (functions), or private, which we can call only
when we are inside a class’s method.

we have to set in the AD9833’s registers to manipulate the


output waveform and its operation. Thus, we will write functions for the
following operations: write data, set frequency, set phase, sleep, reset,
mode, and choose frequency/phase register.

We will be working directly at the bit level. Sometimes we may


want to change the value of an entire register, for example for the
frequency register, but sometimes we want to only change a few bits of
the whole word. To achieve this, we will use the following operations:

 “&=” To set some bits to 0 while leaving the rest undisturbed. (0 =


set to 0, 1 = leave it how it is).
 “|=” To set some bits to 1 while leaving the rest undisturbed. (1 = set
to 1, 0 = leave it how it is).

44
Operation Register Value

Set Frequency FREQ0 FREEQ0: D15 = 0, D14 = 1

Set Frequency FREQ1 FREEQ1: D15 = 1, D14 = 0

PHASE0: D15 = 1, D14 = 1,


Set Phase PHASE0
D13 = 0

PHASE0: D15 = 1, D14 = 1,


Set Phase PHASE1
D13 = 1

Set Mode - Sine CNTRL D5 = 0, D1 = 0

Set Mode - Triangular CNTRL D5 = 0, D1 = 1

Set Mode - Clock CNTRL D5 = 1, D1 = 0

D11 = 0 (choose FREQ0);


Set Frequency Register CNTRL
D11 = 1 (choose FREQ1);

Reset CNTRL D8 = 0 or 1

Sleep - No power-down CNTRL D7 = 0, D6 = 0

Sleep - DAC powered down CNTRL D7 = 0, D6 = 1

45
Sleep - Internal clock disabled CNTRL D7 = 1, D6 = 0

Sleep - DAC powered down


CNTRL D7 = 1, D6 = 1
and internal clock disabled

In the table below from the datasheet contains data of which bits
need to be set to execute the operations.
The registers have different sizes. The control register is 16 bits
long, the phase registers are 12 bits long, and the frequency registers
have 28 bits. To output data via SPI, we send one byte at a time, as can
be seen in the “writeData” function, starting with the low byte (first 8
bits from the data integer) and then the high byte.

Setting the frequency is a bit more tricky because we are not


directly sending the frequency that we want. According to the datasheet,
the analog output is fMCLK/228 × FREQREG. Thus, the frequency
register must be set to:

frequency  2 28
FREQREG =
f mclk

Because the obtained number can be as long as 28 bits, we


divide it into two words, each 16 bits long, and then we send the data
starting with the lower one.

46
4.3 Waveforms

Fig., 4.2 :Sine Wave of 1KHz

47
Fig., 4.3: Triangular Wave of 1KHz

Fig., 4.4: Square Wave of 500Hz

48
5 CONCLUSION
In this thesis, a function generator has been achieved. Three kinds of
waveforms have been generated by simulating the function generator and
debugging the model of the function generator. Also the frequency of the
each kind wave can be changed by changing the resistance and capacitance,
but the amplitude of the waveforms is unable to change.

It has the following advantages. It can produce a sinusoidal output


and without other help. The mould of the function generator can be
constructed on a bread board, so it facilitates us in learning and help us learn
more about function generator. Nothing is perfect, so it also has a few of
disadvantages. If the square wave and triangle wave wants to be achieved,
above all obtain sinusoidal; if not, there is nothing observed for this function
generator. External conditions such as connection problem easily interfere
with the process of the function generator.

In this study, use RC Wien bridge oscillator to achieve sinusoidal


wave; use the comparator circuit to convert sinusoidal wave into square wave;
use the integrating circuit to obtain triangle wave. It is one of the useful
models to help us to learn more about function generator. This kind of
function generator has been chosen as our study. The reasons for this are as
follows. To begin with, this system is independence, which means that the
system needs not to apply on an input signal or voltage. The system can
directly achieve wave form without other conditions. Moreover, the circuit of
the function generator is not complicated and easy to understand. Lastly,
these electronic components employed in the model are so easy to find in our
laboratory and then the model can easily be constructed. So this method has
been employed in our study.

49
Multisim is equipped with a database of as many as 22,000
components from leading semiconductor manufacturers such as Analog
Devices, National Semiconductor, NXP, ON Semiconductor, and Texas
Instruments. Choose from a comprehensive list of up-to-date amplifiers,
diodes, transistors, switch mode power supplies, and other components to
rapidly design and evaluate analog and digital circuits. So when use the
Multisim to simulate the function generator, it is possible to find all
components. But in our laboratory, that is not possible, sometime it is
necessary to change.

To sum up, in the simulation, the three kind of wave form


successfully achieved, so a correct way to construct a function generator was
employed, but if need other kind of wave form, that is not possible. In the
future, further research will have to improve it. In our laboratory, the main
circuit was built in a bread board and performance has been verified by the
oscilloscope and in our future, plenty of this kind of function generator can be
produced to let students learn more about the structure of a function generator.
For the future work, the project can focus on how to change the amplitude for
the waveform, and more kinds of waveform can be added in the function
generator. And the framework of the circuit can be improved, to make it more
embellish, the circuit can be soldering on the circuit board. Then the whole
system of the function generator will be more distinct and perfect.

50
We believe there were a number of factors that allowed us to
succeed in this Industrial project. After finishing the Industrial Training,
we set ourselves a team goal that consisted of learning from the hands-on
practical experience in the industry. The sessions consisted of learning
various of the block level components used in a Function Generator and
learn how they work internally. These practical sessions pushed us to
refine our knowledge quickly and get to a grasp on the system. Once we
were able to display output waveform of Function Generator on the screen
of CRO, we implemented additional features on top of the original
waveforms like Lissajous patterns. Therefore, in the three weeks of the
training, we were always building on top of a working system. Finally, we
set ourselves clear goals every week and wrote them in a report. This
document served as a Go-To list to find out what we had to achieve each
week.

6 REFERENCE

http://www.hiqelectronics.com/

51

S-ar putea să vă placă și