I wonder whether I could bore the community with a question which is more about using FPC/Lazarus effectively than the language or tools.
I have a cheap oscilloscope as a pocket tool: as described at
https://hackaday.com/2017/08/08/touchscreen-oscilloscope/ it's a handy bit of kit for its price, although in practice it will need new leads with the appropriate (MMCX?) connectors.
I've written a program that captures data over USB, where- as is fairly common- the device looks like a serial port (CP2102). This is entirely adequate to save screenshots to go into project documentation etc., at least in the time domain. Running on Linux x86_64 with FPC 3.2.0 and Lazarus 2.1.0, but also tested on other versions/variants.
My problems start when I try to convert the collected time domain data to frequency domain using FFT. I was initially using the code discussed at e.g.
https://lists.freepascal.org/pipermail/fpc-pascal/2017-April/050717.html but have also got the same questionable results using FFTW, so it's obviously my interpretation of the results that's at fault.
The scope's calibration signal is 1kHz 3.3V. If I capture that with the timebase set to 1 mSec per division I get 512 values, and can derive appropriate voltages etc. for on-screen annotation. There's 20 divisions, so it's 20 mSec across the entire 512 values or 39.06 uSec per value hence a sampling rate of 25.6 kHz.
/If/ my understanding is correct, that implies that each bin in the FFT output is 25.6 kHz/512, or 50Hz. However because this is mirrored with the zero in the middle and +-Nyquist at each end what I've actually got is a usable 256 bins from 0 to 12.8 kHz (still 50Hz per bin). Displaying that with an arbitrary 32 divisions should give me 400 Hz per division.
Please could somebody who knows what they're doing confirm my logic there before I wade into my code again. I attach a couple of screenshots, showing the sort of problem I'm having.
The bigger picture is that I'm trying to get the graphical side of this wrapped up as a way of revisiting TAChart. Then I'm going to add graphical output to a program that reads data from a multimeter (Mastech MS2115B), and the code that does that will be adapted in short order to read a pulse oximeter which is obviously of topical interest.
MarkMLl