DIY Portable Waveform Generator (USB Powered)

by Saptarshi Talukdar in Circuits > Arduino

148 Views, 3 Favorites, 0 Comments

DIY Portable Waveform Generator (USB Powered)

DIY Waveform Generator.png

In this project we will build a DIY Waveform Generator based around the AD9833 Programmable Waveform Generator IC. The Waveform Generator can be powered using USB-C and does not require AC mains. The brains of the waveform generator is an Arduino Nano which is responsible for controlling the AD9833 IC and the OLED Display. It can generate square, triangle, and sine waves with adjustable DC offset and amplitude up to ±12 V. The frequency can be adjusted from 1Hz to 1MHz (Can be upgraded to 10MHz). The maximum current draw is 40mA (Can be upgraded to 100mA). So let's begin without further ado!

Get the Parts!

Here you can find the parts list with a suitable link to buy each part (non-affiliate):

Note: Most links are for India only, but you can buy the parts from any seller.


1 x Arduino Nano: https://robu.in/product/arduino-nano-v3-0-ch340-chip-mini-usb-cable/

1 x XL6009 Boost Converter: https://robu.in/product/xl6009-dc-dc-step-up-converter-performance-ultra-lm2577-booster-circuit-board/

1 x AD9833 Programmable Waveform Generator: https://robu.in/product/gy-9833-ad9833-programmable-sine-square-wave-dds-signal-generator/

1 x Female USB-C Connector: https://www.mouser.com/ProductDetail/CUI-Devices/UJC-HP2-3-SMT-TR?qs=HoCaDK9Nz5cglCCyoWNzZg%3D%3D

2 x 1N5822 Schottky Diode (Any Schottky Diode Works): https://robu.in/product/1n5822-1w-schottky-diode-pack-of-10/

2 x 1000nF (1uF) Polyester Film Capacitor: https://robu.in/product/1uf-250v-dip-polyester-film-capacitors-pitch-10mm/

1 x Rotary Encoder: https://robu.in/product/m274-360-degree-rotary-encoder-module-brick-sensor/

2 x Push Buttons: https://robu.in/product/12x12x7-3mm-tactile-push-button-switch-10pcs/

1 x 0.96 Inch Yellow-Blue I2C OLED Display Module: https://robu.in/product/0-96-inch-yellow-yellow-blue-oled-lcd-led-display-module/

1 x 8-pin IC Socket: https://robu.in/product/8-pin-dip-ic-socket-base-adaptor-pack-of-10/

1 x 10k Trimmer (Any 10k precision trimmer works): https://robu.in/product/3296w-10k-ohm-trimpot-trimmer-potentiometer-pack-of-5/

1 x 100k Potentiometer (Any 100k pot works): https://robu.in/product/rm065-100k-ohm-trimpot-trimmer-potentiometer-pack-of-10/

1 x Resistor Kit: https://robu.in/product/30-different-valued-metal-film-resistor-assorted-kit-for-diy-electronic-projects-and-experiments/

1 x 220uF Electrolytic Capacitor: https://robu.in/product/35px220mefc8x11-5-rubycon-aluminum-electrolytic-capacitor-220uf-35v-20-radial/

1 x 2-pin Screw Terminal: https://robu.in/product/2-pin-2-54mm-pitch-pluggable-screw-terminal-block-pack-of-3/

1 x TL071 OpAmp: https://s.click.aliexpress.com/e/_dXd3VYL

Note: I used a UA741 OpAmp because I only had that laying around, but using a better OpAmp with higher output current and with a higher frequency rating like the TL071 will allow the waveform generator to perform better at higher frequencies and allow you to draw more current from the output as well.

Other Generic Parts and Tools:

Perfboard: to build your circuit on. If you want to take it to the next step you can also make a PCB design (link your project in the comments if you do!)

Female Header Pins: for connecting your Arduino Nano to the circuit. You can also directly solder the nano to the perfboard but I wouldn't recommend it.

18-22 AWG Insulated Hookup wire.

Soldering Iron and Solder Wire.

Oscilloscope: to measure the generated waveforms. Not necessary but really handy to have one. Even a basic DIY version does the job.

Understand the Circuit

The Waveform Generator is divided into 3 main sections:

1) Power Supply: The USB-C provides 5V power to the Arduino Nano, OLED Display, AD9833 IC. The boost converter generates +12V, and the Schotty Diodes and Capacitors are used to make a charge pump which generates -12V to power the OpAmp.

Parts Required: 1 x XL6009 Boost Converter, 1 x Female USB-C Connector, 2 x 1uF Polyester Capacitor, 2 x Schottky Diode, 1 x 220uF Capacitor.

Note: The Capacitors and Diodes are used to build a charge pump which generates -12V for the negative power input of the OpAmp. The charge pump requires a PWM signal which is obtained from the anode of the diode on the XL6009 Boost Converter. A wire needs to be soldered to the anode of the diode as shown in the figure below.

2) Waveform Generator: The microcontroller takes input from the user using the rotary encoder and push buttons and generates the required waveform. However the signal generated comes with a DC offset and has a peak to peak voltage on only 0.65V.

Parts Required: 1 x Arduino Nano, 1 x OLED Display, 1 x AD9833 IC, 1 x Rotary Encoder, 2 x Push Buttons.

3) Amplifier: Since the signal generated is only 0.65Vpp, it needs to be amplified using an OpAmp. The opamp is configured as an Inverting OpAmp where the 100k potentiometer controls the amplitude and the 10k trimmer controls the DC offset.

Parts Required: 1 x OpAmp, 1 x 100k potentiometer, 1 x 10k trimmer, 1 x 2k Resistor, 8-pin IC Socket.

Note: The DC offset adjustment is very sensitive due to which we need to use a precision trimmer potentiometer to set the offset accurately.

Build the Circuit

Schematic_Waveform Generator_2024-07-28.png
PWM_Image.jpg

Follow the schematic above to build the circuit. There's also a pdf version of the schematic attached below for better resolution.

Note: To get the PWM signal from the XL6009 Boost Converter, solder a wire to the anode of the diode or pin 3 of the XL6009 IC as shown in the picture above.

Upload the Code

Here's the arduino code for the Waveform Generator. Feel free to modify the code and make it better!

How to Use It?

Marked_Circuit.png

The main controls of the Waveform Generator includes a rotary encoder, two push buttons, and two potentiometers:

1) Rotary Encoder: Rotating the Rotary Encoder clockwise increases the frequency, while rotating it anti-clockwise decreases the frequency of the wave. The Rotary Encoder Push Button can be used to change the waveform (OFF → Sine → Triangle → Square).

2) Push Buttons: The Right and Left Push Buttons are used to adjust the resolution of the frequency adjustment. The current resolution is indicated by a small arrow above the frequency digits. By default, the resolution is set to 1000Hz (this means that one increment of the Rotary Encoder will increase the frequency by 1000Hz).

3) 100k Potentiometer: The 100k Potentiometer is used to adjust the amplitude of the waveform (from 0V to ±12V).

4) 10k Trimmer: The 10k Trimmer is used to adjust the DC offset of the waveform.