Function/Waveform Generator || DIY or Buy

Building a Function Generator: A DIY Approach

As electronics enthusiasts, we often find ourselves needing a function generator to evaluate filter circuits or stress test small MOSFET circuits. While expensive models like the Siglent SDG2082X offer tons of features, they can be out of budget for beginners. Fortunately, there are cheaper alternatives available, such as the AE20125, which can produce sine, square, and triangle waves up to 10 MHz.

However, this generator's maximum output level between -5V and +5V is not satisfactory. In this article, we'll explore two approaches: building a DIY function generator or buying an existing model. We'll delve into the design process, component selection, and testing of our own function generator using the AD8933 Programmable waveform generator IC.

Defining Features for Our DIY Function Generator

Before starting the project, it's essential to define what features we want in our DIY function generator. In this case, we aim to produce a signal that can cover frequencies up to 12.5 MHz, with an adjustable output voltage between +12V and -12V. We also need an offset adjustment feature, which will allow us to move the waveform around between the two voltage rails.

To achieve this, we'll use an inverting op-amp circuit with an adjustable gain through a potentiometer. This will provide enough boost to amplify the AD8933 IC's maximum output voltage of 0.65V up to 12V. The second potentiometer connected to the non-inverting inputs will be used to generate the offset further amplified waveform.

Designing Our Circuit Around the AD8933 IC

After researching existing projects, such as Caesar Chirilla's article on Allaboutcircuits, we decided to base our code around his and make a few minor adjustments. The AD8933 IC is a powerful component that allows us to produce frequencies up to 12.5 MHz with an adjustable output voltage.

We started designing our circuit schematic, taking into account the power supply requirements, op-amp circuits, and the Arduino's role in managing everything. Our power supply consists of a center-tapped transformer, which provides an AC voltage of 30V RMS between its outer pins. We also need to create a +12V and -12V rail at the end of the circuit, which will power the op-amp.

The first potentiometer connected to the op-amp is used to adjust the gain, while the second potentiometer is used to generate the offset further amplified waveform. The Arduino manages everything, displaying the current frequency and waveform on an LCD display. It also adjusts the values according to the rotation and button presses of a rotary encoder.

Soldering Components onto Perfboard

After designing our circuit, we started soldering all the components onto a piece of perfboard. This involved connecting the transformer terminals, op-amp circuits, Arduino, and DDS IC to the perfboard. We also added headers and wires to make it easier to connect the external components.

Once everything was connected, we hooked up the 3D-printed housing and glued the transformer and perfboard into place. After testing the function generator for a bit, we found that it comes with most of the features we were looking for, but especially in the higher frequency range, it doesn't work as well as we would have liked.

Conclusion

In conclusion, building a DIY function generator using the AD8933 Programmable waveform generator IC offers a great price-performance balance. For mere 50 euros, it provides a decent balance of features and quality. While there are still some limitations in our project, such as the high-frequency range, we believe that this approach is worth considering for electronics enthusiasts.

As always, we appreciate your feedback and comments on our project. If you have any suggestions or questions, please feel free to share them with us. Don't forget to like, subscribe, and hit the notification bell to stay updated on our latest projects and content.

WEBVTTKind: captionsLanguage: enOwning a decent functionWaveform generator is sometimes pretty much mandatory or for an electronics tinkererto for example evaluate filter circuits or stress test a small MOSFET circuitthe one I've been using is the Siglent SDG2082XWhich works like a charm and offers tons of awesome additional featuresThe only problem is that electronics beginners probably do not want to spend 600 euro on such a piece of equipmentThankfully though, cheaper function generators do exist like this AE20125which you can get for around 70 euro andWhile this generator does create sine square and triangle waves up to a frequency of partly 10 megahertzI'm not satisfied with its maximum output level between - and +5 voltsSo in this episode of DIY or Buy, let's see whether we can make our own decent function/waveform generator or whether we should stick to the buy version insteadLet's get started...This video is sponsored by JLCPCB(.com), which is slowly becoming a worldwide known PCB brand$2 PCB's, continuous good quality and fast turnarounds is what they are known forSo upload your gerber files today and test their serviceFirst off, I had to define what features my DIY function generator should come withObviously, it should be able to provide a sine, triangle and square voltageWith a frequency of up to ten megahertz and a peak to peak voltage from minus to plus 12 volts (peak-to-peak)The amplitude of the voltage also needs to be adjustable as well as the offset for this voltageWhich means it should be able to provide an AC voltage as well as a positive or negative DC voltage. Ithink those features are decent base for good function generatorSo let's think about creating the different waveformsWhich brings us to the problem whether we should go with the analog or digital routeIf we would go analog then a simple op-amp configuration like this can be found everywhere on the InternetAfter building the circuit up on a breadboard and powering it, we can use an oscilloscope to probe each op-amp stageTo find out that the first one creates a supposedly square wavethe second one a triangle wave and the third one a sine wave andBy adjusting the potentiometer at the first stage. We can also adjust the frequency of the waveformsThe way this works is that an op-amp outputs will do anything inOrder to keep the difference voltage between its inputs to zero voltsThus at the first stage, We got a multi-vibratorWhich means the op-amp outputs will alternate between its high and low states to charge/Discharge the capacitor so that it reaches the same voltage level as on the non-inverting inputsCreated by the voltage divider. At the second and third stageWe got a classical integrator op-amp circuits whose output will fall negativelyIf a positive constant voltage is applied and rise positively if a negative constant voltage is appliedIt does that to, like always, keep the inverting input at the same defined voltage level as the non-inverting inputs.In theory, those op-amp circuits sound promisingBut practically they do not deliver decent waveforms and also come with a minimum frequencyWhich means we would have to change passive components on the fly to alter the frequency range.That is a hassle though?Which is why I would only recommend such op-amp circuits if you're looking for one specific waveform that you do not want to changeBut if you desperately want to stay analog,then you can always get yourself an xr2206 function generator ICit provides a square wave and triangle slash sign outputs with a frequency of up to one megahertz andonly requires a few complementary passive components andIf you want to be lazy like meyou can even get a complete kit based around them for only six euro andLet me tell you that it works really well for its priceBut we are still not even close to the features. I said at the beginning of the videoSo let's turn to digital and let's talk about DDS-which stands for direct digital synthesisTo explain it better though. I firstly searched for DDS IC and found thisAD8933 Programmable waveform generator ICIt's functional block diagram might seem confusing at firstBut after studying the 21 pages of the data sheets, it is pretty clear how this DDS IC worksFirst off. We got the phase accumulator, which super simplifiedstores all the possible voltage values of a sine wave as phase information between 0 & 2 PInext the SIN ROM turns the phase information into actual mathematical voltage amplitudes andFinally, we got a digital to analog converterWhich then spits out our beautiful sine waveSo in a nutshell, it is a more or less glorified memory with attached DACto generate whatever waveform is stored in the memoryand speaking of waveforms, by writing to the control frequency and phase registersWe cannot only achieve a frequency of up to 12.5 megahertzBut also a triangle and square wave andSince adjusting the output voltage between plus minus 12 volts and adding an offset should be easy to do with an op-amp circuitI started designing my DIY function generator around this AD8933 ICBut while I was getting close to finishing my circuit schematicI noticed that someone else already created a very similar projectCaesar Chirilla over at Allaboutcircuits actually created such a project about 1.5 years agobut since I used other componentsI will still explain my circuits before eventually coming back to his work inOrder to use most of his code to save a bit of time and effortAnyway for the power supply we need a center tapped transformer like this oneAfter connecting it to mains voltage, which you should not do if you never worked with electronics before, since that can be lethalWe can see here that between its outer pinsWe got an AC voltage of 30 volts RMS and between the outer pins and the middle pinaround 15 volts RMSThis is mandatory to create a plus and minus 12 volt rail at the end of this power electronic circuitwhose only job is to power the op amp which allows us to move the waveform around between the two voltage railsOf course, we also got a 5 volt regulator to power the Arduino, rotary encoder AD8933 IC and LCDNeedless to say the Arduino manages everything like displaying the current frequency and waveform on the LCDAdjusting the values according to the rotation and button presses of the rotary encoderand of course sending the current frequency and waveform information over to the DDS IC andFinally like already mentionedWe also got an inverting op-amp circuit with an adjustable gain through a potentiometer of around 22Which should be enough to boost the DDS IC maximum output voltage of0.65 volts up to 12 voltsby the wayThe second potentiometer connected to the non-inverting inputs is used to generate the offset further amplified waveformSo with the theory out of the way,I started soldering all of my components onto a piece of perf board andAfterwards to one another according to my final schematicAs soon as my circuit was complete after around 4 hoursI added wires to the external components as well as headers andUltimately hooked them all up to the circuitsAfter then connecting the 3 transformer terminals to the circuitIt was time for the first powerup, which did not result in an explosionPerfectInstead. I measured all the required voltage rails and thus continued with the programmingNow at this point I highly recommend checking out Caesar Chirilla's article to find out how the code worksSince I based my code around his and just changed a few minor thingsSo after I uploaded the code I used my oscilloscope to check whether everything worked correctlyWhich it surely didbut since such naked function generator is not comfortable and safe to work withI started measuring the dimensions of all the components and designed a housing for its in 123D designAfter then 3d printing its which took around 15 hours. I mounted the external components in placeand glued the transformer and perfboard into the boxWhich means my DIY function generator was completeNow after testing it for a bit, I have to say that it comes with most of the features that I was looking forbut especially in the higher frequency range, it does not work as well as I would have likeOf course, it does also not offer a crazy advanced features like my expensive function generatorBut I have to say that for price of merely 50 euroIt offers a pretty decent price performance balance, which is why for me DIY is this time the winnerAs always thanks for watchinglet me know your opinion about this project in the comment section below andas always don't forget to Like share subscribe andHitting the notification bellStay creative and I will see you next time!