LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex string to 32 bit float

Solved!
Go to solution

I also wish that thier manual / web site had little more on communication procedures...

 

Though the EM6400 can send upto 20 different values against a single query, just to keep it simple, I am basically trying to read only value - the line to line AC voltage.

 

The query is this : 0103 0F44 0002 870A

 

01 : EM6400 Modbus ID

03 : Query type number for reading a register.

0F44 : Address where the Line Voltage is stored. (3908 decimal)

0002 : Number of registers to read. Two 16 bit registers for one 32 bit Single precision value

870A : CRC value

 

And I know that the above is correct from a third party Modbus checking software ( SimplyModbus 6.3.6), which when used to query the EM6400 with the above query, results in a response of 410.0, which is correct.

 

As to support from Conzerv, all they can tell is to buy thier ConPad software. This forum is far better.

 

Thanks

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 11 of 24
(3,024 Views)

Have you tried my suggestion?

 

It seems possible that you're extracting the string with an offset that's wrong by one. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 12 of 24
(3,021 Views)

Steve,

 

I am yet to try the suggestion. I do feel that it could be a possible way out to try different offsets.

 

This is a large machine and the Modbus link is a small part of it and I will need the machine to try out other possible data reads to check out. Right now other trials are on. And we have issues with LV2009 like charts that do not display minor tick values ; jumble up clusters in a file read / write . We are in touch with NI for solutions and waiting.

 

So now you know that I am not in an enviable position 😉 Will keep you posted asap.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 13 of 24
(3,016 Views)

Raghunathan,

 

The reason I suggested reading 4 registers is because I suspect your register address may be off by 1.  Reading 4 would let you see more registers as a test.  Another way to verify this is to use NI-Spy to monitor the communications between your third party modbus software and the instrument.

Message Edited by Wayne.C on 09-16-2009 08:23 AM
0 Kudos
Message 14 of 24
(3,004 Views)

Hi Steve ,

 

As promised I have been able to get a few more samples and the result values in decimal . Reproduced below is the HEX response byte from the EM6400 and the corresponding decimal result as shown in the SimplyModbus test software :

 

Response                                   Result

 

01 03 04 87 9B 43 73 D3 BD     243.52971

               6E C8           17 F0      243.43274     ( Giving only values that are different from first row )

               74 B1           C1 31     243.45583 

               5B B9           48 27     243.35829

               42 0B           EF 5C     243.25798

               4E 5D           DC 1C     243.30611

               44 EB           EE 22      243.26921

 

( 01 = Device ID; 03 = query type ;  and the last two bytes are the CRC value. Not sure about others)

 

              

 Does the above ring any bell ??

 

Thanks

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 15 of 24
(2,963 Views)

 Does the above ring any bell ??

 

It's easy enough for YOU to find that out - now that you know the "correct" answers, you can find where the data is:

 

Picture 2.png

 

Since you know that line 1 (for instance) is 243.52971, that there are 9 bytes in the line, and that 4 of them are accounted for, then you know that it cannot be a DBL, it has to be a SGL (there are no 5-byte floating-point formats).

 

So type cast a SGL with one of the known values into a U32, and display it in hex.

Find that pattern in your data stream and make a rule for decoding it. 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 16 of 24
(2,958 Views)

Raghunathan,

 

Byte 1 = Device ID/Address

Byte 2 = Query Type

Byte 3 = # bytes of data

Bytes 4-7 = Data

Bytes 8-9 = CRC

 

I took your SGL results and type cast them to a U32 and looked at the hex representation.  Picture below.  Notice that in each case you returned 2 of the 4 bytes correctly.  Notice that bytes 4-5 of your returned data matched the two lower bytes of the expected hex data.  As I stated previously I'm pretty sure you are using the wrong register address in your modbus query.

 

Example_VI_FP.png

Message 17 of 24
(2,921 Views)

Hi Wayne,

 

While Steve had pointed the way to find the solution( 1 Kudos) , I was under tremendrous time pressure with other problems. Thanks for the posting with array. I can now work it forward. (Solution!)

 

Thanks

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 18 of 24
(2,894 Views)
Solution
Accepted by topic author MogaRaghu

Wayne.C wrote:

Raghunathan,

 

Byte 1 = Device ID/Address

Byte 2 = Query Type

Byte 3 = # bytes of data

Bytes 4-7 = Data

Bytes 8-9 = CRC

 

I took your SGL results and type cast them to a U32 and looked at the hex representation.  Picture below.  Notice that in each case you returned 2 of the 4 bytes correctly.  Notice that bytes 4-5 of your returned data matched the two lower bytes of the expected hex data.  As I stated previously I'm pretty sure you are using the wrong register address in your modbus query.

 

Example_VI_FP.png


Actually if you look more closely, all 4 bytes are correct, it just formatted that bytes 4-5 are the least significant word and bytes 6,7 are the more significant word.  If you do a swap words before typecasting it to a single, it is just fine.

Message Edited by Ravens Fan on 09-23-2009 10:58 PM
Message 19 of 24
(2,888 Views)

Hello Ravens,

 

Apart from getting my problem solved, this thread has been really useful in understanding certain functions like the TypeCast and Swap Words. One glance at the way they are used and the function is clear.

 

There could be an argument that there is the help file. There are times when you need help to understand "help" files - particularly for functions in the Advanced palatte !

 

thanks.

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
Message 20 of 24
(2,871 Views)