Jump to content

Read Single-precision arrays with Modbus TCP/IP


Recommended Posts

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 

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

  • MVP 2023
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

image.png.aa836017f7286be2383037c6b4dfdaef.png

 

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.

  • Like 1
Link to comment
Share on other sites

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.

 

  • Like 1
Link to comment
Share on other sites

  • MVP 2023
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".

image.thumb.png.c41cba62b2efc15da549231d516ffac7.png

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.

 

  • Like 2
Link to comment
Share on other sites

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.    

image.png.18e915ba4d7da79834a0a1d46a88cd6e.png

Best Regards,

Charalambos

 

 

Quote

 

 

 

 

Link to comment
Share on other sites

  • 4 months later...
  • 4 years later...

hello

I have a communication problem using modbus tcp ip between a Sick gas analyzer and a PLC/HMI US5/7-X10-TA30.

The communication works perfectly until it disconnects by itself and the data freezes.

Can you tell me where some diagnostic bit? What are the SBs like in the visilogic?

Do you have any clear diagnostic tools? to see the accumulation of errors or to allow me to diagnose the communication.

Luis

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...