Arduino Nano, and AD9850, how can I decrease my sweep time

I am currently using Arduino and AD9850 to output frequency from 0 to 200Khz. it takes about 7 to 8 seconds to complete a sweep. How can I decrease the sweeping time?

#include <AD9850SPI.h>
#include <SPI.h>
const int W_CLK_PIN = 13;
const int FQ_UD_PIN = 8;
const int RESET_PIN = 9;
int phase = 0;
void setup() {
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, RESET_PIN);
  DDS.calibrate(124999500);
}
void loop() {
  sweep();
  DDS.down();
  delayMicroseconds(200);
  DDS.up();
}
void sweep() {
  for (unsigned long freq = 1; freq <= 200000; freq++) {
    DDS.setfreq(freq, phase);
  }
}

Decrease this number:
delayMicroseconds(200);

Increase by more than 1 here:
for (unsigned long freq = 1; freq <= 200000; freq++) {

Instead of freq++, use freq = freq + 2, or 3 or 10 or whatever

Do you really need a linear scale, with all 199998 values between 1 and 200000? If you change the datatype of freq to a double, you could replace freq++ with (for example) freq*=1.1 to create a logarithmic scale. That would make it a lot faster, and also make more sense (IMHO). This will of course not end at exactly 200,000Hz!

PS.: Or use steps of 1.05946309436 (= twelfth root of two), which is a semitone. That will give 12 steps per octave (= ratio 1:2).

I cannot use logarithm scale as it will miss frequency in-between.
"Use a step of 1.05946309436" Can you explain more on what this is? Could you give an example.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.