# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution
Highlighted

For the task described below, please give advice on what parts should be performed in LabView, what parts should be performed in Matlab, and the best way to get the Matlab code running on LabView.  I am a Matlab programmer with no experience in LabView or MathScript; I am working with a LabView programmer who hasn't integrated Matlab before. So your advice will help us figure out our approach. Here is the task:

• LabView is running on a machine and generating text files every 10 minutes containing time stamped measurements of temperature, humidity, pressure, etc.
• Every hour, I need to concatenate all the text files from the past hour, extract the temperature measurements, and perform some statistics.
• Presently I have a Matlab function which estimatates the statistics.  The input to the function is the hour's worth of temperature measurements. The Matlab function estimates a FFT from the measurements, scales and sums the FFT output, and estimates the mean and median of the temperature measurements. There are also constants that are passed to the function as inputs, such as a scaling factor for the FFT.
• The output of the Matlab function is 3 summary values (temperature at resonance, peak temperature, and mean temperature). These values need to be time stamped and written to a text file. We produce 1 set of summary values every hour.
• We expect a lot of debugging as the Matlab code is integrated with LabView, since this is a new application.

How much of this task should be performed in LabView (just the file concatenation and writing the output file, or all of it, or ...?) What is the best way to pull Matlab into this (MathScript, or use Matlab Coder to generate a *.exe executable or C source code, or skip Matlab altogether?)

Because the code only needs to run once an hour, and because we are new to this, execution speed is less important than getting something running.

Message 1 of 9
(1,414 Views)
Solution
Accepted by topic author KE1590

Frankly, I'd start by avoiding integration and keeping the LabVIEW and Matlab parts totally independent.  That best suits your development skills with each of you familiar with exactly one of those environments.  (Even more frankly, I'd personally do it all in LabVIEW, though I might still break it into independent processes.  Depends whether there's value in maintaining a raw data archive with a standalone post-processing tool.)

I'd highly recommend that the LabVIEW acqusition and raw file writing code plan to structure the output files with separate folders for each 1-hour chunk of data to be processed.  I'd further suggest that the writing code initially write to a temp folder, then move the folder into the proper location only after the full hour has passed.

Now the Matlab code can simply watch for a new folder to appear, do all its post-processing on the files in it, voila!   And you now have a tool to enable re-analysis on the raw data in the future when someone is interested in other aspects, because that almost always happens.

-Kevin P

Message 2 of 9
(1,380 Views)

I largely agree with Kevin (including the suggestion to "Do it all in LabVIEW").  However, instead of writing to a Temp File, you could use a unique naming pattern to distinguish "ten-minute" files from "concatenated hourly files" and keep them all together in the same folder.  Get LabVIEW to do the concatenating (it is really simple to do this, and LabVIEW "knows" the file formats and, more important, "knows" when to concatenate, and can even do all of this in parallel with the task of continuing data acquisition and writing of the 10-minute files).  Now MatLab just hangs around, checking every minute or 10 for a new Concatenated File, and processes it.

Bob Schor

Message 3 of 9
(1,370 Views)

I should have added: we only have LabView not Matlab on the machine that is doing the data collection, and the LabView files are not on a network that is accessible to the computers I use Matlab on. GIven that, is there some way Matlab can do the processing, as you describe? It would be a relief.

Message 4 of 9
(1,368 Views)

Telepathy?  Not having a way to get the data easily to a machine that can process it, and not having the two different Software systems (LabVIEW and MatLab) on the same computer, really does make it difficult, and really does suggest the "Do it all in LabVIEW" as the best answer.

Can you describe in reasonable detail just what kind of processing you need to do with this data (in MatLab)?  Does it need to be done as the data are acquired, or can you use "SneakerNet" to collect the data on Monday, put it on the USB Key on Tuesday, load it on the MatLab machine on Wednesday, and process on Thursday?  [You can probably speed this up a bit ...]

Note that LabVIEW supports (and encourages!) doing tasks in parallel, so it is entirely reasonable that as you collect the data, you can also be processing it, particularly if your data rates are "modest" (i.e. KHz rather than GHz).

Bob Schor

Message 5 of 9
(1,353 Views)

As each hour of data becomes available, ideally we would start to process it then make a text file containing the output. We could accept ~1 hour of delay between availability of temperature data and saving the output file, but we are seeking 'sort of' real time output. Sneakers can't access the data either, unfortunately: LabView is collecting data on a physically remote system. 'All in Labview' may be the best bet...guess I will start reading up on 'Signal Processing in LabView for Dummies'!

Message 6 of 9
(1,350 Views)

Since you're going to save development time compared to the highly integrated combined LabVIEW and Matlab approach, spend a little side-by-side time with the LabVIEW programmer.  He/She should be able to code up the Matlab algorithm you need if you're there to help explain it.  And then you can learn a little about LabVIEW signal processing as the coding is being done.

From what you described, the signal processing sounds pretty straightforward, there shouldn't be any real issues doing it directly in LabVIEW.  Just watch the units & scaling on the various spectral algorithms.  If your Matlab code is confirmed correct, you can process the same dataset both ways to help confirm the LabVIEW implementation.

-Kevin P

Message 7 of 9
(1,304 Views)

It didn't take our LabView programmer long to rewrite the Matlab code in LabView, and we have compared the outputs of the FFT component as suggested. Thanks for everyone's help.

Message 8 of 9
(1,263 Views)