LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spectrum Issue - spectrum line doesn't appear

Solved!
Go to solution

Hello,

 

In this VI (please, see below) staircase SIN (0.1Hz) is superposed with "parasite" frequency (SIN, 200Hz).

I'm not aware if I correctly use spectrum staff, but 200Hz doesn't appear on spectrum graph.

Sampling frequency is 8192Hz, so 200Hz item must appear at 200/8192 ... i.e. 0.025 (where blue cross is placed).

But there is nothing.

Where is a problem.

Thanks

Pavel.

 

spectrum_issue.JPG

 

spectre_issue.png

0 Kudos
Message 1 of 4
(3,319 Views)

I did not spend much time trying to debug your code. I think part of the problem is you do not have enough data to get the frequency resolution you want. The resolution, df, is fs/N where fs is the sampling frequency and N is the number of samples. Your code has both fs and N set to 8192, making df 1 Hz. This means that your 0.1 Hz signal is mixed in with any DC offset in the first bin of the spectrum. It also means that you never have a complete cycle of the lowest frequency in the buffer at any time. The FFT works best when it has complete cycles. If synchronized sampling is not available and fractional cycles will occur, then it is best to have at least 5-10 complete cycles plus the fractional cycle.  With the numbers you are using, you will not get good results.

 

I put together a simple example using the Tones and noise VI. When you set the number of samples to small values like 1000 or even 8192 you will see both spectral lines bouncing around in amplitude. Setting the number of samples to a much larger number like 81920 gives very stable behavior and you can clearly see that the low frequency component is not zero.   I prefer to look at spectral responses in logarithmic (dB) mode so I put a switch on the front panel to allow selection of the mode.

 

Lynn

0 Kudos
Message 2 of 4
(3,299 Views)

I think the problem in my case was the format of input data: spectrum analyzer needs waveform, not array of values.

I added "Create Waveform" block and now it looks much better.

Anyway, the problem with interpretation persists.

Thus, in this setup the value of disturbance frequency is 200Hz, whereas on spectrum analyzer it's located on 0.2 (yellow encirclement on the screenshot below).

Taking into account that sampling frequency is 8192 Hz, the value of disturbance frequency is 8192*0.2 = 1638.4 Hz.

Probably waveform isn't properly generated ... in your example spectrum analyzer has X-axis implicitly in Hz.

 

spectrum_with_array_transformed_to_waveform.JPG

 

spectre_issue_with_waveform (1).png

0 Kudos
Message 3 of 4
(3,269 Views)
Solution
Accepted by topic author Pavel_47

Resolved ...

In "Build Waveform" block on must specify interval between datapoints. In my case it's while loop delay (i.e. 1ms)

When this block is put on BD the "dt" entry is hidden, so one have to drag top edge to see other entries (i.e. t0 and dt)

spectrum_issue_resolved.JPG

 

0 Kudos
Message 4 of 4
(3,254 Views)