Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: excessive ringing on WAVEFORM waves

  1. #1
    Member
    Join Date
    Aug 2016
    Location
    Texas
    Posts
    25

    excessive ringing on WAVEFORM waves

    Anyone else notice excessive "ringing" when looking at the output of the waveforms on a scope when using the WAVEFORM oscillator?

    As a test I have a WAVEFORM module wired directly to the i2S1 output, set the frequency to 1000, and look at the waveforms output by the audio shield.
    Sine and Triangle seem fine, but Saw, Square, S/H all have excessive ringing at transient points. This is not from my oscilloscope not being calibrated either.

    As a side note, PULSE waveform doesn't seem to generate any signal.

    At first I thought I was hearing aliasing but this should not be occurring at this medium frequency should it?
    Then I though maybe it's the additional harmonics of these waveforms causing the aliasing, but it should be possible to make a square wave up to 20K with nice sharp edges (ie, without this ringing) shouldn't it?

    Haven't tried it yet, but would assume that even using the PWM pin output I would get better high frequency square waves than what I'm seeing using the audio shield's DAC/Codec.

    Is the waveform module still a work in progress?

  2. #2
    Member
    Join Date
    Aug 2016
    Location
    Texas
    Posts
    25
    I'm begging to think this ringing is due to the SGTL5000's built in filtering.

    With a sample rate of 44,100, the ringing measures 45.3us, or a frequency of 22,050hz.
    Changing the sample rate to 22,050 lowers the ringing frequency to half what it was, and doubling the sample rate increases the ringing to 2x in frequency.

    When sending the waveform to the Teensy's 12 bit DAC I see only nice stair-stepped waveform as expected.

    I also made sure on the SGTL5000 that all audio processing was off.

    It's interesting that I don't notice issues when playing back rather high frequency samples, but it is obvious when playing back waveforms.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,860
    Would you like me to take a look here?

    If so, I need you to post the exact code I should copy into Arduino and run here.

  4. #4
    Member
    Join Date
    Aug 2016
    Location
    Texas
    Posts
    25
    Hi Paul,

    My work computer is not online for easy transfer of code into the forum. However the test setup was simply to wire a WAVEFORM object to the i2S1 output object in the GUI. The write simple code to define sawtooth as the waveform, with a frequency of 1,000hz.
    At other times I had a potentiometer controlling the frequency of the oscillator, but removed this from the equation as even small jumps in value are likely to occur which can add other inconsistencies in the oscillator pitch.

    After more research and testing what I'm experiencing appears to be due to what other term band-limiting for the oscillator waveforms. As I read other people saying that lookup tables are used for higher octave waveforms that essentially reduce the harmonic content of the waveform, limiting the amount of harmonics or overtones that would occur above nyquist.

    However that still does not answer my question of where are these overtones becoming offensive?
    A DAC can create whatever waveform within the sample rate limit. However even a 20Khz square wave generated by a DAC will contain harmonics past nyquist frequency. The DAC really does not care that these additional harmonics exist, it is still capable of producing a 20K square wave.

    So then I ask is it the filter function following the DAC in the Codec that is the issue?

    I tried placing an 8 pole low pass filter between the WAVEFORM object and the i2S1 output, and set the filter to 5,000hz, and 10,000hz. Still terrible aliasing and ringing occurs. I really don't understand this, as the more offensive higher frequencies should not be getting to the DAC/Codec.

    Yet if I select a sine waveform in the WAVEFORM object, I can run it up to 15,000hz (without any filtering) and it still sounds pure to my ears without additional artifacts. Which is peculiar to me in that the higher a sine wave goes in frequency VS sampling rate, the more the sine wave should turn into a square wave. Although as I approach these higher frequencies with a sine wave I just don't hear that happening.

    Makes me wonder if instead of using lookup tables to do band-limiting for each higher octave... would it not work to say generate a sawtooth waveform and sine waveform simultaneously (in phase) and simply fade levels from the saw to sine as the frequency increases? Same goes for the square wave. Might be a fun experiment.

  5. #5
    Member
    Join Date
    Apr 2014
    Location
    Flevoland, 5 meters under water
    Posts
    32
    Hi FRS,

    I found this article very informative,
    it describes how and why aliasing arises, and how to band limit waveforms to avoid it.
    Band limited waveforms often still have the ringing, which seem to be called the Gibbs phenomenon.

    http://hackmeopen.com/2010/11/bandli...ble-synthesis/

    Hopefully it's useful to you.

  6. #6
    Junior Member
    Join Date
    Dec 2016
    Posts
    16
    Hey guys, I am having the same issue here with SGTL5000, i ve tryed all sorts of ways from different topics, long wire, resistor, etc. I don't have the 600ferite as shown in the audio adapter but i've tryed one smaller and no difference at all. Also i made the connection as close as i can on the pins as you can see above. the VDDD is from tennsy dac set to 1.8 V, I tryed also with a external regulator but is the same.

    Here are the connections
    Click image for larger version. 

Name:	IMG_3846.jpg 
Views:	22 
Size:	122.9 KB 
ID:	12925

    here is the code:
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveform       waveform1;      //xy=110,75
    AudioSynthWaveform       waveform2;
    AudioMixer4              mixer1;
    AudioMixer4              mixer2; 
    AudioOutputI2S           i2s1;           //xy=642,290
    AudioConnection          patchCord1(waveform1, 0, mixer1, 0);
    AudioConnection          patchCord2(waveform2, 0, mixer2, 1);
    AudioConnection          patchCord3(mixer1, 0, i2s1, 0);
    AudioConnection          patchCord4(mixer2, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;          //xy=303,78
    int freq; 
    // GUItool: end automatically generated code
    
    void setup() {
        // set pins 2 through 13 as outputs:
        pinMode(A14, OUTPUT);
        analogWriteResolution(12);
     analogWrite(A14, 2240);
      sgtl5000_1.enable();
      sgtl5000_1.volume(0.8);
      AudioMemory(15);
      waveform1.begin(WAVEFORM_SAWTOOTH);
      waveform1.amplitude(0.85);
      waveform1.frequency(480);
      waveform2.begin(WAVEFORM_SQUARE);
      waveform2.amplitude(0.85);
      waveform2.frequency(480);
    }
    
    void loop() {
    /*  
     freq = random(1, 5000);
       waveform1.frequency(freq);
        delay(1000);
         waveform2.frequency(freq);
          delay(1000);
    */
    
    }
    The two outputs on the dac showing the ringing
    Click image for larger version. 

Name:	IMG_3848.jpg 
Views:	29 
Size:	142.9 KB 
ID:	12926
    The problems are appearing only for waveforms with straight falls, for sine and triangle seems ok.
    So If anyone of you can give me any explanation and a solution i would really appreciate it.
    Thanks!

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    17,860
    Try running this and measure the digital signal on pin 3 for comparison.

    Code:
    void setup() {
      analogWriteFrequency(3, 480);
      analogWrite(3, 128);
    }
    void loop() {
    }
    If you see similar or even worse ringing, the problem is very likely how you're connecting the oscilloscope probe. Long wire between the probe tip or probe ground and the Teensy pin & ground can cause any higher bandwidth scope to show this sort of ringing. It's a well known problem with high bandwidth measurements.

  8. #8
    This is not unique to the SGTL5000. It is the result of band limiting a function that has no frequency limit. I have seen this on other sigma-delta DAC's. When you band limit, say, a square wave, the ringing represents the negative of the parts of the waveform that were removed.

    There is lore that linear-phase filtering (FIR filters) stop ringing, but not so. Never-the-less, if you compare with a single in-out path filter (called a minimum-phase filter) it is quite a bit worse than the linear phase FIR filters such as are used here.

    Bob

  9. #9
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    960
    I'm confused... don't we want that 'ringing' as it's the band limited signal itself that contains it. Having none of it would mean aliasing high frequency content as low frequency content.
    It is the result of band limiting a function that has no frequency limit.
    Huh? Doesn't band limiting mean limiting harmonic content to within Nyquist frequency?

    I'm totally an amateur with DSP but in my experience seeing sharp transitions in audio means you have or will have aliasing and you don't want that with audio.

    Am I missing something?

    (or is this just to say the filtering is too aggressive and it is limiting harmonic content well below Nyquist?? And if so the I guess Paul's post is saying it's an artifact of the scope and it's settings??)

  10. #10
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,671
    When I was young and digital audio made its way into consumer electronics (we are talking about the 1980ies), it was considered good practice to add an analog 18dB/oct or even more Bessel low pass (be it an active Sallen-Key or a passive LC) as a reconstruction filter behind each DAC to get a clean signal without artifacts...

    And by the way, thanks to M Fourier, every signal with sharp transitions (harmonics beyond the filter corner frequency) will look like ringing when low pass filtered because the higher harmonics which would compensate this are eliminated. Thus, everything looks ok for me. cf. https://archive.cnx.org/contents/72f...es-square-wave

  11. #11
    Most everything you see is within the Nyquist frequency. The square wave has frequency components at all odd multiples of the base frequency. They decline in amplitude as the number goes up, of course. The LP filter in the DAC limits this to a finite number of components, and the overshoot and ringing is the result.

    Plus some minor issues associated with real world implementation.

  12. #12
    Junior Member
    Join Date
    Dec 2016
    Posts
    16
    Quote Originally Posted by PaulStoffregen View Post
    Try running this and measure the digital signal on pin 3 for comparison.

    Code:
    void setup() {
      analogWriteFrequency(3, 480);
      analogWrite(3, 128);
    }
    void loop() {
    }
    If you see similar or even worse ringing, the problem is very likely how you're connecting the oscilloscope probe. Long wire between the probe tip or probe ground and the Teensy pin & ground can cause any higher bandwidth scope to show this sort of ringing. It's a well known problem with high bandwidth measurements.

    Hey Paul I did it, i don't think it's a probe problem, i did check with a analog one and is the same.
    Here are the two signal
    Click image for larger version. 

Name:	IMG_3852.jpg 
Views:	22 
Size:	147.5 KB 
ID:	12930

  13. #13
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,671
    This picture shows clearly that there is exactly NO problem. This is not ringing what you see, but missing higher harmonics due to low pass (nyquist) filtering. Everything is fine.

    If you add a FIR with same coefficients and depth to the digital output that you are probing, you will see the same result.

  14. #14
    Junior Member
    Join Date
    Dec 2016
    Posts
    16
    I didn't fully understand it and how to apply it, but anyway I did it from audiotool for 480 hz, and yes it's going to filter the harmonics. The problem is if i increase the frequency above 5000hz for ex, the waves are unintelligible..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •