The AD9833

Introduction

Today (October 2018) the AD9850 boards on eBay go for about £10, but you can buy a similar product based around the AD98333 for about £2.50 or £5 with buffers and fancy connectors.

The AD9850 handles higher-frequencies (up to 60MHz) whilst the AD8933 is limited to 12.5MHz. That’s fine for me though: I’m interested in frequencies below 100kHz. To be pedantic the AD9833 can handle frequencies up to half the frequency of the reference clock, but all the eBay boards use a 25MHz oscillator.

I was interested in using these to build a swept-frequency generator i.e. to create a signal which is basically sinusoidal with slowly increasing frequency.

Incidentally you can also get similar boards based around the Silicon Labs Si53514 chip. These generate multiple clocks and cost about £10.

A conceptual view

At the heart of the AD9833 is a phase accumulator which increments at a rate determined by both the external master clock and the value loaded into one of the chip’s registers. The official block diagram shows this:

You can see there is more than I’ve described. In particular:

The AD9833 lets you store two different frequencies and then switch between them easily. This makes it easier to implement frequency-shift keying5.

The phase of the output can also be tweaked. This makes it easier to implement phase-shift keying6.

However, we can ignore these if we just want to generate a slowly changing sine wave.

Arduino interfacing

Google will furnish many articles on ad9833 arduino7, but it’s not quite clear of their relative merits.

Most of the libraries implement a C++ class which hides the functionality of the chip behind a nice API. Sadly the one I tried seemed to reset the phase accumulator when the frequency changed, leading to discontinuities in the output.

Given the datasheet, It is simple to program the chip to generate a single frequency, so I thought it better to just drive it directly.

There is one wrinkle though: although the interface to the AD9833 is essentially SPI, blog posts commonly talk about it finding it hard to use the system SPI and instead use bespoke bit-banging code. I followed that advice here, and stole the SPI code from Marco Colli’s library8.