Browse over 10,000 Electronics Projects

AD9834 and the IoT Beacon

AD9834 and the IoT Beacon

I’ve been playing with a new RF generator for the IoT beacon

Actually, I do myself a disservice, because I’ve done rather more than just play with the RF generator.

First, I’ve replaced the little USB to serial dongle which I used to program the original system and built a complete interface, using the same FTDI chip which was on the original dongle. The thinking behind this is to avoid the requirements for a clumsy interface to some of the more unusual UART lines (such as RTS and DTR), which are not taken out to the nice big header pins on a standard USB-Serial device.

Then, I’ve changed the RF generator – moving from the AD9850 DDS module as used previously to the AD9834 chip. You can see the hardware here…

Getting the FT 232R device talking to the ESP8266 was easy. But arranging the interface to the AD9834 was a little less straightforward.

I have the AD9834 on a DIL carrier (thanks Dennis) and I built the master clock oscillator on some “prototyping area” at the top of that carrier board, as you can see in the photo below…

The hardware all seemed to work FB – so all that was needed was some code for the ESP8266.

Fortunately, Nick Johnson has written an Arduino library to control the AD983x, which is available here .

Unfortunately, the library didn’t work with the ESP8266 (I can’t say whether it works with anything else as I didn’t try it).

I did some head scratching and ended up writing some code which implemented a software SPI interface between the ESP8266 and the AD9834 and got that running OK.  That was enough to allow me to see that the problem with the library appeared to be an issue with the specification of the SPI Mode…

I played with a little test program for SPI on the ESP8266…


Setting the SPI DataMode to 2 (which was the mode used in the library) results in a data transfer in which the data is read at upward transitions of the clock signal, as demonstrated by this capture of the output of one burst from the test program above on the logic analyser…

(I’ve added the red annotation to the logic analyser screen to try to show what’s going on – the arrows define the time instants when the data is valid and the binary data speaks for itself).

If the DataMode is changed to 1, the data is valid on the falling transitions of the clock …

Certainly, the AD9834 data sheet specifies that the serial data should be valid on downward transitions of SCLK (see Figure 5, page 6).

Suddenly, the AD9834 was working fine, producing nice sine waves at its output…

What you can’t see from the clumsy photo of my ‘scope screen above is that the frequency is actually being changed once a second – the ESP8266 can control the AD9834.

A note of caution: there are some known ‘holes’ in the ESP8266’s implementation of the SPI Modes (mainly with the clock ‘polarity’ – not with clock phase). I don’t know if what I’ve described above relates to ALL applications of the ad983x library – or just to its use with the ESP8266. I haven’t the time (or the need) to test with other controllers. If you use it elsewhere, take care.

All that I care about is that the FT 232R / ESP8266 / AD9834 combo is now ready to work as the ‘brain’ of a QRSS beacon.

…-.- de m0xpd