Author Topic: Square wave DDS Function Generator Design (to be built)  (Read 9843 times)

0 Members and 1 Guest are viewing this topic.

Offline BiOzZTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
Square wave DDS Function Generator Design (to be built)
« on: August 15, 2013, 06:10:55 pm »
OK lets start from the beginning

i needed a bench top square wave generator with an adjustable output and adjustable duty cycle

i obtained an AD9850 jellybean DDS generator dev board complete with 8 stage LC filter ... it outputs a 1.2v p-p DC sine wave .. i need a square wave

so first off we need to convert this in a square wave and there was a few ways to do this but i decided to go with an AD8561 high speed comparator (as of suggestion by someone on here) and using a pot i could adjust the level that it trips off of ... the lowest voltage i can put in here is well below the offset that the AD9850 DDS generator creates ... because a sinewave is used this wont be a perfect linear slide but will work good enough for me and i can use some math in the micro to estimate the duty because the output of the POT is buffered with a gain of 3 in to an ADC pin of the micro (see below)  ... the pot that controls the duty will be supplied by a cheap 2.5v LM4128 reference (that i have a ton of) than brought down to a max voltage of 1.25 via a 50k resistor and a 50k pot ... this prevents changes in duty by the flux of the power supply when it reaches that point (that can be dodgy)

that is then outputted in to 2 counters acting as dividers with x/10 making an x/100 divider that can each be shorted threw 2 reed relays (not the model shown but high bandwidth ones i have taken out of a dead pocket scope) diving an x/1 , x/10 or x/100 output that can give me finer control of the HZ steps (1hz at x/1, 0.1hz at x/10 and 0.01hz at x/100) ... the reed relays are controllable by the micro

Edit: That is outputted in to 1 counter that is acting as an x/10 divider that can be shorted out using a reed relay (not the model shown but high bandwidth ones i have taken out of a dead pocket scope) and give both finer control and higher stability (thanks to user cosmos)

that is than taken in to a MAX4428 highspeed MOSFET driver ... this operates from 4.5v to 18v in a stable way but i think its safe to bring it down to 3.5v without a problem tho i might need to divide the input voltage by half (will run tests ... i bought 4 of them with expectation to kill a few) this driver provides a buffered and an inverted output at the input voltage supplied at as much as 1.5A (will only run to 1A each and i will probably glue a small heatsink to it for good measure) than as of now that is taken in to 50ohm resistors than right in to BNC connectors threw a short peace of 2A coaxe

For the power i start with a linear external supply that provides 18v at 2A and 7V at 1.2A that is ground isolated ... that is brought in to the box and brought in to an LM7805 and an LM317 ... the LM317 uses a 500R R1 and a 5K pot with a 1K resistor on R2 to give me ~15v max and ~3.5v minimum (that might be upped to give a minimum of 4.5v) ... because the lower the voltage out is the hotter it will get i want to have the option to use the 5V supply on the output so i added a switch to allow me to enable the LM317 and use that or just use the LM7805 with the LM317 disabled ... the voltage is divided with an attenuation factor of 2.2 than put in to an ADC pin of the micro to monitor that ... the output is than switched

this is brought in to a 0.1R resistor and a couple of opamps to give me up to 1A current feedback on the micro so i can monitor the output even the micro can switch off the output if it gets too high

the micro im using DEAD SIMPLE Arduino bootloader in an ATMEGA328 with an LCD and a simple single rotary encoder with a single pushbutton on it ... also an FTDI programming cable is used and will also be used for computer control ... the micro is running off of 5V and a 16mhz clock ... i might add in a MAX232 and a serial port but i dont think thats really necessary ...

The AD9850 dev board was a $8 ebay find ... i was so iffy about the cost of this i made a few checks and mods ... i checked and verified all the components inside ... i had to replace 2 inductors and i also put in a much better input cap and i soldered 0.1uf SMD caps right to the inputs (so C10 and C31 won't be used) ... i also replaced the input pullup resistors but that was rather unnecessary ... i also replaced the 125mhz crystal with another more expensive one that would probably add stability and it has some heat protection to prevent drift (but its no TCO or OCO ... dont need that)

i have tested the DDS module, rotary encoder and the LCD with basic code and that works fine

i made the schematic in eagle so its nice and cluttered but you get the basic idea ...


EDIT: schematic updated (2:36pm 5/15/13)

EDIT: WOOPS ... found that PTC 1 and PTC 2 are swapped ... woops ... the 1.5A should be on the 18v output ... sorry about that
Found another where a trace is overlapped on the micro ... you can figure it out i dont think i need to update the image on here but i am fixing it for the final


Tell me what you guys think about it ... i will be building it up when the parts come in just a few days!

There probably will be some mistakes ... there will be some spelling mistakes ... you can ask for clarification but im not here to get lectured on proper schematic layouts or my grammar ... thank you!

EDIT2 : User: cosmos pointed out to me that the datasheet says it has a "resolution of 0.0291 Hz for a 125 MHz reference clock" ... i have NO IDEA where i got 1hz ... i WILL be removing one of the dividers i have removed one of the dividers but i will keep one for some stability and even finer control purposes  ... thanks allot!
« Last Edit: August 15, 2013, 06:39:10 pm by BiOzZ »
My one regret in life is learning to speak English on the internet ...
 

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #1 on: August 16, 2013, 04:32:36 am »
Are you using those same little AD9850 dev boards that I got, about 2.5" long, maybe 1.5" wide, sometimes blue PCB, sometimes green PCB, 2 sets of headers, one set for parallel, one set for serial control, etc.?
I got 4 of those awhile back.  If they are factory rejects (because they're so damn cheap compared to the 'real' AD9850 chip off Digikey), it must be cosmetic 'cause I haven't had any issues with any of my boards..at least nothing I can detect or anything that matters to me.

Incidentally, I just did the same thing last weekend.  Used a PIC, 4bit parallel LCD, a few buttons, 4 cell NiMH pack, and a quad-opamp, for an adjustable freq 3.3v/5v sine/square wave output.  Wasn't shooting for perfectly clean square waves though, just something to use as a dirt simple sine/square freq generator around the shop.
Next time around, I think I'd want to use the AD9837 though...has a switchable sine / triangle wave at the outputs.
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7755
  • Country: nl
Re: Square wave DDS Function Generator Design (to be built)
« Reply #2 on: August 16, 2013, 01:15:38 pm »
The AD9850 has an internal comparator :) In fact you can get cheap boards which use it to vary duty cycle :
http://www.amazon.com/AD9850-Signal-Generator-Module-0-40MHz/dp/B0095R21JM

PS. if you want a precise repeatability you will need to change the potmeter for a microcontroller with DAC.
« Last Edit: August 16, 2013, 01:17:54 pm by Marco »
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Square wave DDS Function Generator Design (to be built)
« Reply #3 on: August 16, 2013, 01:21:22 pm »
or you break into the signal on those boards and use a very cheap dac to vary duty cycle :)

having set up something myself near identical to yours, i know just how fast an arduino can get... mine was doubling as a low frequency counter based on an interrupt, and was happily counting 100Khz, calculating the pulse width and duty cycle of it and at the same time driving a frequency ramp and lcd, was a good learning experience :)
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7755
  • Country: nl
Re: Square wave DDS Function Generator Design (to be built)
« Reply #4 on: August 16, 2013, 01:22:57 pm »
or you break into the signal on those boards and use a very cheap dac to vary duty cycle :)
That's what I meant.
 

Offline BiOzZTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #5 on: August 16, 2013, 04:41:28 pm »
The AD9850 has an internal comparator :) In fact you can get cheap boards which use it to vary duty cycle :
http://www.amazon.com/AD9850-Signal-Generator-Module-0-40MHz/dp/B0095R21JM

PS. if you want a precise repeatability you will need to change the potmeter for a microcontroller with DAC.

i did experiments with the internal comparator and after 2 mhz the signal is entirely unusable ... could just be my board or an internal defect
*looks at the datasheet* it says it has a propagation delay of 5.5 ns rise and a rise/fall of 3 meaning it should work fine well above 100mhz ... but oddly enough the one i have wont let me approch an order of magnitude lower than that ... i wil have to look in to this ... thanks
My one regret in life is learning to speak English on the internet ...
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11725
  • Country: my
  • reassessing directives...
Re: Square wave DDS Function Generator Design (to be built)
« Reply #6 on: August 16, 2013, 05:06:46 pm »
i did experiments with the internal comparator and after 2 mhz the signal is entirely unusable ... could just be my board or an internal defect
*looks at the datasheet* it says it has a propagation delay of 5.5 ns rise and a rise/fall of 3 meaning it should work fine well above 100mhz ... but oddly enough the one i have wont let me approch an order of magnitude lower than that ... i wil have to look in to this ... thanks
my ad9850 square function on my diy pcb can go to 30MHz with very fine pot tuning required to get 50% duty cycle. at 10MHz i can get a usable around 20-80% PWM. the problem is with hysterisis it create a kind of ringing during rise time, esp visible at lower frequency, not sure whether my pcb or the ad9850 fg module is at fault. it was a sloppy built, if i want to achieve as what you want, i'll find the culprit causing the hysterisis/ringing issue before making full fledged circuit as you posted for square. my 2cnts.

Offline Skimask

  • Super Contributor
  • ***
  • Posts: 1433
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #7 on: August 16, 2013, 05:22:11 pm »
Same here with all 4 of my modules.  They all put out decent sine/square waves past 20Mhz or so.  Above about 35Mhz things start to get really ugly.
Post a picture of the dev board you got?
We might be talking apples and oranges...
I didn't take it apart.
I turned it on.

The only stupid question is, well, most of them...

Save a fuse...Blow an electrician.
 

Offline BiOzZTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #8 on: August 16, 2013, 07:59:20 pm »
i will take a better look at that part of the module when the other parts come in and try just connecting that directly to the mosfet driver and see what the output looks like ... maybe cleaning it up with an 74HC14 or somthing of the sort

i have completed the microcontroller and DDS part as shown below ... not shown i also got a metal case and cut up some perf and put an LCD, rotary encoder and 2 pots on it ... you also cant really see in the underside image but yeah there is 2 22pf SMD caps on the crystal on the underside to ground




i may need to put some shielding between the SPI traces and LCD traces when i start writing the LCD code ...
My one regret in life is learning to speak English on the internet ...
 

Offline ptricks

  • Frequent Contributor
  • **
  • Posts: 672
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #9 on: August 16, 2013, 09:31:01 pm »
One issue you will likely see is noise injected because of the wiring.  Unfortunately perf boards are not known for low noise and there isn't a whole lot you can do to change that. You will need a proper ground plane to get the noise figures low at the higher frequencies.
 

Offline BiOzZTopic starter

  • Regular Contributor
  • *
  • Posts: 237
  • Country: us
Re: Square wave DDS Function Generator Design (to be built)
« Reply #10 on: August 16, 2013, 09:59:49 pm »
One issue you will likely see is noise injected because of the wiring.  Unfortunately perf boards are not known for low noise and there isn't a whole lot you can do to change that. You will need a proper ground plane to get the noise figures low at the higher frequencies.

well the wiring here is all digital and some analog feedback lines ... when doing the HF stuff i have all of that worked out and i will go in to more detail when i get that part done
My one regret in life is learning to speak English on the internet ...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->