Compare Instruction strange observation (TIA Portal)

IdealDan

Member
Join Date
May 2017
Location
MA
Posts
480
Hi Guys,

In TIA Portal, I observed a 'Less than' Instruction transition to TRUE when the compared value is not less than the desired stated value.

Has anyone noticed such before?
 
Is it possible the the Compare is working correctly because the value is changing faster than you can see in the GUI? I have seen this behavior before.
 
Is there any remedy for this?


If you have a 1500, there is a trend feature you can use to graph values scan by scan.


Otherwise, for just monitoring code, no. The scans are 1) way too fast for the human eye 2) would overload the comms if they needed to send ALL the data
 
If you have a 1500, there is a trend feature you can use to graph values scan by scan.


Otherwise, for just monitoring code, no. The scans are 1) way too fast for the human eye 2) would overload the comms if they needed to send ALL the data

Cheers Bro, I appreciate your response.
 
What is the data type of the compare instruction, and what is the data type of each tag? Are you mixing signed and unsigned integers?
 
I've seen this on various platforms and every single time, it's a case of scan sequence. Something like

Scan Start:
Set MyVariable to 10
...
more code
...
If MyVariable < 20 Set MyFlag
...
more code
...
Set MyVariable to 30
...
End of scan

So when you look at the GUI, you see that MyVariable is 30, and MyFlag is true, because that's the state of those tags at the end of the scan. But at the instant the LES instruction is executed, the value of MyVariable is 10.

Easy check: right before the LES instruction, Move the value of MyVariable into a diagnostic tag. Then you get to see the value of MyVariable as the LES instruction sees it. I would bet a carton of my favourite Hazy IPA that you'll find it is, in fact, less than the specified comparator.
 
I've seen this on various platforms and every single time, it's a case of scan sequence. Something like

Scan Start:
Set MyVariable to 10
...
more code
...
If MyVariable < 20 Set MyFlag
...
more code
...
Set MyVariable to 30
...
End of scan

So when you look at the GUI, you see that MyVariable is 30, and MyFlag is true, because that's the state of those tags at the end of the scan. But at the instant the LES instruction is executed, the value of MyVariable is 10.

Easy check: right before the LES instruction, Move the value of MyVariable into a diagnostic tag. Then you get to see the value of MyVariable as the LES instruction sees it. I would bet a carton of my favourite Hazy IPA that you'll find it is, in fact, less than the specified comparator.

Thanks for your input, so in such a scenario what could the solution?
 
If this code is structured text then develop it in a more friendly IDE and then port it back to TIA.
Or develop your code in TIA for S7-1500 that supports breakpoints then port it to other hardware.

Otherwise, if this is ladder, you're pretty much stuck with using test tags like ASF suggested.
 
Last edited:
Thanks for your input, so in such a scenario what could the solution?
If this is the case, there is no problem. The program is working exactly as it's supposed to. It's just difficult to see it.

Unless the fact that the LES instruction is evaluating true is causing some other problem, but if that's the case we'll need a lot more context and information to work out how to solve that problem.

First things first; prove what's causing the behaviour (e.g. using the test I described above).
 

Similar Topics

Hi, Have done a few programs with CCW and am slowly getting my mind around it. Previously I have used compare instruction blocks to start drives...
Replies
4
Views
2,159
Hello, I've been having trouble getting the syntax correct in my expression for a CMP instruction. My expression is: (VarA > VarB) AND (VarA >...
Replies
20
Views
13,799
Hi to all, Is it to possible to compare a string, which is in DM100 TO DM109 with the strings which are in DM300 TO DM309, DM310 TO DM319...
Replies
0
Views
1,559
can i include some compare instructions or any instruction to the my add on instruction or in the udt in rslogix5000.i know this may be possibly...
Replies
15
Views
9,164
can i include some compare instructions or any instruction to the my add on instruction or in the udt in rslogix5000.i know this may be possibly...
Replies
1
Views
3,534
Back
Top Bottom