ad9833-3channels

hussainfawzi/ad9833-dds/ad9833-3channels

No description
ad9833-3channels
@/ad9833-3channels
CS1port
Chip1 select pin (channel-1)
CS2port
Chip2 select pin (channel-2)
CS3port
Chip3 select pin (channel-3)
FREQ1number
Frenquency in Hz for channel-1
FREQ2number
Frenquency in Hz for channel-2
FREQ3number
Frenquency in Hz for channel-3
PH1number
Phase angle (0 - 360 degrees) for channel-1
PH2number
Phase angle (0 - 360 degrees) for channel-2
PH3number
Phase angle (0 - 360 degrees) for channel-3
WAVE1number
Channel-1 waveform: 0 - SINEWAVE 1 - TRIANGLE WAVE 2 - SQUARE WAVE
WAVE2number
Channel-2 waveform: 0 - SINEWAVE 1 - TRIANGLE WAVE 2 - SQUARE WAVE
WAVE3number
Channel-3 waveform: 0 - SINEWAVE 1 - TRIANGLE WAVE 2 - SQUARE WAVE
UPDATEpulse
Feed a pulse signal to update the output based on input parameters
ad9833-3channels
DONE
CS1
CS2
CS3
FREQ1
FREQ2
FREQ3
PH1
PH2
PH3
WAVE1
WAVE2
WAVE3
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 CS1_PIN = getValue<input_CS1>(ctx);
    Number CS2_PIN = getValue<input_CS2>(ctx);
    Number CS3_PIN = getValue<input_CS3>(ctx);
    AD9833 chip1(CS1_PIN);
    AD9833 chip2(CS2_PIN);
    AD9833 chip3(CS3_PIN);
    chip1.Begin();
    chip2.Begin();
    chip3.Begin();
    chip1.EnableOutput(false);
    chip2.EnableOutput(false);
    chip3.EnableOutput(false);
    Number FREQ1 = getValue<input_FREQ1>(ctx);
    Number FREQ2 = getValue<input_FREQ2>(ctx);
    Number FREQ3 = getValue<input_FREQ3>(ctx);
    Number PH1 = getValue<input_PH1>(ctx);
    Number PH2 = getValue<input_PH2>(ctx);
    Number PH3 = getValue<input_PH3>(ctx);
    Number WAVE1 = getValue<input_WAVE1>(ctx);
    Number WAVE2 = getValue<input_WAVE2>(ctx);
    Number WAVE3 = getValue<input_WAVE3>(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);}
    if(WAVE3==0){chip3.SetWaveform(REG0,SINE_WAVE);}
    if(WAVE3==1){chip3.SetWaveform(REG0,TRIANGLE_WAVE);}
    if(WAVE3==2){chip3.SetWaveform(REG0,SQUARE_WAVE);}
    chip1.SetFrequency(REG0,FREQ1);
    chip2.SetFrequency(REG0,FREQ2);
    chip3.SetFrequency(REG0,FREQ3);
    chip1.SetPhase(REG0,PH1);
    chip2.SetPhase(REG0,PH2);
    chip3.SetPhase(REG0,PH3);
    digitalWrite(CS1_PIN,LOW);
    digitalWrite(CS2_PIN,LOW);
    digitalWrite(CS3_PIN,LOW);
    chip1.EnableOutput(true);
    chip2.EnableOutput(true);
    chip3.EnableOutput(true);
    digitalWrite(CS1_PIN,HIGH);
    digitalWrite(CS2_PIN,HIGH);
    digitalWrite(CS3_PIN,HIGH);
    emitValue<output_DONE>(ctx, 1);
};