2/26/2014 2:56 PM | |
Joined: 1/17/2007 Last visit: 4/15/2025 Posts: 1560 Rating:
|
It is possible to get REAL (floating point) data over a modbus interface. However, there is a caveat. The modbus protocol does not inherently understand REAL numbers - it only has the concept of BOOLEANS and 16-bit registers. REAL values are encoded in IEEE754 format, which are encoded into 32-bits. So each REAL value will have to be sent as 2 16-bit registers. This is the duty of the application layer, as already stated, the modbus protocol has no knowledge of how to handle REAL values directly. So sending partner must ecode the REAL value into 2 16-bit registers and then send these. The receiving partner must then reconstitute these 2 16-bit registers back into a REAL value format. There are issues in doing this due to the way that different systems enocde the word order for REAL numbers (endian issues). So the reason you are getting garbage could be down to:- 1) the word order of the data is mixed up 2) you have not converted the registers back into REAL numbers (e.g. took each register to be a REAL number which is nonsense as you would only be using have the REAL data). 3) The data really is garbage (wrong address or data is not REAL data). This question has been asked before and is covered in these threads:- /tf/WW/en/Posts/97287 /tf/WW/en/Posts/83233 |
Programming today is the race between software engineers building bigger and better idiot proof programs, and the universe producing bigger and better idiots. |
|
This contribution was helpful to
1 thankful Users |
7/16/2015 1:14 PM | |
Joined: 6/24/2013 Last visit: 4/16/2025 Posts: 1678 Rating:
|
Hi You can use ready functions which handle 64-bit Real from Your PAC meter. Library attached. AttachmentIS0034_LongReal.zip (758 Downloads) |
Follow us on