LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hexadecimal conversion

Hey,

 

My problem is : I have to convert a decimal number to hexadecimal to send it. So, I use the fonction "convert number to hexadecimal string". I connected the output with an indicator.

 

But it doesn't work for my case because when I choose (with left click) hexadecimal display I don't have the "good" thing. For "normal display", the hexadecimal number is good.

 

An exemple : Decimal 200, convert to hexadecimal in normal display : 8C & in hexadecimal display : 3843.

 

Actually my instrument receive "3843" and it don't work.

 

Thank You

0 Kudos
Message 1 of 6
(2,596 Views)

Post your code so we can see what is happening.

 

Also, did you do any search before posting? There are a number of discussions on this topic, one for instance:

http://forums.ni.com/t5/LabVIEW/how-do-I-convert-a-deciaml-input-to-a-hexidecimal-output-in/m-p/2400...

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(2,590 Views)

Hi Hreidmarr,

 

I think I understand what you are saying.

 

Do you need to change the string control to the Hex display? The hex display is showing the ASCII representation of the hex string. If you leave it in normal display you will get the hex value you expect.

 

i.e. 200 = C8

 

Olly

**********************************************************************************************
The day is quickly coming when every knee will bow down to a silicon fist, and you will all beg your binary gods for mercy.
0 Kudos
Message 3 of 6
(2,575 Views)

This!

 

For more details, screenshot and my code

 

1.JPG

 

 

2.JPG

 

 

I think my device doesn't work because it read the normal value but it need the hexadecimal value

0 Kudos
Message 4 of 6
(2,566 Views)

I don't think that's why your device (whatever it is) doesn't work. That is the standard way to send a hex number. Now, if your device requires that the characters be sent in reverse order ("little endian" instead of "big endian" - or maybe the other way around), then maybe sending it 0x3843 (for 200 decimal) may be the trick. There is a LV function to reverse the byte order.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 5 of 6
(2,548 Views)

If you want to see "C8" when setting the string to hex display, I assume that the number is U8 and you want to send a single byte. (I am not sure why you are using DBL representation in your attachment, so change that!).

 

Simply typecast the U8 numeric to a string as shown and you should have all you need.

 

 

Message 6 of 6
(2,539 Views)