2023-06-07 05:54 AM
The application is to fine tune acoustic resonantors. In other words we want to be able to tune DMA DAC output from 29.990 to 30.010 in 1 Hz steps. Ideally we also would like to tune the amplitude. There are some ideas with DAC reference prescalers and different LUTs. Any idea for a more elegant solution?
2023-06-07 06:23 AM
2023-06-07 06:29 AM
At the moment we plan with 20 times oversampling, meaning about 600kHz, but this is potentially adjustable.
2023-06-07 06:58 AM
You can't achieve 1Hz step purely by integer division from cca 170MHz - the minimal step is around 5Hz. That's the case of "reference prescalers and LUTs". For cca 1Hz step you would need system clock of around 900MHz.
If properly written, you should be able to have around 1MHz sampling with software DDS (of course it's still timer/DMA based); question is, if spectral purity and amplitude stability are acceptable for your purpose - IMO the best way is to establish this experimentally. I've done 20Hz-20kHz test signal using DDS in 'F407 in the past, but I don't remember what analog qualities of the output signal have we achieved.
Other than DDS, a fractional-N PLL could perhaps be imagined, but that's nontrivial amount of external components and again, spectral purity is to be determined.
JW
2023-06-07 07:42 AM
Set up the DAC to trigger off of a timer via DMA, and also use DMA to reload the ARR value of that timer from a circular buffer of, say 100 points, on the update event. This gives you very fine control over output sine wave frequency.
Example:
Set up your DAC output buffer with 20 samples for a sine wave.
If your target sine wave frequency is 30 kHz, and your timer frequency is 50 MHz, you want 83.3333 ticks/sample, so set the ARR value buffer to be 83, 83, 84, 83, 83, 84, ...
With 100 samples in the ARR buffer, it would have 8333 ticks (67*83+33*84) total to output 5 full sine waves. So your exact output sine wave frequency would be 30001.2 Hz. If you remove a tick somewhere in the ARR buffer, it becomes 29997.6 Hz, so resolution of ~3.6 Hz. If you want a resolution of 1 Hz instead, increase the ARR buffer length to 500.
Edit: ARR values should be 1 less that what is written above, but that's in the details. Concept is there.
2023-06-07 08:29 AM
Hm, dithering in time domain. I wonder what the consequence for spectrum would be, as compared to the time-wise more regular DDS. Samples are also more "rough" amplitude-wise.
OTOH, much less computations, as you assume to calculate the ARR buffer only once.
JW
2023-06-07 08:38 AM
2023-06-07 08:57 AM
> ~20ns shift is generally small
At 50MHz the individual sinewaves will differ by 15Hz, so in the spectrum you will basically have something like a merger of two peaks 15Hz apart, with mutual amplitude adjusted so that the "average center" will be at the frequency of interest. Of course this will be smeared into more-less one, but relatively wide peak.
> Depends on the application of course
+1
JW
2023-06-07 09:15 AM
Thanks for this idea. Might be worth to look into this especially since we aim to run a closed loop regulation the resonance peak to would just give as simple possibility for the PID controller to increase or decrease ARR counts...
2023-06-07 09:27 AM