Sub Routine in RSL 5000

Bullzi

Lifetime Supporting Member
Join Date
Jun 2012
Location
Colorado
Posts
1,530
Hi all,
In the past I have use Sub Routines more as a organizational tool for my programs than anything else. I would just put things into nice little routines and would have the main program scan them continuously.

Now I have a new project were I have a Sub Routine that is used to search a DINT array for a matching number entered via a PanelView. If that number is found I set a timer to keep the user "logged in" for 30 minutes to get them time to complete a offload. This routine is only executed when a numbers is entered. So the rest of the time the routine isn't scanned or executed.

My question revolve around how the Processor deals with routines and tags in those routines that are not scanned. For example take the routine I just mentioned. If I get a good number and I start the timer then exit the routine. What happens to the timer that is in the routine? Since the routine isn't executed until the timer times out and a new number is entered. Does it just stop were it left off?? What is the best way to handle something like this? Is this a good place to use JMP with Parameters?

Any ideas you can give would be very helpful. I can post the program if needed.
 
If the subroutine containing the timer is not being scanned the timer will not update.

One way to deal with it is to use two subroutines. Put the timer in subroutine A. Put the array search in subroutine B. B does not contain any other code except the search code. Any tags written by B will not change when B is not being scanned, the tags will remain in their last state unless something else changes them. Everything else for the time to complete the offload, etc. goes in A. Subroutine B is called conditionally from Subroutine A when you need to do the search. Subroutine A is called unconditionally from the main routine.

Be sure to document how B is called well so that anyone looking at B's code understands that it is not always being scanned.
 
If a sub-routine isn't called then NOTHING happens. NOTHING changes after the last time it was called (including timer updates as TConnolly mentions). Energized OTEs stay energized for example.

One way to help is, on first beginning to call the subroutine, one-shot the condition and set an 'initialization' bit. Within the subroutine use that bit to set things to the initialized state. For example, in your case, use a NC contact of the initialization bit as one of the conditions for the time to ensure that it restarts.

To 'anthropomorphize' the situation, the subroutine does not 'know' it wasn't being scanned and just takes up where it left off.
 
Last edited:
I've thought about this a little more.

If you use a DTR and FSC instruction then the search can be programmed in just one rung. Use DTR to detect that a new number has been entered into the tag at the PV. DTR will make the rung go true for just one scan. Use FSC as the output instruction to search the array for a match. If there is a match then start the timer. In this case make the one subroutine unconditional (you won't need a second conditional subroutine), and the search will still only execute when the number is changed on the PV.
 
Thanks for your ideas.
I have looked into the DTR and it makes some sense to me. The mask is a little bit confusing. I understand that a 1 passes the bit and 0 doesn't pass the bit. So what do I put into the mask to get new number to pass through and compare with the "old" number?
 

Similar Topics

We have a project that has all the routines viewable but not editable. I just want to force a bit high but cant do it. The only way to do so is...
Replies
2
Views
2,842
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,725
Hello everyone, I am new to ladder logic and am currently working on a small project where I might need some help. So I am modifying the sequence...
Replies
9
Views
2,432
Currently I am using a bunch of TON's and TOF's to start up and turn off a motor sequence. I created a sub routine for the manual sequence and I...
Replies
15
Views
4,711
I'm sorry to be a pest, but I was making some program modifications at home yesterday and downloaded it to the controller this morning , and I am...
Replies
4
Views
3,083
Back
Top Bottom