• No se han encontrado resultados

Direct Digital Synthesis (DDS) is a method of producing an analog waveform (usually a sine wave) by generating a time-varying signal in digital form and then performing a digital-to-analog conversion. Because operations within a DDS device are primarily digital, this gives fast switching between output frequencies, fine frequency resolution, and operation over a broad spectrum of frequencies.

The ability to accurately produce and control waveforms of various frequencies and profiles has become a key requirement common to a number of industries. Many possibilities for frequency generation are open to a designer, but the DDS technique is rapidly gaining acceptance for solving frequency (or waveform) generation requirements in both communications and industrial applications because single-chip IC devices can generate programmable analog output waveforms simply and with high resolution and accuracy. By using modern DDS chips, we can obtain sine wave, triangular and rectangle signals with low-level total harmonic distortion (THD).

This section describes the programmable waveform oscillator using a popular DDS chip AD9850 which can produce the sine wave and square wave signals in a wide range of frequencies. The device output frequency is controlled through the SPI-compatible interface by the BeagleBone Black board. Before we start describing the

hardware/software let’s see on how AD9850 works. The brief description that follows is taken from the datasheet on the device.

The AD9850 is a highly integrated device that uses advanced DDS technology coupled with an internal high speed, high performance D/A converter and comparator to form a complete, digitally programmable frequency synthesizer and clock generator function.

When referenced to an accurate clock source, the AD9850 generates a spectrally pure, frequency/phase programmable, analog output sine wave. This sine wave can be used directly as a frequency source, or it can be converted to a square wave for agile-clock generator applications.

The AD9850’s innovative high speed DDS core provides a 32-bit frequency tuning word, which results in an output tuning resolution of 0.0291 Hz for a 125 MHz reference clock input. The AD9850’s circuit architecture allows the generation of output frequencies of up to one-half the reference clock frequency (or 62.5 MHz), and the output frequency can be digitally changed (asynchronously) at a rate of up to 23 million new frequencies per

second. The device also provides five bits of digitally controlled phase modulation, which

enables phase shifting of its output in increments of 180°, 90°, 45°, 22.5°, 11.25°, and any combination thereof. The AD9850 also contains a high speed comparator that can be configured to accept the (externally) filtered output of the DAC to generate a low jitter square wave output. This facilitates the device’s use as an agile clock generator function.

The frequency tuning, control, and phase modulation words are loaded into the AD9850 via a parallel byte or serial loading format. The parallel load format consists of five iterative loads of an 8-bit control word (byte). The first byte controls phase modulation, power-down enable, and loading format; Bytes 2 to 5 comprise the 32-bit frequency

tuning word. Serial loading is accomplished via a 40-bit serial data stream on a single pin.

The AD9850 Complete DDS uses advanced CMOS technology to provide this

breakthrough level of functionality and performance on just 155 mW of power dissipation (3.3 V supply).

The following circuit diagram (Fig.71) illustrates connecting AD9850 to the BeagleBone Black.

Fig.71

Assembling such a circuit can be a hard work, so it would be much better to apply one of numerous low-cost ready-to-use modules with AD9850. One of such modules taken to this project is shown in Fig.72.

Fig.72

It is seen that the reference clock fed to the AD9850 chip is 125 MHz, therefore the output frequency can reach 62.5 MHz. As to this module, it is stated that the real output

frequency can reach 40 MHz because of the low-pass filter placed at the DAC output of AD9850. However, the developers experimenting with this module will be capable to pull up the output to its maximal frequency.

The project described here uses the above module. Fig.73 shows connections between the AD9850 module and the BeagleBone Black board.

Fig.73

In this circuit, the DATA line (pin D7 of AD9850) is connected to pin P8.15 of the

BeagleBone. The framing signal FQ_UD goes to pin P8.14 and the clock input W_CLK of AD9850 goes to pin P8.13 of the BeagleBone Black.

Note that the connections in circuit shown in Fig.73 are specific for my own AD9850 board purchased at www.dx.com; the pin configuration on other AD9850 boards may be

different, so you must carefully examine your own AD9850 board before connecting it to the BeagleBone!

In order to calculate the tuning word for configuring the AD9850 output frequency, we need to know the relationship of the output frequency, reference clock, and tuning word of the AD9850. This is determined by the formula taken from the datasheet on AD9850 (Fig.74).

Fig.74

Here ΔPhase is the value of the 32-bit tuning word, CLKIN is the input reference clock frequency in MHz and fOUT is the frequency of the output signal in MHz.

The following source code (Listing 27) allows to directly set the output frequency using the formula shown above.

Listing 27.

import Adafruit_BBIO.GPIO as GPIO import math

FQ_UD = “P8_14” # AD9850 FQ_UD pin is tied to P8_14 W_CLK = “P8_13” # AD9850 W_CLK pin is tied to P8_13 DAT = “P8_15” # AD9850 DATA pin is tied to P8_15

def setFreq(freq):

freqWord = freq * pow(2, 32) / 125000000 # ref.clock = 125MHz mask = 0x1;

w = 0;

while (w < 32): # writing bits W0—>W31 GPIO.output(W_CLK, GPIO.LOW)

GPIO.output(DAT, freqWord & mask)

GPIO.output(W_CLK, GPIO.HIGH) freqWord = freqWord >> 1

w += 1 w = 32

while (w < 40): # writing the last byte = 0x0, bits W32—>W39 GPIO.output(W_CLK, GPIO.LOW)

GPIO.output(DAT, GPIO.LOW) GPIO.output(W_CLK, GPIO.HIGH) w += 1

GPIO.output(FQ_UD, GPIO.HIGH)

GPIO.setup(FQ_UD, GPIO.OUT) # set P8_14 as output GPIO.setup(W_CLK, GPIO.OUT) # set P8_13 as output GPIO.setup(DAT, GPIO.OUT) # set P8_15 as output

GPIO.output(W_CLK, GPIO.HIGH) GPIO.output(W_CLK, GPIO.LOW) GPIO.output(FQ_UD, GPIO.HIGH) GPIO.output(FQ_UD, GPIO.LOW) setFreq(27599); # output frequency in Hz

In this source code, the setFreq() function sets the frequency of the sine wave output of AD9850. The function takes a single parameter which the desired frequency in Hz. When entered, the function calculates the binary code corresponding to the output frequency and stores the value in the freqWord variable by executing the following statement:

freqWord = freq * pow(2, 32) / 125000000

Then the freqWord bits are written to the AD9850 control registers using two while loops. The W_CLK, FQ_UD and DAT constants are assigned the pins being used in the SPI interface.

Documento similar