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!


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.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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