Sub-Routine problems

Gnash Rambler

Member
Join Date
Oct 2002
Posts
3
Some of the programs I am writing require the use of sub-routine instructions. What I had in mind was a program that would run only the sub-routine,(disregarding the main program ), until the input that triggered the jump was false.What I am experiencing is, the processor does run the sub-routine,but immediately afterward,it goes right back to the main program, no matter the status of the trigger input. I'm using RS Logix software and Micrologix 1000 controllers. Thanks.
 
You should post the relevant code. I can guess, though.

What you describe is exactly what a suboroutine is supposed to do.

You seem to be trying an IF-THEN-ELSE command. The if and then are working but the else always executes. You could put the main in a sub that executes when your input is false or make a conditional jump that jumps to the end of the main.
 
As Rick said, the Main program is sopposed to do exactly what you describe is happening.

There are several ways you can proceed:

1) As Rick said, put a JMP / LBL pair to jump over the logic you don't want scanned. You may have to add a 'dummy' coil as the last rung of your code to put the LBL on.

2) Use the MCR instruction to disable the LAD 2 code you don't want scanned.

3) Put the rest of the ladder that you don't want executed into another subroutine, and only call that up when you don't call the first subroutine.

4) Put a branch around the JSR for your subroutine (to the right of the conditional) with a TND (Temporary eND) instruction. This will stop execution of LAD 2, and go immediately to the I/O update part of the scan.
 

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,830
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,705
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,407
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,703
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...
Replies
6
Views
2,536
Back
Top Bottom