LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

maintain timestamp on waveform data

I have an interesting problem regarding trying to graph dynamic data with a time stamp.  The data are coming from an array of dynamic data that are converted to one array of waveform data and split into two (or more) arrays for different types of post processing.  I use different subVI's for the post processing.

I originally wrote two subVI's, (one very simple and one a little more complex) but the waveform data passed into these sub-VIs would lose the time stamp.  I made the sub-VI's operate on array inputs and outputs, but I could not find an obvious way to maintain the time stamp or to coerce the sub-VI arrays to accept waveform data.  In both subVI's, the data were double precision upon operation. 

Now, I have solved the problem with the simpler subVI (posted below) by remaking it using NI's "Create SubVI" option under the edit menu.  I cannot do this with the more complicated VI (I don't understand why), so I have tried to mimick the change that occured between NI's subVI creation and my own, which is the array that data are passed into in the subVI accepts waveform data.  When I create an array on the front panel of the more complicated subVI, I can't figure out how to enable the array for waveform data.  I have tried building, getting, setting, etc. an analog waveform and feeding it to the start array, but thus far, no dice.  I have posted both the simple subVI (mine and NI's) and the more complicated subVI to inspire ideas. 

I know this is probably easier than I've convinced myself, so thank you in advance for any help.

Brad
0 Kudos
Message 1 of 11
(4,193 Views)
Two things that might help:

One, a waveform is really just a special type of cluster.  It has a start timestamp (t0), a step interval (dt), a 1D array of readings (Y), and attributes (beyond the scope of this thread).  Since all your functions operate on the array, you can just Get Waveform Componets, perform the math on each Y and then just rebuild the Waveform with the original t0 and dt.  Easy as cake.

Two, it looks like you are evaluating a polynomial.  I highly recomend looking up polynomials in the help.  It is really quite detailed.  I think the Polynomial Evaluation function will help you a lot.  I just did one of the polynomials in my example.  The same sort of case structure can be applied to all three polynomial sub-cases.


Message Edited by jasonhill on 03-03-2006 03:53 PM

Message 2 of 11
(4,176 Views)
The Analog Waveform Datatype is similar to a cluster with three elements (To, dT, data).  You can use the "Get Waveform Components" and "Build Waveform" primitives in the waveform palette to get and set any of those three items.  On a high level, you can get the data from an analog waveform as an array of DBLs, and pass that to your subVI. Then use the "Build Waveform" primitive to re-add the new array of DBLs returned from your subVI back to your original analog waveform. This will preserve the To and dT.
 
Alternatively for your issue, I'm having trouble understaning a couple of things.  In your NI version of the easy subVI, you are using an array of Analog Waveforms as your data.  But in your easy subVI, you are just operating on a single DBL array.  An array of Analog Waveforms would be the equivalant of an array of clusters containing an array of DBLs.
 
I'm going to assume you want to use an array of waveforms rather than a single array of doubles.  In your complicated subVI, you will need to put a for loop around your current for loop to index through the array of analog waveforms. See my changes to your subVI.
Message 3 of 11
(4,172 Views)
I was messing around a little more, and the Polynomial Evaluation is polymorphic.  You can pass the Y array straight to it and it will automajically switch from single element evaluation to array evaluation, eiliminating the need for the inner for-loop.


Message Edited by jasonhill on 03-03-2006 04:14 PM

Message 4 of 11
(4,168 Views)
Thanks for the input, all of it!  You make it sound rather easy, and that polynomial polymorphic subVI will help a lot.  I appreciate the input and I will tinker away on Monday!

Cheers,
Brad
0 Kudos
Message 5 of 11
(4,162 Views)
Hi Jason

Okay, I have a quick and simple question about arrays of waveform data now that I have been tinkering.  To make my subVI (more complicated subVI pasted above) I created an array in the front panel and wired this to the connection diagram of the subVI.  Now, in order to solve this problem as  you have suggested, this array needs to be an array of waveform data in order to be wired to the Get Waveform Attributes through the for loop.  Question: How do I change the array properties to waveform data?  I cannot find an option such as this in the representation or the properties of the array in question.  I realize that I could re-build the sub-VI to make this work, but the question is whether I have to or whether I am missing something obvious about arrays.

Thanks,
Brad
0 Kudos
Message 6 of 11
(4,149 Views)
Jared and Jason,

Thanks for the suggestions - I have it working.  I think Jared had already answered my most recent dumb question, but Jason's pretty pictures distracted me. 

Still, from a newbie's point of view, it seems odd that there is no property of an array that can be selected for waveform data, however waveform arrays can "happen."  I don't see how it is a cluster of arrays of waveform data, because I can't create an array of waveform data out of thin air.  Am I wrong here?

Thanks,

Brad
0 Kudos
Message 7 of 11
(4,148 Views)
Hi Brad,
 
That's a very interesting point.  You can't just pull a waveform constant or control off of the LabVIEW palettes.  However, if you put down any VI that has a Waveform input or output terminal, you can right-click on this terminal and create a Waveform constant, control, or indicator.
 
Hope this helps!
Megan B.
National Instruments
0 Kudos
Message 8 of 11
(4,129 Views)
Thanks Megan,

I guess the reason I ran into trouble is because I wanted to create a subVI from scratch that would accept an array of  waveform data.  Knowing what I know now, I would take other steps to avoid this.  For one, I wouldn't start the subVI with something accepting waveform arrays.  Secondly, I wouldn't try to get waveform components from an array before going into a subVI. 

Brad
0 Kudos
Message 9 of 11
(4,122 Views)
There is a waveform control on the front panel I/O palette.  From there you can change it to an indicator or constant.  Although, I confess that normally I just create what I need from a waveform terminal.  A nice trick when creating on terminals: to get one that is unwired, create a constant or control on an output terminal; or create indicators on an input terminal.
0 Kudos
Message 10 of 11
(4,121 Views)