Audio library, sine wave harmonics present that I had not seen before?

PaulS

Well-known member
Recently, while I was testing a Teensy 4.0 with this PCM5102A-based audio board, I noticed second & third harmonics showing from a 1KHz sine wave using a Scarlett 2i2 USB audio interface :

TrueRTA_TD157.png

The FFT on my scope shows the same harmonics:

SDS00089.png

What is strange is that I tested this in january 2021 and that screenshot did not show the harmonics:

TrueRTA-TD153.jpg

Also forummember Rolfdegen tested a PCM5102 board in this thread and that also shows no harmonics.

In my january 2021 post, I wrote that I was "Using Arduino 1.8.13, Teensyduino 1.53, modified output_i2s & output_pt8211 to support TLC."
Well, perhaps the audio library had changed since then, causing the harmonics?

So I reverted to that version of Arduino and Teensyduino by uninstalling my current Arduino 1.8.19 & Teensyduino 1.57 version and installing 1.8.13 & 1.53.
To be sure no remnants were left after uninstalling Arduino, I also deleted C:\Users\Paul\AppData\Local\Arduino15\ and C:\Users\Paul\AppData\Local\Temp\ .

Unfortunately that did not change the situation - still the 2nd & 3rd harmonics are present.
Then I installed the modified output_i2s & output_pt8211 I mentioned - still the 2nd & 3rd harmonics are present.

This is the code I had been using back then and still used today:

Code:
#include <Audio.h>

AudioSynthWaveformSine   sine1;
AudioOutputI2S           i2s1;
AudioConnection          patchCord1(sine1, 0, i2s1, 0);
AudioConnection          patchCord2(sine1, 0, i2s1, 1);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);

  AudioMemory(2);

  sine1.frequency(1000);
  sine1.amplitude(0.5);  // -6dB
}

void loop() {
}
What else have I tried after this?
- Arduino 1.8.12, Teensyduino 1.52
- Arduino 2.1.0, Teensyduino 1.58.1
- Teensy 3.2 & Teensy 4.0
- use a different USB audio interface (Motu M2)
- use an older version of TrueRTA
- power the Teensy plus audio board by laptop over USB, by a USB wallcharger and by a 5Vdc lab powersupply
- more PCM5102A-based boards:

boards.jpg

All the above did not help getting rid of the harmonics I see today.

I'm out of ideas right now, so any suggestions or otherwise are much appreciated!

Thanks,
Paul
 
That's -70dB down, it only takes a small issue on the analog path to add distortion at this low level - perhaps you have overloaded the Scarlett front-end? Added a ceramic capacitor into the signal path? Have a dodgy connection with oxide build up (oxide layers can be non-linear).
 
Thanks Mark, it's probably a combination of what you suggested.
An hour ago I hooked up a third USB audio interface (an ESI U24XL) and that one shows this on TrueRTA:

U24XL.jpg

Now -90dB down...

Still not sure what I measured 2 years ago. The Scarlett 2i2 was the only audio interface I had at that time. I will give the connectors and cables a cleanup with DeoxIT.

Paul
 
And yes, the Scarlett front-end was apparently overloaded - when I changed the output amplitude of the PCM5102 board to
Code:
sine1.amplitude(0.0625);  // -24dB
the spectrum analyzer shows this for the Scarlett:

Scarlett2i2.jpg

For comparison, here is the U24XL spectrum with the same -24dB signal:

U24XL-24dB.jpg

Apparently the U24XL shows a slightly higher noise level (probably because I had to add more gain to show ~1.3dB on the spectrum analyzer) but it can handle higher amplitude input signals.

@Mark, thanks again for your suggestions!

Paul
 
I've often seen distortion figures for ADCs and DACs quoted at -6dB full scale - current steering DACs in particular become non-linear for larger output voltages if the outputs are clamped to virtual ground with an I-V converter circuit.
 
Back
Top