LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search timestamp array for a specific value

Hello,
 
I need some help creating a VI that will allow me to do some data post-processing.  The problem is multifaceted, so help on any aspect will be of great help.  The end goal of the VI will allow the user to select two times, intial and final, and create a plot based on the corresponding data vs. the time selected, and output to a .jpg. 
 
1.  How do I find the index of the time array?  Right now, no matter what time value i input, the index is zero.  The time input should only be significant at most to seconds.
2.  How do i select all the values between the two chosen times?
3.  Is there a better way to read in my .tdm file?
4.  Documentation on exporting plots?  I also have Diadem.
 
Attached is the VI that im working with.  The post unfortunately does not allow .tdm files.  I can't say that i've gotten very far, so any advice would be much appreciated.

Alex
0 Kudos
Message 1 of 10
(4,718 Views)
You can't use the Search 1D Array function since fundamentall a timestamp is a double and you can't perform an exact match against an array of doubles. You should do a numeric conversion to DBL for the timestamp array and your search elements and use the Threshold & Interpolate functions. Something like this:


0 Kudos
Message 2 of 10
(4,688 Views)
Those are definately some functions I would never have thought about using.  I'm not even sure if I completely understand now, after having studied them.  However, I do understand the basic idea.  One problem though.  No matter what time I input, it always displays the last point in the array.  Why is this?
Thanks,
Alex
0 Kudos
Message 3 of 10
(4,664 Views)
The "Threshold 1D Array" works in a similar manner as the "Search 1D Array" except that it doesn't try to find an exact match. It finds the two array elements between which your search value falls. It then tells you a fractional index that basically tells you where it falls between those two values. So, a value of 2.5 means it falls smack in the middle between the third and fourth elements of the array. A value of 2.1 means it would fall just after the third element, and a value of 2.9 means it would fall just before the fourth element. The one caveat is that the array must be monotonically increasing. The "Interpolate 1D Array" can be used to interpolate a value given the fractional index. In your case it isn't really necessary - I was showing it for demonstration.

As to your specific question, I'm not sure which array you're talking about. When you run the VI does the "32bit ingerer" indicator give you the correct index based on the timestamp that you're looking for?
0 Kudos
Message 4 of 10
(4,647 Views)
Ok, that makes more sense.
 
The 32 bit integer always displays the same number no matter what I choose my timestamp to be.  My data file has 36,404 entries, and the index displayed is always that.   
0 Kudos
Message 5 of 10
(4,641 Views)
Hmmm... Not sure what's going on there, unless there's something wrong with the array of timestamps. It's unfortunate you can't submit the TDM file. Perhaps if you zipped it up?

Alternatively, create an indicator at the output of the second "Read Data" VI where you grab the time data (right-click on the wire coming out of the "Read Data" VI and select "Create Indicator". Run your VI. The indicator on the front panel will be populated with the data extracted from the TDM file. Then, drag and drop this indicator onto a blank VI. From the Operate menu select "Make Current Values" default and save this VI. Close this VI and then reopen it from disk and verify the indicator still has the data in it. Post this VI.
0 Kudos
Message 6 of 10
(4,633 Views)
Ok, this should work.  Should have thought of this before.
0 Kudos
Message 7 of 10
(4,630 Views)
OK, I was able to run the VI, and I have to ask an obvious question... Are you putting in the right date? The data shows the year as being all from 2005. Are you searching for a timestamp with a year of 2006? If so, it will always go to the last element. I created a copy of your VI with the data extracted from the TDM file saved to controls and you can see that the search works.
0 Kudos
Message 8 of 10
(4,622 Views)

Hahaha!

Well, I was relieved to find out that the date was correct.  However, after going back and forth between the two versions of the program, I realized I had made an equally dumb mistake.  I was in PM instead of AM!  *doh*

Thanks alot for the help.  Now that I've gotten that step taken care of, hopefully I can make some more progress on the others. 

Alex

0 Kudos
Message 9 of 10
(4,619 Views)
Bingo. Glad to hear that it was something easy to catch. Gee, maybe there is a good reason for military time after all..

Good luck with the rest of your program.
0 Kudos
Message 10 of 10
(4,614 Views)