06-21-2012 09:32 AM
Hi all,
I'm working on a program which will compare elements (y1 and y2 from index i1 and i2 respectively)
If y1 is not equal to y2 then I want to store the first time value of the waveform/array that I'm getting the data from. I would then step through the array to compare all the elements in order. I'm assuming that the time values are the same as the index which I can get from the loop iteration count. I want to store these time values/specific indices in a 1D array to display.
But I'm having trouble with the last part and I'm not sure if this is how I go about this problem.
All answers are much appreciated and welcome.
Thanks!
06-21-2012 09:45 AM
06-21-2012 09:56 AM
Hi GerdW,
Sorry, I should have attached the vi earlier. Here it is! What I described earlier is the bottom section of the while loop.
Don't be too alarmed when you see the code, I am still new to Labview and not sure what I'm doing wrong.
Thanks for helping me.
06-21-2012 09:58 AM - edited 06-21-2012 10:08 AM
Time time values will not be the same as the array index unless you are acquiring at 1 hz. What I usually do if needing to convert a waveform to x and y arrays is use get waveform components and that will give you the y array. Then use "ramp pattern.vi" VI to create an X array of timestamps. Here is an example
06-21-2012 10:09 AM - edited 06-21-2012 10:13 AM
Sorry, attached the wrong VI so I'm reposting because I ran out of time to edit! This may be a little overly-complex so there may be a better way. But let me know if this is more what you're looking for. You'll have to add the logic for the greater than into the for loop yourself. Also, I am not sure what you want to compare index 0 from the array to. Do you want to skip the comparison there or compare it to zero? If you want to skip that comparison and just start at index one, you could use a case structure around all the code in the for loop and if i=0 you don't do anything.
Edit: Just realized you weren't looking for a difference but an equality, you will have to modify the code a bit but hopefully this is a starting point.
06-22-2012 10:26 AM
Hi,
Thanks a lot for this. I was wondering if there was another way to set up the x values into the array. It doesn't seem to work for me or maybe it has something to do with formatting the time values.
Is there another way to get time without using time stamps?
Thanks
06-22-2012 11:28 AM
@Ghoster wrote:Is there another way to get time without using time stamps?
Thanks
I'm not exactly sure what you're asking. Do you mean you want to convert the doubles back to timestamps? There is a convert to timestamp primative available in LabVIEW.