2020-04-19 08:06 AM
Hi,
I've been trying to synthesize different waveforms with my F446 DAC. Three things have come to my attention here, which I can't explain.
First, when I am using the full range of the DAC with values from 0 to 4095 the signal gets distorted like this for sine and ramp:
whereas using the range from 0 to 2047, the signal looks great like this:
Second, using the smaller range, when I am going to higher audio frequencies the SNR suffers greatly as seen in these spectra:
with frequencies over about 5k or 6k being reduced to white noise.
Third, using the buffer distorts the signal even worse like this:
To synthesize the signals I am using a timer to trigger the dma to push values from a LUT to the DAC.
If anybody has any ideas what could be causing these problems, I'd appreciate comments.
2020-04-19 09:08 AM
I think you might have both hardware and software issues. First, try a direct digital synthesis algorithm using a fast enough counter to generate a constant sample rate, remembering Nyquist and sin(x)/x dac errors. Also double check the output circuitry. I have had good luck using the 2 dacs in f7s to make audio using a single audio quality opamp per channel (with +/-12 v supplies) to shift the signal down by 1/2 Vref and then feeding a pair of balanced line drivers.
2020-04-19 11:44 AM
Thanks for the pointers. About the hardware, I was thinking my output circuitry might be the problem, thats why I grabbed the signal right from the µC pin with buffers enabled, as I figured this should result in a clean signal. Unfortunately I don't have an oscilloscope here so I used my Computer line in to visualize the signal.
As for software, you might be right. I didn't generate a signal with a constant sample rate and with proper DDS. Although I didnt't think this would affect the problems with using the full range of the DAC?
2020-04-19 12:14 PM
You did not tell us which STM32 are you using, but generally the STM32 DAC does not cover the whole range well, and with buffer it's even worse. Review the DAC parameters in datasheet.
JW
2020-04-19 12:36 PM
F446, he says.
Definately try DDS. are you trying to create variable frequencies by simply changing the timer controlling the dma?
2020-04-20 12:00 AM
yup, I was trying to change the ARR according to the frequency as a first attempt to get a signal out, but now I see why this wasn't a good solution for higher frequencies.