Catégories
Liens
Ceci est une ancienne révision du document !
2 sine wave and 2 square wave output AD9850: 0-40MHz After the 20-30MHz frequency harmonics increases, the waveform will be less and less clean Square Wave: 0-1MHz Low-pass filter with 70MHz, so the waveform better than SN Parallel and serial data input can be selected via a jumper DA produced the benchmark pin (PIN12) leads for easy adjustment to do the magnitude of the output waveform Application Comparator reference input voltage generated by the variable resistor, the resistor can be adjusted duty cycle square wave of different Active AD9850 125MHz crystal oscillator modules
Sans librairie à installer
/* * USE TWO AD9850 * Modified from http://nr8o.dhlpilotcentral.com/?p=83 */ // 1st MODULE #define W_CLK 8 // Pin 8 - connect to AD9850 module word load clock pin (CLK) #define FQ_UD 9 // Pin 9 - connect to freq update pin (FQ) #define DATA 10 // Pin 10 - connect to serial data load pin (DATA) #define RESET 11 // Pin 11 - connect to reset pin (RST). // 2nd MODULE #define W_CLK2 4 // Pin 4 - connect to AD9850 module word load clock pin (CLK) #define FQ_UD2 5 // Pin 5 - connect to freq update pin (FQ) #define DATA2 6 // Pin 6 - connect to serial data load pin (DATA) #define RESET2 7 // Pin 7 - connect to reset pin (RST). #define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); } // transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line void tfr_byte(byte data, int pin_clock, int pin_data) { for (int i=0; i<8; i++, data>>=1) { digitalWrite(pin_data, data & 0x01); pulseHigh(pin_clock); //after each bit sent, CLK is pulsed high } } // frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32 void sendFrequency(double frequency, int pin_clock, int pin_fq, int pin_data) { int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on 9850 for (int b=0; b<4; b++, freq>>=8) { tfr_byte(freq & 0xFF, pin_clock, pin_data); } tfr_byte(0x000, pin_clock, pin_data); // Final control byte, all 0 for 9850 chip pulseHigh(pin_fq); // Done! Should see output } void setup() { // configure arduino data pins for output pinMode(FQ_UD, OUTPUT); pinMode(W_CLK, OUTPUT); pinMode(DATA, OUTPUT); pinMode(RESET, OUTPUT); pinMode(FQ_UD2, OUTPUT); pinMode(W_CLK2, OUTPUT); pinMode(DATA2, OUTPUT); pinMode(RESET2, OUTPUT); pulseHigh(RESET); pulseHigh(W_CLK); pulseHigh(FQ_UD); // this pulse enables serial mode - Datasheet page 12 figure 10 pulseHigh(RESET2); pulseHigh(W_CLK2); pulseHigh(FQ_UD2); // this pulse enables serial mode - Datasheet page 12 figure 10 } void loop() { sendFrequency(1320, W_CLK, FQ_UD, DATA); // freq sendFrequency(440, W_CLK2, FQ_UD2, DATA2); // freq while(1); }
Avec la librairie AH_AD9850.h
// from http://www.arduino-projekte.de #include <AH_AD9850.h> #define CLK 6 #define FQUP 7 #define BitData 8 #define RESET 9 AH_AD9850 AD9850(CLK, FQUP, BitData, RESET); void setup() { AD9850.reset(); //reset module delay(1000); AD9850.powerDown(); //set signal output to LOW // initialize serial communication Serial.begin(9600); } void loop(){ //set_frequency(boolean PowerDown, byte Phase, double Freq); AD9850.set_frequency(0,0,1000); //set power=UP, phase=0, 1kHz frequency delay(1000); AD9850.set_frequency(2500); //set 2.5kHz frequency delay(1000); AD9850 << 5000; //set 5kHz frequency in C++ style delay(1000); //phase test for (int phase=0;phase<32;phase++) { AD9850.set_frequency(0, phase, 1000); //change phase delay in 11.25°(2PI/32) steps delay(1000); } }