An inexpensive DDS Signal generator based on the AD9851 module to generate sine wave of up to 70MHz (20-30MHz realistically). The module also has a built-in reference square wave up to 1 MHz, this works independent of the sine wave and the duty cycle is controlled through a potentiometer built in the module itself.
The project utilizes an Arduino Nano, I am using a clone version that can be purchased for just a couple of dollars. I am also using a rotary encoder to control the signal frequency for the sine wave. I am using the KTM-S1201 7 Segment LCD display only because it's the only display I had at hand (It's not the best option but works). The LCD display requires a potentiometer to control the display contrast.
- potentiometer (10K)
Total cost approximately $16-$20.
Wiring the componentsThe Pin connectivity can really be pretty arbitrary as you can specify the assignment in the Arduino code. However the CLK pin of the rotary encode needs to be connected to either D2 or D3 on the Arduino as these are the only two pins that support interrupt attachment on the Arduino Nano.
Rotary encoder- connect Nano D2 to encoder CLK
- connect Nano D3 to encoder DT
- connect Nano D4 to encoder SW
- connect encoder ground to ground
- connect encoder Vcc to Arduino +5v
- connect Nano D5 to DDS Reset
- connect Nano D6 to DDS Data
- connect Nano D7 to DDS Load
- connect Nano D8 to dds Clock
- connect DDS ground to ground
- connect DDS Vcc to Arduino +5v
- connect Nano D9 to LCD CD
- connect Nano D10 to LCD Reset
- connect Nano D11 to LCD CS
- connect Nano D12 to LCD N_SCK
- connect Nano D13 to LCD SI
- connect LCD ground to ground
- connec LCD Vcc to Arduino +5v
- connect pot left pin to ground
- connect pot right pin to Arduino +5v
- connect pot center to LCD CS
The code is pretty straight-forward and self explanatory and I have split it into two files for manageability. All functions related to configuring and controlling the DDS is in a separate file that gets automatically pulled in by Arduino IDE.
The top of the main file specifies the pin selection for each of the components (LCD, Rotary encoder and AD9851). The rest of the code uses the identifiers instead of the actual pin numbers. This provides flexibility in changing the wiring to suit individual design and needs.
The setup initializes the signal generator to and initial value of 5 KHz and the rotary encoder step to 1Hz. Pushing the encoder as a button increases the frequency step by multiples of 10 all the way up to 1MHz and then back to 1Hz.
The 7 Segment LCD display shows the set frequency in KHz to 4 decimal place resolution and shows the increment step when the encoder is pushed.
Next StepsThe Arduino code is available through my GitHub repository.
I plan to put everything in an enclosure to turn it into something I can use day to day. I am also thinking of using the ESP8266 or ESP32 instead of the Arduino to possibly control it over WiFi. Leave a comment if you are interested in either or both of the options.
I hope others find this useful and can implement their own version.
Comments