I wouldn’t say an 8bit capture of a sine with about 30 samples per cycle like you show is a very good representation of a sine wave.
It’s a very poor one actually, and it would be strange to not get a lot of harmonics.
If you increase the time resolution (samples per cycle) you’ll start getting better results.
…but please remember - this is a 256 samples FFT.
It’s usefulness is limited.
Had some problems reverting back to the 1024 points FFT I had first implemented, and will probably not be trying to get it running any time soon.
If someone want’s to have a go at it… (all the FFT related code in the source is delimited with “// FFT” comments, and is actually very few lines of code)
This is another video with the AP1_100 version in SCAN mode with buffer set to 360(smallest setting). This problem does not happen here. Sad we don’t have the sources for AP1_100
Please let me know if I there is a way I can help. Right now, I cannot figure out the whole code, so, not sure where to look. But, I am guessing SYNCHRO and PROCESS are the right places to look.
It is far from perfect. At first - the signal from the DAC is not filtered. Second - the output buffer amplifier goes to a limiting on the signal levels close to GND and Vss, it is noticeable even visually, and produce harmonic components.
I use a 10kHz “sine” from the internal DAC, channel A with 0.5V/div, 100uS/div as an example.
[list]
[*]when I vary the amplitude of the sine, the spectrum changes completely. For example, at amplitudes of about 1.7V, the highest peak is at 20kHz, not 10kHz (and it is more then 2 div higher than the 10kHz)
[*]with an amplitude of 2.1V, the picture changes: now the highest peak is at 10kHz and 2 div higher than the 20kHz
[/list]
Maybe this has to do with the fact that only 256 samples are used, i.e. only about 10 periods and this is not enough - does the FFT only give good results when there is an integer number of periods in the 256 samples? Could this explain why the sines have so many harmonics?
I had another problem, which looks like a bug: when moving the “navigator B”, changing between the “trigger” and the “auto/norm…” menus - but not changing anything at the settings - sometimes the FFT result change completely!!!
Two more questions: [list]
[*]if the number of samples is the problem, why not make an FFT with 4096 sample? Why is it more complicated than with 256?