12-30-2009 11:50 AM
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
Solved! Go to Solution.
12-30-2009 01:28 PM - edited 12-30-2009 01:31 PM
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
12-30-2009 01:46 PM
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!