04-03-2012 07:20 PM
I'm a labview newb currently working on a program that controls movement of an air cylinder via solenoid valves and collects/processes the data generated. I seem to have figured out most of it from reading through various posts in the forums and looking at various example problems but I am struggling with one section of the data processesing.
Attached is a screenshot that contains the front panel of the VI with a sample of typical data, the section of the main VI block diagram of concern and the block diagram of the sub vi that I am struggling with. If you look at the data, the blue line is the voltage signal from a pot in the cylinder that gives me position, the red trace is a reading from a load cell and the green is a continuinty measurement that signals when the items I'm pulling apart has been separated.
What I want to be able to do in data processesing is determine the slope of the blue line (velocity of the cylinder) at the instant continuity is lost as well as the peak value of the load cell reading in a window around that time. I have a DAQmx task configured to trigger upon a rising edge 1in signal on the cylinder and collect a finite sample of 250 points at 5khz. The daqmx read in the loop is configured to pull one sample waveform when its available and enque it. The second loop is configured to deque this array of 3 waveforms and display it on a chart, process the data and write the data to a text file.
One of the things I noticed while testing this VI is that the data seems to be being dequed a single data point at a time (or at least plotted like it is) but I was under the impression that the whole waveform should be dequed as one element? As for the data process sub vi, it seemed to work wthen I was testing a simplified version of it without the search waveform function so I suspect my issue could be with that. I would really apprciate any feedback you guys could provide. Thanks!
P.S. Please excuse the really hokey way I have the while loop conditionals set up, I hope to have something a little more elaborate before I deploy the code.
Solved! Go to Solution.
04-03-2012 07:56 PM
daBub,
The slope will be the easy part. First find the continuity break by searching for the place where the value drops to about 2 V. The Search 1D array will do this if you reverse the array. It only searches for rising signals. Then extract a set of data points from the velocity data before and after the index of the break. Use Linear Fit.vi from the Mathematics >> Fitting palette. Outputs include slope and intercept. Your data looks quite clean so a linear fit should work fine.
Your data is being dequeued one point at a time because that is the way you are acquiring it! Change the Read VI to acquire NChan NSamp.
Lynn
04-04-2012 12:47 PM
Good point on the NchannelNsample, I actually had it set correctly in some test code so I thought it was really strange when it worked differently in the main program.
I have a question on the search 1D array function, it seems that function will only work if the actual value is in the array but I can't guarantee that the continuity data will contain a data point of exactly 2V or in fact any discrete value. I was hoping to use the search waveform function because it seems that it has a tolerance window for the value searched. Is this the wrong way to implement it?
04-04-2012 01:59 PM
daBub,
Use the Threshold 1D Array function rather than the search function. This is what I get for generating a reply without looking things up. The Threshold 1D Array finds the first place where eon element is below the threshold and the next element is above it. That is why you need to reverse the array since you are looking for a falling edge.
Lynn
04-04-2012 06:19 PM
Lynn,
That worked perfectly! Thanks a bunch.
04-04-2012 07:30 PM
daBub,
Glad to be able to help.
Lynn