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: 

changing unit text limitations -error 1128

Solved!
Go to solution

Hey everyone,

 

I'm developing a VI which uses the native power of LabVIEW Units to do all my number conversions.

 

Here's my question, once the units are set for a control at edit-time can i change the Unit Text to something unrelated at run-time in order to prepare my indicator for a different signal? For instance lets say Channel 1 is a temperature for Test1 so programmatically converting from Fdeg to Cdeg and back is no problem for LabVIEW. For Test2, the same VI is used but now Channel 1 is a pressure. Can i programmatically change my indicator units from Fdeg now to a pressure unit like psi, atm, or bar? I'm getting Error 1128 "Input unit is not compatible with the current unit." even though the unit is correct when entered at Edit-time.  Any thoughts?

 

Thanks,
Craig

0 Kudos
Message 1 of 3
(2,516 Views)
Solution
Accepted by topic author craige

Hi craige,

 

no, you can't change the unit type at runtime. This will be fixed at compilation time... You can only change to other representations of the same physical property (like Pa to bar or to some obscure psi for pressure).

 

One old trick when using units:

You may use "$1" as unit for a control. Using a "Convert unit" function also set to "$1" you can then strip the unit. So your subVI will accept any unit for the connected control - but that doesn't solve your perticular problem Smiley Wink

Message Edited by GerdW on 12-30-2009 08:31 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(2,505 Views)

You've answered my question. The solution you provided does help in at least displaying the units but unfortunately does nothing for leveraging the numerics ability to convert within unit types.

 

At least with the method you described I could store the unit in its righful place, programatically extract the unit later, and make my own conversion VI. Thank you!

0 Kudos
Message 3 of 3
(2,499 Views)