05-30-2014 03:35 PM
Hello all,
I am working on a test stand that applies force to a part repeatedly through the sinusoidal motion of a ram. I'm looking to determine the maximum and minimum values of the force and log these max/min values in a spread sheet along with a time stamp. My first attempt here is using the "Array Max & Min" SubVI. The idea is to load all the instantaneous force values into an array and find the max/min for each cycle.
I am able to find an initial min and max. However, I'm having conceptual issues with finding a method that can append these values to a final array, then discard them and find two new values.
I have installed a switch on the test stand which is closed during the lower portion of the loading ram's cycle. I was attempting to use while loops based on when the switch is active to find a max or min. My current VI seems to freeze (race?) when I run it. I assume this is due to the improper use of local variables and property nodes.
Does anyone have any suggestions on how to move forward with this?
Regards,
Steve
05-30-2014 04:51 PM
You state that force is applied sinusoidally, which implies you have a periodic motion. The really simple way to do this is to synch your analysis with the stimulus. For example, suppose you are sampling at 100 Hz, and the sinusoidal force has a period of 10 seconds. If you take 1000 samples, you should have captured a single sinusoid. Simply use the Max/Min function to find the Max value and index (which gives you essentially the Time information), discard the data, and take another 1000 samples. Note that you might want to do something clever on initialization to be sure that you don't start sampling near a max or a min.
BS
06-02-2014 11:20 AM - edited 06-02-2014 11:23 AM
That's a novel way of approaching it. Would I perhaps put a DAQ Assistant subVI into a for loop with the 'N' terminal set to the number of samples I want? Or would calling the subVI over and over in that particular manner create a lot of overhead?
Also, if I were to take that approach, there is another issue. The period of the oscillation on the test stand is set with an analog dial control box. So, it's hard to determine accurately how many samples would be needed. I suppose I could employ some Fourier analysis on the waveform to determine the frequency/period, but this seems to me like taking a jumbo jet to cross the street. I imagine that Fourier transforms might take a fair bit of system resources to compute? I have not had to implement that sort of thing in code before, so I'm trying to be aware of that.
EDIT: I suppose that I do have that switch installed on the test stand. I could prompt the user to set the speed before the rest of the VI computes anything and the use the switch to determine the period in some manner.
06-03-2014 08:10 AM - edited 06-03-2014 08:10 AM
Well, here's my new problem. I used the tone expressVI to determine the frequency of the machine speed before any actual "logging" takes place. I then reciprocate and multimply by my sampling frequency to get the number of samples I need to take. Now I get a "Memory Full" error. I'm not sure why when it worked fine when I had a Simulate Signal expressVI in place of the DAQ Assistant.
06-03-2014 10:07 AM
As a general rule, I avoid Express VIs (such as the DAQ Assistant) at almost all times! They are fine for quick "slap-it-together and see-how-it-works" Test code, but they hide so many details that you probably should know about that, in my (limited) experience, they actually hinder (me) more than they help.
There is a wonderful tutorial (which you can find if you do a Web search for DAQmx Tutorial, then look for the White Paper "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications". I think this is the link to it ...
http://www.ni.com/white-paper/2835/en/
You need to think a bit about your signal(s), stimuli, and how that relates to your sampling rate. You want to sample about 10 times faster than the highest frequency-of-interest in your data. Another (crude) rule of thumb is for analyzing the results of a "simple" periodic stimulus, something like 1000 samples per period might be sufficient. So if your test stimulus has a period of 10 seconds, you could consider sampling at 100 Hz and analyzing "batches" of 1000 points at a time (one period).
If you want to simultaneously acquire and analyze, you should look at the Consumer/Producer Design pattern (I think you can find it as a Demo Project when you open LabVIEW 2012 or 2013). This has two loops -- a Producer Loop that continually takes (say) 1000 samples and puts them in a Queue, and a Consumer Loop that waits for data in the Queue and then processes it. Note that in the example scheme I described, a "batch" of points would be "produced" every 10 seconds, which means that you have a lot of time (10 seconds!) to get the data analyzed. Also, the Producer won't "miss" any points, since it is continuously sampling and delivering the points in a "bunch", but without missing any samples.
BS
06-04-2014 02:21 PM
Bob,
Let me say, thanks for your input so far. I attempted to use the bare DAQmx components, but I am still having the "Memory Full" error once my VI gets to the second for loop in the appended image.
I have yet to implement the producer/consumer model, though I would like to try that after I figure this problem out.
Regards,
Steve
06-05-2014 03:47 PM
Hi Steve,
Instead of configuring a For Loop for the number of samples you want to collect, try instead changing the DAQmx Read VI. This is a polymorphic VI, meaning you can change the functionality very easily to fit your needs. In the white box below the VI where it says "Analog DBL 1 Chan 1 Samp", pull the drop down arrow and configure it for one channel multiple samples. Then you can wire the appropriate number of samples to the input of that function at the appropriate terminal.
Would it be possible for you to collect all the data at once into an excel or tdms file? Then once you're done testing, close the DAQmx task and then perform your analysis that finds the relative max and mins. Because this is an oscillating signal, it would likely be relatively straightforward to find local max and mins in your array. Below is a community example that you might find useful for doing this:
Community: Find the local max and mins of your array:
https://decibel.ni.com/content/docs/DOC-6796