Subroutines

metz

Member
Join Date
Nov 2002
Posts
1
I'm currently in college, taking a PLC course using AB SLC 500 series. We have this problem where we are to take an analog signal (1-5V) scale it, from 0-100%, Subroutines are required to process under and over range values. Thought I'd use LTE and GTE commands to send it to the appropriate subroutine. Problem is in the subroutine we must have a bliking O/P and an acknowledge I/P so that the LED goes solid. When the variable goes between the set values the alarm condition should clear itself off. I used a Limit command to do this but if the O/P was put to steady state by acknowledging the alarm the O/P doesn't reset before exiting the subroutine. How do I solve this?? do I clear it in the subroutine or on the next rung in the program??
 
Congratulations! You've learned something. To wit: When you stop SCANNING an output (by no longer calling the subroutine), the output stays in the last state.

I suspect that's why your teacher had you use subroutines. Well done!

So, your question is, "how do you solve this?". There are several ways, some better than others.

You could, as you've suggested, move the light logic out of the (dead) subroutine. This might not work, however, if you use conditions that the subroutine controls on the rung that's outside of the subroutine.

Since you need to call the subroutine in order to control the light, one solution is to call the subroutine when you have EITHER an over-range condition, OR the light is on.

Another technique might be to create a "In range" subroutine, which would also control BOTH lights (turning them off). This "double coiling" technique is frowned upon by most programmers, but as long as you are ABSOLUTELY SURE that one and only one subroutine can be on during the same scan, then you won't have any conflicts which can lead to sudden hair loss ("All the conditions to turn the light ON on this rung are true - why isn't the light coming ON ?!?"

There is no "right way" - there are only better and worse ways. "Right" means that it works. "Good" means that someone else (or even you) can understand what's going on, and change things without unexpectedly changing something else.
 

Similar Topics

I have been asked to extensively modify a piece of machinery that is very mission critical to the operation, thus not allowed much downtime or...
Replies
4
Views
2,321
We have an application where we need to indicate a piece of machinery needs maintenance. I have created a routine which resets a value of "days...
Replies
12
Views
3,765
Hi all. Please see attached. Tried to google the error with absolutely no results. I did the same at payed version and real PLC so I'm almost...
Replies
7
Views
2,350
hello all is there a rule of thumb as to using or not using subroutines when writing a program ? i am using an Allen Bradley slc 500 thank you...
Replies
5
Views
1,755
All, Using RSLogix 5000. I was wondering if there is a way to quickly check to see if all subroutines are being called by the Main Routine (in...
Replies
3
Views
1,616
Back
Top Bottom