2025-11-15 9:46 AM
Hi, I need a little explanation about what is wrong behind my reasoning..
I am using STM32F411. reading, two inputs of ADC in scan mode over circular DMA triggered via TIM2 update event.
TIM2 is triggering ADC at 100KHz, so I have 50Khz sample rate per adc input. At input of both ADC channels I connected signal generator feeding 1Vrms sine @20KHz.
Everything works ok, I am using printf of both channels over (USB-CDC) as and I can see two sinusoide signals on serial plotter. I am using this serial plotter:
https://web-serial-plotter.atomic14.com/
Now the problem and confusion starts here:
If I change only TIM2 frequency to 10KHz, I am getting 10X lower sample rate also (now 5KHz pre channel, all checked with Logic Analyzer), but I still can see clear 20KHz sine at serial plotter, without degradation and this contradicts Nyquist theorem...
How is this possible and what I am missing?
2025-11-17 10:29 AM
Ok, I tought about that, what should I do then to check, how my sampled data looks like?
How would you check is your sampled data ok, or corupted for whatever reason?
Thank you lot for your time!
2025-11-17 10:43 AM
You need to come up with a better way of getting data out. You can use USB CDC but use a secondary buffer before you send it over. Send lots of data at once rather than single bits. 4 kB is a good size. If you don't need continuous data, save up 4 kB of data and then send it out. Ignore new data until that transfer is complete.
How will you get your data out in the final application? Focus on that.
You could pause in debug mode and read out values in the buffer, but this is tedious.
2025-11-17 11:05 AM - edited 2025-11-17 11:57 AM
Hi,
your data is not "corrupted" , its just undersampling... read:
https://en.wikipedia.org/wiki/Undersampling
+
>what should I do then to check, how my sampled data looks like?
The "usual " way : put the data in an array and send/view this; data is in fixed time interval, as you set the sampling.
AND have an input filter, to suppress any frequencies over the Fs/2 frequency, as this will mirror in the frequency area and look like "new or impossible" inputs.
A simple way -without a suitable analog input filter- to see the real analyzed data and its speed is: not using periodic permanent signals, but just one pulse of known length. Then you see just this pulse - or nothing (or one event), if the pulse is much shorter, than the sampling frequ. No undersampling images possible then.
btw
At university the subject was called systems theory.
-> https://de.wikipedia.org/wiki/Systemtheorie_(Ingenieurwissenschaften)