Generating a Swept Sine Wave on Arduino Zero

Hi everyone,

I'm working on a project using the Arduino Zero, and I need to generate a swept sine wave (i.e., a sine wave whose frequency changes over time, also called a chirp signal).

I understand that the Arduino Zero has a DAC, which should be useful for outputting analog signals. My goal is to generate a sine wave that sweeps from a lower frequency (e.g., 1 Hz) to a higher one (e.g., 100 Hz) over a given sweep rate.

Has anyone done something similar with the Zero? What would be the best approach for this?

I'm particularly interested in:

  • Whether to use a lookup table or generate the values on the fly
  • How to control the frequency sweep (e.g., linear or logarithmic)
  • Timing accuracy and DAC update rate limits
  • Any sample code or library recommendations

Thanks in advance!

The DAC can support up to 350,000 samples per second, but with a frequency as low as 100Hz, I doubt that is a problem.

The key question is what resolution are you expecting on the output? With 8 bit resolution you need to output a sample every 39 us, which is not a lot of time. A lookup table would be required.

There are quite a few examples for the Zero, it should be easy to adapt one.

When you say "8 bit resolution", are you referring to a sampling rate of 255 samples per period?

To get an 8-bit resolution on the output voltage amplitude, the sampling rate would need to be about 80 kS/s, so 12 µs per sample.