Simple Signal Generator Using the AD9833
by fhdm-dev in Circuits > Electronics
3099 Views, 5 Favorites, 0 Comments
Simple Signal Generator Using the AD9833


This instructable shows how to create a very basic AD9833 based signal generator. The frequency and signal type settings are controlled by a rotary encoder and a few momentary switches. The settings are displayed on a 0.96inch OLED screen.
The motivation for this project was that I needed to be able to generate signals to test a Raspberry Pi Pico based oscillscope that I've been working on.
This signal generator doesn't include a fancy enclosure or a ton of features. It is however very simple and you should be able to put it together relatively quickly.
Supplies
SSD1306 0.96 inch I2C OLED
Arduino Uno
4 x 10k resistors
4 x 0.01 μf ceramic capacitors
3 x momentary switches
Solderless breadboard
AD9833 module
Initial Wiring of the Encoder, Switches and OLED


- Insert the rotary encoder, switches and OLED screen into the breadboard as shown above
- Connect one end of each switch to ground (including the switch built into the encoder)
- If you like you can connect the other end of each switch to ground via a 0.01uf capacitor for some rudimentary debouncing (in the image I've only done this for the 2 red switches)
- Connect the centre terminal of the encoder to ground
- Connect the 2 other terminals as shown in the schematic
- Connect the OLED VCC to 5V and Gnd to ground
- FYI. The yellow component between the red and yellow switches is a resettable fuse. I have a bad habit of shorting my circuits so I always put a fuse on the input.
Connect the Rotary Encoder and OLED to the UNO. Upload Sketch.

- Connect the left terminal of the encoder to the Arduino by running a wire from digital pin 4 to the junction of the leftmost resistor and capacitor. See image above and schematic
- Do the same for the right terminal of the encoder. This connects to digital pin 5 of the Arduino.
- Connect SDA of the OLED to A4 and SCL to A5
Install libraries and upload and test the sketch
- Install the MD_AD9833 library using the Arduino IDE Library Manager
- Install the U8g2 library using the Arduino IDE Library Manager
- Upload the func-gen-ad9833.ino sketch to the Arduino UNO
- The OLED should now display a frequency and the wave type. The selected digits might seem to change randomly. That's OK because some of the input pins on the Arduino are still floating (we'll fix that in the next step).
- You should now be able to rotate the encoder shaft and see the selected value change
Downloads
Connect the Switches

- Connect the left red switch to digital pin 2 of the Arduino
- Connect the encoder push switch to pin 3
- Connect the right red switch to pin 6
- Connect the yellow switch to pin 7
- You should now be able to change which digit is selected by using the red switches. The yellow switch changes the signal type (sine, square, triangle). The encoder button sends the changes to the AD9833 module (which of course we don't have connected yet!)
CAUTION: The output of the AD9833 is about 0.7V for the Sine and Triangle waves. However when generating a square wave the output is 5V.
Wire Up the AD9833 Module

- Insert the AD9833 module into the breadboard as shown above
- Wire up the module as follows:
- VCC to 5V
- DGND to GND
- SDATA to pin digital pin 11 of the Arduino
- SCLK to pin 13
- FSYNC to pin 10
- AGND to GND
- OUT is where we measure the signal (next step)
Testing

- Connect the output and ground of the AD9833 module to your signal viewing device of choice
- Use a combination of the red buttons and the rotary switch to select the desired frequency
- Use the yellow button to select the type of wave you wish to generate
- Press the encoder button to send the current settings to the AD9833
CAUTION: The output of the AD9833 is about 0.7V for the Sine and Triangle waves. However when generating a square wave the output is 5V.