MD_AD9833 Programmable Waveform Generator Library 1.3
Library to manage AD9833 Programmable Waveform Generator
|
#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) |
Core object for the MD_AD9833 library
enum MD_AD9833::channel_t |
enum MD_AD9833::mode_t |
Output mode request enumerated type.
This enumerated type is used with the setMode() methods to identify the mode request.
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).
dataPin | output on the Arduino where data gets shifted out. |
clkPin | output for the clock signal. |
fsyncPin | output for selecting the device. |
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).
fsyncPin | output for selecting the device. |
MD_AD9833::~MD_AD9833 | ( | void | ) |
Class Destructor.
Released allocated memory and does the necessary to clean up once the object is no longer required.
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.
MD_AD9833::channel_t MD_AD9833::getActiveFrequency | ( | void | ) |
Get current frequency output channel
Get the last specified AD9833 frequency output channel selection.
MD_AD9833::channel_t MD_AD9833::getActivePhase | ( | void | ) |
Get current phase output channel
Get the last specified AD9833 phase output channel selection.
uint32_t MD_AD9833::getClk | ( | void | ) |
Get AD9833 reference clock frequency
Get the last specified AD9833 reference clock frequency.
float MD_AD9833::getFrequency | ( | channel_t | chan | ) |
Get channel frequency
Get the last specified AD9833 channel output frequency.
chan | output channel identifier (channel_t) |
mode_t MD_AD9833::getMode | ( | void | ) |
Get channel output waveform
Get the last specified AD9833 channel output waveform.
uint16_t MD_AD9833::getPhase | ( | channel_t | chan | ) |
Get channel phase
Get the last specified AD9833 channel phase setting in tenths of a degree.
chan | output channel identifier (channel_t) |
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.
hold | optional parameter that holds the reset state. Default is false (no hold). |
boolean MD_AD9833::setActiveFrequency | ( | channel_t | chan | ) |
Set the frequency channel for output
Set the specified AD9833 frequency setting as the output frequency.
chan | output channel identifier (channel_t) |
boolean MD_AD9833::setActivePhase | ( | channel_t | chan | ) |
Set the phase channel for output
Set the specified AD9833 phase setting as the output phase.
chan | output channel identifier (channel_t) |
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.
reference | freq frequency in Hz |
boolean MD_AD9833::setFrequency | ( | channel_t | chan, |
float | freq ) |
Set channel frequency
Set the specified AD9833 channel output frequency.
chan | output channel identifier (channel_t) |
freq | frequency in Hz |
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.
mode | wave output defined by one of the mode_t enumerations |
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.
chan | output channel identifier (channel_t) |
phase | in tenths of a degree [0..3600] |