Tone generator off a Nano (classic)

@SamBrownADK - I looked around for a library that might be less of a slog than mozzi.

I found nothing I would recommend.

Whatever you end up doing, you will have learned some things. I wonder aloud whether getting to know a library well enough would be better (easier, good for your future (!) &c.) than just figuring out how DDS works and how the Arduino can do it.

You would learn what is at the base of any DDS device or library.

In any case you have a final problem which is getting the audio out of the Arduino. analogWrite() is not suitable. Conceptually yes, but the PWM carrier frequency is too low. mozzi does some clever tricks behind the scenes, but it's output is also PWM that must be filtered to be usable. It's not a big deal, the rate is fast enough so a simple RC filter works.

You can get d/a converter ICs or modules; SPI comms is fast enough to keep up with a decent sample rate.

a7

Ok, thank you. I was wondering how to do the other side of the coin: have a nano read the wave form. Even if the “audio” is just a square wave from tone(), how to read the “wave form” (it would be 50% duty cycle)? I would probably have to do some timing tricks with interupts i am guessing. Do you know of such a library for arduino so i dont have to reinvent the wheel? Thanl you in advance.

There is a function, pulseIn(pin, HIGH) that measures the length of the pulse in microseconds. It also works with (pin, LOW).

@SamBrownADK
If you are doing audio processing and signal generation, a teensy and the Audio system design tool might be all you need

I looked into the teensy 4.0 years ago. A fantastic board and superior to nano, mega, etc. But i want not to have yet another ecosystem to what i have aready. So i hope to use the standard nano / uno / mega2560.

Thanks Herb. I will check it out.