LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formula Node

I am trying to do a FFT filter using a formula node, however, I am receiving an undefined variable error on line 5 where I am trying to create an input variable. 

 

Can anyone suggest any tips to improve my code?

 

Thanks in advance - Max!

 

Max2796_0-1655544994873.png

 

 

Max2796_1-1655545053756.png

 

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

My code works when using the MathScript node but this is not recommended for new designs, therefore, I'm trying to implement the formula node instead.

0 Kudos
Message 2 of 7
(2,095 Views)

Why would anyone get the crazy idea to do an fft filter using a formula node in LabVIEW??

 

LabVIEW is primarily a graphical language and has all the signal processing tools you need. So use that instead!

0 Kudos
Message 3 of 7
(2,089 Views)

Mathscript uses Matlab syntax and is very different from the formula node. If it works, there is no need to change. If you have Matlab, you could switch to the Matlab script node. Personally, I would use native graphical code. Much less overhead.

 

There is no FFT in the formula node! (list of functions)

0 Kudos
Message 4 of 7
(2,080 Views)

Altenbach basically already told you the facts. The Formula Node predates the MathScript Node by at least 10 years or more. It initially supported a very restricted set of script language that looked like C but was far from even approaching C in terms of capabilities. They then extended it to work more C like without the pesky pointers and other "advanced" topics that C has. They also introduced the Script Node which initially was for their own product HiQ. Later they added a Matlab backend to that so you could interface directly to Matlab instead of HiQ This needed an installation of Matlab on the same machine. Then they developed the MathScript Node which is basically an NI implementation of Matlab Very Light.

This MathScript Node works for some people but it often fails to run more advanced Matlab Scripts since MathScript does not implement the entire Matlab Runtime environment and all its many features.

 

And now they try to eventually move users back from the MathScript Node to the Matlab Script Node which is a new way of interfacing to a Matlab installation on your machine in a similar way as they have the Python Script Node to let you interface to a Python installation.

 

So there are really 6 technologies (+ 1 anecdotal one that I wrote more than 20 years ago)

 

- Formula Node v1 (LabVIEW 3 and 4 or so), very simple script syntax

- Formula Node v2 (since LabVIEW 5 or 6), mostly same as C, but without pointers and no mathematical functions beyond the basic arithmetic operations

- Script Node (a plugin architecture where a C compiled backend provides the glue to a specific external script host and is used in the next 3 entries

- HiQ Formula Node (since LabVIEW 4 or 5 as an external addon) interfacing to a HiQ installation on the host

- Matlab Formula Node (a little later) interfacing to a Matlab installation on your host

- LabPython Formula Node (an interface I developed somewhere around 2000 to plug into the above mentioned Script Node)

- MathScript Node (LabVIEW 8.?) an NI implementation of parts of the Matlab Runtime kernel directly embedded in LabVIEW

- Matlab Script Node (LabVIEW 2019 or 2020??) a new method to interface to an installed Matlab kernel on your host

 

Only the Matlab Formula Node, the MathScript Node (with limitations) and the Matlab Script Node can execute Matlab scripts. All the others have never heard of Matlab and find its syntax as intelligible as garbled text salad.

 

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 5 of 7
(2,065 Views)

Thank you for this explanation - it's much appreciated!

 

I have subsequently created the following VI: 

 

  • Load Dataet
  • Remove header
  • Perfrom FFT
  • FFT ones - Sub VI => creates array of ones and zeos for selected cutoff frequencies
  • Original FFT is element-wise multiplied with the ones and zeroes.
  • Creates filtered FFT which is transfromed from frequency domain back to time domain.

 

This produces a filtered signal which is smoothed as desired, however, the magnitude of the filtered time domain signal is signifcantly greater than the original signal. Notice how the FFTs the have the same magnitude of frequencies but the aplitude of the filtered signal peaks are significantly greater than the original raw signal/

 

Can anyone suggest why the inverse FFT has this effect?

 

Max2796_0-1655800185837.png  Max2796_2-1655800320928.png

 

 

 

 

Download All
0 Kudos
Message 6 of 7
(1,973 Views)

It doesn't seem to scale for the length of the FFT. Do you notice that the factor seems to be about 25000, pretty much half of your 50000 samples?

 

An inverse FFT is pretty much an FFT of the conjugated input signal, except if you do it that way you need to not only conjugate the signal back afterwards but also correct the amplitude with n/2, where n is the number of samples.

 

I wonder why you are not directly using a FIR or IIR filter.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 7 of 7
(1,961 Views)