Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Comparing negative values(IEC61131-3 Equals block)
Comparing negative values [message #1821470] Thu, 13 February 2020 13:16 Go to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
Hello.

Can somebody give me a hint on how to check negative values to see if they are equal?

In my current application I have used an EQ block from the iec library. It works fine for positive values, but I soon realised that this is not true for negative values.

Casting the value to a dword does also not help as seen in the screenshot.

Is this behaviour expected and what would my alternative be?

Thank you in advance!

[Updated on: Thu, 13 February 2020 15:03]

Report message to a moderator

Re: Comparing negative values [message #1821477 is a reply to message #1821470] Thu, 13 February 2020 14:10 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Hi,

based on this very small snippet and the values I can see there, I would guess you are not using signed data types. How are your EQ ins typed (e.g., what are they connected with)

Best regards,
Martin
Re: Comparing negative values [message #1821484 is a reply to message #1821477] Thu, 13 February 2020 14:54 Go to previous messageGo to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
Hello,

Originally the values were INTs converted to DWORDs, so I tried changing the values to INT when I realised they are not the same size. This is probably converted to DINT I cannot tell exactly as I have tried out some things in the meantime, but it does not work either.

One is connected to the input data of my custom FB and the other is the read value from a ID block.
Re: Comparing negative values [message #1821485 is a reply to message #1821484] Thu, 13 February 2020 14:59 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

ID delivers its values as DWORD. If you would like to have them in a signed format, or the value read is signed then you need a DWORD2DINT FB. Then the output should be signed. Please note that both datatypes connected to the EQ have to be of same type.
Re: Comparing negative values [message #1821486 is a reply to message #1821485] Thu, 13 February 2020 15:07 Go to previous messageGo to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
Hello Alois,

I have provided a screenshot of my current test application. I hope this helps.
Re: Comparing negative values [message #1821487 is a reply to message #1821486] Thu, 13 February 2020 15:10 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Hi Mario,

there is no screenshot attached
Re: Comparing negative values [message #1821489 is a reply to message #1821487] Thu, 13 February 2020 15:15 Go to previous messageGo to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
The screenshot is attached to the original post. Sorry for the confusion
Re: Comparing negative values [message #1821490 is a reply to message #1821489] Thu, 13 February 2020 15:16 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Oh ok, and it does not work this way?
Re: Comparing negative values [message #1821492 is a reply to message #1821490] Thu, 13 February 2020 15:20 Go to previous messageGo to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
Sadly it does not for negative values. Can anybody else confirm such behavior?
Re: Comparing negative values [message #1821493 is a reply to message #1821490] Thu, 13 February 2020 15:20 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Is it on purpose, that the FBs names are F_DWORD_TO_INT (signed), but are of type F_DWORD_TO_UDINT (unsigned)?
Re: Comparing negative values [message #1821494 is a reply to message #1821493] Thu, 13 February 2020 15:21 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Ok, just seeing your post now. You are using the wrong FBs. You need F_DWORD_TO_DINT without the U
Re: Comparing negative values [message #1821495 is a reply to message #1821494] Thu, 13 February 2020 15:32 Go to previous messageGo to next message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
I have changed the block types a lot, therefore the name does not match the type.

After changing the types I ran the program again and you can see that the EQ block outputs false only when comparing negative values. Thoughts?

[Updated on: Thu, 13 February 2020 15:32]

Report message to a moderator

Re: Comparing negative values [message #1821499 is a reply to message #1821495] Thu, 13 February 2020 16:06 Go to previous messageGo to next message
Martin Melik Merkumians is currently offline Martin Melik MerkumiansFriend
Messages: 117
Registered: March 2016
Senior Member
Hmm,

seems like a bug. I will check this on my machine
Re: Comparing negative values [message #1821889 is a reply to message #1821499] Fri, 21 February 2020 15:52 Go to previous message
Mario Krizic is currently offline Mario KrizicFriend
Messages: 38
Registered: April 2019
Member
If anybody has the same problem a quick workaround I found was converting the values to STRING as the EQ block seems to have no problem processing them. It seems inefficient, but it works until the bug is fixed.
Previous Topic:trace running log
Next Topic:Does FORTE run on systems without OS
Goto Forum:
  


Current Time: Tue Apr 16 21:55:13 GMT 2024

Powered by FUDForum. Page generated in 1.00498 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top