Hello,
I'm trying to get the AD9850 module to work using an Arduino UNO R3. After uploading the code, I get no signal.
I looked at the outputs with a multimeter: the second sinusoidal output saturates at 1.7V and the first square output saturates at the supply voltage (3.3V or 5V).
Here's the code I used. Can you explain what could happen? Could it be the AD9850 module, the arduino or the code?
// Pin definitions
#define W_CLK 7
#define FQ_UD 8
#define DATA 9
#define RESET 10
// Macro to generate a high pulse on a pin
#define pulseHigh(pin) {digitalWrite(pin, HIGH); delay(1) ; digitalWrite(pin, LOW); delay(1);}
// Function to transfer a byte to the AD9850
void tfr_byte(byte data)
{
for(int i = 0; i < 8; i++, data >>= 1) {
// Send the least significant bit of data to the DATA pin
digitalWrite(DATA, data & 0x01);
delay(1);
// Generate a pulse on the W_CLK pin
pulseHigh(W_CLK);
}
}
// Function to send the desired frequency to the AD9850
void sendFrequency(double frequency) {
// Calculate the frequency word
int32_t freq = frequency*4294967295/125000000;
// Send the frequency word, one byte at a time
for(int b=0; b<4; b++, freq>>= 8)
{
tfr_byte(freq & 0xFF);
}
// Send control byte (0x000)
tfr_byte(0x000);
// Generate a pulse on the FQ_UD pin to update the frequency
pulseHigh(FQ_UD);
}
void setup() {
// Set the pin modes to OUTPUT
pinMode(FQ_UD, OUTPUT);
pinMode(W_CLK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(RESET, OUTPUT);
// Initialize the AD9850 with pulses on RESET, W_CLK, and FQ_UD pins
pulseHigh(RESET);
pulseHigh(W_CLK);
pulseHigh(FQ_UD);
}
void loop() {
// Set the frequency
sendFrequency(100);
// Infinite loop to stop further execution
while(1);
}
Thanks for any help.
All the best,
Timothée.