1
\$\begingroup\$

I have an MCU controlling a 16bit DAC via SPI (and an additional LDAC output, which triggers the update of the DAC output). The MCU has a precalculated 1120Hz sine wave in a 364-byte long buffer (all calculations in float32, rounded to uint16 for DAC output), sampled at 29120Hz. In a timer interrupt, the update of the DAC is triggered via LDAC and then a new value is loaded from the buffer and sent via SPI. The update to last value is triggered in the beginning to reduce jitter due to memory access races against DMA. Interrupt has a sufficiently high priority to not be delayed.

Althrough visually the sine looks good, FFT of my Rigol DS1054Z behind the DAC (before the reconstruction filter) shows a significant distortion: Distorted signal spectrum behind DAC

The highest peak is the required 1120Hz, others are equally spaced by 260Hz. The right peak seems to be only 5dB below the main!!

The jitter on the LDAC pin is on the order of +/- 0.25us, which I'd consider acceptable against 34.3us sample time. The timer itself runs from the MCUs crystal and should be stable enough.

What kind of a problem would lead to such a distortion pattern? What could be the ways to diagnose and reduce it?

Just in case relevant: the DAC is an AD5686, full-scale reference is 5V, sine amplitude is 25mV which results in roughly the lower 10 bits being "switched".

\$\endgroup\$
  • \$\begingroup\$ 1.5% peak-to-peak jitter is actually quite a lot. \$\endgroup\$ – Dave Tweed Jan 4 '16 at 14:07
  • \$\begingroup\$ 29120/260 = exactly 112 so is one of your sinewave values wrong? \$\endgroup\$ – Andy aka Jan 4 '16 at 14:07
  • \$\begingroup\$ Also, if your sine table is in 364 bytes you'll need to sample this at 407,680 times per second to give 1120 Hz unless you have 14 cycles stored in the table? But why store 14 sine cycles? \$\endgroup\$ – Andy aka Jan 4 '16 at 14:14
  • \$\begingroup\$ subharmonics scream out that your sampling rate is not constant, or your table lookup has a systematic overflow-type issue. Replace your sinewave with (say) 32 cycles of square wave and repeat as an experiemtn. Or stay with the sinewave LUT and hard-code the lookup to simply increment by one location each time. See if either of those give you clues to what is going on. Toggling only the lowest 10 bits of the DAC shouldn't be a problem at this level, but if you have bits swapped over, it will exacerbate the effect. Try changeing the amplitude to full scale for more clues. \$\endgroup\$ – Neil_UK Jan 4 '16 at 14:29
  • \$\begingroup\$ @Andyaka The buffer is designed for a more complex signal, the sine wave is just a case. Playing around as user44635 suggested, will report if I find any clues... \$\endgroup\$ – Maverick Jan 4 '16 at 14:41
2
\$\begingroup\$

I've hooked up a lab signal generator to the input of the scope to compare it to the measured signal and surprisingly saw the exactly same spectrum in it's FFT. Turning up the frequency the subharmonics went away at 1250 Hz. Changing memory depth in the "Aquire" settings from Auto to 6K removed the effect. It seems like some kind of an aliasing problem is going on in the FFT of the DS1054Z.

===

EDIT: Looking carefully at the image you will see a sampling rate of 5kHz shown over the FFT window. It would have been too less to sample the DAC output before the filter. It's surprising that it still looks the same if provided with a clean 1120Hz signal, as it's still below the niquist frequency.

\$\endgroup\$

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.