LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting a Hex number to an string of Hex numbers.

Solved!
Go to solution

Hello all, 

 

I am getting 1036 bytes of data in from a device through VISA recieve, and I would like to insert the data in hex form into a Word report document as it arrives. Whenever I use the append report text VI, I get the ascii representation of my hex numbers. I would like the hex numbers to be inserted into the Word document. 

 

Any suggestions?

 

Thank you!

Jameson

 

0 Kudos
Message 1 of 11
(3,568 Views)

String to byte array.  Then number to hex string.

 

0 Kudos
Message 2 of 11
(3,560 Views)

Can you give your definition of "hex form" and "hex numbers" and "ascii representation"?

 

Do you want the string formatted as 2072 printable characters (0..F), for example?

 

(A word document does not handle binary strings well, I guess you want to format in some way).

0 Kudos
Message 3 of 11
(3,558 Views)

I want a hexidecimal value thats output from a VISA read as "4A" for example to display in Word as "4A". 

 

0 Kudos
Message 4 of 11
(3,555 Views)

 


@JamesonBeebe wrote:

I want a hexidecimal value thats output from a VISA read as "4A" for example to display in Word as "4A". 


Try one of these alternatives (from here)

 

 

 

0 Kudos
Message 5 of 11
(3,550 Views)

@JamesonBeebe wrote:

I want a hexadecimal value thats output from a VISA read as "4A" for example to display in Word as "4A". 

 


Have you tried what I posted?

0 Kudos
Message 6 of 11
(3,545 Views)

I did try your post, not quite what i wanted because it was an array of strings. I needed  to do the second method that Altenbach suggested which was concantenate strings function to put them all together. You can't insert a 1D array into a Word text input.

 

Although now my data looks like: 

 

A00BC000C8E787F002695A5184BA84F4062E0964E454037932C922D2808680E3A80B80004867A7F01249DA5194BA84F4062E1964A4540B79A0C922D2918680E3A00BC101C8E787F00269DA5184BA85F4062E0924E4540379E0CB22D2818480E3A00BC100C8E586F002495AD584BA85B4062E0964E4540379A0C922D2810490E30379A0C922D2018480E3A00BC00188E787B00249DA5184BA85F4462E0964E4540379808922D2218480EBA00BC801C82787B00249DE5184BA84F0066E0964E4140379E0C922D2

 

and I'd like to break it up into words. It looks much nicer as words and is easier to follow. Any suggestions?

 

 

0 Kudos
Message 7 of 11
(3,541 Views)
Solution
Accepted by topic author JamesonBeebe

Then use array to spreadsheet string with a space as the delimiter.

 

 

Note:  It puts a carriage return/line feed which you may or may not need.  If you don't need it, then strip off the last characters of the string.

 

 

0 Kudos
Message 8 of 11
(3,538 Views)

Getting closer...Smiley Wink That groups in bytes.

 

0B 38 A0 C9 22 D2 80 84 90 E3 80 0B 84 01 C8 67 87 B4 00 69 DA 51 80 BA 84 FC 06 6E 09 64 C4 54 83 79 A0 C9 22 D2 80 84 80 F3 A0 0B C0 20 D8 77 87 B0 02 49 DA 51 84 BA 84 F4 06 2E 09 64 E4 54 03 79 A0 C9 22 5A 81 84 80 E3 A0 0B CC 01 C8 47 A3 B0 02 49 DA 51 84 9A 84 F4 06 2E 09 64 E4 54 03 79 A0 C9 22 D2 81 84 84 E3 A0 

 

 

I would like it grouped into words. 

 

0B38 A0C9 22D2 8084 90E3 800B

0 Kudos
Message 9 of 11
(3,532 Views)

Instead of converting to a U8 array, typecast to a U16 array, then use "%04x " (note the space at the end) as format in my upper example (the one with the loop) or use Ravens spreadsheet version with a width=4.

Message 10 of 11
(3,525 Views)