0

I would like to add and plot the spectrum of signal on Qwt Oscillocope's example. My Idea is to create another seriesData class. SerieData. I wonder if there will not conflict between sample of SeriesData and sample of Signaldata or I just need to modify the signaldata? Any help and Advice would be appreciated. Thanks

The Man
  • 407
  • 1
  • 7
  • 19

1 Answers1

1

input signal is usually in form of cyclic buffer the output buffer can be static one. This applies also for time domain plots. Without actually see your structures is impossible to answer if you had to change them or not Here is how I do this:

  1. make some buffer (array) for FFT

    can be static ... No changes in it will happen. It size has to be at least slowest_timebase/fsampling samples. In case your FFT has complex domain input then double the size. If you want to scroll/zoom/unzoom then enlarge the size accordingly

  2. find the start sample of the actual Oscilloscope view

    via trigger or for starters just last N-samples (but it will flicker because of phase ...) or you preview all samples by N-sample chunks from start to end with the same speed as sampling. Similar like you would send data to sound-card to play sound. You just start after some time so you have enough sampled data already ...

  3. process data

    Copy data from start point to FFT buffer add imaginary part of samples if needed (Im=0.0) and process FFT. Then plot the first half of output for example sqrt(Re^2+Im^2).

    The frequency of i-th sample (out of N) is f=i*samplerate/N [Hz] where i={ 1,...,(N/2)-1} skipping i=0 which represents DC component.

    You can also add logarithmic axises to frequency. In that case do not forget to change the x value in plot too

  4. update start position

    simply add to start position the size of used samples (N) and do not forget that trigger also use this time as start point before finding the real start...

for more info and demo see plotting real time Data on (qwt )Oscillocope

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • now I can plot signal and FFT on real time. now I would like to add some function to my oscilloscope like trigger.How can I implemente the trigger function using qt/c++ – The Man Aug 17 '14 at 17:57
  • @TheMan easy now you play the input data buffer continuosly, so do not FFT/draw from current buffer position but instead start there and search for the selected trigger condition. if found start FFT/draw from that point. next frame do the same way but start searching from next position like no trigger was used. that is it. In order to make trigger work properly the buffers should be large enough (screen + few periods of input signal at least 2) – Spektre Aug 18 '14 at 07:42
  • @TheMan it is the same like on oscilloscope just before applying FFT you find the right starting position ... – Spektre Aug 18 '14 at 07:50