Feed a pulse signal to update the output based on input parameters
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 CS1_PIN = getValue<input_CS1>(ctx);
Number CS2_PIN = getValue<input_CS2>(ctx);
AD9833 chip1(CS1_PIN);
AD9833 chip2(CS2_PIN);
chip1.Begin();
chip2.Begin();
chip1.EnableOutput(false);
chip2.EnableOutput(false);
Number FREQ1 = getValue<input_FREQ1>(ctx);
Number FREQ2 = getValue<input_FREQ2>(ctx);
Number PH1 = getValue<input_PH1>(ctx);
Number PH2 = getValue<input_PH2>(ctx);
Number WAVE1 = getValue<input_WAVE1>(ctx);
Number WAVE2 = getValue<input_WAVE2>(ctx);
if(WAVE1==0){chip1.SetWaveform(REG0,SINE_WAVE);}
if(WAVE1==1){chip1.SetWaveform(REG0,TRIANGLE_WAVE);}
if(WAVE1==2){chip1.SetWaveform(REG0,SQUARE_WAVE);}
if(WAVE2==0){chip2.SetWaveform(REG0,SINE_WAVE);}
if(WAVE2==1){chip2.SetWaveform(REG0,TRIANGLE_WAVE);}
if(WAVE2==2){chip2.SetWaveform(REG0,SQUARE_WAVE);}
chip1.SetFrequency(REG0,FREQ1);
chip2.SetFrequency(REG0,FREQ2);
chip1.SetPhase(REG0,PH1);
chip2.SetPhase(REG0,PH2);
digitalWrite(CS1_PIN,LOW);
digitalWrite(CS2_PIN,LOW);
chip1.EnableOutput(true);
chip2.EnableOutput(true);
digitalWrite(CS1_PIN,HIGH);
digitalWrite(CS2_PIN,HIGH);
emitValue<output_DONE>(ctx, 1);
};