LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unexpected implict conversion from unitless to unit

If I drop a constant unitless double value on a diagram and a doube indicator in the front panel, with some kind of units, and connect both, I get a broken wire, i.e. no implicit conversion from unitless to units.

 

If I drop a constant unitless double value on a diagram and connect it to both input choices of the buit in select, connect some value to the selector, and connect the output of the selector to a double indicator with some kind of units, I get a broken wire, i.e. no implicit conversion from unitless to units.

 

If I drop two constant double values on a diagram, one unitless and the other with units, and connect each to the two inputs of the selector, connect to the selector a constant that selects the unitless constant, and connect the output of the selector to a double indicator with the same units as the input with units, I get all valid connections and an implicit conversion from unitless to the base unit of the input.  This is a bit unexpected, shouldn't I get a broken wire in there somewhere?

units.png

0 Kudos
Message 1 of 7
(2,757 Views)

Working in 2014 the bottom scenario will result in a broken arrow if the meters is connected to the true input of the select regardless of what the input to select is.

 

Not saying this makes sense at all, it is just an observation.  I don't really use units in LabVIEW often but I'll see if I can find any other information.

 

Edit:  You can disconnect the select and try this out, if you look at the resulting error it will say that there is a data type mismatch where both the source and sink are "No Units"

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 7
(2,738 Views)

Okay, it's a slow Friday so here is what I found.

 

1. If we connect one unitless input and one input with units to a select function we receive a broken run arrow only when the the true input has units.

 

2. If both inputs have units but do not match, we receive a broken run arrow regardless of input placement.

 

3. In Range and Coerce will actually coerce units, it is the only simple primitive I found that does this.

 

4. Stuff gets really, really wierd with units. Follow these steps:

     a. Create four double constants, two unitless and two "m"

     b. Drop a select function and an "In range and coerce" function

     c. Wire one "m" to the true input on select and one into the upper limit of the in range function

     d. Wire one unitless numeric constant to the false input of select and one to the lower limit of the in range function.

     e. Delete the Select function

     f. Undo

 

In conclusion: LabVIEW units, how do they work?  If I have time next week I'll try to ask around.

 

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 7
(2,722 Views)

I'm on 2012, and didn't try swapping the inputs to select.

I don't want any implicit conversion to happen, as there is no way LabVIEW can tell which units the user has in mind for the unitless branch.

A broken wire will force the user to realize the need to  insert a Convert Unit with the proper units.

 

0 Kudos
Message 4 of 7
(2,716 Views)

How do you convert from a wire with units to a wire that is unitless?

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 5 of 7
(2,033 Views)

@eximo wrote:

How do you convert from a wire with units to a wire that is unitless?


With the same node that you use to do the opposite!

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 7
(2,025 Views)

@eximo wrote:

How do you convert from a wire with units to a wire that is unitless?


With the same node that you use to do the opposite! If you think about that is quite useful as you want to be able to define in which scale the unit less value should be. (eg. kg, g, mg, ug)

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(2,024 Views)