LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slider to scale up and down frequency

Loop3r_III_0-1668952239305.png

 Hi, I am trying to make a virtual oscilloscope that displays a signal and its FFT. How can I set the slider under the graph as in the picture? 
Thanks in advance,
Cheers

0 Kudos
Message 1 of 7
(1,380 Views)

I'm not at all sure what your problem was in creating the FFT Graph and the Slider underneath it.  I created this in LabVIEW 2021 (which I was using at the time), but saved it (and am attaching it) in LabVIEW 2017, "just in case".  Here's how it looks:

FFT Front Panel.png

You may be wondering how to get the Slider to go out to 20000.  Right-click the Slider, select Properties, and look at the Scale tab.  Set the Scale Range to 0 and 20000.  You can also set Data Entry Minimum, Maximum, and Increment as you desire (you might want, for example, an increment to be 1, or 10).

 

Note that when you do Frequency Analysis (by doing an FFT) and plot Frequency against Amplitude, Frequency is almost always plotted with a Logarithmic scale (as is Amplitude).

 

One final note -- the Tab Control is a little clumsy and "messy" to use.  I learned about Sub-Panels at an NIWeek conference in Austin a decade(?) ago, and have been using them ever since.  The one "catch" is that you need to put the code you want to run in a sub-VI whose Front Panel is "what you want to see in the sub-Panel".  When you create a sub-Panel, it makes for you an Invoke Node that you load with a reference to the sub-VI you just created.  When you "Invoke" it, the sub-VI's Front Panel fills the sub-Panel (you might have to tweak the sizes a bit), and all you need to do after that is to run the sub-VI, passing into it any arguments it needs (like the data for the Graph).  You can learn more about sub-Panels by doing a Web search for "LabVIEW Subpanel".

 

Bob Schor

0 Kudos
Message 2 of 7
(1,359 Views)

@Bob_Schor wrote:

You may be wondering how to get the Slider to go out to 20000.  Right-click the Slider, select Properties, and look at the Scale tab.  Set the Scale Range to 0 and 20000.  You can also set Data Entry Minimum, Maximum, and Increment as you desire (you might want, for example, an increment to be 1, or 10).


All you need is click the max and enter a different value, e.g. 20000. Same for the graph x-axis (... and make sure to disable autoscaling). More importantly, disable "autoadjust scales" (in: right-click graph... advanced...) else the x-scale will change in length if the y-axis markers need more room.

 

I probably would also change the label of the slider to just "Frequency". The max is determined by the hardware or simulation and in this case probably 20000. "max frequency" is not the same as "frequency with max FFT amplitude" or similar. You set the frequency and the FFT will show all the frequencies, including the one with max amplitude.

0 Kudos
Message 3 of 7
(1,342 Views)

Hi, thank you for the reply, I attach the VI I modified. I have a problem with its work: when I do the FFT of the sine wave, I obtain 0 amplitude for every frequency value I set. 

0 Kudos
Message 4 of 7
(1,340 Views)

@Loop3r_III wrote:

Hi, thank you for the reply, I attach the VI I modified. I have a problem with its work: when I do the FFT of the sine wave, I obtain 0 amplitude for every frequency value I set. 


I don't.

Be aware that the plain FFT is Niquist centered and complex and contains positive and negative frequencies. You can get zero in the RE part if it is 90 degrees out of phase. You also need to correctly calculate df for the frequency axis. To get the magnitude, that the absolute value of the FFT.

 

You only generate 128 samples severely limiting you frequencies, (... and you get alias frequencies instead). Try to also display the signal before FFT to learn what's going on.

0 Kudos
Message 5 of 7
(1,322 Views)

If you set the number of samples to twice the max frequency and correctly wire the normalized frequency, things seem to work just fine.

 

(Note that the second half of the FFT is outside the displayed axis range. For any other number of samples, you need a little bit more math, of course. Start reading here)

 

altenbach_0-1668961836100.png

 

0 Kudos
Message 6 of 7
(1,318 Views)

Have you looked at the 128-point "Sine wave" that you send to the FFT?  It is 128 values all 0 (which is correct).  The FFT of 0 is 0.  We now know your plot is of an FFT.  Your sample is 128 points, which means you can get out 63 frequency components.  Why is your frequency axis going from 0 to 20,000?  I'll repeat that FFT plots of amplitude vs frequency usually use log-log coordinate scales.

 

Bob Schor

0 Kudos
Message 7 of 7
(1,257 Views)