0% found this document useful (0 votes)
91 views

Function Generator (AD9833 Based) : Step 1: Demonstration

This instructable describes how to build a function generator using an AD9833 chip. The generator can produce sine, triangle, and square waves up to 12.5 MHz. The author details the circuit design and components used, including an ATmega328p microcontroller to control the AD9833 module. Potential noise issues are discussed and solutions presented, such as using a capacitance multiplier for power supply filtering and adding resistors to reduce noise from the MAX7219 display driver. PCB design files are provided to fabricate a printed circuit board for the project. Construction and testing of the built function generator is shown.

Uploaded by

Henwa Mostafa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Function Generator (AD9833 Based) : Step 1: Demonstration

This instructable describes how to build a function generator using an AD9833 chip. The generator can produce sine, triangle, and square waves up to 12.5 MHz. The author details the circuit design and components used, including an ATmega328p microcontroller to control the AD9833 module. Potential noise issues are discussed and solutions presented, such as using a capacitance multiplier for power supply filtering and adding resistors to reduce noise from the MAX7219 display driver. PCB design files are provided to fabricate a printed circuit board for the project. Construction and testing of the built function generator is shown.

Uploaded by

Henwa Mostafa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

instructables

Function Generator (AD9833 Based)

by Gursimran Singh 425

Hi, I am Gursimran Singh href="https://www.allaboutcircuits.com/projects/how-


to-DIY-waveform-generator-analog-devices-ad9833-
In this Instructable, I will guide you through on how to ATmega328p/">project by Cezar Chirila.
make a "functional" function generator, which can be
very helpful when working with electronic circuits. A I will explain the problems I encountered and how I got
function generator can generate di erent kinds of rid of them in upcoming steps. Also, you'll learn how to
signals like sine wave, square wave or even a triangular fabricate your own PCB at home.
wave at a particular frequency set by the user.
This project is powered by AC Mains Supply (220
The design explained in this ible uses AD9833 which can Volts), playing with electricity is not a good idea. If
ideally generate frequencies up to 12.5 MHz as per the you are interested in making this project ,then
datasheet. I came across AD9833 when reading this please make it under the supervision of a

Step 1: Demonstration

Function Generator (AD9833 Based): Page 1


The 3 LEDs indicate the wave to be synthesized (Red for
Triangle, Green for Sine and Blue for Square Wave), each
of them can be selected by the horizontal black
https://www.youtube.com/embed/alO8FfdyaY4
rectangular switch.

The rst knob (potentiometer) from the left controls the

amplitude of output, maximum is 12 volts. On reaching the desired place, button(Rotary Encoder's
Push Button) is pressed, the pointer is locked at that
The middle knob (potentiometer) controls the o set position. Now scroll the encoder to increase or decrease
voltage of output. the number value at the place. Pressing the button once
again sets the value at the respective place and now the
The Red knob is attached to a rotary encoder which is encoder can be scrolled to move on any other place.
used to set the frequency, basically scroll the encoder
clockwise and anti-clockwise to move the pointer I know I couldn't explain the whole value setting process
(Decimal on 7-Segment :P) right and left respectively to properly :) The above video can help in visualizing the
a desired place. whole process.

Step 2: Circuit and Conceptualization

Signals related Stu A 7-segment display array controlled via MAX7219 IC is


used for displaying frequency and what else could be
AD9833 based modules with ability to synthesize signals better way for making menu interface other than THE
up to 12.5 MHz (As per datasheet) can be found all over ROTARY ENCODER.
the internet. Fortunately these are damn easy to use,
thanks to developers of compatible libraries. Skeleton of Power Supply
project is very straight forward. Atmega328p
microcontroller communicates with AD9833 module A generic 12-0-12 center-tapped transformer power the
which spits out desired frequency signal (Sine, Triangle whole thing rated at max 500 mA which should su ce
or Square wave), which is obviously not capable of for most situations. Recti ed voltage is fed into two
driving enough current and voltage levels too peak out linear regulators LM7812 (for +12 V rail) and LM7912 (for
at a maximum of 0.65 volts. -12 V rail), -12 V and + 12 V rails are for Op-Amp. For
powering Atmega328p, Display, Rotary Encoder etc. 2
The output of it is fed into inverting terminal of a yes! two LM7805 regulators have been used. I'll explain
commonly available Op-Amp (LM386,TL071 etc.) , the why in upcoming steps.
o set and amplitude being controlled by two
potentiometers. This nally is connected to output port.

Function Generator (AD9833 Based): Page 2


Step 3: Noise Noise....Different Kinds of Noise

Coding part was a piece of cake, removing noise wasn't actually!

Power supply circuit we just made in previous step doesn't really get rid of ripples completely. But when making such a
device, one should try to achieve the lowest possible noise.

I ruled out three reasons that could be causing noise issues:

Ground Loops! I prototyped everything on breadboards before soldering everything on a PCB and
breadboards are notorious noise lovers. Ground loops can be removed by using Star-Grounding and
using PCBs.
MAX7219 is also known to introduce high frequency noise(see pictures) in power rails.

I am no expert in designing PCBs neither did I have enough budget to get it fabricated from fabrication house. Thank
God! I found a video on "Capacitance Multiplier" by Dave Jones of EEVblog (I am his big fan!)

https://www.youtube.com/embed/wopmEyZKnYo

Using this method instantly solved all noise related problems. I was greeted by clean output.

Even then, I tried to eliminate ground loops as much as I could.

I found an interesting read on allaboutcircuits forums about a gentleman who was able to solve noise issues with
MAX7219 by limiting current drawn by its data lines simply by using 2 resistors. Linked here.

Function Generator (AD9833 Based): Page 3


Step 4: Finally Inner Peace!

The MAX7219 issue was solved by placing 2.2 k ohm delighted by it that I didn't touch it (fearing I would
resistors in DIN and LOAD pins. This was suggested by accidentally mess something up), until I was done with
helpful folks in this All About Circuits forum post designing PCB.

Also, I used two LM7805 Linear Regulators, one for the "The Fear" was born when AD9833 decided to stop
microcontroller and the other for the display. This too working for unknown reasons when I was busy
helped in reducing noise. removing noise. I had to order another module :(

One I was able to achieve desired output! I was so

Function Generator (AD9833 Based): Page 4


Step 5: Ki-CAD Files

This was the most fun part of the project! Designing PCB was bugged with noise and pretty unstable, instead after
and learning bits about "PCB Design Rules". I have no watching GreatScott! video I ended up using TL071 Low
professional training in this subject (Maybe in the future Noise Operational Ampli er IC. In fact, the Operation
I will, I am an EE student though) random youtube Ampli er Implementation is done identically to that of
videos and articles on the web helped me through it. GreatScott!'s

The schematic of the project is attached below as pdf His channel is just plain awesome, go check it out for
le, picture shown above isn't very clear though. more electronics-related videos.

I tried using LM358 Operation Ampli er but the output

Function Generator (AD9833 Based): Page 5


Download

https://www.instructables.com/ORIG/FDI/MWC7/KP5H88CB/FDIMWC7KP5H88CB.pdf

Step 6: Supplies

Capacitors :

1000 uF Electrolytic Capacitors (6x)


470 uF Electrolytic Capacitors (4x)
10 uF Electrolytic Capacitor
100 nF Unpolarized Capacitor (High Voltage Rated) (4x)
100 nF Ceramic Capacitors (Number 104) (3x)
22 pF Ceramic Capacitors (2x)

Resistors :

220 ohm (3x)


1k ohm (2x)
2.2k ohm (3x)
10k ohm (3x)

Function Generator (AD9833 Based): Page 6


Potentiometers :

10k ohm
47k ohm

Semiconductor Devices :

D2SBA60 Full Bridge Recti er


BD137 NPN Transistor (2x)
LM7805 (2x)
LM7812
LM7912
LM358/TL071 Operational Ampli er
AD9833 Breakout Board
Atmega 328-PU

Connectors and Jacks :

Pin Headers (Male and Female)


BNC Connectors (Mountable Socket and Jack)
Screw Terminal Block (3 terminal)
DC Barrel Jack
DC Port

Misc. Components :

Rotary Encoder Breakout Board


Buzzer
16 MHz crystal
7-Segment (8 Digit) SPI Display [Uses MAX7219 Driver]
Push Buttons
500 mA Fuse
Compatible Fuse Holder
12-0-12 500mA transformer

For PCB Fabrication :

PCB Clad (One Sided)


Ferric Chloride
Glossy Paper
Laser Printer!
PCB Drill
Sandpaper ( ne grit)

Function Generator (AD9833 Based): Page 7


Step 7: Preparation for PCB Fabrication

It's extremely important to remove stains and oxidation from Copper Clad PCB before proceeding. Isopropyl alcohol is
useful, but I used very ne-grit sandpaper. Don't overdo sanding as might just remove too much copper.

Step 8: Transferring Toner

Print the attached pdf le on glossy paper using "Laser Printer". Please make it is Laser Printer only. Actually, this method
itself is known as the "toner transfer method".

When printing make sure quality is set to high and "Actual Size"option is selected.

Get your iron heated up


Place glossy side facing copper

Function Generator (AD9833 Based): Page 8


Smoothly glide the iron over other side of the paper (where traces are not printed) while applying
pressure on board
Do it for 10 minutes, making sure each and every corner has been heated and pressed.

Download

https://www.instructables.com/ORIG/FWD/8E4A/KP5H88EL/FWD8E4AKP5H88EL.pdf

Step 9: Peeling Off

Now drop PCB into cold water and let it soak for around 5 minutes this will make removal of paper easy.

Don't forget to turn o Iron

Now carefully peel o paper, most probably it won't come o in single try.
Paper can be removed from inaccessible areas by rubbing using ngers gently.
Although toner sticks quite well to copper, you can use brute force but make sure you don't end up
removing traces instead.

Function Generator (AD9833 Based): Page 9


Step 10: Preparation for Etching

In upcoming steps you are going to play with corrosive toner transfer isn't perfect. If you nd broken/missing
chemical like Ferric Chloride, and it stains really bad! To traces while visually inspecting, use a sharpie/Permanent
prevent dying your skin yellow for a week (Or possibly CD marker to correct it.
worse situation).Please make sure to wear gloves and
if possible use safety goggles too. These markers hold up pretty well in ferric chloride.

Anyways before we do anything permanent. Sometimes

Function Generator (AD9833 Based): Page 10


Step 11: Etching

Take spoonful of ferric chloride and add su cient amount to water so that PCB is fully submerged.

A spoon of FeCl3 (Ferric Chloride) might not su ce, you can add accordingly, fortunately same solution can be used
multiple times.

Function Generator (AD9833 Based): Page 11


Shaking the container might speed up the process. It took 20-25 minutes to completely eat away unwanted copper.

Again be careful when handling corrosive chemicals.

Step 12: Appreciation of Beauty

After you see no copper except under toner (which you can't see anyways!), remove PCB from solution and rinse it in
water, make sure to clean it completely (Remainder chemical on board and corrode traces after toner is rubbed o )

Function Generator (AD9833 Based): Page 12


Step 13: Drilling Holes

Here comes the boring part, btw end result is somewhat After holes have been drilled use a ne grit sandpaper
satisfying. I used a cute hand-drill which is suitable for again to rub-o toner exposing shiny copper traces.
PCB drilling and other ne work. Isopropyl alcohol might be a better option as it removes
risk of over sanding.
0.8 mm bit was used for majority of components and
wherever it was too tight for components to t I drilled
with 1 mm bit.

Step 14: Lessons Learnt

Dremel/Rotary tool is widely used for PCB drilling but the problem is without dress press its very inaccurate and nicky to
use. If you have a drill press go for it. But I don't have any and ended up destroying one copper pad(Although it wasn't a
big deal)

Function Generator (AD9833 Based): Page 13


Step 15: Soldering

Aha! The most fun part of build when you see your project coming to life. I spent much of my day meticulously soldering
components in place. Please maker sure you are placing components correctly keeping in mind polarity and pinout.

Wrongly placed electrolytic capacitors can end up in disaster!

Please refer to Ki-CAD les provided when soldering. Double check when soldering capacitors and transistors.

Function Generator (AD9833 Based): Page 14


Step 16: Finishing Off PCB Build

By evening I was done with soldering. As you can see in the second picture I had reference board le opened in front of
me because I don't want to place capacitors in opposite polarity and end up getting hurt. You should also do the same!

Step 17: Burning Bootloader on Atmega328p

Function Generator (AD9833 Based): Page 15


This is where I made a mistake in rst attempt. Gammon's website that worked awlessly I recommend
you to do the same. But his setup programs and Arduino
I bought Atmega328P which usually doesn't come with UNO being programmed by another Arduino UNO. The
bootloader installed. You have to do it on your own. Arduino UNO being programmed is our Atmega328p in
Using this method I was able to upload code on my setup. But how to wire Atmega328p to the
Microcontroller but ISP communication doesn't require programmer? Use wiring used in this link, you'll need
bootloader. some components like 16MHz crystal and 2x 22pF
capacitors. You need another Arduino UNO with sketch
My end goal was to leave a port on PCB from where I can (Github link mentioned on Gammon's website)
modify code without removing Atmega328P from its uploaded onto it. This process can be confusi, If you have
socket. ISP protocol uses just too may pins that too any problem with this task you can contact me.
common with the pins I was already using for 7-
Segment display Finally bootloader was up and running, I tested blink
sketch.
When searching on web I found this method on Nick

Step 18: Code

The code attached below requires some libraries to be Go to sketch > Include Library > Add .ZIP Library and
installed, to make your work easy I have mentioned all navigate to where you have downloaded them
the links to their respective github pages below
Repeat this process for all three of them.
AD9833.h
Math and TimerOne are preinstalled in IDE I guess.
ClickEncoder.h
I got some idea about using ClickEncoder.h from this
LedControl.h youtube video. Precisely where I implemented the menu
kind of function for setting the frequency using Encoder.
Download them as zipped folders In fact, the same channel educ8s.tv has many great
videos about arduino projects.
After downloading them Open Arduino IDE

Download

https://www.instructables.com/ORIG/FK1/J6MN/KOFRB4Y5/FK1J6MNKOFRB4Y5.ino

Step 19: Enclosure Design

I used bakelite sheets to sandwich wooden frame inside as my enclosure.

3-D printed option is probably a better option but I don't have access to any currently.

For making the front plate:

Function Generator (AD9833 Based): Page 16


Place all components giving enough space for wires etc.
Mark points for holes to be drilled
These holes will be used for mounting components using nut/bolts or nut/washer combo that comes
with potentiometers.

Wooden frame is nothing but a quarter inch thick plywood cut according to make a box with 4 sides (3 attached
permanently to one another and the 4th one to be used a lid and held by screws).

This process doesn't require any xed parameters you can easily make it tting your requirements.

Rough size of enclosure I made is 15cm X 20cm X 8cm

For making square cutouts, rstly drill large holes and then use le to make cutout square.

Step 20: Fuse and Safety

For safety, I added a fuse between AC Mains Electricity and Primary of our transformer. See above schematics for more
detail.
Function Generator (AD9833 Based): Page 17
Step 21: Packed Everything In

Used M3 nuts and bolts to mount everything in front and backplates.

Now it was time to test the whole thing.

Please be careful, this project deals with AC mains power supply! Make sure you are a professional or make this project
under a professional's supervision! Accidents can be lethal!

Function Generator (AD9833 Based): Page 18


Step 22: Final Thoughts

Overall I am very satis ed with the build, after so many years I got to make a project. It is quite functional and so far I
haven't encountered any major issues. But this is not by any means perfect. A lot many things can be improved :

The enclosure is quite bulky, extruded aluminum enclosure could be better.


The size of PCB can be reduced but soldering SMD components require a higher level of skills and special
equipment.
The transformer heats up a bit after continuous usage, nothing to be worried about. But that can be
cooled using a PC fan.
It can remain stable at a pinpoint frequency say 345789 Hz, as evident from the above photo frequency
can jump around a little.

I hope you liked it:)

Thanks!

Function Generator (AD9833 Based): Page 19


Very nicely done. Nice and neat. But I think a fuse on the ground line (J2.2) is a really bad idea.
Be careful.
Glad you liked it!
In most linear regulated power supplies I've seen, J2.2 is grounded. I think fuse can be at max
useless as it functions just like a connection to ground. I'll be happy to learn if/how that can be
dangerous? I mean I've seen some designs with J2.2 connected to an ON/OFF switch connecting
to ground. So there is surely something that I am missing...
PS : I had already added an external fuse (mounted on the enclosure) for safety, connected
between mains and primary of transformer

Hi Gursimran
If there is a short on the board that blows the J2.2 fuse, the hot lines (J2.1, J2.3) are still hot and,
if presented with a path to ground (I'm assuming your case is grounded) there will be a shock,
spark, damage to your circuit. If the transformer is something like a 12v CT, the voltage (24VAC)
will not be dangerous to you but would easily damage your circuit.
Yeah, that's a classic mistake! It would be better to add a fuse on hot lines instead! But I think a
fuse on primary side should suffice . Anyways I am modifying the schematics and PCB file.
Thanks a lot for letting me know!
Nice project, very well explained in all the steps.
Can I have the Kicad files?
Very nice project and construction! Whar is the tichness of thew plastic sheets? The neme is
really "bakelite"? I know bakelite as the denomination for avery old type of plastic. Congrats,
Paulo, Brazil
Yeah, you are right, bakelite is a type of plastic. The sheets I used are probably 3-4mm thick.
Thanks a lot :)

Function Generator (AD9833 Based): Page 20

You might also like