is it possible filter before FFT?

Having problems ? let us know the details here
Post Reply
panna
User
User
Posts: 2
Joined: Fri Feb 28, 2020 11:12 am

is it possible filter before FFT?

Post by panna »

Hi,
I'm new of Picoscope and I would need your help..

*I'm using a Picoscope5442A, connecting channel A to a Volt-signal.
*My goal is studying signal spectrum.
*I set Picoscope sample rate at 62.5MHz.
* I look at Picoscope FFT spectrum.

In order to make spectrum analysis more simple, I would like to apply a bandpass filter [bandPass(chn A, 1MHz, 25MHz)]. It would help me cutting low frequency noise and aliasing lines in the spectrum.
Is it possible building such a filter through the MathChannelWizards?

I do it, but if A-channel is in "spectrum mode" I see nothing on the bandPass-mathChannel, like if it didn't work.
If I do the same having A-channel in time-mode (and not in spectrum mode), I can visualize the filtered signal in time, but I'm not able to make Picoscope calculate the FFT on the filtered signal.

Thus my question is: can Picoscope (v6) do what I need or not? if yes, can I have the recipe, please?

many thanks,
Anna

Gerry
PICO STAFF
PICO STAFF
Posts: 1145
Joined: Mon Aug 11, 2014 11:14 am

Re: is it possible filter before FFT?

Post by Gerry »

Hi Anna,

There are 2 points I need to highlight here, regarding your questions.

The first point is that you need to be clear on what you are attempting to achieve, before trying to figure out how to implement it:

"In order to make spectrum analysis more simple, I would like to apply a bandpass filter [bandPass(chn A, 1MHz, 25MHz)]. It would help me cutting low frequency noise and aliasing lines in the spectrum."

First of all, you can't remove Aliasing because it is an artifact of the sampling process. You have to prevent Aliasing from happening by making sure that the highest frequency in your signal will not cause aliasing. You can do that by making sure that you sample the incoming data at a fast enough rate. Theoretically this would be the Nyquist frequency (sample rate / 2) but in practice this is not sufficient, because it assumes that you go from the pass-band to the stop band in 0Hz (i.e. you use a Brick-Wall filter, which is impossible to implement in the time domain). So, you need to give up some of the usable frequency range to allow the highest frequencies to be rolled off gently by the Scope Circuitry. You can treat the circuitry as a first order filter, which means that you need to sample the data at a rate that is at least 5 times your highest frequency in order to avoid significant aliasing in your reconstructed signal.
Any noise generated or induced in the input circuitry, connectors, power supply, and signal source tends to be close to broad spectrum white noise for the bandwidth of interest. So, attempting to apply a filter to a signal buried in noise is not a very effective way of getting rid of the noise (because you can't do that without reducing the level of the signal as well). Fortunately we have better methods of effectively reducing the noise in the Spectrum Plot, as follows:
1/ You can apply Averaging, by clicking on the Spectrum Options (the icon to the right of the 'Spectrum Mode' icon) and Selecting Average for Y-Axis->Display Mode. This reduces the variance of the noise and stabilises the signal level so that you have more accuracy and resolution for the signals and their harmonics.
2/ You can select a larger Number of 'Spectrum Bins'. Every doubling of the number of Spectrum Bins reduces the noise floor, typically, by approximately 3dB (for the most commonly selected 'Window Functions'). The reason for this is that we plot a Linear Spectrum, and for this you have to apply a correction factor called 'Coherent Gain' (or 'Process Gain' which is further explained here: https://www.picotech.com/support/topic25101.html?&p=86081&hilit=process+gain#p86081) which has the side effect of reducing noise.

So, the second point is that the order in which software tools are applied is important.

"Is it possible building such a filter through the MathChannelWizards? I do it, but if A-channel is in "spectrum mode" I see nothing on the bandPass-mathChannel, like if it didn't work.
If I do the same having A-channel in time-mode (and not in spectrum mode), I can visualize the filtered signal in time, but I'm not able to make Picoscope calculate the FFT on the filtered signal."


In PicoScope 6, Scope Mode and Spectrum Mode are 2 modes of capturing data. When you switch to Spectrum Mode, the data is first captured then immediately transformed into the frequency domain and then displayed, so there is no way of applying a filter before displaying the Spectrum.
In Scope Mode you can create a secondary view and choose Spectrum for the Mode of display (by going to Views->Add View). The Spectrum plot will then be a secondary view of the Scope Mode display. Because the Spectrum view is a secondary view, the Input Channel Options (which you you can get to by clicking on the icon with the letter for the channel, just above the graph) will be applied before the FFT is calculated for the Spectrum plot (the Axis Scaling will have no effect because it is not actually changing the data). This means that you can filter the primary view of the Scope Mode plot, and the filter will be applied to the data in the Secondary View plot (see attached Image and psdata file, where the same signal is applied to channels A and B, with the input filter being applied to A but not to B).
Filtering a Spectrum plot.psdata
(319.82 KiB) Downloaded 304 times
Filtering a Spectrum plot.png

Note that a Math Channel filter applies a filter algorithm to the Time domain data (the data captured in Scope Mode) so trying to apply a Math channel to the data that has been transformed into the Spectrum plot is not going to work (as the Math Channel filter doesn't have a corresponding Digital filter Algorithm for Spectrum Mode). So, if you want to apply a filter using a Math Channel you would have to Apply the filter to the Time domain data, and then perform a Spectrum plot of the Math Channel (which you could do by first selecting the secondary Spectrum View, by clicking on its Tab, and then going to Views->Channels, and clicking on the name of your Math Channel).

Regards,

Gerry
Gerry
Technical Specialist

panna
User
User
Posts: 2
Joined: Fri Feb 28, 2020 11:12 am

Re: is it possible filter before FFT?

Post by panna »

Hi Gerry,

thank you very much for your post: clear and helpful.

I'm getting all your suggestions. Trying to reproduce the "filtering a spectrum" picture, I'm having some problems:
1) I cannot open the file you sent me, because the software I'm using is an older version (version 6.9.12.3). Can you send me the file again, in such a way I can open it?
2) If I try to reproduce the example (I input a noise signal on the A channel), I can display and see on the "scope type view" A-channel and "filtered A"-math-channel; I can open a second view of "spectrum type" and display channel A. I can also select "filtered A" channel to be displayed on the spectrum view, but I cannot see it. I don't know if it is either a scale problem (but I tried to zoom it very much), or a math-channel definition mistake, or anything else.
I attach few screenshots that could help you in finding my mistake.

* When I set a filter, shall I use frequency range in Hz-unit, isn't it? For example, if I want to build a band-pass filter from 5MHz to 15MHz on A-channel, I should use: bandPassFilter(A,5000000,15000000), does'n it?
I tried both, using frequency in Hz and in MHz, but I see not trace on the spectrum-view, in both the case.

* A more general question: If I were interested in looking at the signal spectrum, but I were not interested in filtering data, do you suggest me either to acquire the signal in spectrum mode, or to acquire the signal in scope mode and to make the spectrum view, later? have they different resolution/ accuracy?

many thanks,
Anna
Attachments
picoscope_esempio_1.png
picoscope_esempio_2.png
picoscope_esempio_2.png (10.67 KiB) Viewed 4688 times

Gerry
PICO STAFF
PICO STAFF
Posts: 1145
Joined: Mon Aug 11, 2014 11:14 am

Re: is it possible filter before FFT?

Post by Gerry »

Hi Anna,

I would recommend that, rather than trying to open the file in an old version of PicoScope 6, it would be better to upgrade the software to the latest version for windows 10 (or windows XP if you are still using that) which you can download from here: https://www.picotech.com/downloads.

Regarding the Math Channel, that will not work at all in Spectrum Mode because the FFT is only applied to the actual physical data, while the Math Channel is calculated data (sorry my mistake I was thinking of another Math channel application that does work in Spectrum Mode). The Math Channel filter cut-off-frequency is always in Hz.

But, once again, you shouldn't be trying to filter the noise away, unless you have no other method of reducing the noise, because you are likely to end up removing some of the signal as well.

If you want to compare the Frequency domain view alongside the Time domain view from which it was derived, then you will need the Secondary Spectrum view. However, if you need as much space on your monitor for your Spectrum plot then the Primary Spectrum view would be the best choice. Other than that there is not much of an advantage difference between the spectrum plots of a primary and secondary view.
Both Spectrum views will only only use the the number of samples they need to perform the FFT conversion (so this normally means that the Secondary Spectrum view only represents the first x samples of the Primary Scope view, where x is roughly, but not exactly, twice the number of bins in the Spectrum plot).
In the Secondary Spectrum view the bandwidth will always be the bandwidth up to the Nyquist frequency for the Primary Scope view (i.e. half of the sample rate used). As the Sample rate is only changed by changing the Timebase you can flick through the Timebase values to effectively select the Spectrum Bandwidth that you need. It looks like there are more choices of bandwidth for the Secondary Spectrum view because there are way more timebase values then there are bandwidth values in the Primary Spectrum view, however, as the Timebase values get shorter there are more cases where the number of samples that will be used for the capture change instead of the sample rate, when you change the Timebase value. So both views will actually have a similar number of bandwidths that can be selected, but some of them may be slightly different, for instance here are the bandwidths for the Primary view of a PicoScope 5444D in 15-bit Mode:
63 31 16 9 5 2 MHz
992 500 200 100 50 20 10 5 2 kHz
1000 500 200 100 Hz
and here are the bandwidths for the Secondary view:
62.5 31 21 9 5 2.5 MHz
992 500 250 100 50 25 10 5 2.5 2 kHz
1000 500 100 Hz
So there may be the odd occasion where there is a closer bandwidth to what you need in the other type of Spectrum view.
(note that with the 5000 series PicoScopes the bandwidth values also change with the bit resolution, so with that Scope series you have a lot more choice).

Regards,

Gerry
Gerry
Technical Specialist

Post Reply