09-02-2025 12:53 PM
Attached is my VI that I have been working on for some time.
For whatever reason, I am unable to convert two hexadecimal bytes to a number. I have tried using the functions "Hexadecimal String To Number", "Type Cast", and "Scan Value". I receive the correct two-byte hexadecimal string data. However, it does not convert the string to a number, allowing me to perform the necessary math to convert it to a voltage value.
Example:
The hexadecimal string, Byte 1 = 0A and byte 2 = B2 (0AB2), should return the number 2738. I would then perform a conversion to 2.738V.
Solved! Go to Solution.
09-02-2025 01:40 PM - edited 09-02-2025 01:58 PM
Typecasting to U16 would be correct:
(Your attached code makes very little sense, for example if your array size is >3, you take a subset of three elements starting at three, so that subset could be anywhere from 0 to a huge number of elements)
09-02-2025 01:47 PM
Your attached VI takes an array of u8 numbers, not a string. From your example 0AB2 being "returning" the number 2738 it sounds like you are getting a 16 bit number (or maybe bigger) returned as an array of 8 bit numbers. You can take a 2 element array of u8 [0A/10] [B2/178] and type cast it to u16 to get 2738.
I suspect you want something like this.
This assumes unsigned numbers and only 2 bytes in the string. If you really are looking at three bytes you will need to use a bigger data type than u16.
09-02-2025 02:09 PM
Thanks! It was a matter of where I was taking the value from and not using a string to a byte array.
09-02-2025 02:10 PM
Sorry my code does not make sense. I have not used LabVIEW in the last 10 years. Little rusty with my code. You solution did work! Thanks!!!!