EEVblog Electronics Community Forum

Electronics => Microcontrollers => Topic started by: legacy on November 23, 2013, 01:42:09 am

Title: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 01:42:09 am
hi
is it possible with AD9850 or AD9851 ?

i need to produce a variable frequency square wave in where software could also change the duty cycle from 1% to 99%

i need this for testing purpose
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: c4757p on November 23, 2013, 01:43:43 am
The AD9850/1 is a sine wave synthesizer. Why would you want to use them to generate a square wave?!
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: edavid on November 23, 2013, 01:55:19 am
hi
is it possible with AD9850 or AD9851 ?

i need to produce a variable frequency square wave in where software could also change the duty cycle from 1% to 99%

i need this for testing purpose

You can connect the output to a comparator... the internal comparator is probably not good enough, but it depends on how accurate the duty cycle has to be.  The comparator threshold would be set by a 10-12 bit DAC.

The AD9850/1 is a sine wave synthesizer. Why would you want to use them to generate a square wave?!

What chip should the OP use instead?
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: dannyf on November 23, 2013, 02:09:43 am
The internal comparator has both its inputs routed out, and is fairly fast, so it is possible to use it to generate variable dc square wave - assuming you can control a reference voltage.

However, as others have pointed out, it is an overly complicated way of doing simple things.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: vk6zgo on November 23, 2013, 03:09:34 am
By definition,once you change the duty cycle,it is no longer a square wave--it becomes a rectangular wave! ;D
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: daveatol on November 23, 2013, 03:13:06 am
From the datasheet, regarding the reason someone might do this:
Quote
The AD9850 also contains a high speed comparator that can be configured to accept the (externally) filtered output of the DAC to generate a low jitter square wave output. This facilitates the device’s use as an agile clock generator function.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: Mechatrommer on November 23, 2013, 07:34:17 am
ad9850 module from ebay china got trimpot to adjust comparator threshold, if you want software configurable, i believe you need to tap the threshold line and connect to DAC.
The AD9850/1 is a sine wave synthesizer. Why would you want to use them to generate a square wave?!
because it can.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 02:25:50 pm
However, as others have pointed out, it is an overly complicated way of doing simple things.

cause i have 10 modules AD9350/AD9351 in lab =D
anyway, can i change my question into: what do you suggest to do it simpler ?

i need a square wave generator from 200Hz to 2Khz with duty cycle variable from 1% to 99% with a step of 1%, but i need the MPU able to change it automatically by software
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: alm on November 23, 2013, 02:28:39 pm
Triangular wave + comparator fed by a DAC?
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: Andy Watson on November 23, 2013, 02:40:58 pm
i need a square wave generator from 200Hz to 2Khz with duty cycle variable from 1% to 99% with a step of 1%, but i need the MPU able to change it automatically by software
Wobbling an I/O pin at 2 kHz with 1% resolution is well within the capabilities of most MPUs, why try to complicate things? If you don't want to devote software -run time to the task, add another single-chip mpu.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: c4757p on November 23, 2013, 02:52:46 pm
If you don't want to devote software -run time to the task, add another single-chip mpu.

Yes, this is what I would suggest as well. A cheap microcontroller with a timer or two would be a very good way to get a variable duty cycle.

The AD9850/1 is a sine wave synthesizer. Why would you want to use them to generate a square wave?!
because it can.

I should have read the datasheet more carefully! It does seem like awful overkill, but if OP has ten of them and it's just a one-off... Of course, I still can't think of a reasonable way to get digitally controlled duty cycle without complicating it even more.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 03:12:27 pm
Ok, i will add a dedicated chip (probably an AVR8 tiny, i mean something in dip8 package), i have no resource available on the main MPU, full at 97% of its schedulable task's list (it is a poor 328 @ 8Mhz) =P

also the AD9350 is already onboard of this equipment, each PCB has one AD9350 on it because it is needed by an other kind of test in where 16 tones must be provided to the circuit under test.

anyway i will add a tiny MPU mounted on a tiny PCB in piggy back to the "mother" pcb, i should have enough space ;D

umm, just an other question: what is the easiest way to build a "custom wave" synthesizer ? Today i was thinking about the USB-audio board, building a wave on PC then putting it into a .wav file, then using a linux machine (such as an usb router with usb-sound driver) to "play" the custom wave.

i also need a custom wave cause i'd like to test an "event detect" algorithm i am implementing on dsPIC33F that should be able to a seismic signal, and seismic signal is not definable as "sinusoidal" or "triangular" or "square" wave, unfortunately
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: dannyf on November 23, 2013, 03:13:29 pm
Quote
but i need the MPU able to change it automatically by software

The simplest would be a mcu with hardware pwm.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: G0HZU on November 23, 2013, 04:37:36 pm
Quote
i need a square wave generator from 200Hz to 2Khz with duty cycle variable from 1% to 99% with a step of 1%, but i need the MPU able to change it automatically by software

That's a fairly similar requirement to a basic car engine management system that has to control and time fuel injectors. This can be done with a fairly basic 8 bit MCU provided it has a decent 16 bit timer and has the required interrupt/port functions built in.

However, if you absolutely 'want' to use the AD9850 and an MCU then one (wacky) method would be to use the DDS to clock the MCU with the MCU set to a 16 bit PWM mode.
Obviously you would have to come up with a scheme where the MCU is initially clocked by something else or it won't be able to program the DDS at the start of the whole process :)

But the end result would be 16bit PWM and ultra fine frequency resolution via the DDS. But as you only want 200Hz to 2kHz o/p you can do the whole thing with a fairly basic MCU chip and keep the DDS chips for something else...
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 04:42:30 pm
If you mean you already have an ATmega328 on the board then it won't take many cpu cycles to setup one of it's timers to output the square wave with variable duty cycle.

Yes, ATmega328, but unfortunately all the hw resources are already used for other stuff, in particular all the timers are used, no one is free (one timer is used to schedule things, for example), this is the reason why i need to add an external MPU.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 04:45:29 pm
Quote
i need a square wave generator from 200Hz to 2Khz with duty cycle variable from 1% to 99% with a step of 1%, but i need the MPU able to change it automatically by software

That's a fairly similar requirement to a basic car engine management system that has to control and time fuel injectors. This can be done with a fairly basic 8
bit MCU provided it has a decent 16 bit timer and has the required interrupt/port functions built in.

you are right, that's for an automotive test equipment, unfortunately the PCB was already engineered and i was asked to modify it "adding" the new testing functions. That's the reason why i found a AD9350 already soldered on the PCB and partially used by 3 of the testing functions in the firmware i found aboard the main MPU =P

in other words, i was asked to to fix the jam =P
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 23, 2013, 05:06:24 pm
what do you think about this (http://www.ebay.com/itm/DDS-Signal-Generator-Function-Generator-Signal-Source-For-HAM-/171083224308?ssPageName=ADME:X:RTQ:US:1123) kind of equipment (very low price, may be … too low price) ?
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: dannyf on November 23, 2013, 10:11:32 pm
Quote
what do you think...

I think you want to ask yourself,

1) what you are trying to do; and
2) how using the parts you have proposed will help you do what you are trying to do.

Lay them out on a piece of paper and hopefully it will be clearer to you.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 24, 2013, 12:28:44 am
hey  :-DD?

@dannyf
about me and what i am trying to do, i was already fine with the suggestion provided me in the previous page: MPU used like PWM generator with duty cycle variable from 1% to 99%

we are doing brainstorming (1) now, so i can point out that DDS300 is a cheap function generator module with two output signals, one is for PWM signal, the other is for the DDS signal. The module is TTL and has a 232 port, we can connect it to arduino (or to host computer) in order to choose a variety of waveform output , respectively {sine wave, square wave , triangle wave, heart} wave

It may be helpful if you need such a signals to be probed, and I was asking what do you think about this module, in order to keep attention to a low cost and very cheap tool that may help others, too. Also the DDS300 needs to be hacked, more specifically it needs to be reversed about the protocol, just cause the .exe application provided is for Windows Only without any sources, and this is the second reason i was asking about: more specifically, "has anyone already hacked this module ? does anybody know something about this module's protocol ?"

(1) is a group or individual creativity technique by which efforts are made to find a conclusion for a specific problem by gathering a list of ideas …


about PWM, something similar may be of any interest following this (http://electronics.stackexchange.com/questions/68284/arduino-analogwrite-and-its-frequency-and-effectiveness) suggestion (that's about an arduino PWM library) :D
Title: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: WarSim on November 24, 2013, 12:32:10 am

If you mean you already have an ATmega328 on the board then it won't take many cpu cycles to setup one of it's timers to output the square wave with variable duty cycle.

Yes, ATmega328, but unfortunately all the hw resources are already used for other stuff, in particular all the timers are used, no one is free (one timer is used to schedule things, for example), this is the reason why i need to add an external MPU.
Consider making a timer multipurpose.
Or alter your method and use gating of you DSS instead of Duty scheduling and use your DSS clock. 
Depending on the configurability of your chip I may use zero to two more pins.

 


Sent from my iPad using Tapatalk (http://tapatalk.com/m?id=1)
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 26, 2013, 01:03:26 pm
i am also evalutaing AD9834 which has much more features about the waves it can produce =P
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 26, 2013, 01:30:03 pm
The AD9833 comes as an incredibly small (M-SOP package) chip with an onboard 10 bit DAC, and it's a serial programmable DDS (SPI with a 25 MHz master) with 28bit resolution which can output from 0 to 12.5 MHz {sinusoidal, triangular, square} wave

Connections are as follows:
MOSI ==> SDATA
SCK ==> SCLK
PB0 ==> FSYNC

easy powerful chip !
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: Crazy Ape on November 26, 2013, 02:27:10 pm
The AD9833 comes as an incredibly small (M-SOP package) chip....

At least there are not many pins to solder.

If this is just a one-off / hobby project, grab a module with all the support circuitry already on board, that way you can avoid the possibly tricky soldering (though it's really not that hard).
Example of a couple of modules from random on-line vendors:
http://www.goodluckbuy.com/ad-9833-module-dds-singnal-generater-module-sine-wave-square-wave-triangular-wave-.html (http://www.goodluckbuy.com/ad-9833-module-dds-singnal-generater-module-sine-wave-square-wave-triangular-wave-.html)
http://www.edoomart.com/dds-module-ad9833-signal-generator-with-circuit-diagram-p-844.html (http://www.edoomart.com/dds-module-ad9833-signal-generator-with-circuit-diagram-p-844.html)
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 27, 2013, 08:46:16 am
what do you think about the quality of these circuits ? i am wandering about the Q factor of the smd inductors and capacitors mounted around the tiny module, what do you think about ?

correct me if i am wrong, may be that an smd inductor has an inferior Q factor ?

have you ever bought these modules ? and what do you think about the DDS60 (http://midnightdesignsolutions.com/dds60/index.html) ?
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: Crazy Ape on November 27, 2013, 09:30:06 am
what do you think about the quality of these circuits ? i am wandering about the Q factor of the smd inductors and capacitors mounted around the tiny module, what do you think about ?

correct me if i am wrong, may be that an smd inductor has an inferior Q factor ?

have you ever bought these modules ? and what do you think about the DDS60 (http://midnightdesignsolutions.com/dds60/index.html) ?

Ummmm, I only see capacitors on the modules I linked. I've never bought or used them personally so can't help with specifics.

Not sure about the DDS60 kit, though I have used the AD9851 in a radio modification project and it worked well for that.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 27, 2013, 10:51:25 am
the output filter should have inductors, differently they must be provide externally.
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: legacy on November 27, 2013, 10:52:27 am
(http://midnightdesignsolutions.com/dds60/DDS6-%20Schematic%20A4%200714.gif)

See L1,L2
Title: Re: AD9850 is it possible to generate a square wave with variable duty cycle ?
Post by: Crazy Ape on November 27, 2013, 11:50:09 am
Yep, I see em. But I hadn't looked at it at as you seemed to be asking about the modules I linked to. I imagine the modules I linked to are to be designed to be used as part of a bigger design, which would include the filter. The filter specifications are going to change depending on the application, therefore I suspect it's usually left to the designer.

The DDS-60 looks to be a more completed, hobbyist targeted design.

It all comes down to your application.