JSR(Jump to subroutine) problem

colorofwind

Lifetime Supporting Member
Join Date
Jun 2012
Location
Edmonton, Alberta
Posts
38
Hello, I have a simple JSR problem which confuses me. The software is RSLogix 5000.
In the main routine, I have a rung like this
A
------| |----------------|JSR|---------

When switch A is turned on, it jump to the subroutine.

In the subroutine, I turn on some coil B (not latch coil).

--------------------------(B)-----------

However, when switch A is turned off, coil B in the subroutine is still energized. Why can this happen?

Please share your thought, thanks a lot!
 
Because there is no condition that makes it not true.

It stays in the last state because there is nothing to turn it off.
Turning off switch A is nothing more than telling the controller not to scan the routine - does not reset anything.
 
When switch A is turned on it scans the subroutine and writes a 1 to "B".
When switch A is turned off, it does not scan the subroutine, it doesnt write any value to "B", even though "B" in your mind is false, it is still set in memory, and there is nothing writing to "B" to tell it to turn off.

Hope that helps.
 
That is one of the main gotchas when using conditional subroutines. Try to avoid them if you can.
 
When switch A is turned on it scans the subroutine and writes a 1 to "B".
When switch A is turned off, it does not scan the subroutine, it doesnt write any value to "B", even though "B" in your mind is false, it is still set in memory, and there is nothing writing to "B" to tell it to turn off.

Hope that helps.

Thanks guys! It makes sense. But how can I turn off coil B in this situation?
 
Whatever rung coil "B" is on needs to be scanned false. Remove the condition for that subroutine. Is there some special reason you need a conditional subroutine?
 
Whatever rung coil "B" is on needs to be scanned false. Remove the condition for that subroutine. Is there some special reason you need a conditional subroutine?

We compare reading from thermocouple to some constant temperature settings and then choose which mode PLC should work at. Each mode is a subroutine. Then we use the output as an input to trigger the subroutine, like this:

------|CMP|------------------(Mode A)-----

------|Mode A|----------------|JSR|--------

I'm new to PLC and there must be some better ways to do it.
 
If you want mode A's subroutine to rung and not mode B,C..., then I would put something
on the rungs within the routines you don't want to run to make them false.
 
If you want mode A's subroutine to rung and not mode B,C..., then I would put something
on the rungs within the routines you don't want to run to make them false.

Yes, you're right. I put a switch before B in the subroutine instead of before JSR. Now it works perfectly. Thank you so much! (y)
 

Similar Topics

does anyone know how to use the jump to subroutine jsr function
Replies
5
Views
2,216
Jsr
We have a motor control JSR with Input and Output parameters, There are 36 motors that are controlled by the same JSR. What or how can I view...
Replies
8
Views
524
I intend to pass a BOOL array to an ST routine (for loop) to count the true bits. (should never have used a Bool array, lesson learned) The ST...
Replies
10
Views
846
Currently, I have a 1769-L36ERM that is being using to control a machine with 15 servos. Due to the nature of the process, the code is very...
Replies
9
Views
1,543
I have this program: ZIP (.rss inside no documentation). PDF (Italian documentation). Allen Bradley SLC5/03 PLC. I want to know how is the...
Replies
8
Views
2,043
Back
Top Bottom