LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Hex Conversation

Hello,

Long time havent used LV and forgot a lot of things. 

 

I just got myself in trouble with this.

 

I got string  "AC100080B240" which is the HEX values i need to use, but they are in string

How to manipulate the string to got the date as hex format to send. 

Attrt_0-1637086292787.png

I have tried something like that, but without any success.

 

Thanks in advance for the support.

0 Kudos
Message 1 of 10
(1,430 Views)

You probably want to use String Subset in a loop to split the string into 2-length strings (each letter is just 4 bits, so to get a U8 value you would want two at a time).  Then convert each 2-length string using Hexadecimal String To Number.  

0 Kudos
Message 2 of 10
(1,424 Views)

Thanks, but I failed again. Forgoted a lot about that loops

0 Kudos
Message 3 of 10
(1,418 Views)

Kyle97330_0-1637088872505.png

 

0 Kudos
Message 4 of 10
(1,412 Views)

How about something like this?

S2HCapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 10
(1,399 Views)

@Attrt wrote:

I got string  "AC100080B240" which is the HEX values i need to use, but they are in string

How to manipulate the string to got the date as hex format to send. 


Well, that string is not "HEX values", but already hex formatted (all characters are 0..F!). There is nothing to do!

 

Please explain what you need to "send" and what "Hex format" even means in this context. What does the "receiver" on the other end expect? (some numeric type? U8 array? binary string?, i.e. a string that "looks right" when the display is set to hex display, etc.)

0 Kudos
Message 6 of 10
(1,390 Views)

Do you want one number or an array of U8's? If one number, just use Scan from String with format code %x (and make sure your output is of sufficient size to display the new number, like a U64).

 

Example_VI.png

0 Kudos
Message 7 of 10
(1,359 Views)

They are formatted as HEX, but they are like string for me in LV.

Attrt_0-1637141897240.png

Hex are displayed as hex. String displayed as normal Display.

 

Any suggestion, i just got totally blocked with this.

0 Kudos
Message 8 of 10
(1,334 Views)

Hi Attrt,

 


@Attrt wrote:

They are formatted as HEX, but they are like string for me in LV.

 

Hex are displayed as hex. String displayed as normal Display.


These are all strings in your image…

 

For your "string" part of the blockdiagram: switch all string constants (and the array indicator) to "hex display" mode. And make the displaymode symbol visible for all string constants…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(1,324 Views)

@Attrt wrote:

They are formatted as HEX, but they are like string for me in LV.

Attrt_0-1637141897240.png

Hex are displayed as hex. String displayed as normal Display.

 


 

You are confusing all of us with your image, because you don't say which style is your input and which style is the desired output.

 

The display style is a purely cosmetic property and has no effect on the underlying data. To convert between the two, the data needs to change.

 

It would be so much easier if you could attach a small VI containing the array of diagram constants that you have as input (i.e. one of of the two shown in the image, but which one???) and we'll will show you how to convert it to the other.

0 Kudos
Message 10 of 10
(1,300 Views)