Produce codes for some DDS chips

Tessellated Circuits: Home => New Home => Li'lBoard Support Calculators => AD9833 calcs.  

This is a php program that produces sets of hex codes which can be loaded into an Analog Devices AD9833 or AD9837 DDS chip to produce sweep frequency sets. You may hide/show any section that has a coloured background ± in its title.

Introduction:  ± 

Little breakout boards with these chips (especially the 10 lead MSOP AD9833) are becoming quite cheap. (I can't buy the bare ICs for less than these boards), so I thought it was time to “refactor” (software Engineering lingo for “fix”) this page...

Some features:

  • The resultant values are rounded to integers to maximize the accuracy, then converted to the hex/binary format needed;
  • The error from the ideal is printed for each computed value, both as an absolute and a percentage;
  • The maximum error (the resolution) is calculated as a function of the master clock being used. This does not include whatever error is inherent in your oscillator;
  • Sweeps can be ascending or descending;
  • Either linear or logarithmic sweeps can be selected;
  • The waveshape may be selected (sine, triangle or square);
  • Whether to use one frequency register or two is selectable;
  • The user can request that single-register writes be used if possible;
  • The outputs are formatted such that they can be just dropped into an assembler file.

How to use:  ± 

  1. Enter the chip's master clock frequency. Keep at or below the maximum for the chip;
  2. Enter the start value in the “Start Value:” box. Zero or negative numbers are replaced by 1;
  3. Similarly, enter the top value to use in the “End Value:” box. The end value can be lower than the start value, to produce decreasing steps;
  4. Enter the number of steps. There may be one more value produced in the table, depending on the “Add top value at end?” option;
  5. If the end value is wanted (at the end of the sequence, of course), tick the “Add top value at end?” box;
  6. Pick the waveform;
  7. If you want to know the effective gain error, check the “Show sin(x)/x factor?” box. More important with higher frequencies;
  8. The Method buttons choose between linear or log sweeps;
  9. It is recommended by ADI to alternate the frequency registers to produce the cleanest sweep, however this is not always desireable or necessary. The “Use one frequency register?” box controls this;
  10. The initial frequency register to use can be chosen by the last pair of “radio buttons ” Having control of this will allow chaining of tables together since the register selection should always alternate if both are used. If one register is being used this box selects it;
  11. The frequency registers are composed of two 14-bit parts. The chips can be set up to receive only one of the parts. This halves the amount of data and increases the update rate. Checking the “Use single writes if possible?” box allows the rediuction if and only if the MS14 bits are constant.;
  12. The next input field of the form is the “Double byte prefix?” box. This defaults to FCB for Freescale (Motorola) syntax, however DB could be used for other assemblers. If it is blank, then the whole code table generation step is skipped. At the end a C-like array is also produced. Note that the entries are heavily commented;

Some examples:  ± 

  1. To generate all 88 piano notes (see Wikipedia ) click here. Compare the last generated note, 4.186009005 kHz to the Wikipedia page's value, 4186.009: can't get any better!
  2. One can extend the concept to the theoretical 109-note piano from the same reference: click here. There is a slight difference in the top notes here: 7.90213301 kHz generated vs 7902.133 Hz from the table, but the difference is two digits past the table's numeric representation.

Choose the DDS IC:
AD9833 AD9837A AD9837B
Oscillator's frequency:
  in [MHz]
Start value:
  in [Hz]
End value:
  in [Hz]
Number of steps?
 
Add top value at end?

Waveform:
sine triangle square square f/2
Show sin(x)/x factor?

Method:
linear logarithmic
Use one frequency register?

First/start frequency register:
FREQ0 FREQ1
Use single writes if possible?

Double byte prefix?
  (If blank, no formatted codes produced.)