Charalambos Posted May 30, 2019 Report Share Posted May 30, 2019 I use a PLC (US5-B10-TR22) and communicate with a smart meter throw MODBUS TCP/IP. The registers of this smart meter store values as 'single'-precision floating-point variables. Throw the UniLogic is not possible read 'single' values and I did not find a way to do this conversion.. How can I solve this issue? Charalambos Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted May 31, 2019 MVP 2022 Report Share Posted May 31, 2019 I don't know definitively on the UniStream, but the Modbus command to read float registers is the same as the one to read holding registers (3). Have you tried reading the value from the meter to a Real type tag? Joe T. 1 Quote Link to comment Share on other sites More sharing options...
Charalambos Posted May 31, 2019 Author Report Share Posted May 31, 2019 Thank you Joe T. for your answer! I tried with Real type tag, but the returning number is not correct! This is happened because the Real type tag is (64-bit double precision floating point), in contrast this smart meter registers values are single (32-bit single precision floating point)... Charalambos Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted May 31, 2019 MVP 2022 Report Share Posted May 31, 2019 Send your request to support@unitronics.com and let us know what they answer. Joe T. 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted May 31, 2019 MVP 2022 Report Share Posted May 31, 2019 14 hours ago, Charalambos said: This is happened because the Real type tag is (64-bit double precision floating point), Actually, it's not. According to the Unitronics Help under Contents->Tags->Data Types So that leaves me to believe you may have a byte order problem, which is not unusual in reading 32 bit data from a Modbus device. I'm looking into if it's possible to read the data into a UINT32, swap bytes, and then convert to Real. Otherwise someone at Support may be able to help. Joe T. 1 Quote Link to comment Share on other sites More sharing options...
AlexUT Posted June 2, 2019 Report Share Posted June 2, 2019 Hi Charalambos, Please publish here content of 2 sequential MIs you read from meter in HEX and tell us what number it should show. *Read it from meter display, if possible. Having this information it is simple to negotiate if pairs of Bytes should be swapped or Bytes should be arranged in some order. AABB CCDD -> CCDD AABB B.R. 1 Quote Link to comment Share on other sites More sharing options...
Charalambos Posted June 5, 2019 Author Report Share Posted June 5, 2019 Hi Joe & Alex, I try to read from meter the value (0,149075001478195). The int32 I receive through Modbus to PLC is 0x A71E 3E18 Charalambos Quote Link to comment Share on other sites More sharing options...
AlexUT Posted June 5, 2019 Report Share Posted June 5, 2019 Hi, I used next link: https://www.h-schmidt.net/FloatConverter/IEEE754.html Result is 0x3e18a71e, as you have. Now you have to swap 0x3e18a71e to 0xa71e3e18 and use "Vector->Use Offset->Copy Memory" to copy ML/DW to MF. Than MF should show right number. Update us if it is working for you. 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted June 7, 2019 MVP 2022 Report Share Posted June 7, 2019 On 6/5/2019 at 4:35 AM, AlexUT said: use "Vector->Use Offset->Copy Memory" to copy ML/DW to MF. Those would be the Visilogic function blocks. As you've already done, read the data from the device into a UINT32 tag. For testing I made one called "Read Data" that I could simulate, and a tag called "Conv Value" to hold the swapped bytes. The data will land in a REAL called "Converted". In UniStreamSpeak- 1. Copy the data you read from the device to the working tag and Swap the bytes using "Logic->Swap Single Tag Bytes" with Swap Type.ABCD_CDAB. 2. Copy the swapped data to a 4 byte BUFFER array type so you can manipulate the memory directly. Mine is "Conv Buffer[4]". 3. Use "Buffer Tools->Copy Tag to Buffer" to get the "Conv Value" data into the buffer tag and "Copy Buffer to Tag" to get it from the buffer to the REAL "Converted". There you go. Sorry it doesn't have all the digits you're looking for. If you need to convert several values write a UDFB to move the data into this logic with a pointer. Joe T. 2 Quote Link to comment Share on other sites More sharing options...
Charalambos Posted June 7, 2019 Author Report Share Posted June 7, 2019 On 6/5/2019 at 12:35 PM, AlexUT said: Thank you both for your help! What I did:I read as INT32 the value, then I converted it to 32 bits-array , swapped the first 16-bits with the last 16-bits of this array and final converted the 32 bits-array to a REAL. The value in the REAL now is the correct value! Below is the Function block diagram I used for this. Best Regards, Charalambos Quote Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted June 8, 2019 MVP 2022 Report Share Posted June 8, 2019 I like your way, too! It demonstrates that you can think in terms of bits, which are the foundation of all the other data types. There's a cat being skinned multiple ways somewhere.... 😁 Joe T. 1 Quote Link to comment Share on other sites More sharing options...
Oscar Peralta Posted October 25, 2019 Report Share Posted October 25, 2019 Hello. I made a program for V700 Series that read and converts HEX 64-bit double precision floating point of Decimal (Only Entire part, not decimal point) of Mass Field Instrument. Attach example, Hope that help somebody. BR KROHNE.vlp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.