Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

otAD9833 Class Reference
[AD9833 - Library to control the AD9833 DDS waveform generator., AD9833 - Library to control the AD9833 DDS waveform generator.]

Library to control the AD9833 DDS waveform generator. The library allows the user to independently program frequency, phase, and waveform type for both registers. The AD9833 is a low power, programmable waveform generator capable of producing sine, triangular, and square wave outputs.
Waveform generation is required in various types of sensing, actuation, and time domain reflectometry (TDR) applications.
The output frequency and phase are software programmable, allowing easy tuning.
No external components are needed.
The frequency registers are 28 bits wide: with a 25 MHz clock rate, resolution of 0.1 Hz can be achieved; with a 1 MHz clock rate, the AD9833 can be tuned to 0.004 Hz resolution.
The AD9833 is written to via a 3-wire serial interface.
This serial interface operates at clock rates up to 40 MHz and is compatible with DSP and microcontroller standards.
The device operates with a power supply from 2.3 V to 5.5 V.
.

#include <otAD9833.h>


Public Types

enum  WaveformType { SINE_WAVE = 0x2000, TRIANGLE_WAVE = 0x2002, SQUARE_WAVE = 0x2028, HALF_SQUARE_WAVE = 0x2020 }
enum  Registers { REG0, REG1, SAME_AS_REG0 }

Public Member Functions

 otAD9833 ()
void init (int id, U32 referenceFrequency=25000000UL)
void applySignal (U16 waveType, U8 freqReg, F32 frequencyInHz, U8 phaseReg=SAME_AS_REG0, F32 phaseInDeg=0.0)
void reset ()
void setFrequency (U8 freqReg, F32 frequency)
void incrementFrequency (U8 freqReg, F32 freqIncHz)
void setPhase (U8 phaseReg, F32 phaseInDeg)
void incrementPhase (U8 phaseReg, F32 phaseIncDeg)
void setWaveform (U8 waveFormReg, U16 waveType)
void setOutputSource (U8 freqReg, U8 phaseReg=SAME_AS_REG0)
void enableOutput (bool enable)
void sleepMode (bool enable)
void disableDAC (bool enable)
void disableInternalClock (bool enable)
F32 getActualProgrammedFrequency (U8 reg)
F32 getActualProgrammedPhase (U8 reg)
F32 getResolution ()


Member Enumeration Documentation

enum otAD9833::Registers
 

Enumeration values:
REG0  Register 0.
REG1  Register 1.
SAME_AS_REG0 

enum otAD9833::WaveformType
 

Enumeration values:
SINE_WAVE  Sine wave.
TRIANGLE_WAVE  Triangle wave.
SQUARE_WAVE  Square wave.
HALF_SQUARE_WAVE  Half square wave.


Constructor & Destructor Documentation

otAD9833.otAD9833 (   ) 
 

Create the class


Member Function Documentation

void otAD9833.applySignal (  U16  waveType,
U8  freqReg,
F32  frequencyInHz,
U8  phaseReg = SAME_AS_REG0,
F32  phaseInDeg = 0.0
) 
 

Setup and apply a signal. Note that any calls to enableOutput, sleepMode, disableDAC, or disableInternalClock remain in effect

Parameters:
waveType Waveform type, see WaveformType
freqReg Used register, see Registers
frequencyInHz Desidered output frequency as Hz
phaseReg Register for phase controls. See Registers
phaseInDeg Phase angle

void otAD9833.disableDAC (  bool  enable  ) 
 

Enable / Disable DAC

Parameters:
enable True enable

void otAD9833.disableInternalClock (  bool  enable  ) 
 

Enable / Disable Internal Clock

Parameters:
enable True enable

void otAD9833.enableOutput (  bool  enable  ) 
 

Turn ON / OFF output using the RESET command.

Parameters:
enable True enable

F32 otAD9833.getActualProgrammedFrequency (  U8  reg  ) 
 

Return actual frequency programmed in register

Parameters:
reg Used register, see Registers
Returns:
Frequency

F32 otAD9833.getActualProgrammedPhase (  U8  reg  ) 
 

Return actual phase programmed in register

Parameters:
reg Used register, see Registers
Returns:
Current phase

F32 otAD9833.getResolution (   ) 
 

Return frequency resolution

Returns:
Frequency resolution

void otAD9833.incrementFrequency (  U8  freqReg,
F32  freqIncHz
) 
 

Increment the selected frequency register by freqIncHz

Parameters:
freqReg Used register, see Registers
freqIncHz Frequency increment as Hz

void otAD9833.incrementPhase (  U8  phaseReg,
F32  phaseIncDeg
) 
 

Increment the selected phase register by phaseIncDeg

Parameters:
phaseReg Used register, see Registers
phaseIncDeg Phase angle increment

void otAD9833.init (  int  id,
U32  referenceFrequency = 25000000UL
) 
 

Must be the first command after creating the AD9833 object.

Parameters:
id SPI address
referenceFrequency Time base as Hz

void otAD9833.reset (   ) 
 

Resets internal registers to 0, which corresponds to an output of midscale - digital output at 0. See EnableOutput function

void otAD9833.setFrequency (  U8  freqReg,
F32  frequency
) 
 

Update just the frequency in REG0 or REG1

Parameters:
freqReg Used register, see Registers
frequency Desidered output frequency as Hz

void otAD9833.setOutputSource (  U8  freqReg,
U8  phaseReg = SAME_AS_REG0
) 
 

Output based on the contents of REG0 or REG1

Parameters:
freqReg Used register, see Registers
phaseReg Register for phase controls. See Registers

void otAD9833.setPhase (  U8  phaseReg,
F32  phaseInDeg
) 
 

Update just the phase in REG0 or REG1

Parameters:
phaseReg Used register, see Registers
phaseInDeg Phase angle

void otAD9833.setWaveform (  U8  waveFormReg,
U16  waveType
) 
 

Set the output waveform for the selected frequency register

Parameters:
waveFormReg Used register, see Registers
waveType Waveform type, see WaveformType

void otAD9833.sleepMode (  bool  enable  ) 
 

Enable/disable Sleep mode. Internal clock and DAC disabled

Parameters:
enable True enable


The documentation for this class was generated from the following file: footer
otStudio - Library Reference - (C) 2020-25 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0