LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: convert hex string to number

Solved!
Go to solution

Good Afternoon;

I am trying to do the same thing.  I am reading 8 bytes of data from a modbus gateway.

I grab the substring that I am interested in....if I set the display to normal the reading is non printable.....set to hex display the reading is 3098 should be decimal 12440 I believe?

This feels like I am close but not quite.............

 

0 Kudos
Message 1 of 7
(3,897 Views)

@mned wrote:

Good Afternoon;

I am trying to do the same thing.  I am reading 8 bytes of data from a modbus gateway.

I grab the substring that I am interested in....if I set the display to normal the reading is non printable.....set to hex display the reading is 3098 should be decimal 12440 I believe?

This feels like I am close but not quite.............

 


If you have the section of the string that is your data, use Unflatten From String to convert to your number (either I16 or U16).  I say to use the Unflatten instead of the Type Cast since you can specify Big Endian or LIttle Endian.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(3,878 Views)

@mned wrote:

Good Afternoon;

I am trying to do the same thing.  I am reading 8 bytes of data from a modbus gateway.

I grab the substring that I am interested in....if I set the display to normal the reading is non printable.....set to hex display the reading is 3098 should be decimal 12440 I believe?

This feels like I am close but not quite.............

 


You do have it.

 

Decimal 12440, whether it is U16 or I 16, will directly typecast to hex 3098.

 

If you don't think you have it, then post a VI that shows the data you have saved as default in a control and the way you are trying to manipulate. it.

0 Kudos
Message 3 of 7
(3,871 Views)

Here it is, String2 and substring are set to hex display.

String2 is read directly from a device.

The payload of the string is 08B6.

I need to convert this to decimal......should be 2230.

the 2230 / 100 = the position that I sent the actuator to.......22.3mm.

 

I can not get the conversion...... 

0 Kudos
Message 4 of 7
(3,845 Views)

I know my last post was with a different value than the first.....I have 2 different axis

 

0 Kudos
Message 5 of 7
(3,842 Views)
Solution
Accepted by topic author crossrulz

@mned wrote:

I can not get the conversion...... 


Did you even try our suggestions (Type Cast or Unflatten From String)?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 7
(3,839 Views)

THANK YOU!!!!!!!

0 Kudos
Message 7 of 7
(3,834 Views)