LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best data type for my application?

Hi all,

 

I have an application I'm developing that reads in recorded data from a file on disk (was recorded by a non-NI DAQ).

 

I am trying to determine the best data type to use to work with the data in Labview. The end goal of my application is to translate the data into another file format.

 

My data is stored in 16 bit binary format. I have all the information to convert each data point to a scalar. I also have the following time information for each channel:

  1. Sample rate
  2. Number of samples in channel
  3. Number of samples that were recorded before a "trigger" event

I was thinking of using the waveform data type to organize my data before I write it to the output file. I was looking at the documentation for the waveform type and if I understand correctly, t0 corresponds to the start time of my first data sample (absolute time).

 

Is there a way to create a waveform with a relative time (i.e. my data starts at -1024 ms and ends at +6000 ms)?

 

Is there a better data type to use? I also considered an array of clusters, where each cluster contains a channel's metadata and an array of data points.

0 Kudos
Message 1 of 9
(2,931 Views)
0 Kudos
Message 2 of 9
(2,870 Views)

I see two ways:

1. Two arrays. One with data and second with properties in class. Classes you may use in other projects and it have properties, methods and private settings.

2. Variant. labview 2017 has a functions for recognize datatype inside variant. Or you can store data type in attributes of variant.

0 Kudos
Message 3 of 9
(2,854 Views)

Waveform with "Pre-trigger" Attribute sounds reasonable and efficient.  Leave t0 "as is" (if you have it, use it, otherwise you can set it to 0, which will look like a time near midnight on New Years Day, 1905), set dt to your sampling time (0.001), and set Pre-Trigger to 1024 (and save an Array of 1024 + 6000 Dbls, scaling them as appropriate to "useful Units" instead of 16-bit integers, unscaled).

 

Bob Schor

0 Kudos
Message 4 of 9
(2,791 Views)

Hi to all. I don't know why do you use the "t0" propertie? NI waveform has a builtin properties.

t0 = NI_ExpStartTimeStamp;

Name = NI_ChannelName.

All of that properties shown in help link.

0 Kudos
Message 5 of 9
(2,768 Views)

Bob,

 

Which attribute is the Pre-trigger one? The documentation I can find is:

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/set-waveform-attribute.html

 

Do I use the "NI_ExpTimeStamp" and set it to -1024 (see attached vi snip)?

0 Kudos
Message 6 of 9
(2,738 Views)

@sirwin wrote:

Is there a way to create a waveform with a relative time (i.e. my data starts at -1024 ms and ends at +6000 ms)?


Sorry, I was unclear.  As I understand your description of your data, when you start sampling, the first 1024 ms of the sample occur before the "real" stimulus occurs, and you then record for an additional 6000 ms.  Your Waveform's t0 corresponds to the start of the entire session (1024 msec before the stimulus).  What I was suggesting is to create a Waveform Attribute called "Pre-Trigger" and set it to 1024 (or 1.024, depending on whether you make it an I32 in milliseconds or a Dbl in seconds).  When you go to process these data, you could read this Waveform Attribute and account for this offset as you wish. This preserves the body of the Waveform Definition that NI has created, so you can use "regular Waveform functions" to process your data.  One of these could be to write a VI that takes a "Waveform with Pre-Trigger" and returns a Waveform with the Pre-Trigger part removed, i.e. a Waveform that starts at the Trigger point.  Here's how you'd make this:

  1. I recommend using Bundle/Unbundle Waveforms from the In-Place Element Structure.
  2. The new t0 is the original t0 + the time offset represented by Pre-Trigger (if it is 1024, then add 1024/1000 to t0).
  3. The new Y is the original Y with the initial Pre-Trigger data removed (a simple Delete from Array function).

Bob Schor

0 Kudos
Message 7 of 9
(2,728 Views)

@sirwin wrote:

Which attribute is the Pre-trigger one


Bob was suggesting to use the Attribute variant, which you can have any number of variant attributes inside of.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 9
(2,717 Views)

@sirwin wrote:

Bob,

 

Which attribute is the Pre-trigger one? The documentation I can find is:

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/set-waveform-attribute.html

 

Do I use the "NI_ExpTimeStamp" and set it to -1024 (see attached vi snip)?


Attribute names can be anything- there are a handful that NI uses for some "under the hood" stuff. I'd just use the name "Pretrigger" where you have "NI_ExpTimeStamp" and call it a day. Attributes work as key-value pairs, where the key can be anything and the value can be any datatype (AFAIK).

0 Kudos
Message 9 of 9
(2,696 Views)