I2S DAC overshooting signal form

dg9ngf
Posts: 2
Joined: Mon Sep 16, 2019 6:49 pm

I2S DAC overshooting signal form

Postby dg9ngf » Mon Sep 16, 2019 7:09 pm

Hello,

I'm playing with my first experiments using an ESP32. My current aim is to play a fixed frequency sine wave as long as a button is pressed. The tone should start and end smoothly and goes through an audio amplifier to a loudspeaker. In the future, the button presses will be analysed and Morse code will be decoded.

For now I'm having some issues with the waveform generation (like the frequency is wrong and the are noisy sounds at the start and end of a tone, but I'll look into this further and may create another topic for that). One of them is that the signal looks a bit strange to me. I've attached a screenshot of what I see on the oscilloscope, measuring the DAC output to ground. It looks the same with or without the amplifier in place. The DAC is connected over two resistors (10k and 330 Ω) to ground, in the middle point the amplifier may be connected.

The timing of the discrete voltage levels looks good, resulting in about 44 kHz sampling rate. Just the transistions between the levels look odd. Is this normal? Am I measuring wrong?

Here's some extract of my code from Arduino:

Code: Select all

#include "driver/i2s.h"

// I2S configuration 
int i2s_num = 0;   // I2S port number
i2s_config_t i2s_config =
{
  .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
  .sample_rate = 44100,
  .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
  .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
  .communication_format = I2S_COMM_FORMAT_I2S_MSB,
  .intr_alloc_flags = 0,   // Default interrupt priority
  .dma_buf_count = 8,
  .dma_buf_len = 55,
  .use_apll = false
};

void setup()
{
  // Initialize I2S with configurations above
  i2s_driver_install((i2s_port_t)i2s_num, &i2s_config, 0, NULL);
  i2s_set_dac_mode(I2S_DAC_CHANNEL_RIGHT_EN);   // Pin 25

  while (true)
  {
    // ...
    uint8_t buffer[i2s_config.dma_buf_len];
    // ...
    size_t bytes_written;
    i2s_write((i2s_port_t)i2s_num, buffer, i2s_config.dma_buf_len * sizeof(uint8_t), &bytes_written, 100);
  }
}

void loop()
{
}
Attachments
NewFile1_marked.png
Signal screenshot
NewFile1_marked.png (28.99 KiB) Viewed 125 times

ESP_Sprite
Posts: 2832
Joined: Thu Nov 26, 2015 4:08 am

Re: I2S DAC overshooting signal form

Postby ESP_Sprite » Tue Sep 17, 2019 3:20 am

This looks more-or-less normal. Internally, the DAC consists of a bank of resistors that are switched on or off. The glitch you see is probably from the fact that not all switches switch at exactly the same time. I wouldn't worry about them: there is very little energy in them and the rest of your audio path is probably lowpass enough that it'll filter it out.

Who is online

Users browsing this forum: No registered users and 9 guests