top of page

[ENG] AD9850 signal generator + Arduino (basic and cheap items for a maker laboratory)

In this post i will talk how to configure and use a simple low cost signal/function generator, and in the next post i will talk about the low cost oscilloscope/logic analyzer, all for personal maker laboratories (this oscilloscope i already use in this post).

All the steps that i had done in this post was recorded and could be visualized at the video below:

Signal/Function Generator (wikipedia)

A signal generator is an electronic device that generates repeating or non-repeating electronic signals in either the analog or the digital domain. It is generally used in designing, testing, troubleshooting, and repairing electronic or electroacoustic devices, though it often has artistic uses as well.

Traditionally, signal generators have been embedded hardware units, but since the age of multimedia PCs, flexible, programmable software tone generators have also been available.

Low cost maker signal generator

This post maker signal generator will be done based on HC-SR08 module with AD9850 embedded chip. This module with the embedded chip is easily purchased in sites like deal extreme por $12.99 ($14.39 @ ebay). The below pictures illustrates in two ways the module different pinouts and components, as well as the PCB top and bottom.

The HC-SR08 module embeds a complete digital synthesizer AD9850 ASIC (Direct Digital Synthesizer - DDS), an arbitrary waveform frequency synthesizer that create waveform from a single fixed frequency reference. The module could be powered by 3.3V or 5V DC supply (i had used 5 volts in this post).

The AD9850 core uses a digital configuration frequency word of 32 bits that provides 0.0291 Hz frequency resolution for an 125 MHz seed clock. AD9850 circuit architecture allows a generated frequency up to half of the seed frequency (62.5 MHz), where the output frequency could be changed asynchronously and digitally in a 23M frequencies changes per second, this allows a data modulation rate up to 16M symbols per second, considering Nyquist criterion).

The device also has a phase control through a five bit control word, allowing phase increments (modulation) of 180°, 90°, 45°, 22.5°, 11.25°, or any combination between these options.

The AD9850 contains a high speed comparator which could be configured to allow an external DAC filtered output generating low jitter square waveform, facilitating this device use as an agile configurable clock generator.

A frequency tuning word, control and phase are loaded into the AD9850 through an parallel 8-bit interface or serial interface (we will use the serial interface in this post).

A single HC-SR08 module enables the user to extract two complementary square waveforms (3.3-5V peak-to-peak) and two complementary sine waveforms (1V peak-to-peak), with tuning frequencies from 0.02 Hertz up to 40 MHz (with good signal quality).

3) Hardware

HC-SR08 AD9850 with ARDUINO circuit connections

I have used jumper cables (male-female) to connect the AD9850 with an Arduino UNO. You can easily find these cables at ebay around $2.73 (120 jumper set with 40 male-male, 40 male-female and 40 female-female).

4) Firmware

You can find all firmware for the Arduino board at my github repository (

The firmware was developed in C++ in Eclipse environment configured to work with Arduino boards through Sloeber plugin (see previous post about how to mount and configure this environment).

The firmware uses serial communication port from Arduino (using serial monitor utility) to send the string information once you click on send button without CR+LF, this way it is not recommended to use TeraTerm or Hyperterminal, to set the signal generator frequency. Follow below the header string that appear at Arduino serial monitor utility when you connect after compile and download the firmware to the Arduino UNO.

Signal Generator - jrfo Please enter frequency in Hz:

One class was built to communicate with the HC-SR08 (AD9850) module (i had used the following link code as base). Inside this class it is possible to call several methods (functions when we instantiate an AD9850 object), however the more important methods for our application are: begin (to initialize the HC-SR08 to be controlled), calibrate (optional, used to fine calibrate the AD9850) and setfreq (the main method which sets the desired frequency passed as an argument to the DDS).

The above pictures illustrates the serial communication logic diagrams presented at the AD9850 datasheet (called in the initialization method begin_priv called from begin method), illustrates the frequency and phase update command logic diagrams (executed by the method setFreq after acquire the desired frequency to adjust through the serial monitor communication).

General firmware flow:

a) Before setup function we instantiate an global DDS object through the following code line: "static hc_sr08::ad9850 dds;" inside signal_generator.cpp file.

b) Inside setup function (signal_generator.cpp), we realize the following initialization steps: led pin initialization at Arduino (this led will visually indicate firmware activity), serial port communication initialization (9600, 8 bits, no parity, 1 stop bit = 9600 8N1), AD9850 instance pins configuration/initialization with it's respective pins as arguments "begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN)", which configures all respective pins (Arduino UNO pins 8, 9, 10, 11), and AD9850 calibration (optional).

c) Inside loop function it is printed on the prompt the header string (Arduino serial monitor) questioning about which frequency the user wants to adjust at AD9850, and then will execute a led blinking to show activity every time that pass into loop function, followed by a conditional execution of frequency adjustment if some frequency is inputted by the user.

5) Integration and tests

In this section i will integrate all things mentioned above as well as validate the AD9850 communication interface through an oscilloscope (generated signal) and logic analyzer (communication protocol).

To implement this generator test integration, i had used an very cheap oscilloscope/logic analyzer (Hantek 6022BL). This oscilloscope costs only $89 dollars at Amazon.

I really recommend this oscilloscope for low speed maker activities, that makes use of signal frequencies up to 5MHz. I have to say this because the 48M oscilloscope sample rate, when we look this against the most common rule of thumb (that recommends to have at least 10 points per frequency), this implies for the Hantek 6022BL oscilloscope a maximum read signal frequency of 4.8 MHz, approximately 5MHz.

Additionally, this oscilloscope is very interesting because it embeds a 16 channel logic analyzer. The only issue for this logic analyzer today is that the hantek software to acquire this data is really awful. However the logic analyzer firmware is compatible with the excellent saleae logic analyzer software as shown in this post. Then in this post i have made the use of the saleae software to get the communication timing diagrams with the AD9850.

In case you have problems with Hantek driver installation (it is common to appear a digital signature problem), follow the link for the digitally signed driver for windows 10.

To use Hantek as an oscilloscope, it is necessary to push the Hantek back button to the position H (as shown in the above figure). To use Hantek as a logic analyzer compatible with saleae software, it is necessary to push the Hantek back button to the position P. Just remember that this must be done with the Hantek powered off, and both drivers and softwares for oscilloscope and logic analyzer must be properly installed.

The above picture illustrates the sine and square (at same time) setup test bench (considering that the device is tuning only at 1MHz), This setup gets at same time the sine and square waves (normal and complementary waves) with two oscilloscope channels.

It is easy to see that the signals are really complementary through the 180º of phase difference, the both signals are exactly at 1MHz as previously configured through the serial monitor interface, and the both sine signals presents 1 Vpp (volt peak-to-peak) and the square waves presents 5 Vpp (volt peak-to-peak).

The above pictures illustrates the logic analyzer connected and the acquired wave forms when we are communicating with the AD9850. The first logic diagram presents the serial mode communication selection, the second logic diagram presents the first two bytes from the serial communication when we are adjusting the AD9850 frequency.

With the Arduino UNO we can achieve a 60-80k bits per second data rate, then we are capable to refresh the AD9850 frequency 42 bits command in 0.5-0.7ms or 1.9-1.4KHz using the serial communication.

The above pictures illustrates the sensed square wave with the Hantek oscilloscope for several different frequencies (1, 2 e 5 MHz), as well as visualize it's respective logic diagrams showing the tuning word that is loaded into AD9850 to configure each frequency. It is easy noted that we can reach precisely the requested frequencies at 5Vpp of output amplitude, with 50% duty cycle.

Important: In case you do not visualize oscilloscope waveform at first time, the duty cycle could stay adjusted in an extreme situation (0-100%). You can change the duty-cycle adjusting R13 trimpot available at the HC-SR08 module. Use a small screw driver to adjust trimpot and observe in same time the duty-cycle changing at oscilloscope.

Now you can ask why i do not tested frequencies beyond 5MHz (10, 20, 40MHz). The answer is that i had tested these frequencies, however due the oscilloscope bandwidth limitation (that will be show in the next post), square wave frequencies beyond 5MHz starts to generate siganl alias at the oscilloscope, which appear distorted on the Display. Follow below some examples of these distorted measurements.

It is possible to visualize that as we pass over the 5MHz signal frequency using Hantek oscilloscope to measure signal, it's limited bandwidth starts to distorce the read signal in such a way that, at 10MHz we see the square wave sensed by the Hantek as sine wave, mainly because the oscilloscope sampling rate make a high harmonics filtering, and at 10MHz signal it is only shown it's first harmonic.

For higher frequencies the filter effect is so deep that the peak-to-peak value drops and the DC level starts to domain at the oscilloscope measurement. The AD9850 continue to generate the square wave, however the oscilloscope is not capable to sense due it's sample rate (48M sample/s).

The statement for this Hantek 6022BL oscilloscope is: it worth to use it if the frequency that you want to sense is below 5MHz, otherwise don't use this scope.

6) Future works:

A - Add push-buttons and trimpots/potentiometers to make direct frequency adjustment;

B - Add an analog amplifier with adjustable gain, with and without DC level at the AD9850 outputs;

C - Add a LCD/Display to show generator information;

D - Change the serial to parallel communication interface with the AD9850 to increase the frequency update rate;

E - Implement several other functions (AM modulation, FM modulation, saw-tooth waveform and etc);


#Electronics #Firmware #Arduino #realtimemeasurement #dataaquisition #CC #Maker #osciloscope #English

Featured Posts
Recent Posts
Search By Tags
Nenhum tag.
Follow Us
  • LinkedIn Social Icon
  • Facebook Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • YouTube Social  Icon
bottom of page