LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number convert to hex string and write to port

Hi,
       i want to convert decimal number to hex string.i am using global variable as decimal integer.i want single data from globle variable as a single bit,means 8 globle variable as a 1 byte.
0 Kudos
Message 1 of 14
(5,123 Views)
Hi shubhlaxm…,
here is an example.
 
 
Mike


Message Edited by MikeS81 on 06-06-2008 08:25 AM
0 Kudos
Message 2 of 14
(5,120 Views)
Hi,
     i dont understand can u explain it in brief.how to make that constant.
0 Kudos
Message 3 of 14
(5,116 Views)
Hi shubhlaxm…,
i thought you have 8 numbers which you want to combine. If you only want to convert a number to a hex string, then only use the "Number to hexadecimal String" function.
Mike
0 Kudos
Message 4 of 14
(5,105 Views)

Create a numeric constant. Right click and get properties. select "show index" in the appearance tab.

Then you can choose index like decimal, binary, octal or hexa....

0 Kudos
Message 5 of 14
(5,104 Views)


shubhlaxmi22 wrote:
 i want to convert decimal number to hex string.i am using global variable as decimal integer.i want single data from globle variable as a single bit,means 8 globle variable as a 1 byte.

We cannot help you because we don't know what you have and wat you want. Your question is not clear.
 
What is the datatype of the global variables? If each integer is one bit and you have 8 of those, we need to know how they map to the bits. (e.g. "0,1" for "bit set/not set", resp.).
 
Then we also need to know whay you mean by "hex string". Is it a hexadecimal formatted string consisting of the letters 0..F, each representing a nibble, or do you want a binary string where 1 byte represents your 8 bits.
 
One solution might be to make an array of your 8 globals, wire it to a "not equal zero", and then convert the result to a number using "boolean array to number". If you want a bunary string, you would then typecast it to a string. If you want a formatted string, you would use "number to hexadecimal string".
 

The following code converts 8 "0/1" values to a binary string. Modify as needed.
 


Message Edited by altenbach on 06-06-2008 12:10 AM
0 Kudos
Message 6 of 14
(5,099 Views)
Hi,
     Thanks it works properly.
 
0 Kudos
Message 7 of 14
(5,087 Views)
Hi,
     It works but when i connect more than 8 global variable means 9th variable to build array then what happens?
0 Kudos
Message 8 of 14
(5,047 Views)
Hi shubhlaxm…,
if you need more inputs, then you can resize the build array function. I recommend to visit the free courses on the ni site.
See this link please: http://www.ni.com/academic/lv_training/how_learn_lv.htm

Mike

Message Edited by MikeS81 on 06-06-2008 07:44 PM
0 Kudos
Message 9 of 14
(5,044 Views)
hi,
    when i connect 8 global variable it gives me output in BCD count but if i want 9th variable as a first then what should i do when i resize that array.i am sending u attachment see my logic. consider 8 variable means 1 byte  then from 9th to 16th  2nd byte.is it right ?


Message Edited by shubhlaxmi22 on 06-06-2008 12:51 PM
0 Kudos
Message 10 of 14
(5,040 Views)