04-09-2013 05:47 PM
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.
Solved! Go to Solution.
04-09-2013 06:45 PM
@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").
05-14-2013 09:10 AM
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.
05-14-2013 09:55 AM - edited 05-14-2013 09:56 AM
How's this for simplified?
05-14-2013 10:46 AM
That's the simplification I was counting on 🙂
Thank you for your support and knowledge.
Best regards.