LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO PASS HEX VALUE FROM MAIN PROGRAM VI ENUM, TO SUB VI ENUM

Solved!
Go to solution

HOW TO PASS HEX VALUE FROM MAIN PROGRAM VI ENUM, TO SUB VI ENUM.

HOW TO MAKE IT SO IT WILL PICK CORRECT HEX ENUM VALUES ON SUB VI.

0 Kudos
Message 1 of 13
(5,056 Views)

PLEASE DON'T YELL.

 

That or your caps lock is stuck on.

 

I really don't understand what you are asking for.  Perhaps you can attach a VI or two that explains what the hex value has to do with your enum.

Message 2 of 13
(5,049 Views)
I am assuming the hex enum in the main VI is NOT the same strict type def of the enum of the sub VI and that they are not the same data type size (U32, U16 or U8). Do you get a red DOT on the sub VI?

 

Make sure the size of the data type matches for the enum U32, U16 or U8!

 

Wiring a I16 into a U16 enum input control of a sub VI will NOT give you the expected results.

 

Use a strict type def for your enum and you will not have to worry about this ever again.

Omar
Message 3 of 13
(5,038 Views)

Actually I did not formulate the problem correctly.

 

What I need is to  pass a (Hex value Control Number U32) for example value hex 33 to a  SUB VI ENUM listing, so the sub will run somthing based on Input (30,31,32,33,34,35,36,37.38.39....) from the main program.

 

 

Attached is the Sub vi ENUM.

 

Thanks

0 Kudos
Message 4 of 13
(5,032 Views)

Convert the hex number to a hex string.  Then use this message to get the enum.

Message 5 of 13
(5,000 Views)
Solution
Accepted by topic author Metachnet

The enum values are strings so you need to first convert the hex value to a string represtation of the hex value.

Then convert that to the enum.

 

HexToEnum.png

 

Omar
Message 6 of 13
(4,998 Views)

I am trying to replicate your example:

How do you make Const x32 to Format Value Function.

Does the ENUM to the Scan From String Function needs to have values.

 

Plese look at attachment.

Thanks.

 

0 Kudos
Message 7 of 13
(4,966 Views)

Thank you for the advise.

my program started working but only after I defined Format of Scan from string as %s.

And only after Inputing ENUM List same as in Sub VI.

 

Thanks.

0 Kudos
Message 8 of 13
(4,951 Views)

You actually don't need the %s for the Scan from string.

 

1 & 2.  That is a numeric constant with the radix showing and set to hex display.

3.  That constant should be the same definition as your indicator.  To make sure you don't have issues, that enum should be made into a typedef and the constant and indicator based on that.

 

If you have a hex value that isn't part of the list, the Scan from String will throw and error which you should handle in some way by wiring up the error output from Scan from String.

0 Kudos
Message 9 of 13
(4,944 Views)

You could use "Scan Value" VI which will not throw an error if the string in does not match any of the strings in your enum.

But as Ravens Fan stated you will have to handle the cases when the HEX string is not defined in your enum or except the value of the enum that you wire into the default value input.

 

But I have to ask why are you converting from a numeric (that could be set to display hex) to emun of hex strings. I don't see the gain for the problems you are having converting.

Since you did not know how to set the radix of controls I guess it to display the values in hex instead of decimal.

 

Then guessing again, as to what you are doing in your "Key Select" VI that you might have a Case Structure and wanted to have the case label show the hex value instead of decimal. The radix of the case structure can also be set to HEX by right clicking on the edge of the case structure.

CaseRadix.png

 

So you might not need the enum at all and just use the HEX values.

 

NOTE: you have a RED DOT at the input of the enum of the "Key Select" VI. That tells me the two enum are not exactly alike. May not be a problem, but you should verfy that the RED DOT is OK.

 

Omar
0 Kudos
Message 10 of 13
(4,933 Views)