ad9833

hussainfawzi/ad9833-dds/ad9833

No description
ad9833
@/ad9833
CSport
Chip select pin
FREQnumber
Frenquency in Hz
WAVEnumber
Waveform: 0 - SINEWAVE 1 - TRIANGLE WAVE 2 - SQUARE WAVE
UPDATEpulse
Feed a pulse signal to update the output based on input parameters
ad9833
DONE
CS
FREQ
WAVE
UPDATE
DONEpulse
Spits a pulse when done.
To use the node in your project you should have the hussainfawzi/ad9833-dds library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD require "https://github.com/Billwilliams1952/AD9833-Library-Arduino"

{{#global}}
#include <AD9833.h>
{{/global}}

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    if (!isInputDirty<input_UPDATE>(ctx))
        return;

    Number CS_PIN = getValue<input_CS>(ctx);
    AD9833 chip(CS_PIN);
    chip.Begin();
    chip.EnableOutput(false);
    Number FREQ = getValue<input_FREQ>(ctx);
    Number WAVE = getValue<input_WAVE>(ctx);
    if(WAVE==0){chip.SetWaveform(REG0,SINE_WAVE);}
    if(WAVE==1){chip.SetWaveform(REG0,TRIANGLE_WAVE);}
    if(WAVE==2){chip.SetWaveform(REG0,SQUARE_WAVE);}
    chip.SetFrequency(REG0,FREQ);
    digitalWrite(CS_PIN,LOW);
    chip.EnableOutput(true);
    digitalWrite(CS_PIN,HIGH);
    emitValue<output_DONE>(ctx, 1);
};