Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Some questions about a Function Generator Design

Status
Not open for further replies.

akabela

New Member
Hi,
I'm in the process of designing a small function generator based on the MAX038CPP ——a sort of handheld device with just this chip and a PIC to output the frequency to a small LCD. (RF:MAX038CPP.pdf)
The PIC will also control the form of the output wave, since you can do it digitally, but I'm not sure if I can also do the same with the capacitors for selecting the range; so my first question is:

1 - Is there any way to digitally switch between the capacitors for selecting the frequency range? I mean, having a button or two connected to the PIC which would emulate the function of a rotary switch.

2 - My second question is about the Phase Detector function of the MAX038: would I be able to add this in any useful way without connecting any external device; like getting a modulated frequency or any other function that could be added to this design? I already read the section about this function on the datasheet, but I can't figure out what use I can get out of this function without an external input.

3 - I've already chosen the power supply, but I've been think about this for a long time: is there any simple way to double the +5v supplied by an USB port -getting 10v out of it-? For example, the equivalent of this simple AC circuit, but for DC:

QQ截图20170117170812.png

Thanks in advance for your help!
 
I built the function generator from the EPE mag... It used all the components you speak of... It works well and I still use it today, However!! The sine wave wasn't very good from this chip... If you can get a copy of EPE magazine March 2003.... Its in there!!
 
I would suggest You to use a DDS Chip like the AD9851 from Analog Devices.
It works completely digital. Only an external oscillator and an anti aliasing filter is required.
An output amp should be installed too.
AM an FM Modulation is possible with a fast Controller ( AM with a DAC at rset, FM by writing new values into the frequency register ).
The phase can be controlled by a phase register and also be modulated.
 
1) you could use an npn transitor to switch the caps, collector to cap, emitter to ground and base to the uC through a 10k, this will only work if the caps were grounded one end, which I think they are on the '038, this will limit the high end freq a bit as there will be stray capacitance in the trannys.

2) I dont really get the question, you can use the phase detector to sync the '038 with another waveform, maybe with a clever bit of thinking you might be able to make a staircase wave with it, I remember this being done in a magazine article or something like that, something for an old hand in the hobby I'dve thought.

3) You could get a cheapo boost convert from china off ebay, use that to bosst to say 15v from usb, then use a linear reg to step that back down to 12v or whatever to give you a reasonably clean supply rail, 12v directly from a switch mode boost converter might be a little too noisy for a sig gen.

Hope this sheds some light.
 
1 - Is there any way to digitally switch between the capacitors for selecting the frequency range?
NPN transistors will not work. That's becuase the voltage on the COSC pin is negative respect to GND.

I have already built a MAX038 signal generator which works well from 0.3 Hz to appprox. 20 Mhz. I used a rotary switch with shortest wires as possible do tue parasistic components. I had to use 2 relays for the last two caps.. :nailbiting:

I've already chosen the power supply
Build yourself a linear PS or get a very stable no noisy (quiet difficult) SMPS.
In the latter case, all the noisy garbage will be amplified by the output stage amplifier (I suppose you will use one).
 
Last edited:
Hi,

I was thinking relays too.
The caps have to source and sink current, so i dont think a transistor would work right. Perhaps an analog switch.
 
The relays I choose were two RF relays (2cm x 2cm) placed as near as possible to the last two capacitors, because the wires were actuating as antennas. The output wave was going on and off when putting my hand near and far from the IC. :D

You will have to care the PCB..
 
I would suggest You to use a DDS Chip like the AD9851 from Analog Devices.
It works completely digital. Only an external oscillator and an anti aliasing filter is required.
An output amp should be installed too.
AM an FM Modulation is possible with a fast Controller ( AM with a DAC at rset, FM by writing new values into the frequency register ).
The phase can be controlled by a phase register and also be modulated.

I would also suggest the AD9834 which is cheaper and has a serial interface, ideal for MCU control: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9834.pdf

spec
 
For any of them, the stumbling block, to me, is the output filter. Lot of people saying "easy" but no one actually helping. A source of frustration. I ended buying a commercial dual generator.
I suspect that you have a fairly demanding sine wave application where harmonics are a problem, but for general use these synthesizers are adequate.

To get a variable frequency pure sine wave you would probably have to use a sine wave oscillator phase locked to the synthesizer output, rather than a filter.

And, of course if you want a decent square wave output you can use the on-chip comparator with the AD chips, which is quite handy.

spec

PS; Incidentally the MAX038 has long been obsolete- unfortunately.
 
Last edited:
For any of them, the stumbling block, to me, is the output filter. Lot of people saying "easy" but no one actually helping. A source of frustration. I ended buying a commercial dual generator.

Hi,

The filter for these things i think is a seven pole filter, and it has to be right. There will also be some frequencies that output higher than others due to aliasing. The best bet is to buy a board with the filter already on it, like a dev board (development board).
Do note that you will need to design and build an output amplifier that can do 40Mhz though if you get the board with the 100MHz oscillator as the output from these things is only around 0.5vac peak. For the board with the lower frequency oscillator you can get away with probably a 20MHz amplifier.
 
Hi MrAl,

Hi,

The filter for these things i think is a seven pole filter, and it has to be right.
Does the filter have to be adaptive (related to output frequency)?

spec
 
Hi,

The filter for these things i think is a seven pole filter, and it has to be right. There will also be some frequencies that output higher than others due to aliasing. The best bet is to buy a board with the filter already on it, like a dev board (development board).
Do note that you will need to design and build an output amplifier that can do 40Mhz though if you get the board with the 100MHz oscillator as the output from these things is only around 0.5vac peak. For the board with the lower frequency oscillator you can get away with probably a 20MHz amplifier.


All I remember now is it being elliptic ( no much really). I considered reproducing precisely that in a demo board but seemed quit demanding a design.

I forgot with which actual chip there was a batch of signal generator boards, being sold very cheap because the output filter had been implemented with wrong values.

I found fascinating the idea of programming a micro to control it plus a display. But my signal generator does all that already.
 
Hi MrAl,


Does the filter have to be adaptive (related to output frequency)?

spec

Hi there spec and atferrari,

Well the data sheet on the AD9850 (the one i was really referring to) shows a passive seven pole elliptic filter. It actually works with a 125MHz crystal to get up to 40MHz out. I know the sine output is clean up to about 2MHz but i could not test any higher than that.

Yes i heard there were boards being sold with the wrong filters too, but not sure which ones. It also depends on what kind of accuracy and total harmonic distortion you are looking for. I know some frequencies wont be as clean as others but dont remember too much about this. There is an app note somewhere that explains the differences though and why this happens.

The output originates as a DAC output so it should be clean up to a certain frequency and then there will be more bumps as the frequency is tuned up higher. You'd need a good scope to see this. My scopes have limited bandwidth so i can only go so high.

I suppose an adaptive filter would work better but if you could tune it by hand you could set it for a clean output. For example, even a second order bandpass filter set to the required frequency would put out a nice clean sine. How you tune it would probably be with a variable capacitor and that would probably be limited too.

I dont think you would want to use this for audio unless you could verify the output was clean for every frequency you had it set for, but then again you would probably want to use a THD meter for that anyway.

One interesting note here is that i dont think you can get a triangle, if you need that. It's just sine and square. Also no pulse output at less than 50 percent duty cycle. If you buy a programmable frequency generator (under 100.00 USD) you get full programmability which even sometimes means you can program in a pulse train with different width pulses.

So this is partly about what you need and what you can get away with and what you want to spend. For me, i did not need super clean output for every frequency and if it was not clean for one frequency then i would just go to a different frequency and test with that instead. The nice thing was that the frequency could be tuned with something like 0.05 Hz resolution, so if you had set it for 10000000.00Hz you could increase it to 10000000.05Hz with a change of one bit in the setting code word. That's something like 0.0000005 percent resolution which is unheard of in the analog world.
 
I dont think you would want to use this for audio unless you could verify the output was clean for every frequency you had it set for, but then again you would probably want to use a THD meter for that anyway.

Perfectly fine for audio, remember it's a function generator, not a super low-distortion sinewave oscillator for measuring THD - which is normally fixed frequency anyway.

One interesting note here is that i dont think you can get a triangle, if you need that. It's just sine and square.

You're looking at the wrong devices then :D

Try the AD9833 which does sine, triangle and square:

http://www.banggood.com/CJMCU-9833-...Waveform-Generator-For-Arduino-p-1103107.html

I've recently ordered a couple to have a play with, there's also a nice webpage with a project (Arduino/AVR based) here:

http://www.vwlowen.co.uk/arduino/AD9833-waveform-generator/AD9833-waveform-generator.htm
 
I was going to build a new FG based on an AD9834... AD only ever recommends a simple lowpass filter!!

Hi,

Yeah it's not going to be as easy with that one because a low pass filter will eat up the sharp peaks of the triangle. You might have to switch filters as you go, just as you would do if you went from sine to square.

And yeah, i was talking about the AD9850 which is one heck of a sine wave generator. The filter for that is a seven pole passive, but it could be used for the sine output of any of those chips. For the triangle you'd have to settle for less filtering if you want sharp peaks.
 
Some people use a perfect squarewave and filter out its harmonics with a switched capacitor filter IC. I made it better by making a stepped "sinewave" with 8 digital steps and after filtering it with a switched capacitor filter IC the distortion could not be measured. The frequency of the oscillator is digital and changing its frequency also changed the clock frequency of the filters.
 
the distortion could not be measured.

While I don't doubt you made a pretty decent generator, I seriously doubt that claim :D

If you couldn't measure the distortion, then your measurement methods were suspect - I don't recall that the switched capacitor filter IC's were anything exceptional in the distortion or noise stakes either?.
 
The HP analyser at work measured less than 0.005% distortion and noise. People making a switched capacitor filter of a squarewave also got pretty low distortion and noise. I used two National Semi 4th order Butterworth filters in series.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top