Looking for <$50 function generator - Page 1
Forum section: electronics / testgear

author: robca
author_rank: Frequent Contributor
timestamp: May 26, 2020, 06:58:49 pm
content: I'm looking to buy a cheap (cheap) function generator to complement my oscilloscopes (good old Hitachi analog dual trace 100MHz and DS2072A which I got for a song out of an estate sale).I mostly work with digital circuits (STM32, ESP32) and I have one of those cheap 8 bit logic analyzers that together with sigrok allows me to do most of the digital and protocol debugging. Rarely audio circuits, and for those I use the amazing Daqarta function generator with the PC soundboard (http://www.daqarta.com/dw_gen.htm)From time to time, though, I would like to have a basic (sine, triangular, square) function generator, up to a few MHz. Up until now I mostly used square waves out of one of the many microprocessor boards I have around and a bit of code.So I started looking at options on eBay, from the cheap XR2206 units to AD9833 kits, all the way up to the FY3224s which currently can be found for ~$50 shipped to the USA.It's very easy to start from the FY3224s, get carried away and end up with a ~$130 arbitrary function generator (and I have seen many: FY6900, UniT, etc). After all, spending $50 poorly or more for a much better product seems smart, but I'm trying to stick to a cheap solution for basic waveforms, given how rarely I have needed it in the past decadesAny suggestion is welcome

author: nctnico
author_rank: Super Contributor
timestamp: May 27, 2020, 11:49:24 am
content: IMHO the FY3224s is just fine but it needs a grounded AC inlet with the ground connected to the 0V of the power supply. This modification is easy to make.

author: MarkF
author_rank: Super Contributor
timestamp: May 27, 2020, 01:09:26 pm
content: If you want a DIY project?I built my own with an AD9834 DDS for just the same reason (very little use).It has sine, triangle, square, sine sweep up or down with start trigger, and PWM.Frequency is 1Hz to 15MHz at 2Vp-p.

author: Electro Fan
author_rank: Super Contributor
timestamp: May 27, 2020, 08:51:31 pm
content: FeelTech looks to be closest to your preferred budget.Up a bit in price (might be lower elsewhere) is:https://www.amazon.com/Waveform-Generator-Arbitrary-Function-Sampling/dp/B0819W89DH/ref=pd_sbs_328_3/130-6234271-5610843?_encoding=UTF8&pd_rd_i=B0819W89DH&pd_rd_r=0dddad65-cb5a-46a6-80fe-a7d05d6ed780&pd_rd_w=gJ4vD&pd_rd_wg=RZxoI&pf_rd_p=12b8d3e2-e203-4b23-a8bc-68a7d2806477&pf_rd_r=RCQ64G0938PZDSH3BATW&psc=1&refRID=RCQ64G0938PZDSH3BATWPlenty of info on FeelTech and some on Uni-T in the forums.

author: robca
author_rank: Frequent Contributor
timestamp: May 27, 2020, 09:58:30 pm
content: Quote from: Electro Fan on May 27, 2020, 08:51:31 pmAs I said at the beginning, I know that I can get a much better instrument a around $130. It's just roughly $100 higher than I want to spend, though. Given how infrequently I might need to use it, I don't think it makes sense spending that much at this point. And if in the future I need a better instrument, I can always buy at that time (and I'm sure that there will be even better ones for less)

author: robca
author_rank: Frequent Contributor
timestamp: May 27, 2020, 10:33:49 pm
content: Quote from: MarkF on May 27, 2020, 01:09:26 pmI would consider building something but based on what I saw, it might not be worth the time/cost unless I were looking for something unique. I looked at the reference designs for the AD9834, and it looks like I would need to have specific filters to avoid having spurious harmonics. For example, I'm attaching a rather common board (eBay), where there are R/C filters for both outputs, which is something that seems to be implemented differently in yours (and I would not have enough knowledge to design something that produces clean waves at those frequencies)I was looking at possibly getting one of the AD9833 from eBay with the built-in amplifier, and simply add an Arduino front end with a display. In that case I would rely on the amplifier and digital potentiometer on the board to do all the hard work (https://www.handsontec.com/dataspecs/module/Module%20Collection.pdf,with the relevant attached portion below). Given that I have already plenty of displays and microprocessor boards around, the only actual cost would be the AD9833. And using an ESP32 oe ESP8266, would be even possible to send commands to it wirelessly. The downside is that it would have no enclosure and the software never finishedIs your project shared somewhere?

author: robca
author_rank: Frequent Contributor
timestamp: May 27, 2020, 10:34:56 pm
content: Quote from: nctnico on May 27, 2020, 11:49:24 amYes, I did see that while browsing the forum here for the FY3224, but thanks for pointing it out anyway. Better safe than sorry...

author: MarkF
author_rank: Super Contributor
timestamp: May 27, 2020, 11:27:12 pm
content: Quote from: robca on May 27, 2020, 10:33:49 pmThe advantage of the AD9834 over the AD9833 is that it has an external reference you can use to control the amplitude (See attached App Note). Plus the differential output allows you to adjust the amplitude and DC offset independently of each other.I didn't see much need for a reconstruction filter because the output is pretty clean. If I get a chance I'll get a screen capture and measure the harmonics. However, I did a 2nd order filter with the help of an online LC filter program.https://www-users.cs.york.ac.uk/~fisher/lcfilter/Here is a 5th order filter:(Updated design)

author: robca
author_rank: Frequent Contributor
timestamp: June 07, 2020, 05:15:00 pm
content: Just following up in case anyone wants to consider the same AD9833 board I mentioned. Don't!!!It's a pretty useless board above audio frequencies, and you will be better off with one of the much cheaper AD9833 only boards and a better filter/amplification stage. The only saving thing for me, is that the individual chip outputs are broken out in edge connectors and the chip connected with a 0 Ohm resistor, so it's easy to isolate the AD9833 and use only the chips you want. I haven't had time to look at how to improve it, but I think that the weak link in the chain is the MCP41010, with a pretty slow rise and fall time. the AD8051 should be plenty capable of dealing with the frequencies in playHere are a few screen captures, at 1Khz, 100KHz, 1MHz for sine, triangle and square waves on the main board output (the AD8051 out), and the square and triangle waveform at 2MHz for the AD8051 out and the AD9833 out (the latter much better)

author: MarkF
author_rank: Super Contributor
timestamp: June 07, 2020, 07:39:47 pm
content: Here are some screen captures of my AD9834 based Function Generator shown abovewith a48MHz clock, 1Vp-p output and 2nd order filter:The triangle and square waves above 1MHz are not very useful.

author: MarkF
author_rank: Super Contributor
timestamp: June 07, 2020, 07:42:37 pm
content: And some signal analysis:Ending with 10MHz triangle waveform:

author: robca
author_rank: Frequent Contributor
timestamp: June 07, 2020, 11:58:34 pm
content: There's no questions: your circuit works much better (which I knew since the beginning, I was just hoping in something better from a cheap module). Since Ii could not find any high frequency waveform from the module I used, at least I can help others considering buying itThanks again for sharing both your design and waveforms, I might go with an AD9834 if I decide to do something better. Ironically I also have one of those $20 testers (https://www.eevblog.com/forum/testgear/$20-lcr-esr-transistor-checker-project/) and that generates a very clean 4MHz square wave (with a 16MHz clock). The only problem is that there are limited options for frequencies at the high range of the frequency, due to the limited number of dividers available when running code at close to the limit of the chip.I will hack my module to bypass the MCP41010 and use a potentiometer instead, and for the time being that will work for me for the time being

author: bob91343
author_rank: Super Contributor
timestamp: June 08, 2020, 12:28:56 am
content: I have three function generators but only need one. So PM me if you are interested.

author: MasterT
author_rank: Frequent Contributor
timestamp: June 08, 2020, 01:08:24 am
content: What value of the MCP41010? Be aware, that pot 10k has 1 MHz bandwidth, 50k & 100k likely 280kHz and 145kHzI see there is a typo in the microchip datasheet:http://ww1.microchip.com/downloads/en/devicedoc/11195c.pdfMHz instead of kHz.If stm32f4 having around, there is a way to get sine up to 6 MHz using internal DAC. It would allow to regulate amplitude in software, to some - 20dB and frequency with acceptable resolution

author: MarkF
author_rank: Super Contributor
timestamp: June 08, 2020, 03:52:47 am
content: Quote from: robca on June 07, 2020, 11:58:34 pmFor a higher frequency square wave, you can do what I did in order to generate a PWM waveform:In certain modes, the AD9834's Sign_Bit output pin is high impedance.So, I multiplexed it with one of the MCU pins.You need to be very very careful when switching the AD9834 mode and the state of the MCU pin(i.e. Always select both pins to high impedance before enabling the function you want).I used a PIC18F2550 as my MCU which has a maximum clock rate of 48MHz.The AD9834CRUZ can go to 75MHz (FYI. not the AD9834BRUZ version, only 50MHz).Therefore, you could use separated clocks or a MCU capable of 75MHz.This would allow all the waveforms to double their frequency. I limited mine to 15MHz.The only drawback here is that the combined digital output has NO amplitude control (5V in my case).You could add something to scale the digital output as well.As an aside, the PIC18F2550 only has 32K program memory and I used 99% of it compiling the program with the XC8 compiler.The other specialty item is the1.27" Color OLED Breakout Boardfrom Adafruit.

author: MarkF
author_rank: Super Contributor
timestamp: June 08, 2020, 04:08:12 am
content: Another thought:I have a LM7171 Op-amp on the output.It gets hot driving a 50Ω load at 2Vp-p.(My artificial output limit not to burn it up.)The boards do not have an output buffer. So.......

author: robca
author_rank: Frequent Contributor
timestamp: June 08, 2020, 04:08:16 pm
content: Quote from: MasterT on June 08, 2020, 01:08:24 amYes, the MCP41010 is clearly the problem.I was looking for a pre-made solution that could get me most of a low-end function generator. I could go with a barebone AD9833 board and add a way to amplify the signal, or look at boards with more support. I saw at least another project built around the same AD9833 board I used and the author seemed to be happy with the results. So, given that the price difference of a barebone AD9833 and the one I got was not that high, I went with the board with the 3 chips, naively believing that if someone designed and sold it, it must be working. Naively being the key word. And that's why I provided the waveforms, so that anyone else would know what to expectI can easily bypass the MCP41010 and still get something half usable, so not a complete lossI have an STM32F407 and an STM32H743 board and can definitely use them to build a signal generator. With DMA and plenty of memory, I should be able to also have arbitrary waveforms.But I'm unclear on how you you would get a 6 MHz sine, given that the DAC rate on an STM32F407 is 10.5Msps, and you would need at a minimum 128 samples for a full sine with half decent SNR. Do you have more info on what technique is used for that?According to ST, you can expect much lower frequencies from a STM32F407 even using multiple tricks and optimizationshttps://www.st.com/resource/en/application_note/dm00129215-extending-the-dac-performance-of-stm32-microcontrollers-stmicroelectronics.pdf

author: MarkF
author_rank: Super Contributor
timestamp: June 08, 2020, 04:33:55 pm
content: Here is a little code I did for a PIC16F877A to generate a sine wave.It outputs parallel 8-bit samples to a MC1408 DAC from an interrupt routine.The main() function does the setup from USB data.I abandoned it because of its limited frequency range. About 10KHz max with the 20MHz PIC clock.These are just pieces of code. See if you can follow it.And you are right. You need to send out a lot of samples at a fixed rate.You are probably better off with the DDS and adding an output driver.Code:#ifdef WAVEGENtypedef union {uint8_t b;uint16_t i;} bits_t;uint8_t S_Count;uint8_t S_Phase;uint8_t S_PhaseRate;uint8_t S_TimeRate;uint8_t S_Triangle;bits_t S_Time;bits_t S_Time1;bits_t S_Time2;const uint8_t cosine ={254, 254, 254, 254, 254, 254, 253, 253, 252, 251, 251, 250, 249, 248, 247, 246,245, 244, 242, 241, 239, 238, 236, 235, 233, 231, 229, 228, 226, 224, 221, 219,217, 215, 213, 210, 208, 205, 203, 200, 198, 195, 193, 190, 187, 184, 182, 179,176, 173, 170, 167, 164, 161, 158, 155, 152, 149, 146, 143, 139, 136, 133, 130,127, 124, 121, 118, 115, 111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81,78, 75, 72, 70, 67, 64, 61, 59, 56, 54, 51, 49, 46, 44, 41, 39,37, 35, 33, 30, 28, 26, 25, 23, 21, 19, 18, 16, 15, 13, 12, 10,9, 8, 7, 6, 5, 4, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 8,9, 10, 12, 13, 15, 16, 18, 19, 21, 23, 25, 26, 28, 30, 33, 35,37, 39, 41, 44, 46, 49, 51, 54, 56, 59, 61, 64, 67, 70, 72, 75,78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 115, 118, 121, 124,127, 130, 133, 136, 139, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173,176, 179, 182, 184, 187, 190, 193, 195, 198, 200, 203, 205, 208, 210, 213, 215,217, 219, 221, 224, 226, 228, 229, 231, 233, 235, 236, 238, 239, 241, 242, 244,245, 246, 247, 248, 249, 250, 251, 251, 252, 253, 253, 254, 254, 254, 254, 254,};#endif//================================================================================void main(void){while (1) {receivePacket();switch () {#ifdef WAVEGEN// Sine wave generation token...// MC1408 8-Bit Multiplying Digital-to-Analog Converter// buffer == Time1 MSB// buffer == Time1 LSB// buffer == Time2 MSB// buffer == Time2 LSB// buffer == Time rate// buffer == Phase rate// buffer == Triangle flag// buffer == Voltage referencecase FT_WAVEGEN:S_Time1.b=buffer;S_Time1.b=buffer;S_Time2.b=buffer;S_Time2.b=buffer;S_TimeRate=buffer;S_Time.i=S_Time1.i;S_PhaseRate=buffer;S_Triangle=buffer;S_Phase=0;S_Count=0;TRISC=0x00; // set port C as output// Setup voltage ref configurationTRISAbits.TRISA2=1;CVRCON=buffer;// Setup CCP1 configurationCCPR1H=S_Time.b;CCPR1L=S_Time.b;CCP1CON=0x0B; // Compare mode, trigger special event// Setup Timer1 configurationTMR1H=0;TMR1L=0;T1CON=0x05; // 1:1 Prescale | TMR1CS | TMR1ON bits// Enable CCP1 interruptPIR1bits.CCP1IF=0; // CCP1 Interrupt Flag bitPIE1bits.CCP1IE=1; // CCP1 Interrupt Enable bitINTCON=0xC0; // GIE and PEIE interruptsbreak;#endif}}}//================================================================================#ifdef WAVEGENvoid __interrupt() isr(void){if (PIE1bits.CCP1IE && PIR1bits.CCP1IF) {PIR1bits.CCP1IF=0; // clear CCP1 Interrupt FlagIOCKpin=0; // set CLOCK- pin lowif (S_Triangle) {if (S_Phase < 128)PORTC=S_Phase*2;elsePORTC=(255-S_Phase)*2;} else {PORTC=cosine;}S_Phase+=S_PhaseRate;if (S_TimeRate > 0) {if (S_Count == 0) {if (S_Time2.i > S_Time1.i) {S_Time.i+=S_TimeRate;if (S_Time.i > S_Time2.i) S_Time.i=S_Time1.i;}if (S_Time2.i < S_Time1.i) {S_Time.i-=S_TimeRate;if (S_Time.i < S_Time2.i) S_Time.i=S_Time1.i;}CCPR1L=S_Time.b;CCPR1H=S_Time.b;}S_Count++;}IOCKpin=1; // set CLOCK- pin high}}#endif

author: ogden
author_rank: Super Contributor
timestamp: June 08, 2020, 04:39:28 pm
content: Quote from: robca on June 08, 2020, 04:08:16 pmName of technique: filtering. With good filter you can achieve better than 60dB SNR up-to 1:10 fout/mclk rate. 6MHz sine is above Nyquist frequency of 10.5 Msps, it means harmonic mode with steep bandpass filter and huge SNR penalties. I would not go higher than 1/4 MCLK meaning 2.5MHz for 10.5Msps. Further reading:https://www.ieee.li/pdf/essay/dds.pdf.

author: helius
author_rank: Super Contributor
timestamp: June 08, 2020, 05:01:09 pm
content: There are many XR2206 based function generators under $7 on ebay. It's an obsolete part, but they seem to have made millions of them.

author: robca
author_rank: Frequent Contributor
timestamp: June 08, 2020, 05:12:47 pm
content: Quote from: helius on June 08, 2020, 05:01:09 pmYes, thanks, it's one of the cheap options I mentioned in my original post. Alas, most (all?) of the XR2206 on eBay are built using Chinese clone chips that are not as good as the original especially at higher frequencies, so I would have to buy a kit, then look for an original XR2206 (which from time to time pops up on eBay but tend to be expensive).They didn't make that many original XR2206, but Chinese cloners seem to have filled the void

author: MasterT
author_rank: Frequent Contributor
timestamp: June 08, 2020, 06:13:21 pm
content: Quote from: robca on June 08, 2020, 04:08:16 pmThe trick is you don't have to run 128 samples / period of sine. 4 samples is sufficient at high frequency end, and there are 2 DAC . Filtering would smooth out edges and take care of SNR. Triggering DAC's by two Timers in "interleaved" manner with preconfigured DMA & LUT. Having master clock 180MHz on stm32F446re frequency resolution is about 6kHz with 1MHz output, well not milliHertz .Pictered 1 dac at 4MHz clock outputs sine, stm32f446re, built like AP note you linked, with external buffer ad4891 and 4-th order sallen-key filter.

author: MasterT
author_rank: Frequent Contributor
timestamp: June 16, 2020, 02:51:29 pm
content: I tested STM32G474 -nucleo board, to see what max data rate could get. FYI, micro has 7 DAC's, 4 of them 15 msps. Theoretically 60 msps AWG, but dma limits this value down to 40 msps.I also checked out overclocking possibility, and find out that micro is stable at 280 MHz internal clock, not bad for rated as 170 over all temperature range. So, rate jumps up to 40 x 280/ 170 = 65.88 mspsThe issues with 4 to 1 MUX upconverter, using internal MUX-OPA I was able to build one in two stages. Two mux-es (OPAMP6 & 5) driving 10 msps up to 20 (nominal clock PLL 160MHz) , and than one mux (OPAMP2) brings 20 to 40. Problem with slew rate of internal OPA, switching inputs with OPA been in high power mode complicates stability, settling time is too big , like 100 nsec or so. Idea may works with external up-converter LVC4066 and fast high speed opamp.If not to chase high rates, than 4 buffered channels AWG at 10 msps per each channel easily obtainable out of $23~ CAD board.

author: Chris Roubis
author_rank: Contributor
timestamp: July 08, 2020, 11:48:01 am
content: I have the FY6900 Function generator.Cannot complain, except when I do a square wave, anything above 10mhz and the square wave starts looking like a sine wave.Other than that, its all good.

author: robca
author_rank: Frequent Contributor
timestamp: July 12, 2020, 08:23:29 pm
content: In the end I went with a 1980s era Wavetek 190, for which I paid around $30, shipping included. It works well up to 5MHz, starts having problems with distortion above that. Still need to calibrate it, though, so it might get better.https://www.eevblog.com/forum/testgear/help-restoring-1980s-era-electronics-(wavetek-190-function-generator)I have to say that I really like the old school potentiometers and rotary switches to quickly set up everything. Clearly not as powerful as a modern one, but does everything I need and then someBefore calibrating, though, I need to ensure I have the proper 50 Ohm terminators and cables. I can see big differences in signal, especially square waves, when I use different probes and switch the oscilloscope input to 50 Ohm (which I need to be careful doing, since the scope I use has only a tiny 50 Ohm resistor and the signal generator can provide 15 Vpp at 50 Ohm)So for your FY6900 you also might need a pass through 50 Ohm terminator or a T with a 50 Ohm terminator on one side

author: Gyro
author_rank: Super Contributor
timestamp: July 12, 2020, 08:59:18 pm
content: Good solid old-school choice.

author: MarkF
author_rank: Super Contributor
timestamp: July 12, 2020, 10:01:24 pm
content: Quote from: Gyro on July 12, 2020, 08:59:18 pmHow about some pictures of the inside.

author: robca
author_rank: Frequent Contributor
timestamp: July 13, 2020, 05:01:07 pm
content: Just posted pictures on my Wavetek 190 restoration threadhttps://www.eevblog.com/forum/testgear/help-restoring-1980s-era-electronics-(wavetek-190-function-generator)/

author: parasole
author_rank: Contributor
timestamp: February 17, 2022, 12:05:59 pm
content: Quote from: MarkF on May 27, 2020, 01:09:26 pmWhat about source code, is it available?

author: bob91343
author_rank: Super Contributor
timestamp: February 17, 2022, 06:06:16 pm
content: I have a couple of function generators I don't use. Might let one of them go for $50 plus pack and ship from Los Angeles.