MD_AD9833 Programmable Waveform Generator Library 1.3
Library to manage AD9833 Programmable Waveform Generator
Loading...
Searching...
No Matches
MD_AD9833 Class Reference

#include <MD_AD9833.h>

Public Types

enum  channel_t { CHAN_0 = 0 , CHAN_1 = 1 }
 
enum  mode_t {
  MODE_OFF , MODE_SINE , MODE_SQUARE1 , MODE_SQUARE2 ,
  MODE_TRIANGLE
}
 

Public Member Functions

 MD_AD9833 (uint8_t dataPin, uint8_t clkPin, uint8_t fsyncPin)
 
 MD_AD9833 (uint8_t fsyncPin)
 
void begin (void)
 
void reset (bool hold=false)
 
 ~MD_AD9833 ()
 
Methods for AD9833 frequency control
mode_t getMode (void)
 
boolean setMode (mode_t mode)
 
channel_t getActiveFrequency (void)
 
boolean setActiveFrequency (channel_t chan)
 
float getFrequency (channel_t chan)
 
boolean setFrequency (channel_t chan, float freq)
 
uint32_t getClk (void)
 
void setClk (uint32_t freq)
 
Methods for AD98933 phase control
channel_t getActivePhase (void)
 
boolean setActivePhase (channel_t chan)
 
uint16_t getPhase (channel_t chan)
 
boolean setPhase (channel_t chan, uint16_t phase)
 

Detailed Description

Core object for the MD_AD9833 library

Member Enumeration Documentation

◆ channel_t

Channel enumerated type.

This enumerated type is used to specify which channel is being invoked on operations that could be channel related.

Enumerator
CHAN_0 

Channel 0 definition.

CHAN_1 

Channel 1 definition.

◆ mode_t

Output mode request enumerated type.

This enumerated type is used with the setMode() methods to identify the mode request.

Enumerator
MODE_OFF 

Set output all off.

MODE_SINE 

Set output to a sine wave at selected frequency.

MODE_SQUARE1 

Set output to a square wave at selected frequency.

MODE_SQUARE2 

Set output to a square wave at half selected frequency.

MODE_TRIANGLE 

Set output to a triangle wave at selected frequency.

Constructor & Destructor Documentation

◆ MD_AD9833() [1/2]

MD_AD9833::MD_AD9833 ( uint8_t dataPin,
uint8_t clkPin,
uint8_t fsyncPin )

Class Constructor - arbitrary digital interface.

Instantiate a new instance of the class. The parameters passed are used to connect the software to the hardware. Multiple instances may co-exist but they should not share the same hardware Fsync pin (SPI interface).

Parameters
dataPinoutput on the Arduino where data gets shifted out.
clkPinoutput for the clock signal.
fsyncPinoutput for selecting the device.

◆ MD_AD9833() [2/2]

MD_AD9833::MD_AD9833 ( uint8_t fsyncPin)

Class Constructor - Hardware SPI interface.

Instantiate a new instance of the class. The SPI library is used to run the native SPI hardware on the MCU to connect the software to the hardware. Multiple instances may co-exist but they should not share the same hardware Fsync pin (SPI interface).

Parameters
fsyncPinoutput for selecting the device.

◆ ~MD_AD9833()

MD_AD9833::~MD_AD9833 ( void )

Class Destructor.

Released allocated memory and does the necessary to clean up once the object is no longer required.

Member Function Documentation

◆ begin()

void MD_AD9833::begin ( void )

Initialize the object.

Initialize the object data. This needs to be called during setup() to initialize new data for the class that cannot be done during the object creation.

The AD9833 hardware is reset and set up to output a 1kHz Sine wave, 0 degrees phase angle, CHAN_0 is selected as source for frequency and phase output.

◆ getActiveFrequency()

MD_AD9833::channel_t MD_AD9833::getActiveFrequency ( void )

Get current frequency output channel

Get the last specified AD9833 frequency output channel selection.

See also
setActiveFrequency()
Returns
last frequency setting for the waveform

◆ getActivePhase()

MD_AD9833::channel_t MD_AD9833::getActivePhase ( void )

Get current phase output channel

Get the last specified AD9833 phase output channel selection.

See also
setActivePhase()
Returns
last phase setting for the waveform

◆ getClk()

uint32_t MD_AD9833::getClk ( void )

Get AD9833 reference clock frequency

Get the last specified AD9833 reference clock frequency.

See also
setClk()
Returns
the last frequency setting for the specified channel

◆ getFrequency()

float MD_AD9833::getFrequency ( channel_t chan)

Get channel frequency

Get the last specified AD9833 channel output frequency.

See also
setFrequency()
Parameters
chanoutput channel identifier (channel_t)
Returns
the last frequency setting for the specified channel

◆ getMode()

mode_t MD_AD9833::getMode ( void )

Get channel output waveform

Get the last specified AD9833 channel output waveform.

See also
setMode()
Returns
last mode_t setting for the waveform

◆ getPhase()

uint16_t MD_AD9833::getPhase ( channel_t chan)

Get channel phase

Get the last specified AD9833 channel phase setting in tenths of a degree.

See also
setPhase()
Parameters
chanoutput channel identifier (channel_t)
Returns
the last phase setting in degrees [0..3600] for the specified channel

◆ reset()

void MD_AD9833::reset ( bool hold = false)

Reset the AD9833 hardware output

The AD9833 reset function resets appropriate internal registers to 0 to provide an analog output of midscale. Reset does not reset the phase, frequency, or control registers.

Parameters
holdoptional parameter that holds the reset state. Default is false (no hold).

◆ setActiveFrequency()

boolean MD_AD9833::setActiveFrequency ( channel_t chan)

Set the frequency channel for output

Set the specified AD9833 frequency setting as the output frequency.

See also
getActiveFrequency()
Parameters
chanoutput channel identifier (channel_t)
Returns
true if successful, false otherwise

◆ setActivePhase()

boolean MD_AD9833::setActivePhase ( channel_t chan)

Set the phase channel for output

Set the specified AD9833 phase setting as the output phase.

See also
getActivePhase()
Parameters
chanoutput channel identifier (channel_t)
Returns
true if successful, false otherwise

◆ setClk()

void MD_AD9833::setClk ( uint32_t freq)

Set AD9833 reference clock frequency

Set the specified AD9833 reference clock frequency.

The library sets the value SD_MCLK at initializations, which will be suitable for most applications.

See also
getClk()
Parameters
referencefreq frequency in Hz

◆ setFrequency()

boolean MD_AD9833::setFrequency ( channel_t chan,
float freq )

Set channel frequency

Set the specified AD9833 channel output frequency.

See also
getFrequency()
Parameters
chanoutput channel identifier (channel_t)
freqfrequency in Hz
Returns
true if successful, false otherwise

◆ setMode()

boolean MD_AD9833::setMode ( mode_t mode)

Set channel output mode

Set the specified AD9833 channel output waveform to one of the mode_t types.

See also
getMode()
Parameters
modewave output defined by one of the mode_t enumerations
Returns
true if successful, false otherwise

◆ setPhase()

boolean MD_AD9833::setPhase ( channel_t chan,
uint16_t phase )

Set channel phase

Set the specified AD9833 channel output phase in tenths of a degree. 100.1 degrees is passed as 1001.

See also
getPhase()
Parameters
chanoutput channel identifier (channel_t)
phasein tenths of a degree [0..3600]
Returns
true if successful, false otherwise

The documentation for this class was generated from the following files: