Tuesday 16 October 2012

Filter for the AD9835 Function Generator

In the last post I used the AD9835 Breakout board from Sparkfun.  I'm going to use it to make a function generator for my local hackspace and probably one for my own bench too.  I could buy one but that doesn't get me loads of content for the blog and I think I can add some value by adding features that aren't available on some Bench Function Generators.

A quick search on Ebay showed that good function generators on Ebay cost around £200.  I think I can do a little better with the one I'm designing but we shall see.....There are some awful ones for a lot less and If I was in a real hurry I might consider buying one.  Buying test equipment is always a problem for engineers and hobbyists alike.

The Sparkfun AD9835 breakout board cost £26.46.  I don't think that's too bad a deal.  It was quick to get up and running and produces a pretty good sine wave.  I like the fact that I can use it with my arduino and it's a great learning project as to make a full function generator will use a lot of different electronic techniques to achieve what is required.

And now back to the Function generator...

The one thing that isn't provided on the AD9835 breakout board is a filter.  Why does it need a filter? Well.....you could use it as is without one but prolonged use will show that it's output is tainted with the 50MHz source clock coming from the reference oscillator on the breakout board....That sounded very technical!  What does that mean?  The tainted bit means that the sine wave at the output will look very square and choppy at certain frequencies because of interference from the reference clock. In order to get the AD9835 DDS chip to work it needs a 50 MHz reference clock which is a square wave pulse which oscillates (changes state from High to Low) every 0.00000002 seconds or 20 nanoseconds.   It is better to have what is known as a spectrally pure output which is an output with only the signal we want and not the 50 MHz reference clock.  

Oscilloscope Screenshots showing the output of the AD9835 when it's output hasn't been filtered. 
If we look at the output of the breakout board in terms of frequency instead of time by using a spectrum analyser we can more easily visualise the problem.  A spectrum analyser is a special piece of test equipment quite like an oscilloscope that shows a graph electronic signals with volts on the 'y' axis and frequency on the 'x' axis.  It's a piece of test equipment that RF engineers use all the time.  I wish I had my own sometimes!  I have the use of a couple at work...which is helpful.

Spectral Output of the AD9835 when unfiltered.  
In order to get a spectrally pure output we are going to have to add what is known as a low pass filter to the output of the AD9835 breakout board.

Electronic Filters are special circuits that are used to purify electronic signals.  It's a way of removing the parts of the signal we don't want leaving the information that we do want.  A real world example of a filter is a pair of sunglasses.  We don't want our eyes to be dazzled by bright light so we filter the bright light out using some darkened lenses.

Anyway the AD9835 breakboard needs a filter to remove the 50 MHz reference clock.  When I specified what I wanted the function generator to do I specified that the frequency output range needs to be from 1 Hz to 10 MHz.  This being the case we can now design a filter that allows all signals to pass through the filter up to 10 MHz but completely blocks any signals above 10 MHz.  To  give us some margin I'm going to design the filter to cut off (stop allowing signals through) at about 15 MHz - this is known as the corner frequency.  The filter is known as a 'Low Pass Filter' - this is because it allows low frequency signals through but blocks (attenuates) high frequency signals.  Other types of filters are available including High Pass, Notch, Bandpass etc.

Filters is a huge subject in electronics and there are several thousand books and tutorials on the subject.  There are so many different types of filter that I can't cover them all here.  If people need more information on filters then the following sites might be of some help:

http://en.wikipedia.org/wiki/Filter_(signal_processing)
http://www.allaboutcircuits.com/vol_2/chpt_8/1.html

For the AD9835 breakout board I'm going to design a passive filter known as a 'Chebyshev' filter.  It is a passive filter made of inductors and capacitors.  It's called Chebychev because it uses polynomials found the by the Russian Mathematician Pafnuty Chebyshev.  The mathematics involved are incredibly complicated.  I'll be honest....I didn't go through it all and do lots of Maths.  I used an online filter calculator like this one:

http://www.wa4dsy.net/filter/hp_lp_filter.html

I used the one built in to National Instrument's simulation software - Multisim.  It came out with the following circuit.  I changed the values to suit what I had available.

AD9835 Filter circuit with values

Ignore the 0V DC source - its present to allow me to simulate the circuit.  What I'm going to simulate is what will happen at the output of this circuit if we place a sine wave at Vin with a frequency from
1 Hz to 50 MHz.  This is where circuit simulators are very useful as they can tell the design engineer how a circuit is going to respond before building it.  It gives confirmation as to what should happen. Simulators are also very useful because you can change component values and see what that changes to the circuit's function.  All good design engineers should use simulators - it's the best way to quickly check the function of a circuit.


So here is the result of a frequency sweep from 1 Hz to 50 MHz:


Chebychev Filter using 4.7uH Inductors and 100pF Capacitors
The top graph or trace shows the filter response.  If a 1 V sine wave is placed at the input with a frequency less than 12 MHz the signal will not be reduced or attenuated in size.  If the signal is above 12 MHz it will drop in magnitude at the rate indicated by the slope of the graph.  

The lower trace is the phase relationship between the input signal and the output signal.  What that means is that at around 7 MHz the phase between the input signal and output signal reverses.  In our case this doesn't really matter but it might be of interest if you need to ensure that the input signal is always in phase and not reversed (audio circuits....perhaps).

So....if we construct this filter carefully using the above components and a sensible PCB layout we will get the above response.....Well guess what I did and here it is:



The above screen shot seems to correlate quite nicely with the trace from the simulation.  This means that the filter works and my layout was sufficient to provide the correct response.  Not bad seeing as that was incredibly rushed and I paid no attention to component placement!  Sometimes I'm lucky!

Here is a video showing the testing:




I wish I could afford a Vector Network analyser for my own nefarious purposes!  For some reason my missus won't let me buy one...at £25000 I suppose I understand!  Vector network analysers are a very specialised piece of electronics instrumentation used for assessing the frequency response of electronic circuits and cables.  The one I used in the above video has a frequency range of 100 kHz to 8 GHz!  We use it at work for testing antennas, filters, amplifiers and coaxial cables.

So now that we have proved this part of the design, I'm going to add this filter circuit to the output of the AD9835 breakout board.  This will prevent the reference clock interfering with the output.  The next part of the circuit to design will be the amplifier stage.  

Cheers for reading - take care

Alex
    

No comments :

Post a Comment