Limite DAC Arduino Nano R4

Probabilmente la libreria AnalogWave, che farebbe parte di quelle incluse con il core, 1.5.1 per precisione, per le R4, ha un limite di frequenza o quanto meno ci potrebbe essere un potenziale baco.

Questo limite, comune a tutte le forme d’onda selezionabili, sinusoidale, quadra e dente di sega, risulta di 10,42KHz.

Già a questa frequenza, su oscilloscopio analogico con banda di 35MHz per ottenerla nuovamente visibile bisogna “scendere” con la base tempi in un intorno dei 20ms.

Sketch di esempio:




#include "analogWave.h" // Include the library for analog waveform generation

analogWave wave(DAC);   // Create an instance of the analogWave class, using the DAC pin

int freq = 10;  // in hertz, change accordingly

void setup() {
  Serial.begin(115200);  // Initialize serial communication at a baud rate of 115200
  wave.square(freq);       // Generate a sine wave with the initial frequency
  
}

void loop() {
 
  freq = 10420;
  // Print the updated frequency to the serial monitor
  Serial.println("Frequency is now " + String(freq) + " hz");

  wave.freq(freq);  // Set the frequency of the waveform generator to the updated value
  delay(1000);      // Delay for one second before repeating
}