Sunday, February 27, 2011

Fun with DACs

Today I have been playing around with an AD5330 8 bit DAC (datasheet) and generating different waveforms.  For inspiration, I am using a document from Analog Devices (MT-085 Tutorial) on the Fundamentals of Direct Digital Synthesis (DDS).  This is an excellent primer on the subject and I recommend it highly.

The setup is an Arduino Uno and a breadboarded AD5330 DAC from SparkFun.

From a block diagramme perspective, I have implemented a Numerically Controlled Oscillator as shown below (from MT-085 referenced above):

The "System Clock" initially in my software implementation is just the main loop of the Arduino sketch.  Each time through the loop, the phase accumulator contents is updated.  The tuning word (M stored in the delta phase register) is added to the number in the phase accumulator.  I use the upper 8 bits of the phase accumulator as the address of a lookup table containing the digital amplitude information for whatever waveform I am generating.  This table maps the phase information from the phase accumulator to a digital amplitude word which then drives the DAC.

As you can see from the photographs below, this prototype is only a proof-of-concept implementation and the system clock will need be a much more granular (and stable) implementation.  The next step is to implement the system clock in a timer interrupt handler firing at about a 32KHz rate to make the waveform output much smoother.

I can change the waveform by just filling the digital amplitude lookup table with appropriate values.  I have implemented SIN, Square, Triangle, Sawtooth with a positive slope, Sawtooth with a negative slope and random waveforms.  It should be a simple matter to allow for a custom waveform to be uploaded in a general purpose function generator implementation (a project for another day perhaps...).

Off to figure out Arduino timers.  I have used them to generate PWM output, but now need to figure out how to just generate an interrupt a precise intervals without interfering with the various digital output pins I require for DAC purposes.

1 comment:

  1. Jeff,

    I love your New Blog, it is fun to keep up with your project.

    Hey, I recommended that you include links in the blog page to your resources, it is a nice way to share and bookmark associated data you use on your projects. Ether way, it is great blog.

    Eldon - WA0UWH

    ReplyDelete