From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to separate a variant?

Solved!
Go to solution

Using the DAQmx Counter - Read Pulse Duty Cycle and Frequency example, the data is stored in a variant with both duty cycle and frequency. If you want to separate the two values so they are each an independent array, how do you accomplish that? I've tried indexing the array, which only removes a single pair of values, and not one of the sets. Then, I though to use get variant attribute, but that didn't work either.

0 Kudos
Message 1 of 5
(2,481 Views)
Solution
Accepted by randomguy77

The example VI I'm looking at doesn't have a variant.  It has an array of clusters.  Each cluster has the duty cycle and frequency.  So you just need to index and unbundle.

 

Counter%20-%20Read%20Pulse%20Duty%20Cycle%20and%20Frequency%20(Continuous)_BD

0 Kudos
Message 2 of 5
(2,475 Views)

It depends on how the data is stored, but I'm guessing it is the Variant to Data you are looking for.  You specify the data type of the variant and then the output is the data in that format.  Of course this only works if the data type is correct and if it is wrong it will generate an error.  It is odd to me that this function doesn't just return the data in the native data type.

0 Kudos
Message 3 of 5
(2,468 Views)

Ah that is what it is then. My first thought was that it was a cluster, but I didn't index them first when I tried to unbundle, and so got an error on the wire. Thanks.

0 Kudos
Message 4 of 5
(2,460 Views)

Just hover over the wire or the terminal with context help turned on, or look at the indicator on the front panel and it will et you know how the data is structured.

0 Kudos
Message 5 of 5
(2,455 Views)