LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hexadecimal format as part of the command syntax

Hi all,

I am communicating with multi-gauge instrument and commands have to be specified in hex.
My program will prompt the user to assign the value for particular gauge set point.
The user specifies the three digits of decimal number and the exponent at the end (e.g. 4.44E-2).
The first two digits (4.4) I have to convert and group in a chunk of two digits in hex and send to the device.
I basically used case structure and tried assigning the string in HEX display mode for each number from 0 to 9 that user chooses.
So for the 1st digit "4" I send "04" in hex display and same for the 2nd digit.
Then I hoped when I concatenate these "04" + "04" in hex display will become "44" but it results in "0404".
This way I get extra zeros in the front of 4's.
Since the set point value has precision 2 (4.44), for the last "4" I send "40" in hex and it works fine but
unfortunatelly I can't do the same with previous two digits.

I have attached my program "ConfigureSetPoints.vi" showing the ideal command and the actual command with 2 extra 0's that I need to get rid of.

Can anybody suggest the solution to this problem or some other alternative so that I can generate proper command.

Thanks a lot,
Peja
0 Kudos
Message 1 of 3
(2,858 Views)
Peja,

Each HEX characters is only a nibble (4 bits), thus you need to combine 2 into a byte.
Assuming that the 4 high-order bits are false, you can simply shift the first nibble by 4, then OR it with the second nibble. etc.

I have attached a quick modification to show the procedure.


Some issues:
Do you need to terminate the command with /r/n? Your "ideal" command does not contain it. Add them back if needed.
I recommend a button switch set to latch for the action keys. a latching toggle switch is not natural.
If you make your digits U8, you can typecast them. No need for complex case structures.
You don't need a timeout event. Nothing needs to be done in the empty case. (However, you need a stop event so the VI can be stopped).
You don't need the big case structure. The event structure alone does just fine. 🙂

Message Edited by altenbach on 03-16-2005 04:00 PM

Message 2 of 3
(2,850 Views)
Thanks a lot!

I eventually figured another way to do it but this looks very good.

Thanks again,
Peja
0 Kudos
Message 3 of 3
(2,828 Views)