LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a 16bit Hex string to a 16bit binary array

Hello, I have three registers 35, 36 and 37. This is the format of
the register number and word:

35 FF42
36 02FF
37 002C

How can I extract the 16bit hex word (like say from register 35) FF42
and convert it to a 16bit numerical binary array.

Thanks for your help,
Rajesh.

0 Kudos
Message 1 of 6
(6,045 Views)

Hi Triniboy

i think you just have a representation problem. if you have data, no matter if it is in hex or decimal, simply connect it to an indicator, and in "properties/format and precision", just set to hex or floating point.

is it helpfull?

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 6
(6,043 Views)


@triniboy wrote:
35 FF42
36 02FF
37 002C

your question in its current form does not have an answer. The answer depends on how your data really looks like.

  1. Do you have three lines of ASCII formated text with the %04x formatted number starting at postion 3 of each line?
  2. Is it an array of strings, one element for each line?
  3. Is it an array of binary strings with the first number being the index and the second number the value displayed with the string set to "hex display"?
  4. Is it an array of U16 integers with the display set to hex format?

Depending on the flavor of your data, you have to use e.g. "scan form string", "Hexadecimal string to number (with offset set to 3)", "typecast", "unflatten from string", "nothing", etc. It all depends.

We can only give you the appropriate answer if you tell us exactly what kind of data you have. Where does it come from? Could you attach a small VI that has your data in a diagram constant so we can see how it looks like in real life? Thanks! 🙂

0 Kudos
Message 3 of 6
(6,036 Views)
On May 5, 12:10 pm, altenbach <x...@no.email> wrote:
> triniboy wrote:35 FF4236 02FF37 002C
>
> your question in its current form does not have an answer. The answer depends on how your data really looks like.
>
> - Do you have&nbsp;three lines of ASCII formated text with the %04x formatted number starting at postion 3 of each line?
>
> - Is it anarrayof strings, one element for each line?
>
> - Is it anarrayof binary strings with the first number being the index and the second number the value displayed with thestringset to "hex display"?
>
> - Is it anarrayof U16 integers with the display set to hex format?
>
> Depending on the flavor of your data, you&nbsp;have to&nbsp;use e.g.&nbsp;"scan formstring", "Hexadecimalstringto number (with offset set to&nbsp;3)", "typecast", "unflatten fromstring", "nothing", etc. It all depends.
> We can only give you the appropriate answer if you tell us exactly what kind of data you have. Where does it come from? Could you attach a small VI that has your data in a diagram constant so we can see how it looks like in real life? Thanks! 🙂

Hello,

To make it simplier, I just wanted to type in the register data (eg
FF42) from the keyboard into a string input box, and from that,
convert just the data (typed in FF42) to a 16bit binary array. Is
that possible?

Thanks,
Rajesh.

0 Kudos
Message 4 of 6
(6,016 Views)
Yes, Just use "hexadecimal String to number" with a U16 constant wired to the default.
 
However, even easier (and better!) would be to just use a plain numeric control. Simply right-click it and...
  1. Set the representation to U16
  2. Set the format of the control to hexadecimal, four characters wide, pad with leading zeroes.

Now you can type in you hexadecimal number directly and you don't need to worry about illegal characters. WIth a string control, there is always a chance that you type characters other than 0..F, possibly messing up the desired result. 😉

Message Edited by altenbach on 05-06-2007 05:51 PM

Message 5 of 6
(6,016 Views)

triniboy:

This is the 3rd different thread you have started on the same question (here and here.  Please stick to one thread.  Just reply to the one you already started rather than start a new one.

Please define what do you mean by a binary array as there seems to be some confusion on your requirements.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 6
(5,983 Views)