Logix 5000 Get Rung Number?

jonfarrugia

Member
Join Date
Mar 2008
Location
London
Posts
130
I'm looking at adding some diagnostics to an HMI to show the rung number the program is waiting at for something to occur. Its just a method to allow programmers an easy way to go to the exact location were the error is occurring.

Is there a way to get the current rung number? I was looking at perhaps using a GSV instruction that would return the rung it was executed on. I cant seem to find a way to do it...any ideas? is there an instruction that would do this?
 
The problem with that approach is every rung is being scanned, so how would this instruction know which one you are interested in?

I assume that you have some kind of sequence or state machine that you are working with here? If so, is each state/step unique in that only one is on at a time? If so, I'd create a tag that is named after the routine, then at each step in your sequence of operation, put a MOV box on that rung that moves a value of the rung number into the tag. So if the particular step is on run 32, move a value of 32 into your tag.
 
I am using a sequence to run the code. Your solution would work most of the time. However, there are times during the sequence that multiple additional sequences are started that run asynchronously from the main sequence.
The instruction im looking for would return the current rung number the instruction is being executed on. If I placed the GSV on rung 13, it would return a 13 when execute because it was executed on that rung.
When the program was designed, sequences where not separated into their own routines otherwise your suggestion would work. This program has many sequences running in one routine so im looking for a way to isolate the stoppage for trouble shooting. At this point in the project, we don't have the time to structure the program better.

So I guess I am looking for an instruction that would return the current rung it was executed on.

Major and minor faults have this type of information, just wondering if its possible to get to it.
 
Create a dint tag, name it DebugRungNumber. Program a MOV in each rung.

In rung 13 program MOV 13 DebugRungNumber.

In rung 15 program MOV 15 DebugRungNumber.

Mov will exeucte faster than a GSV anyways.

BTW, the MOV doesn't have to be on a branch, you can stick it inline anywhere on the rung.

Since its unlikely that you will put this in every rung, instead of using rung numbers use way point numbers.
 
I understand the execution times of the GSV. I wasn't planning on using it on every line but certain locations. I have my reasons for an instruction that returns the rung number.

I'm not looking for another way of doing this...I am looking for an instruction what would return the rung number it was executed on.

Does anyone know if one is available?
 
i understand your method, but what happens when a rung(s) gets added or deleted?

regards,
james

That is why i am looking for such an instruction. As rungs are added and/or deleted, the instruction would automatically change to the new rung number it is located on...no need to modify the diagnostic code.
 
That is why I suggested you use way points instead of rung numbers. The use of way points is a old and time honored way of debugging code.

What you are looking for doesn't exist as a GSV. If it did it would be under either the Program class or Routine Class, instance THIS, but there is nothing there that looks like it will return a rung number. I think that when the code is compiled its probable that the processor doesn't know the number of the rung it is executing, there is no good reason for it to know. Compiling as a linked list is more efficient and linked lists as opposed to numbered lists are essential to features like online editing.
 
More on using way points: If you don't have a large number of way points, up to a few dozen, then create multiple way points as boolean tags that have meaningful names, such as debug_Step1 or debug_WaitingForNextStep, instead of using a single tag to which you write a number.

Using booleans with names means you don't have to try and remember what value you assigned to a way point, and using an OTE instruction is as simple as it gets.

Prefixing the way point tags with something like debug_ lets you use a search filter in the tag monitor to display only the debugging tags. It also makes it easy to find and remove them all after debugging is completed.

Hope that helps.
 
As dmroeder pointed out, "current rung number" is not useful in any way. If you could display "current rung number" it would be rolling so fast it would be unreadable. Typical PLC program executes *every* rung more than 10 times each second. It doesn't *stop* at the rung that is active for the current sequence step.

Now as several others have pointed out, displaying a "step number" for a sequence is workable and a very common thing to do. Scrolling through the PLC program until you come to the rung that executes the current step is pretty simple.
 
I've always used timers that time out after rung goes true if the next step doesn't finish within the time period allotted. then send an error code that points to whatever hasn't done it's thing. with so many different routines, rung numbers, without a routine tag are sort of worthless, error codes on the other hand can be tracked back to what would cause the hung condition.
 
Couldn't you trigger some minor fault on the rung you're interested in knowing about, and then display the "rung number of the minor fault"?
 
I'm looking at adding some diagnostics to an HMI to show the rung number the program is waiting at for something to occur. Its just a method to allow programmers an easy way to go to the exact location were the error is occurring.

Is there a way to get the current rung number? I was looking at perhaps using a GSV instruction that would return the rung it was executed on. I cant seem to find a way to do it...any ideas? is there an instruction that would do this?

It is clear to me that you do not understand the basic principle of operation of a PLC. All rungs are scanned continuously, sequentially, and repetitively, they do not "wait" for anything, they are just "expression evaluators".

Perhaps you are confusing "rung number" with "step number", or "state number" or "sequence step number".... the "rung number" has absolutely no viable reference to what the system is waiting for, the logic on the rungs determines what actions are taken...
 

Similar Topics

First off, I'm a hobbyist-level programmer, and this program isn't controlling anything anything that could even remotely be considered "life...
Replies
18
Views
514
Good Morning , I'm merging another RS Logix 5000 PLC program ( CompactLogix ) into another . Everything is working great except this one...
Replies
9
Views
3,715
Has anyone experienced that a rung comment in RSLogix 5000 version 30 was replaced by #NAVN? or #NAME? Do you know what caused it and how to...
Replies
0
Views
1,252
Good evening, I can't drag the rung down around my inputs and outputs for some reason in my PLC program? I can't do it for any programs. I'll...
Replies
0
Views
1,427
Back
Top Bottom