Find tags that are used but never set

clementcbc

Member
Join Date
Sep 2010
Location
Hong Kong
Posts
24
Hi Guys,

I'm using RSLogix 5000, V17.

Is there a way to find all tags that are used (e.g. XIC, XIO etc) but never set?
(e.g. it is used as in XIC, or XIO, or used as a Source etc, but never actually latch/energised/used as Destination).
And also vice versa?

I'm reusing some old code to build some new code.
And every now and then i come across a bug where a Tag used in the code that probably has 0 or junk value.

BTW, i'm not talking about unused Tags.

Thanks!
 
about the only thing I know to do is use the Corss Reference function and look for tags that have no OTE OTL functions.

If the Tag is only used a XIC or XIO and is not part of an array then it is a "dummy" tag
 
@Clay B:
But that would require me to do a cross reference on every single tag, then browse through the results...

@rdrast
No, i'm not talking about unused tags.
I'm talking about tags that are used in the code, but that line of code is probably useless or has a bug because no one assigned proper value to it.

E.g.
|---|EStopBtn|--------(StopStuff)-----|

Where EStopBtn is supposed to be mapped to the correct I/O (say "I:2/0")
Imagine what would happen for whatever reason the I:2/0 is NOT mapped to EStopBtn, or is mapped to EStopIsDown instead.
(Easily happens if another guy changed your code, or reusing old code)

Now you have a problem because
1. I/2:0 does absolutely nothing in your code. Some guy pressing the physical E-Stop frantically, but that input is totally ignored in code.

2. EStopBtn is has got junk (probably "0").
Someone casually looking at the code will think it's fine, but in actual fact it's not mapped.

3. Searching for "Unused Tags" will NOT find EStopBtn, nor I:2/0, nor EStopIsDown.

So you've got this bug in your code that is just waiting to happen at the worst possible moment!

What I'd like is to find all instances of similar situations.

If it were in C-Programming or other language compilers, they usually pop up a warning to say that
- EStopBtn is used, but never set.
- EStopIsDown is set, but never used.
So I can checkout the warning and find the bug before it is released.

I wanted to know if there was similar functionality in RSLogix 5000, V17.


Thanks!
 
That is a programming error. Plain and simple.
By that definition, I've got programs with thousands of 'Unused' tags. But they aren't. They are control bits and numbers and strings that are written to by multiple HMI's.
 
@rdrast
You're right, it's a programming error.
But that's exactly what i want to try and weed out before I release the code.

And yes, there's probably thousand of these, and they probably be:
- Strings - easily spotted cos they are String type.
- I/O - easily spotted cos they start with Local:I:xxxx or similar.
- HMI stuff - You're right, very hard to spot. Hoping that next versions of RSLogix can fix that.....=P
- Constant parameters - hard to spot, but there shouldn't be THAT many.
- Unset tags, or unused tags - These are the ones that I REALLY want to find.


@SD_Scott
Thanks! That's pretty useful!
Not quite the same as a filter on all Tags, but not too bad =)
I'll have a play to see if it can detect bad lines of code.

So i'm expecting most variables to have at least 1 destruct and 1 non-destruct.
If all Destruct, then it means someone is setting it, but no one cares.
If all non-destruct, then it means no one is setting is and it COULD be a dodgey value.

Thanks!
 
The compiler can only catch the structure of the program. it can't predict if, at runtime, an assignment will actually take place. It seems as if you want the compiler to catch mistakes wich must be caught in desk-check, simualtion, or testing at startup.
 
It won't catch runtime bugs, but at least i'm catching few more bugs before it get's released.

I've already found a bunch of tags that don't do anything useful in the code.
 
E.g.
|---|EStopBtn|--------(StopStuff)-----|


1. I/2:0 does absolutely nothing in your code. Some guy pressing the physical E-Stop frantically, but that input is totally ignored in code.

So you've got this bug in your code that is just waiting to happen at the worst possible moment!

I hope to God you're only using this as an example and not a "possible" scenario. An E-Stop should NEVER EVER be wired as an input to a PLC unless that input is just for monitoring purposes. An E-Stop should be part of a hard-wired safety circuit that has NO dependency on the PLC whatsoever. So, it wouldn't matter if the bit was ever set in the code or not.

Again, I figure you already know this....but just in case!
 
The worst thing is trying to figure out if a DB bit is being used in SIMATIC... If the DB is local and is being accessed by another FB directly it won't show on cross-reference and many other stuff that can hide it's use.
 
Hi Guys,

I'm using RSLogix 5000, V17.

Is there a way to find all tags that are used (e.g. XIC, XIO etc) but never set?
(e.g. it is used as in XIC, or XIO, or used as a Source etc, but never actually latch/energised/used as Destination).
And also vice versa?

I'm reusing some old code to build some new code.
And every now and then i come across a bug where a Tag used in the code that probably has 0 or junk value.

BTW, i'm not talking about unused Tags.

Thanks!


Um. No idea how to do this, but as far as "unused" goes be careful.

As has been said, it may be set from an HMI.

Or, as I often do, it may be set by writing a word value using a MOV. I frequently set words to 1,2,4, etc... and then use the bit value elsewhere in my logic.

I sometimes use 3,5,9, etc. In those cases, the first bit in the word can indicate an active state for whatever equipment the word is associated with, while the other bit indicates the particular state or position or some such.
 

Similar Topics

I'm trying to get a list of all of the tags (both HMI and controller) that are used in a FT View SE project. I think when you export the HMI...
Replies
4
Views
10,204
It seems like every time I try to find a tag in Logix/Studio 5000, over the past 15 years, when I select "Find in Tags" I need to go into the find...
Replies
7
Views
2,720
In Rslogix 5000, when searching for tags, is there a way to look only for destructives? Thanks.
Replies
8
Views
3,931
Hi , Where i can find Mitsubishi PLC Card end of line & replacement model details. i am looking for Q02CPU replacement model. Please advice. thanks
Replies
2
Views
124
I have tested every screen and no single screen individually has this fault pop up, but when I compile and send to the PanelView it comes up. If I...
Replies
4
Views
171
Back
Top Bottom