LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change a hex value to normal without changing the characters

Solved!
Go to solution
How can I change "3932" (hex displayed string) to "39 32" (normal displayed string with space)
0 Kudos
Message 1 of 21
(3,605 Views)
Solution
Accepted by topic author chuck72352

Hi chuck,

 

-convert the string to array of U8

-feed that array to an autoindexing FOR loop, convert each byte to hex string of length=2, add a space, wire the concatenated string out of the loop (resulting in a string array)

- wire the string array to a "concat string" node to get a single string, remove the last char (as it is a space)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 21
(3,597 Views)
Thank you, I'll try it.
0 Kudos
Message 3 of 21
(3,593 Views)

No luck with that, but I was able to do it in C and put the result in a file then access it from Labview.

 

Thank you.

0 Kudos
Message 4 of 21
(3,587 Views)
Here's my attempt in LV  ( see attached )
0 Kudos
Message 5 of 21
(3,581 Views)

The following snipit will do the job no matter how long the input string is, as long as it is an even number of characters.  Another requirement is that the input string should not have any spaces.  If it does, just create code to remove spaces from the string.

Hex_Display.png

Message Edited by tbob on 03-25-2010 08:54 AM
- tbob

Inventor of the WORM Global
Message 6 of 21
(3,576 Views)

Thank you,  it works well.

0 Kudos
Message 7 of 21
(3,565 Views)

I don't understand tbobs solution, because it assumes that the input string is in hex formatted normal display while the original problem stated that the input is in hex display. Big difference! (I also don't see why it needs a 100ms wait in the loop, but maybe I am just impatient ;))

 

Assuming the input is a binary string set to hex display and you want the output hexadecimally formatted as normal display with a space between each octet, you could do something like the following. I don't think you need to worry about the final space. Do you?

 

 

 

Message Edited by altenbach on 03-25-2010 09:26 AM
Message 8 of 21
(3,537 Views)

altenbach wrote:

I don't understand tbobs solution, because it assumes that the input string is in hex formatted normal display while the original problem stated that the input is in hex display. Big difference! (I also don't see why it needs a 100ms wait in the loop, but maybe I am just impatient ;))

 


 

I didn't notice that the input was a string set to hex display.  I thought it was a regular string.  As for the time delay, that is my standard practice for all loops to not hog the CPU, unless it is very time critical.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 21
(3,527 Views)
I think your VI works and if I understand what your input data looks like and the output that you want is, does it?I really can't see a better way. Does it not work for what you want? What form is the actual data in as you receive it? (not how it is displayed by the display setting of the string control)

You have the string control set the “Hex display” and that may be confusing some of us as to what the actual input data is.

And what you want your output to look like. Do you get a “stream” of bytes that are the actual numbers in the form of a string?or

Do you get a “string” of ASCII char that represent numbers?

These are two different things, but may look alike depending on the display setting of your controls are set.

 Changing the display mode of a control or indicator does not change the under lying data. It only changes the way your eye “see” it, not how LabVIEW “sees” it. 

We need to know what your raw input string looks like.

tbob's snipit assume your data is one way and your VI assumes another.

 

Omar

Omar
0 Kudos
Message 10 of 21
(3,527 Views)