Bonjour à tous,
Depuis de nombreux jours, j'essaye de générer un signal à l'aide du module AD9850 et d'un Arduino Uno R3.
J'ai donc testé plusieurs codes que j'ai trouvé ainsi que lu la fiche technique du produit de nombreuses fois. Cependant, malgré beaucoup de tentatives, je n'obtiens aucun signal sinusoïdal. >:(
Voici le code que j'utilise :
// 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); delayMicroseconds(10); digitalWrite(pin, LOW); delayMicroseconds(10);}
// 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);
delayMicroseconds(10);
// 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
uint32_t freq = frequency * 4294967295 / 125000000;
Serial.print("Frequency word: ");
Serial.println(freq);
// Send the frequency word, one byte at a time
for(int b = 0; b < 4; b++, freq >>= 8)
{
byte dataByte = freq & 0xFF;
Serial.print("Sending byte: ");
Serial.println(dataByte);
tfr_byte(dataByte);
}
// Send control byte (0x000)
Serial.println("Sending control byte: 0x00");
tfr_byte(0x00);
// Generate a pulse on the FQ_UD pin to update the frequency
pulseHigh(FQ_UD);
}
void setup() {
// Start serial communication
Serial.begin(9600);
Serial.println("Starting setup");
// Set the pin modes to OUTPUT
pinMode(FQ_UD, OUTPUT);
pinMode(W_CLK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(RESET, OUTPUT);
// Initialize the AD9850
digitalWrite(RESET, LOW);
digitalWrite(W_CLK, LOW);
digitalWrite(FQ_UD, LOW);
digitalWrite(DATA, LOW);
// Reset the AD9850
Serial.println("Resetting AD9850...");
digitalWrite(RESET, HIGH);
delay(500); // Hold reset high for a while
digitalWrite(RESET, LOW);
pulseHigh(W_CLK);
pulseHigh(FQ_UD);
// Set a default frequency
Serial.println("Sending frequency...");
sendFrequency(1000000); // 1 MHz
Serial.println("Setup complete.");
}
void loop() {
// Infinite loop to stop further execution
while(1);
}
Sur les pins de sorties j'obtiens des valeurs de tensions constantes à VCC/2 (VCC = 3.3V ou 5V). Les seules cas ou j'obtiens un tension est quand le circuit est alimenté sans RESET.
Je m'en remets donc à vous car je ne trouve pas de solution.
Si vous avez besoin d'une quelconque autre infos concernant mon montage ou une autre question, je reste à votre disposition !
Je vous remercie pour toute l'aide que vous pourrez me donner ! ;D
Tilopecs
Depuis de nombreux jours, j'essaye de générer un signal à l'aide du module AD9850 et d'un Arduino Uno R3.
J'ai donc testé plusieurs codes que j'ai trouvé ainsi que lu la fiche technique du produit de nombreuses fois. Cependant, malgré beaucoup de tentatives, je n'obtiens aucun signal sinusoïdal. >:(
Voici le code que j'utilise :
// 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); delayMicroseconds(10); digitalWrite(pin, LOW); delayMicroseconds(10);}
// 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);
delayMicroseconds(10);
// 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
uint32_t freq = frequency * 4294967295 / 125000000;
Serial.print("Frequency word: ");
Serial.println(freq);
// Send the frequency word, one byte at a time
for(int b = 0; b < 4; b++, freq >>= 8)
{
byte dataByte = freq & 0xFF;
Serial.print("Sending byte: ");
Serial.println(dataByte);
tfr_byte(dataByte);
}
// Send control byte (0x000)
Serial.println("Sending control byte: 0x00");
tfr_byte(0x00);
// Generate a pulse on the FQ_UD pin to update the frequency
pulseHigh(FQ_UD);
}
void setup() {
// Start serial communication
Serial.begin(9600);
Serial.println("Starting setup");
// Set the pin modes to OUTPUT
pinMode(FQ_UD, OUTPUT);
pinMode(W_CLK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(RESET, OUTPUT);
// Initialize the AD9850
digitalWrite(RESET, LOW);
digitalWrite(W_CLK, LOW);
digitalWrite(FQ_UD, LOW);
digitalWrite(DATA, LOW);
// Reset the AD9850
Serial.println("Resetting AD9850...");
digitalWrite(RESET, HIGH);
delay(500); // Hold reset high for a while
digitalWrite(RESET, LOW);
pulseHigh(W_CLK);
pulseHigh(FQ_UD);
// Set a default frequency
Serial.println("Sending frequency...");
sendFrequency(1000000); // 1 MHz
Serial.println("Setup complete.");
}
void loop() {
// Infinite loop to stop further execution
while(1);
}
Sur les pins de sorties j'obtiens des valeurs de tensions constantes à VCC/2 (VCC = 3.3V ou 5V). Les seules cas ou j'obtiens un tension est quand le circuit est alimenté sans RESET.
Je m'en remets donc à vous car je ne trouve pas de solution.
Si vous avez besoin d'une quelconque autre infos concernant mon montage ou une autre question, je reste à votre disposition !
Je vous remercie pour toute l'aide que vous pourrez me donner ! ;D
Tilopecs