Jump to content

Modbus R.F.R #3 how to achieve in UniLogic


mwis750

Recommended Posts

Hi,

 

I've a working solution on Vision V570 - reading a temperature via Modbus as a float (done with MODBUS FB R.F.R #3).

 

However, I cannot make it working on a UniLogic. It looks like problem with a float presentation or convertion.

 

I'm able to read an uint16 array and check that read values can be converted into float (IEEE754) but reading it through

configuration as a tag with REAL type returns incorrect values.

 

Is it possible to read real values from Modbus ? How should I do it ?

 

Thank you,

Michal

Link to comment
Share on other sites

Hi Michal,

If you are getting wrong values for the R.F.R command, there is a good chance that your device sends a swapped message (the bytes order is reversed). In that case, you can use the Swap Single Tag Bytes ladder function block found in the Logic tab. change the swap type to ABCD_CDAB.

Please let me know if that solved the problem.

post-20103-0-02261600-1423479225_thumb.png

  • Upvote 2
Link to comment
Share on other sites

Hi,

 

that solved the problem, thank you.

 

However, I'd like to suggest adding special kind of an operation to Modbus configuration. 

That way all could be still just configuration. Also there is no way to find out

when a new value has been read from a remote slave (is there ?), so what kind of condition should be used for such swap ?

 

Regards,

Michal

Link to comment
Share on other sites

Regarding adding a swapped bytes feature - I will add a request to our features list.

 

Regarding conditions for swapping - there are several approaches for such condition.

I would use the following:

Storing the original tag (lets name it A) to another 2 tags (lets name them B and C)

Swapping the bytes in B

Running a continuous compare function between the A and C - when A is different then C that means that another value was stored to the PLC and another swapping is necessary.

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

The Swap Single Tag Bytes tag will split the integer (16-bit or 32-bit) into two parts: two 8 bit parts for a 16-bit integer, or two 16-bit parts for a 32-bit integer.  It will then switch the order of the parts, thus displaying a different number.

 

For instance, if you read a 16-bit integer, but the bytes are backwards from what they should be, you can place this into the Swap Single Tag Bytes function, and choose the "Swap Type" in the B parameter.  For a 16-bit integer, this is composed of two bytes, therefore the swap type will be AB_BA.  For 32-bit integers, there a four bytes, and two different configurations can be chosen (ABCD_CDAB or ABCD_DCBA).

 

So let's say I get a Hex value read in of 0x2301, but I was looking for a value of 0x0123.  I would use this swap bytes function with a swap type of AB_BA, and the resultant of the tag would now read 0x0123.

 

Please let me know if this helps or if I can clarify any further.

Link to comment
Share on other sites

Hello,

 

Try using a positive transition contact with the swap bytes function.  Set up like shown below, the positive transition contact will be link to when you receive that float value.  So when you receive the float value, it triggers the swap function block once (thus only switching the register bytes once, not every scan).

 

3 31 2015 3 25 09 PM

 
Let me know if this helps.
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...