Author Topic: How hard is it to build a good function generator?  (Read 11731 times)

0 Members and 2 Guests are viewing this topic.

Offline PowermaxTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: us
How hard is it to build a good function generator?
« on: December 19, 2017, 07:32:01 pm »
background:
I was recently looking into designing a high efficiency boost converter, which led to the thought of doing some network analyzing stuff for the inductor, how to locate the resonant frequency, measure ESR over some frequency range, etc. I have a hacked 100 MHz rigol DS1054z scope, but no function generator. For low frequency applications, I used an old phone's DAC. This is fine but not for stuff higher than 15KHz, as one can imagine. (Also the output voltage and output impedance is always an issue, I have to toss together some amp most of the time.)

I don't like the price of most decent function generators, and I want to learn a bit about high speed circuit design as well. So I got the idea to try to make my own! My thoughts are to use a high speed microcontroller such as a ESP32 or (if the learning curve isn't too steep) potentially a small/cheap FPGA. That coupled with a <$10 DAC which matches the maximum speed one of these boards can realistically generate.

------------

what I would like to know:
I don't know much about the high speed DACs. A quick mouser search seems to indicate that the really high speed one's (50 mS/s and up) use parallel interfaces. I assume that I could allocate an entire output register to the DAC on one of these chips. If I plan to use one of the cores in the ESP32 purely for updating the port pins from an array of values in memory (representing common signals such as sine, trig, sawtooth, square, etc) That's assuming I can achieve something like 10 MHz. I would need a DAC capable of 20mS/s, just for sine waves. Commercial function generators seem to use sampling rates about 5 to 10 times higher than the maximum output frequencies. I found this DAC http://www.mouser.com/ds/2/609/AD9748-878113.pdf for a decent price. That differential clock input scares me though.  :P

I would assume that I can write to an port register in a single clock cycle on the ESP32, but I also need to read memory which is an additional clock cycle. Not sure if there is a bit of hardware that allows this read-write-read-write... operations to be pipelined so I can write a value while simultaneously reading the next value. So I guess for prototyping I can use my teensy 3.6, which can be OC'ed to 240MHz. I would imagine 50MS/s is achievable.Any "gotcha's" with the DSP side of things??

Then comes the analog output design. I would need to scale and shift the output, and I guess also stick a 50 ohm resistor in series to get the common 50 ohm termination. (that assumes my amplifier output impedance is 50 ohms as well...) I have never designed a discrete transistor amplifier, I will probably stick close to using op amps with good specs. I have some really high speed 90MHz GBP ones from LT, too!

When it comes to PCB layout, the high speed digital stuff (esp the clock!) would probably need to be carefully laid out. With a parallel interface I would think that trace length matching and good low-impedance grounding would be very important. Any tips / suggestions? If I do this, then the PCB tool I would use would likely be KiCad. (or maybe ultiboard since I get that free as a student)

I guess I would also need to use an external clock as well. Not sure how stable the quartz based one is on those prototyping boards (like the ESP32 or teensy). I'd imagine to cut costs they are not very stable or usable for a good function generator.

 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21608
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #1 on: December 19, 2017, 07:39:46 pm »
I suppose it depends on your definition of "good" and what traits are of value to you. What frequency range do you need? Is low distortion or constant amplitude of value? Do you need programmability? Modulation input? Absolute accuracy? Depending on what you need, a good old fashioned analog circuit might be the way to go.
 

Offline jaycee

  • Regular Contributor
  • *
  • Posts: 206
  • Country: gb
Re: How hard is it to build a good function generator?
« Reply #2 on: December 19, 2017, 07:52:32 pm »
The AD9851 is pretty damn good if you want to make something digitally controlled. small boards featuring this cheap are available dirt cheap online.
 

Offline PowermaxTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #3 on: December 19, 2017, 07:54:21 pm »
Ehh, I just need something that produces a nice looking waveform on my scope, which I can feed through some LTI systems like filters and stuff, and see the Y(t) on the scope.

Frequency range: DC -- 10MHz (maybe more if it's achievable with semi-beginner knowledge)

Low distortion would be good. I don't want to see lots of ringing on my square and trig waves. I would assume 0.1LSB is decent for "distortion." Constant amplitude seems like a fairly easy thing to achieve: Use a stable power supply... (?)

Programmability would be very nice, essentially mandatory. Having the ability to easily create custom waveform would be very cool. That's why I was avoiding many of the 'DIY' signal generators since they are based on some basic chips like the 555 or comparators to create a few different types of oscillators, and are generally limited to less than 1MHz anyway. Modulation would also be a very cool thing. I would get to see that cool 100% modulated AM signal that Dave always uses to test a scope's persistence displays. These schemes would require some FPU operations on arrays, which would decrease how fast a microcontroller can update the DAC. And I don't know ARM assembly :(

I don't think absolute accuracy is necessary or very critical. It would primarily be used to test filters and analog stuff.
 

Offline PowermaxTopic starter

  • Regular Contributor
  • *
  • Posts: 125
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #4 on: December 19, 2017, 07:57:56 pm »
My DS1054Z sucks when it comes to FFT function. Or so Dave says. It does look pretty gritty and low resolution. I guess I could capture the raw data and put that into a computer to compute a better FFT.

Not sure how much one would need to worry about transmission line effects and stuff like that for a project like this...
« Last Edit: December 19, 2017, 08:00:56 pm by Powermax »
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1334
  • Country: gb
    • bitdynamics
Re: How hard is it to build a good function generator?
« Reply #5 on: December 19, 2017, 08:11:19 pm »
I bet you can't make something decent for the price of a s/h function generator on ebay or similar?

Especially if you get lucky with your bidding!  I scored an older Agilent USB Arb FG for peanuts recently and it has pretty decent specs, certainly good enough that matching them DIY stylee would be expensive and time consuming!
 
The following users thanked this post: Someone

Offline Conrad Hoffman

  • Super Contributor
  • ***
  • Posts: 2303
  • Country: us
    • The Messy Basement
Re: How hard is it to build a good function generator?
« Reply #6 on: December 19, 2017, 08:18:03 pm »
It would be a fun learning project, but I'd start here even if your time is worth a penny an hour- https://www.banggood.com/buy/ad9851-dds-generator.html
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #7 on: December 19, 2017, 08:29:58 pm »
If you include your own time in the cost of something you build, the price can go up quite a bit. A second-hand Rigol DG1022 at $200 is going to work far better than some breadboard thing.

https://www.ebay.com/itm/Rigol-DG1022-Waveform-Generator-Tested-Working-Good-Condition-with-Accessories/322914388035

EDIT:

This too: https://www.eevblog.com/forum/testgear/feeltech-fy6600-60mhz-2-ch-vco-function-arbitrary-waveform-signal-generator/
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3534
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #8 on: December 19, 2017, 11:17:21 pm »
As suggested, the AD9851 is a good choice for a start. You will learn a *lot* if you manage to get a clean 60 MHz square wave out of that.  That requires an output PA flat to 700 MHz (11th harmonic)  if you want good rise times.  That will require very careful PCB layout to get the signal to the BNC connector.  You absolutely cannot do this on a solderless breadboard.  You *can* do it dead bug style if you pay attention to the impedances of your lines and keep them as short as possible.

The FeelTech FY-6600  does a very good job if you get one with FW V 3.2 or higher.  V 3.0 & 3.1 are well documented to bork themselves without warning.  There are two long threads about them on the forum.  But don't  buy one until FeelTech resolves the problem for affected owners.  There are spectrum analyzer plots as well as good (1 Mpt) scope FFT plots around page 12-13 of the main thread including a comparison to an R&S AWG using an R&S SA.  The square wave is limited to 25 MHz which is common for AWGs that output a 60 MHz sine.

The problem with the FeelTech is with the UI board so far as anyone knows.  Mine is a V 3.0.  The UI is hosed, but it still functions except for a few waveforms.  The square wave is borked, but the CMOS waveform is fine.  It's just the square wave with a DC shift.

There is a fairly active effort to reverse engineer the FeelTech, so you might want to follow that. The signal generation board uses an Altera Cyclone IIRC.  The UI board uses an 8 bit bus to control the generator.

There is a similar line from JDS which is rebadged under Koolertron and other names.  Somewhat nicer cosmetics (the FeelTech is super el cheapo), but it lacks the back panel connections of the FeelTech.  I don't know anything about that unit though.
 

Offline David Chamberlain

  • Frequent Contributor
  • **
  • Posts: 252
  • Country: nz
    • Zaptronics
Re: How hard is it to build a good function generator?
« Reply #9 on: December 21, 2017, 08:50:00 am »
The elephant in the room here is of-course the fact that you can buy a decent AWG for far less then you can ever make one your self. But that's true of just about everything these days and if we all just shrugged and became consumers then the electronics industry will likely stagnate because it relies on new young people who have a passion to try and investigate.

Anyway here's a shamless plug for my AWG.
https://www.eevblog.com/forum/projects/2ch-50mhz-awg-based-on-ad9102/msg1218865/#msg1218865

It cost $1K easily and did not work perfectly, but that's life.

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9847
  • Country: 00
  • Display aficionado
Re: How hard is it to build a good function generator?
« Reply #10 on: December 21, 2017, 09:53:43 am »
The elephant in the room here is of-course the fact that you can buy a decent AWG for far less then you can ever make one your self. But that's true of just about everything these days and if we all just shrugged and became consumers then the electronics industry will likely stagnate because it relies on new young people who have a passion to try and investigate.

Anyway here's a shamless plug for my AWG.
https://www.eevblog.com/forum/projects/2ch-50mhz-awg-based-on-ad9102/msg1218865/#msg1218865

It cost $1K easily and did not work perfectly, but that's life.
As always, it's wise to pick your battles. Do you want to learn about something and possibly create something nice, build something yourself. If you want to use a tool as soon as possible with the least amount of hassle and probably best bang for buck, buy something off the shelf.

Even if you pay yourself a meagre wage, the time spent quickly ends up being more expensive than buying a product.
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23102
  • Country: gb
Re: How hard is it to build a good function generator?
« Reply #11 on: December 21, 2017, 11:37:05 am »
This shows you how far you can go for not much money. You can build a reasonable SNA for $50: http://hfsignals.blogspot.co.uk/p/sweeperino.html

The above could be improved by mixing the output with a fixed crystal frequency via an SA612 IC or something.

Forget square waves unless you want to start looking at crazy bandwidth amplifiers.
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3534
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #12 on: December 21, 2017, 03:45:44 pm »
@bd139  Thanks for posting that link.  It would be really nice i someone with good PCB design skills put a board layout for that on github or similar.  Might tempt someone in China to sell them.

It is certainly true that most of the time, buying is cheaper than designing and building.  I sometimes say I'm a fan of the most expensive designer in the world, me.

I spent a good bit of time working on an LCR meter such as sells on eBay for $20.  Never finished it.  I've got  the differential instrumentation amps built dead bug style sitting in a bin.  I'll use them for something eventually, possibly an automated xtal tester for filter construction.  Jim Williams had a big bowl of widgets he'd built.  I bought a Peak Technologies LCR45 to use.  I spent a lot of time trying to build things with inadequate  instruments.  It's very frustrating, though still quite educational.

It is arguably cheaper to buy all your test gear and radios, etc.  But then what do you do with them?  Sit and admire them?

I think there is a good case for buying minimal spec gear and then building better gear, in the general spirit of "Max Wien, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams.  One forum member is pursuing a Wien bridge oscillator project.

As has been  noted, square waves demand *really* wide bandwidth amps.  However, these can be bought for $2-3 in quantity one.  The hard part is the PCB design.  Not easy, but tractable if one avoids trying to make it small.  Probably best done as a module with SMA connectors at each end in a small well shielded enclosure.  Such a thing is on my bucket list.  I'm gradually tooling up to build an assortment of such things so I can assemble a bespoke instrument from modules on hand without having it take a lot of time.
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23102
  • Country: gb
Re: How hard is it to build a good function generator?
« Reply #13 on: December 21, 2017, 04:00:33 pm »
The design is pretty simple. I have actually considered knocking up a board already. It is however not without some serious problems in the harmonics department but you know, it's good enough for filter alignment etc.

I have built lots of DIY test gear in the past myself, and even recently as a matter of fact. I recommend it for anyone. I've built waveform generators, voltmeters, measurement bridges and the power supply for an oscilloscope (never got to finish that!), RF probes, a frequency counter, power supplies, all sorts. You do indeed learn a lot.

As for LC measurement (screw R, got a multimeter!), I have been using a simple oscillator as described here: http://www.qsl.net/wm5z/cq199301b.pdf ... Looks like crap but it works very well:

 

Just add frequency counter and calculator.

ARRL and other amateur radio sources have tomes of information on home brewing your own test gear. And I'm all for it (even though I have lots of nice kit I like to use stuff I have made).

Frequency counter I built: http://www.hamradio.in/circuits/freq_counter_lcd.php



So ignore those people who says it's expensive and time consuming, for what is the point of life if you do not create anything?
 

Offline rhb

  • Super Contributor
  • ***
  • Posts: 3534
  • Country: us
Re: How hard is it to build a good function generator?
« Reply #14 on: December 21, 2017, 04:22:02 pm »
So ignore those people who says it's expensive and time consuming, for what is the point of life if you do not create anything?

Amen!
 

Offline Mr. Scram

  • Super Contributor
  • ***
  • Posts: 9847
  • Country: 00
  • Display aficionado
Re: How hard is it to build a good function generator?
« Reply #15 on: December 22, 2017, 09:44:06 am »
I live for creating things. However I don't have an infinite amount of time and if I have to choose, I prefer spending my time on the actual projects.

I've been building my own tools for a long time, mostly due to the economics of buying them ready made not being in my favour, but progress as a whole was often frustratingly slow.
 

Offline trys

  • Regular Contributor
  • *
  • Posts: 170
  • Country: gb
  • I started with the AC128
    • Trystan's Workbench
Re: How hard is it to build a good function generator?
« Reply #16 on: December 23, 2017, 08:07:25 pm »
I think there is a good case for buying minimal spec gear and then building better gear, in the general spirit of "Max Wien, Mr. Hewlett and a Rainy Sunday Afternoon" by Jim Williams.  One forum member is pursuing a Wien bridge oscillator project.

That would be me then! It's amazing how much fun you can have with a collection of light bulbs, an Op Amp, two capacitors and three resistors. It's kept me quiet for many days, and I'm still fiddling with the circuit (testing loading, adding a buffer stage), and reading around the subject; such as discovering the internal capacitance of the op amp input lowering the target frequency.

Trys
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 9836
  • Country: nl
  • Current job: ATEX product design
Re: How hard is it to build a good function generator?
« Reply #17 on: December 23, 2017, 10:24:19 pm »
Function generator isn't hard. You just need a good sine wave, like those AD DDS generators, and a bunch of opamps and comparators, making it square or triangle, or amplifying it.
An arbitary waveform generator is also very simple, if you stick to the lower frequencies. A 12-16 bit SPI DAC will be very simple to control, and SPI an be easily run at 50 MHz with DMA and other tricks, from a moderately fast micro. You can select one and run it around 1-5 MSPS.
The trick is always when you need multiple stuff at the same time. AWG for high frequencies is hard, you need FPGA (none of these microcontroller rubbish) and the project is going to involve parts, that are very expensive. Imagine bottlenecks everywhere.
 

Offline bd139

  • Super Contributor
  • ***
  • Posts: 23102
  • Country: gb
Re: How hard is it to build a good function generator?
« Reply #18 on: December 24, 2017, 01:56:45 pm »
I’ve been playing with sine generation using switched capacitor filters and good old fashioned square waves. Both digitally derived with AGC on the output. Pretty good THD (less than 0.1%!) across a large frequency span.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->