LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with output string size of the 'number to hexadecimal string' VI

Hi everyone.

 

I am new to Labview, so I apologise if this question is too simple. I am trying to convert a float to a hex string so I can pass it to a VISA Write VI. I first cast it, so it becomes a 32-bit int and then on to the 'number to hex string' VI. Now, since after the casting the number is a 32-bit int, I would assume that the output hex string would also be 32-bit long (so 4 bytes, which is what I need). However, I use the 'string length' Vi and it says the hex string is 8-byte long. Could someone please tell me why this is the case?

 

Thank you very much in advance,

 

Gabriel

0 Kudos
Message 1 of 4
(2,215 Views)

Are you sure it is 8 bytes? Don't confuse a nibble and a byte.

 

Try the "flatten to string" function. 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 4
(2,212 Views)

The number to hex string VI converts a number to an ASCII string representation of the number, so 0xABCDEF01 would become the literal string "ABCDEF01", which is 8 bytes long.  If you want the int converted into the binary string, you can use type cast to cast it to a string.  Then it would be a the string "\AB\CD\EF\01" which would be 4 bytes, the first character ASCII 0xAB, etc.

Message 3 of 4
(2,205 Views)

Thanks a lot, type cast solved it. I didn't know it could output strings too.

0 Kudos
Message 4 of 4
(2,194 Views)