Jump to content
mwis750

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

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hi,

I am also facing the same problem of floating integer with the unilogic software.

Can you post any sample on how to use the swap single Tag byte instructions because I am not clear about it.

 

 

Thank you

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thank you for your reply.

 

I tried using the swap single Tag byte function to read the floating point (32 bit) values via modbus RS485 communication in the Unilogic software but still not able to do it.

 

I can read the INT16 bit values but not the Floating point 32 bit values 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×