6

I'm trying to figure out a way to use the raspberry pi to generate AC waveforms of any arbitrary shape. Ideally, using a programable IC where the wave forms are dictated entirely by the higher level software thats programmed into the pi and loaded onto the IC via SPI communication.

I discovered the programable AD9833 by analog devices, yet it only produces square, triangle, and sine waves at different frequencies.

If anyone has any ideas on how to get started on this project or seen other accomplish this before, any information would be great!

2
  • You mean something like this?: instructables.com/…
    – Mladen B.
    Commented Sep 12, 2021 at 7:56
  • What is the highest frequency you want to use in your function generator ?
    – Matt
    Commented Sep 13, 2021 at 5:41

2 Answers 2

1

You are basically asking for an audio DAC to add to your RPi. Actually, your RPi already has two of them, and they are accessible from the audio jack as the two stereo channels. To output arbitrary waveforms through them basically means to play sounds!

The way you output audio on the RPi depends on your software configuration, but you may get good results using PortAudio

If the iternals DACs are not hi-fi enough for you, the last resorts are either using the I2S bus of your RPi or using custom code to drive some other kind of DAC. This is going to be harder, though.

1
  • same comment as for the other answer: audio spectrum is just a tiny range of frequencies... you can't even compare that range with the AD9833 capabilities ("0 MHz to 12.5 MHz output frequency range") that OP mentioned in the question
    – Mladen B.
    Commented Sep 12, 2021 at 8:02
1

For a simple solution, why don't you use audacity to generate waveforms. Install it like so :

sudo apt install audacity

You can also generate waveforms on the fly using SoX :

sudo apt install sox

Here is an example for generating a 10 second square wave :

 sox synth 10s square 10 0 0

Alternatively, you could program your own algorithms to generate waveforms either to file or in real time using libsox, jackd and even ALSA, here is an example set of programming tutorials using gtkIOStream.

2
  • audio spectrum is just a tiny range of frequencies... you can't even compare that range with the AD9833 capabilities ("0 MHz to 12.5 MHz output frequency range") that OP mentioned in the question
    – Mladen B.
    Commented Sep 12, 2021 at 8:01
  • That really depends on what the highest frequency the function generator should have!
    – Matt
    Commented Sep 13, 2021 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.