LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hexadecimal String Content to Decimal Content

Solved!
Go to solution

I am writing a code in LabVIEW to convert MBus data for some Energy Meters.

 

Apparently the meter I am using is sending data as a String in Hex Display format, however after correctly parcing that string in hexadecimal, the real value is the decimal number in that hexadecimal string without convertion.

 

Example:

- Reply from the meter (String in Hex Display):

68 37 37 68 08 07 72 89 12 13 67 A7 32 04 04 00 00 00 00 0C 06 09 58 02 00 0C 14 39 13 79 00 0B 2D 47 00 00 0B 3B 30 32 00 0A 5A 81 03 0A 5E 68 03 0A 62 13 00 0F 21 04 00 00 20 86 16

 

- After parcing I get the Bytes 22 to 25 (09 58 02 00) in the correct order, i.e. 00 02 58 09 which means 25,809 MWh.

 

This means that I must somehow transfer that numbers from the string in hex display to a decimal format and divede it by 1000 to get the proper value in MWh.

 

I have tried to use Type Cast and String Conversion with no success. Can anyone please help me find a solution?

 

Best regards.

0 Kudos
Message 1 of 5
(3,331 Views)

@Quintino wrote:

Example:

- Reply from the meter (String in Hex Display):

68 37 37 68 08 07 72 89 12 13 67 A7 32 04 04 00 00 00 00 0C 06 09 58 02 00 0C 14 39 13 79 00 0B 2D 47 00 00 0B 3B 30 32 00 0A 5A 81 03 0A 5E 68 03 0A 62 13 00 0F 21 04 00 00 20 86 16


OK, don't confuse the issues. If the above string is really what you see if the string indicator is set to hex display, something is wrong, because the byes would be grouped in 4 characters. If the above is a string in normal display, we would need to know what these delimiters are, for example.

 

Can you attach a simple VI that has the exact string you get from the instrument as a diagram constant? (read the instrument so the string shows in an indicator, right-click its terminal and "create constant").

0 Kudos
Message 2 of 5
(3,324 Views)

Dear altenbach, thank you very much for the support, altough I manage to find a solution for this problem.

 

I believe there is a better way to do this, but this is working for me.

 

I am sending in attach the VI I have created. Please feel free to see it and if you have a better solution to do it, please keep me posted.

 

Best regards, and thank you for the support.

0 Kudos
Message 3 of 5
(3,263 Views)
Solution
Accepted by topic author Quintino

How's this for simplified?


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 4 of 5
(3,250 Views)

That's the simplification I was counting on 🙂

 

Thank you for your support and knowledge.

 

Best regards.

0 Kudos
Message 5 of 5
(3,239 Views)