Showing results for 
Search instead for 
Did you mean: 

Argh! Data logger using resample waveform

Hello, has anyone had problems with using the "Resample Waveform (single shot).vi" for multiple waveforms on an RT system?

I've written a data logger that buffers data at 1 kHz, and then resamples that based on whatever sampling frequency the user has selected before saving to file. The user has the option of selecting 2 different sampling frequencies, so we have a second copy of the "resample and save to file" VI.

The strange thing is that the timed loop that does the resampling and saving to file seems to just hang (or die) sometimes, and I need to reboot the RT machine. At first this seemed to happen only when both resampling/saving VIs were running - as if they were competing for some shared resource, because the VI with the higher priority (higher by just 1) would usually win. I suspected NI's "Resample" and put a disable structure around it in both VIs. They ran throughout the night, except they were logging at 1000 Hz all the time, which generated a ridiculous amount of data. I could tell that they were still running by the indicator on the loop counter, and that the files they generated were pretty big.

I tried creating an entirely new copy of the "Resample waveforms (single shot).vi" and all its sub VIs to use in one of the 2 resample and save VIs. That didn't work. I tried completely separating the VIs by having them run on two different RT machines. Again, one of the VIs stopped only 1 min later, while the other one lasted 15 hrs overnight. Up until now, it seems that the culprit is the resampling VI, but now it has just gotten confusing. The CPU usage on either one of these machines is not at a very high level. With all other VIs running, one RT is at about 60% and the other at about 40%. And, when one of the loops "dies", I do not see a spike in the memory or CPU usage - the loop stops and the CPU usage drops, as if the loop has removed itself from execution altogether.

I've contacted NI and have been trying things left and right for a while now. I'd really appreciate some help before my sanity flies out the window! I've attached a stripped down version of this data logging function in a LV8 project.

0 Kudos
Message 1 of 3

This sounds like a classic example of asking the RT system for more than it can give.  Have you attached a monitor to the output of the system to see if any error messages are being returned (such as a memory allocation error)?  If the CPU on a RT system gets maxed out, it will exhibit this type of behavior because it will be trying to run the VIs and the host communication runs at a lower priority than the VIs do.

I noticed that you are using the "Build Array" function in your For Loop. Is this For Loop running for many iterations? This is not a recommended way to putting data together since it reallocates the array on each iteration. A more efficient way would be to preallocate the array using Initalize Array and then use replace array subset to insert elements as you go through the loop. I can show you an example if you'd like.  I would also recommend using the VI Profiler (Tools > Profile > Performance and Memory) to find out what is actually using up all your resources.

Let me know if this helps.

--Paul Mandeltort
Automotive and Industrial Communications Product Marketing
0 Kudos
Message 2 of 3
Thanks Paul. I missed that Build Array. The RT System Manager showed that the CPU/memory usage weren't at high levels, but at about 30%-60%.

There were some other tweaks made to the code, thanks to the help of an NI application engineer. Now that the data logger will run, we're facing some other problems with the actual data itself. We see some delay in updates of the shared variables. I posted that here.

Message Edited by Sima on 04-12-2006 03:24 PM

0 Kudos
Message 3 of 3