Author Topic: DIY Function Generator  (Read 57940 times)

0 Members and 1 Guest are viewing this topic.

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: DIY Function Generator
« Reply #50 on: January 17, 2017, 01:12:06 pm »
External RAM to sample data can be rather fast, but this would need something like an FPGA / CPLD to generate the address sequences. To have a good arb.- generator one might also needs a more or less fine adjustable clock one when to update the clock / data - this is different from an DDS where the clock is fixed.
 
 
The following users thanked this post: ziplock9000

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: DIY Function Generator
« Reply #51 on: January 17, 2017, 03:26:05 pm »
Here I attach the "AWG STM32L.c", that includes all the core functionality of an arbitrary waveform generator for STM32L152RB. You need to link that with peripheral library (available from STM).

It outputs a content of "sin_lut.c" via DAC2 on PA5, trigger output is on PB10 and MCO is on PA8.

I have removed all the USB related stuff as my USB is a mess.



 
The following users thanked this post: ziplock9000

Offline eeFearless

  • Contributor
  • Posts: 31
  • Country: us
Re: DIY Function Generator
« Reply #52 on: January 17, 2017, 04:03:03 pm »
Here is a DDS design from the AARL archives, complete with reconstruction filter and output leveling:

http://www.arrl.org/files/file/QEX_Next_Issue/May-Jun_2013/Fernandes_QEX_5_13.pdf
 

Offline Vtile

  • Super Contributor
  • ***
  • Posts: 1144
  • Country: fi
  • Ingineer
Re: DIY Function Generator
« Reply #53 on: January 17, 2017, 04:50:31 pm »
I could have swear that someone replied to the OPA aproach. What I quickly looked up ie. Tektronix CFG280 function generator 0..11MHz (20Vpp) is build around handfull of uA741s. With much more functionality than one needs to get started. Also there is discrete Wien-Bridge sine oscillator designs (from tubes to transistors) with Pot-selectable output from few tens to few kiloherts outputs, such can also be modified to have other wave froms as output with a few extra components (mainly OPAs and comparators).

(These are also programmable, but the programming language is hardwiring.)
« Last Edit: January 17, 2017, 04:59:35 pm by Vtile »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: DIY Function Generator
« Reply #54 on: January 17, 2017, 04:52:51 pm »
Here is a DDS design from the AARL archives, complete with reconstruction filter and output leveling:

http://www.arrl.org/files/file/QEX_Next_Issue/May-Jun_2013/Fernandes_QEX_5_13.pdf

That's a great document!  It clearly shows that the DDS chip (AD9833) is the least of the problem.  The author wraps a barn full of stuff around the outside.
Really nice work!
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2548
  • Country: us
Re: DIY Function Generator
« Reply #55 on: January 17, 2017, 07:07:15 pm »
Here's my DDS design with only a tenths worth of stuff around it.

   

   

« Last Edit: June 05, 2019, 10:09:52 pm by MarkF »
 

Offline eeFearless

  • Contributor
  • Posts: 31
  • Country: us
Re: DIY Function Generator
« Reply #56 on: January 17, 2017, 07:50:56 pm »
Is VOUTB from the MCP DAC for adjusting DC offset?

Wouldn't you want a big honking cap at the 470/100/2.7K junction, so the AC differential gain is symmetric?
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: DIY Function Generator
« Reply #57 on: January 17, 2017, 08:09:20 pm »
It looks like VoutB is for adjusting the offset. For symmetry one could just use slightly different resistor values (e.g. around 2.78 K in the feedback of the OP) to include the extra resistance.  One might even save one ore resistor and possibly the lower OP.

However this circuit is still missing two parts: the reconstruction filter is very low grade. Also there is no coarse adjustment for the amplitude (like the relay part) in the other circuit. Also the upper frequency limit and amplitude is rather low. In addition the output impedance is not at 50 Ohms in the simple circuit.

So that simpler circuit has some good ideas (like having the offset) and using an DAC to set the amplitude. However there is also a oversimplification in using a slow OP as an filter and the low output amplitude.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2548
  • Country: us
Re: DIY Function Generator
« Reply #58 on: January 17, 2017, 08:55:20 pm »
Yes. VoutB is the offset adjustment and VoutA is the amplitude control. The amplitude gain is set for 2Vpp with a +/- 1V offset control. The op-amp gain could be adjusted for a larger output if desired.  I see no reason for a coarse amplitude adjustment with noise prone relay contacts. The coarse/fine adjustment is part of the GUI with finer adjustments achieved with a 12 bit DAC (MCP4822) instead of the 8 bit DAC (MCP4802) I used.

As for the reconstruction filter, I found it almost unnecessary with the 1Hz to 1MHz frequency range I limited the DDS to. A FFT shows the DDS output to be very clean without one.

The 50 ohm output impedance is a weak point for me. Any suggestion for a fix is welcome.

Edit: See the attached application note on the amplitude control for the AD9834. It is a coarse adjustment in itself.
« Last Edit: January 17, 2017, 09:12:08 pm by MarkF »
 

Offline ziplock9000

  • Regular Contributor
  • *
  • Posts: 173
  • Country: gb
Re: DIY Function Generator
« Reply #59 on: January 17, 2017, 09:42:56 pm »
External RAM to sample data can be rather fast, but this would need something like an FPGA / CPLD to generate the address sequences. To have a good arb.- generator one might also needs a more or less fine adjustable clock one when to update the clock / data - this is different from an DDS where the clock is fixed.
Ah balls. It's looking more and more like even a modest 10Mhz range arb gen is out of range and better to just buy one :/
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: DIY Function Generator
« Reply #60 on: January 17, 2017, 09:53:48 pm »
Fixing the output to get closer to a 50 Ohms output is easy: replace the 51 Ohms behind the OP with 100 Ohms and adjust the filter to 100 Ohms. These two resistors are effectively in parallel to determine the output impedance. Having the filter at the output is not such a good idea.

The output amplitude is also limited by the OPs current limit and the maximum slew rate. For the TLE2081 the slew rate limit is about 10 V_ss at 1 MHz. Which would result in 2.5 V_ss to a 50 Ohms load. So 2 V_ss is already rather close to that limit. There is also a current limit: 1 V at a 50 Ohms load already needs about 30 mA from the OP (with 100 Ohms resistors). So it needs an better OP (or two) to get a higher amplitude.

There is some filtering: the one a the output and the limited bandwidth of the OP also acts like a low pass filter. Still only 4th order with low Q and thus a limit to something like 1-2 MHz despite of a limit of about 10 MHz from the DDS chip.

The amplitude adjustment via the reference input of the DAC in the DDS chip is good for fine adjustment, but not working well for low amplitudes, as this will increase the DDS internal DAC errors. Having a 12 Bit DAC to control does not help here. It is just that one should not go down below about 10% of the maximum for the ref input.

So an additional switchable 20 dB attenuators would really help to extend the amplitude range, without adding to much noise / distortion. For a 50 Ohms signal, relays are not bad and at only 1-5 MHz there is no need for special RF relays. With fine adjustment via the ref input one can get away with just 1 or 2 relays (or maybe just mechanical switches) for steps of 20 dB and maybe another 10 or 20 dB. A passive divider at the output is also the best way to get a really low noise and SWR, at least for the low amplitude setting.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: DIY Function Generator
« Reply #61 on: January 17, 2017, 10:02:04 pm »
External RAM to sample data can be rather fast, but this would need something like an FPGA / CPLD to generate the address sequences. To have a good arb.- generator one might also needs a more or less fine adjustable clock one when to update the clock / data - this is different from an DDS where the clock is fixed.
Ah balls. It's looking more and more like even a modest 10Mhz range arb gen is out of range and better to just buy one :/

Absolutely!

There are some fairly inexpensive AWGs that can produce some very nice results.  Something in the Siglent or Rigol lines will be just fine.  Even the very cheap FG085 can do something useful.  It a very neat gadget up to a 200 kHz (sine).

Within its frequency range of 12 MHz at +- 5V, the Digilent Analog Discovery can do some very impressive work.  For $279, this device is totally underappreciated.
http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/


 
The following users thanked this post: ziplock9000

Offline ziplock9000

  • Regular Contributor
  • *
  • Posts: 173
  • Country: gb
Re: DIY Function Generator
« Reply #62 on: January 17, 2017, 10:54:10 pm »
External RAM to sample data can be rather fast, but this would need something like an FPGA / CPLD to generate the address sequences. To have a good arb.- generator one might also needs a more or less fine adjustable clock one when to update the clock / data - this is different from an DDS where the clock is fixed.
Ah balls. It's looking more and more like even a modest 10Mhz range arb gen is out of range and better to just buy one :/

Absolutely!

There are some fairly inexpensive AWGs that can produce some very nice results.  Something in the Siglent or Rigol lines will be just fine.  Even the very cheap FG085 can do something useful.  It a very neat gadget up to a 200 kHz (sine).

Within its frequency range of 12 MHz at +- 5V, the Digilent Analog Discovery can do some very impressive work.  For $279, this device is totally underappreciated.
http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/
What I was hoping to build looks similar to the FG085 but with a PC/Windows based front end for versatility. Thanks
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: DIY Function Generator
« Reply #63 on: January 18, 2017, 09:04:26 am »
I also like the ideas of a 1Gs 8-channel 14-bit ARB, it would be very interesting to have it on my desk but to be fair I do not have $1000 and anything that sticks beyond 1MHz analog bandwidth is beyond my field of interest. I need a true arbitrary waveform generator (and not sin+square), for embedded, testing and debugging. Current micros are clocked in the range of 50-100MHz, they cannot cope with signals from >1MHz bandwidth (even a stupid PID @ 100kHz is a challenge on a 100MHz micro) so I really have no interest in a 5MHz triangle waveform.
 
What I was hoping to build looks similar to the FG085 but with a PC/Windows based front end for versatility. Thanks
FG085 looks too limited in functionality for me but the bandwidth is ok-ish.

I need:
-a sine sweep, from A to B, in logarithmic scale. Two decades at least. 1Hz:100Hz, 2Hz:200Hz, 5Hz:500Hz,..., 5kHz:~500kHz
-random noise generator, with replay (so not that random)
-trapezoidal shape (for servo control)
-ramp with reset output (for integrating opamp with zeroing)
-external output trigger, input trigger and clock (to synchronize that with external gear for debugging, or to cascade/parallel with second arb generator),
-incremental encoder/pushbutton emulator with switching noise (for testing noisy encoder/button interfaces)
-hardware keyboard and standalone operation not required
-USB interface
« Last Edit: January 18, 2017, 09:07:16 am by Brutte »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: DIY Function Generator
« Reply #64 on: January 18, 2017, 03:51:59 pm »
External RAM to sample data can be rather fast, but this would need something like an FPGA / CPLD to generate the address sequences. To have a good arb.- generator one might also needs a more or less fine adjustable clock one when to update the clock / data - this is different from an DDS where the clock is fixed.
Ah balls. It's looking more and more like even a modest 10Mhz range arb gen is out of range and better to just buy one :/

Absolutely!

There are some fairly inexpensive AWGs that can produce some very nice results.  Something in the Siglent or Rigol lines will be just fine.  Even the very cheap FG085 can do something useful.  It a very neat gadget up to a 200 kHz (sine).

Within its frequency range of 12 MHz at +- 5V, the Digilent Analog Discovery can do some very impressive work.  For $279, this device is totally underappreciated.
http://store.digilentinc.com/analog-discovery-2-100msps-usb-oscilloscope-logic-analyzer-and-variable-power-supply/
What I was hoping to build looks similar to the FG085 but with a PC/Windows based front end for versatility. Thanks

For $35 and a couple of hours work, you can just buy the FG085 and leave it laying on your workbench.  No USB cables, no coupling with the PC, etc.
https://www.amazon.com/Function-Generator-DIY-Tech-FG085/dp/B00C5UO8U6

If building an AWG is a learning project with value beyond just making signals, great!  Building something is good.  OTOH, if the goal is to have some kind of signal source for other projects, maybe $35 isn't such a bad idea.  Besides, you still get some soldering practice and that isn't all bad.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: DIY Function Generator
« Reply #65 on: January 18, 2017, 04:02:43 pm »
I also like the ideas of a 1Gs 8-channel 14-bit ARB, it would be very interesting to have it on my desk but to be fair I do not have $1000 and anything that sticks beyond 1MHz analog bandwidth is beyond my field of interest. I need a true arbitrary waveform generator (and not sin+square), for embedded, testing and debugging. Current micros are clocked in the range of 50-100MHz, they cannot cope with signals from >1MHz bandwidth (even a stupid PID @ 100kHz is a challenge on a 100MHz micro) so I really have no interest in a 5MHz triangle waveform.
 
What I was hoping to build looks similar to the FG085 but with a PC/Windows based front end for versatility. Thanks
FG085 looks too limited in functionality for me but the bandwidth is ok-ish.

I need:
-a sine sweep, from A to B, in logarithmic scale. Two decades at least. 1Hz:100Hz, 2Hz:200Hz, 5Hz:500Hz,..., 5kHz:~500kHz
-random noise generator, with replay (so not that random)
-trapezoidal shape (for servo control)
-ramp with reset output (for integrating opamp with zeroing)
-external output trigger, input trigger and clock (to synchronize that with external gear for debugging, or to cascade/parallel with second arb generator),
-incremental encoder/pushbutton emulator with switching noise (for testing noisy encoder/button interfaces)
-hardware keyboard and standalone operation not required
-USB interface

You really should look at the Digilent Analog Discovery.  It turns out that your 'sweep' requirement is met by the Network app while the Wavegen app will meet the noise, trapezoid and general signal requirements.  External input trigger is probably possible (there are pins for it but I have TESTED it myself).  I'm not sure about trigger out...

It costs nothing to download the Waveforms software and play around with the demo mode:
http://store.digilentinc.com/waveforms-2015-download-only/

Here's an overview page with a link to the Reference Manual (among other things):
https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/start?redirect=1
 
The following users thanked this post: Brutte

Offline AE7OO

  • Regular Contributor
  • *
  • Posts: 65
  • Country: us
Re: DIY Function Generator
« Reply #66 on: April 13, 2019, 04:32:26 am »
I've got the semi-updated (Meaning it has the 12bit/2048 update, but still has the CH340 serial to USB) MHS-5200A - 25Mhz.  Sine wave output to 25Mhz, all other outputs restricted to give or take 6Mhz.  It is a ARB with about 200Ms(Closer to 170 according to Sigrok), 12bit with 2048 points and 15 memories. 
As long as you keep the output to a semi-low level, about 7Vpp above 10Mhz OR 14Vpp below, it works just fine. 
As far as I can tell the complete serial protocol has been reverse engineered, but the native software I've got is not too bad.  It handle outputs of both channels, freq measurements, freq sweeping, and has basic waveform generation.

It runs about from about $70 on Amazon(Prime) for the 25Mhz one.  Trying to go lower than this price, you'll end up with either a Kit, a reference board design, a analog (aka XR220x) generator or a audio only gen.
I know the thread is old but....
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf