Mar
24

Function Generator

History

This project didn’t look complicated but it was. The MCU part is really simple: just some code for the Display, Keypad and DDS Communication.

A DDS is a chip that is driven by a hi-frequency oscillator. I used a 50 Mhz clock. Inside this IC there is a big divider that goes down to less than 1Hz. The resulting clock is passed to another counter which is connected to a Sine ROM table.  If you need a triangle wave, the counter is directly connected to the output.  For a square wave, the signal which drives the counter is redirected to the primary output.
Once my MCU Board and the DDS board were done, I connected everything together and a cool sine wave was coming out of my DDS ranging from 1Hz to 5Mhz. I thought to myself that this project was almost done…. beeeeeeeeeep, wrong again! The worst part was to come. It's not so easy to amplify a signal of 400mv to +/-15v, 300ma at 5Mhz. First you CAN'T prototype this on a bread board. So I built more than 5 PCB's. Also, I had to find a very high speed Op-Amp that came in a package suitable for prototyping. I chose the LM7171 for its low cost and DIP package.  With an Op-Amp like this you must have decoupling capacitors on the – and + side to GND VERY CLOSE to the IC (each Op-Amp separately).

As you will see I mounted the DDS on a small PCB. This animal is so small that I was not sure that I could solder it. If I could then the DDS could be used on another mother-board

Note: The AD9833 DDS datasheet rates it for 25 Mhz, but in the preliminary datasheet it was rated for 50Mhz.  I made my project work at 50 Mhz and there was no problem. Just don't try it for final production. The higher the clock rate, the better the output signal will be.
 

Features

     Frequency from 1Hz to 5Mhz
     Accuracy of 0.1Hz
     Square/Sine/Triangle Output
     Variable duty cycle
    5V TTL output
     Output up to +15v to -15v peek to peek
     Adjustable DC Offset from +15v to -15v
 

Pictures 

(Those pictures are the version 1.0,  The new pictures are to come)

Download

MCU Schematic

DDS Schematic

TTL Board Schematic

Analog Board Schematic

Source Code Schematic




28 Comments to “Function Generator”

  • Bo Qiang August 23, 2010 at 2:55 pm

    Hi,

    Nice project, thanks for sharing it.

    One question: could the number of cycles be programmed? I mean, for example, I want to output 10 cycles of 100 Hz sine wave.
     
    Thanks.
     
    Bo

  • admin August 29, 2010 at 12:50 am

    No it can t be done

  • Chris September 17, 2010 at 11:29 pm

    Nice projects you have here!
    Just a thought, perhaps you should add an BOM list to make it easier to find out what components is needed for the projects?
    Other then that, keep up the good work!

  • Edwin May 24, 2011 at 9:35 pm

    Hi, 
    Just a quick question, the output frequency of the system is stated as being from 1 Hz to 5 MHz, is this a design decision or is it a limitation arising the parts used, as the AD9833 is capable of outputting up to half the driving frequency (i.e. should be able to output 25 MHz if a 50 MHz clock is used).

  • admin May 24, 2011 at 9:37 pm

    It’s due to all the opamp, and digital pot limitation

    Sylvain

  • Mihec July 22, 2011 at 11:32 am

    Hello!
    I'm working with that AD9833 to. I've problem with output stage, when amplifie signal and give a little bit of offset. 
    I've got questions for you. In schematic of output stage, you have capacitor C1 220uF for AC coupling? How much is your low and high cutoff frequency?

  • admin July 22, 2011 at 2:40 pm

    The high is teoricaly infinit, the low just calcul the Zin of the circuit with 220uF, It’s many time lower than 1Hz

  • joseph September 24, 2011 at 9:31 am

    Hi Sylvain
    this is the project what i searched to drive ad9833.i would like to build a generator for hobby purposes.
    seems like the hex file doesen't work,but i tried to complie the *c file  and i cant find nowhere the missing "shortnametype.h" theres not inside nowhere in the earlier versions of the iccavr (doesent exist in  inside v7,v8 demo too),i saw this problem in comment of your Mood light project.   you wrote that "Replace the shortnametype by
    #define ushort unsigned char
    #define uint unsigned int
    but still don't work.the complier has still type errors, missing something ,i am a beginner in c programming.
    can you help?
    Regards
    Joseh

  • admin September 27, 2011 at 1:12 pm

    I just send you the hex file

  • joseph September 28, 2011 at 11:10 am

    Thank you
    i received
    Regards
    Joseph

  • Jack O'Flaherty May 29, 2012 at 8:44 am

    A nice project; I am now building it.
    A couple of things are unclear from the schematics:
    Where does the input to the 74HC14s come from?
    What is the purpose of that second output?
    What is the value of L1, in series with the main output?
    Jack

  • admin May 29, 2012 at 12:23 pm

    74hx14 came from J3 of the analog board,
    the second output is from the 74hc14 and it’s a ttl outpout
    L1 I don’t remember,
    Sylvain

  • Jack O'Flaherty May 29, 2012 at 6:30 pm

    Thanks, Sylvain.
    Jack

  • Yassen June 7, 2012 at 8:20 pm

    I used LM6172 in my smilar project . Best OA, but high price. No need discrete stage.

  • Vadim September 26, 2012 at 8:46 am

    Hello. There are several issues. In the MCU Schematic shown Atmega32 microcontroller, but the source code is under the Atmega324 microcontroller. These microcontrollers are incompatible. What to do?
    Perhaps you have a firmware for the microcontroller ATmega32.
    Thank you.

  • admin September 26, 2012 at 1:01 pm

    It’s a Mega324

  • saravananviswakarma April 3, 2013 at 7:19 am

    hello sir  the compiler   has still type errors please send me the hex file and pcb file

  • tania July 12, 2013 at 5:48 am

    Hello….I am about to design a function generator, but I want to have a flexibility of varying the frequency (increase or decrease say from 2000Hz to 2100Hz  with step size of 1Hz)with the push of keypad button. So I want to ask, is it possible to do with the AD9833 DDS chip. Also I am not able to understand on the waveshaper.pdf circuit the role of PIN6 on JP1 Header 5×2. I think SQR and SINE signal is fed to the Realy G2VN1(Please give the proper part number). 
    Thanks for the post….
    Regards
    Tania

  • admin July 14, 2013 at 4:14 pm

    I think you can use this DDS to do what you need, It’s make a long time I had work on this project
    and I don’t remember everything, but yes the relay is for the squarewave and any GP relay will do the job

  • BUDI July 17, 2013 at 9:27 pm

    hi ..
    I HAVE A QUESTION FOR YOU, CAN WORK WITH AD9850 DDS (CLOCK 125MHz). WHAT SHOULD I DO …?????

  • admin July 18, 2013 at 2:26 am

    Rebuild all the design.

  • shads August 15, 2013 at 10:15 pm

    Brag, as I realized the management of DDS synthesizer …..
    http://www.youtube.com/watch?v=It-F4SHB-Ro
    http://asis-kbr.ru/forum/viewtopic.php?f=11&t=164

  • saravananviswakarma August 29, 2013 at 11:08 am

    sir i want do this dds project please sen me hex code and amega324 circuit diagram

  • Zsolt August 31, 2013 at 6:44 am

    Hi Sylvain,
    I found a very good solution for you in your ad9833 control. so I built, but dds.hex site is not working after programming. Can you help me?

  • wwwoholic December 4, 2013 at 12:42 am

    Hi Sylvain,
    Yours is the only design I could find with +-15V output, thank you. Would you mind giving some advice for my project? What I am trying to make is 0.01Hz..1kHz sine source with adjustable symmetrical output +-0..12V up to 0.8A. Key requirements are symmetry, ability to drive inductive/resistive load (solenoid) and simplicity.
    I am going to use AD9834 + AD5620 combination for adjustable voltage and I have no problem with digital part. For output I hoped to get away with single L272. Will this work?
    I can't figure out how to remove DC offset without dividing resistors, which are not precise enough. AD9834 has COMP output described as "DAC Bias Pin for decoupling DAC bias voltage". There is nothing else about it on the web. Can this be used as center point for op-amp?

  • admin December 5, 2013 at 7:24 pm

    It should be Ok with the L272, there is not dc offset on ouput if you set the offset pot to center

  • Marian May 22, 2014 at 8:54 am

    Hello,
    I would like to ask you about this DDS generator, if square wave is going out only from TTL output, or from +-15V output stage too. I need get 15V square output signal(max 1MHz).
    Thank you for answer,
    best regards,
    Marian

  • admin May 22, 2014 at 2:06 pm

    There is one ouput TTL level 0-5V and the other is variable up to +15 and -15

Post comment

Please note

All my source codes were taken from my personal projects.

Everything is for your information only. The C/C++ codes have been written
with ICCAVR. You can find the header and source CRT files by downloading their compiler.

All is for your information and everything is AS IS without any warranty of any kind. No other files are available and I don't make any modification for any body.

Categories

Blogroll

Electronic Links

Tags

AGC Anemometer AVR AVR Bootloader Bootloader Capacitence Capacitor Clock Color Control DCC Debugger Devices Digital driver Function Generator High Gain Microphone Humidity Inductance Inductor Laser LCD LED 3W Library Lightning Detector MegaLoad Meter Moodlight Mood Light MS5534 Nixie OscilloScope projector Rain Fall Sensor rgb RGB LED Scop Sensor SHT75 Temperature Terminal Tipping Bucket Train Modeling Vintage Water Detector