LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Type Specialization

Solved!
Go to solution

How can I get a malleable VI to break when a numeric input does not have units?

0 Kudos
Message 1 of 5
(214 Views)
Solution
Accepted by paul_a_cardinale

When I don't find an appropriate node to make a specific type assertion, I instead try to find an assertion of the opposite of what I want.

I then use a diagram "break inversion" technique to achieve the initial type assertion:raphschru_0-1776264555412.png

You can even have multiple negative assertions before the actual code if required.

 

Regards,

Raphaël.

Message 2 of 5
(176 Views)

@raphschru wrote:

When I don't find an appropriate node to make a specific type assertion, I instead try to find an assertion of the opposite of what I want.

I then use a diagram "break inversion" technique to achieve the initial type assertion:raphschru_0-1776264555412.png

You can even have multiple negative assertions before the actual code if required.

 

Regards,

Raphaël.


Nice trick! Just FYI though, I played around with it and if you want to filter waveforms that don't have units, you need to add a "Get waveform components" to another "exclusion" frame and do the check again. That assertion will let a waveform through that has units, so the wrong frame will execute:

 

units.png

0 Kudos
Message 3 of 5
(152 Views)

@BertMcMahan wrote:

 

Nice trick! Just FYI though, I played around with it and if you want to filter waveforms that don't have units, you need to add a "Get waveform components" to another "exclusion" frame and do the check again. That assertion will let a waveform through that has units, so the wrong frame will execute:

 

units.png


I don't think units are supported in waveforms. It seems the unit you set in the waveform constant is simply ignored.

"Get Waveform Component" returns a unitless array and "Get Waveform Information.vi" from the Data Type Parsing palette returns a unitless numeric variant type.

0 Kudos
Message 4 of 5
(139 Views)

Looks like you're 99.9% right. Apparently the waveform controls themselves DO handle it, but it seems you can't do anything WITH those units. You can't even wire up an array with units to Build Waveform.

 

But, if you JUST use waveform controls/indicators, it works:

 

 

94c45d26-f39e-4aa4-b725-a8410358d7b6.png

I believe plots will use whatever units you give them, but you can't adjust it anywhere I can see.

 

(seems like every time I try to use units for anything, I find a case like this within about an hour and give up! See also https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Make-units-work-all-the-way-or-skip-them/idi-p/180351...)

0 Kudos
Message 5 of 5
(112 Views)