LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use python on data acquired from LabVIEW

For context: I'm doing a project with sound acquisition where I need to do an FFT analysis of the signal and extract, in real time, the fundamental frequencies of that sound. To do this, I've been using the Spectral Measures.vi in LabVIEW, which gives me the FFT analysis of the sound, and then running the Peak Detection.vi to find the fundamental frequencies. The problem is the Peak Detection can't find any peaks when I'm doing sound acquisition, and only works when I simulate a signal.

logolepser_0-1621412216620.png
In order to fix this, I was thinking of taking the data from the Spectral Measures.vi (the output is a Waveform Graph, which I then convert to an Array with the Convert from Dynamic Data.vi) and running it through a small python program where I use the scipy built in find peaks function instead.


Does anyone know of a better solution? If not, how I can "read" the array taken from the dynamic data using python?

 

0 Kudos
Message 1 of 4
(2,479 Views)

Hi logolepser,

 


@logolepser wrote:

The problem is the Peak Detection can't find any peaks when I'm doing sound acquisition, and only works when I simulate a signal.
In order to fix this, I was thinking of taking the data from the Spectral Measures.vi (the output is a Waveform Graph, which I then convert to an Array with the Convert from Dynamic Data.vi) and running it through a small python program where I use the scipy built in find peaks function instead.


Does anyone know of a better solution? If not, how I can "read" the array taken from the dynamic data using python?


Well, LabVIEW offers more functions to determine your frequencies: have you tried to use other functions as well? And also the PeakDetector offers several options to refine the peak search…

 

Which LabVIEW version do you use? Recent versions offer to call Python scripts and to transfer data to/from those scripts.

 

On using ExpressVIs and DDT wires: most often they hide relevant information…

The DDT wire usually contain waveform data, not just sample arrays: by converting to a plain array you lose any timing information, and so the calculated frequency index needs to be scaled back to frequency value afterwards…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,442 Views)

Hi, GerdW,
First of all, thank you for your answer.
Yes, I've tried other functions including a VI called "Find Harmonic Frequencies". They don't work as well as the FFT analysis though and some of them don't really allow for that refinement you were talking about.
As for the Peak Detector, I've attempted to control the parameters (particularly the width, since my peaks are at very well-defined frequencies), but it still fails no matter which settings I use (even though I can see the peaks in the Waveform Graph produced by Spectral Measures, they don't appear in the array made by the Peak Detector). 
I'm using LabVIEW 2020 32-bit and I know I can use is Python Node, although I've never tried it.
As for your last statement:


On using ExpressVIs and DDT wires: most often they hide relevant information…

The DDT wire usually contain waveform data, not just sample arrays: by converting to a plain array you lose any timing information, and so the calculated frequency index needs to be scaled back to frequency value afterwards…


is there any other conversion I could be using? Peak Detector only accepts arrays as inputs, which is why I used the conversion to array in the first place. I'm not sure if the loss of information is the reason why the Peak Detection doesn't work when I'm in acquisition mode, but I'd be worth a try.

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

Hi logolepser,

 


@logolepser wrote:

As for the Peak Detector, I've attempted to control the parameters (particularly the width, since my peaks are at very well-defined frequencies), but it still fails no matter which settings I use (even though I can see the peaks in the Waveform Graph produced by Spectral Measures, they don't appear in the array made by the Peak Detector).


You could run your VI until you see relevant data in the graph.

Then set all values to default (Edit menu -> set values as default), then save your VI.

Attach that VI so we can run it and try to find peaks in your data…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(2,421 Views)