Generate an arbitrary function by DAC

Hello,

I would like to make a small project (a function generator) with ESP32-WROOM in wich the final goal is to generate an arbitrary function regulated form some setting. My aims is to imitate as much as possible the functions generated from this software below WHITHOUT GUI

My aim is to have tha following features (without GUI)

  • Two channels Left and Right

  • Generation of Sine, Square and Sawtooth wave

  • Modulation AM and FM at low rate (minimum 0.01hz - maximum 100hz)

  • SWEEP in frequency and apmlitude

I want create a function generator controlled by a rotary swith and some buttons but for now I want design only the function generator controlled by serial port.

QUESTIONS 1
Is this project feasable? I mean can i realize a device that generate a function at enought high frequency? My goal is to reach the wave frequency of 5000hz. Is it possible to implement it with ESP32?

QUESTIONS 2
How can I acheive my aim (for example) to generate a 5000hz with AM of 2hz wave?

QUESTIONS 3
I've tried this example that outputs from the DAC a value of -1.7v (0) and a value of 1.7v (255) and I found that the maximum frequency that i can go is around 27khz (see below). If is is like that do i have some chance to generate a 5000hz with AM of 2hz wave and let the microcontroller do other tasks for others (for example to talk via computer by serial)?

CODE: SELECT ALL

#define DAC_CH1 25

void setup() {
}
 
void loop() {
  while(1){
    dacWrite(DAC_CH1, 0);
    dacWrite(DAC_CH1, 255);
  }
}

THANKS

what sampling freq to you think you need? for a sine wave. without filtering

See if this runs faster:
Also set your scope to DC coupling not AC

#include <driver/dac_common.h>

void setup() {
    dac_output_enable(DAC_CHANNEL_1);
}

void loop() {

    dac_output_voltage(DAC_CHANNEL_1, 0);
    dac_output_voltage(DAC_CHANNEL_1, 255);

}

Probably not with that Arduino. 27 kHz is as fast as it can generate output without calculating any of the output values.

have a look at sawtooth-ramp-wave-generator-using-arduino-uno for some example code using an ESP32
also using a DDS module - generating-good-signal-with-60-khz-not-possible

I guess that ESP32 is not fast enought to process digital audio and generate enought fast signal... Is it true?

Do you have other arduino/raspberry pi - like board that you can advice for my project?

Thanks

What kind of processing do you want to do?

telephone quality speech processing is sampled at 8 kHz and 8biit mu-law coding and uses digital signal processors designed for that task.

music quality (~20 kHz) is sampled around 44-48 kHz and at least 16-bits

i don't know of an Arduino like processor that is a DSP

have a look at Texas DSP
however, their dev boards tend to be a bit expensive compared to Ardunos and ESP32s

but can they be used with the Arduino IDE?

besides the DSP, probably also need an DAC that outputs samples based on a sample clock

not as far as I know - I always used Code Composer Studio

the DSP boards I used had plug in daughter ADC and DAC boards but there may be dev boards with DSPs and onboard ADCs and DACs

it's been a couple decades since i used a TI dsp in an optical amplifier. what is the interface between the PC and the board you used?

gigabit Ethernet sampling signals in 1 to 5MHz range

  • Generation of Sine, Square and Sawtooth wave
  • Modulation AM and FM at low rate (minimum 0.01hz - maximum 100hz)
  • SWEEP in frequency and apmlitude

You should look at using a Teensy 4.1 and the Audio library.
https://www.pjrc.com/teensy/td_libs_Audio.html

doubt you used ADC/DAC for sampled ethernet since it's digital

i asked what was the interface between code composer and the DSP? some JTAG connection?

sampling two analogue signals looking at phase difference results sent over ethernet

cannot remember - it was some time ago - probably JTAG

Thanks for sharing these examples of generating waveforms using an ESP32 and DDS module. It's a great resource for anyone looking to explore signal generation projects. 101 Generator

About ESP32 DAC, and what you can do with it : https://deepbluembedded.com/esp32-dac-audio-arduino-examples/

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