gator461
  •  gator461
  • 51.99601% (Neutral)
  • Newbie Topic Starter
2020-04-29T22:38:15Z
i just had a plc course where they explained sbr and jsr and showed demo of operation but never explained how to turn a program into a sbr. i just searched through your site and did not find anything except brief definition and short explanation in Help. i notice the traffic light scenario has to be done in sbr's. could you please get me in the right direction
Guest
2020-04-29T22:39:03Z
Since you have posted this in the RSLogix500 forum I will answer this from the SLC500/micrologix point of view. Most of this will pertain to any AB processor.

The SLC has one program file that is scanned by default and that is program file 2. As you have mentioned, we recommend separating any PLC program into program modules or subroutines. To have those other program files scanned by the processor you must tell it to jump to them - thus the JSR or jump to subroutine command. If your total purpose is to have the processor jump to the subroutine and return back to the rung after where it was called from when complete, then the JSR is all you need. You simply insert a JSR in your program and the only information you need to provide is the program file it will jump to. That is the most common use of JSRs and subroutines in the AB platforms. We would suggest that file 2 be filled with nothing but JSR's pointed at multiple program files (plus maybe some minor overhead logic). Once again, for that purpose thats all you need. The processor will jump to the program file required, go to the end and return back to scan the rung immediately after the calling JSR. No RET statement is necessary unless you want it to jump back before the end of the program file.

The SBR gets a little more complecated. The JSR instruction can pass parameters to the subroutine and the SBR is necessary if you intend to pass parameters and it should be the first rung in the program file you are jumping to. Frankly if you need to do this, you need to ask yourself if your program is over complecated. There may be a rare instance where this is necessary, but they should be rare.

Hope all this helps. Check out the vids on the the JSR instruction for more.
gator461
  •  gator461
  • 51.99601% (Neutral)
  • Newbie Topic Starter
2020-04-29T22:39:57Z
how do you turn (or save) project files into program files to be used as subroutines? the jsr only refers to a ladder number in program file
Guest
2020-04-29T22:40:52Z
Any program file can be jumped into with the JSR and become a subroutine (I doubt you can jump to the calling program file - I suspect that would cause problems). There is no special action that need be taken to the program file to "make" it a subroutine. If you create a program file then you can jump to it with the JSR and the processor will return to the calling program file automatically and begin operation immediately after the calling JSR.
Guest
2020-04-29T22:41:28Z
Mike,

You sent this to us via the contact page, but this sheds some light on what you were asking so I want to copy it here:

"i have tried my question through your forum but i guess you are not understanding my question or maybe im not clear enough. i understand everything you are saying about the soubroutine,. my question is: i have saved some projects into my documents on my C: drive. I want to put those projects into program files so i can make them soubroutines. I didnt save them or start them as a program file. can this be done or do i have to open a program file as ladder 3, etc and re enter my whole ladder all over again or can I import or direct my project file over to the program file and make it ladder 3?"

Now I get the misunderstanding. Keep in mind that the program routines in your PLC program are called program files. I can see where this could be confusing as they have nothing at all to do with the files stored on your computer. You cannot make a separate PLC program into a subroutine. All subroutines must be located in the same program as the calling routine. Hope this helps. Once again you might want to review the videos on JSR or jump to subroutine.

You dont have to enter your whole program over rung by rung, but you can open both programs simultaneously and copy and paste from one to the other.
gator461
  •  gator461
  • 51.99601% (Neutral)
  • Newbie Topic Starter
2020-04-29T22:42:09Z
Thanx for understanding my question. the copy and paste worked fine and got the program up and running
RSLogix500 Introduction
RSLogix500 Inserting Instructions
RSLogix500 Opening a File
RSLogix500 Creating a Project
RSLogix500 Instruction Comments
RSLogix500 Rung Comments Page Titles
RSLogix500 Inserting Branches
RSLogix500 Program Organization, Part 1 - Overview
RSLogix500 Program Organization, Part 2 - Examples
RSLogix500 Using Symbols
RSLogix500 View Properties
RSLinx
RSLogix500 Online Offline
RSLogix500 Dowloading and Uploading
RSLogix500 Processor Modes
RSLogix500 Processor and Cards
RSLogix500 Introduction to Faults
RSLogix500 Indirect Addressing
RSLogix500 Indirect Addressing Faults
RSLogix500 Handling Faults
RSLogix500 Forcing I/O
RSLogix500  Custom Data Monitor
RSLogix500 I/O Configuration
RSLogix500 Advanced Diagnostics
RSLogix500 Instructions OTL OTU, Part 1
RSLogix500 Instructions OTL OTU, Part 2
RSLogix500 Instructions OTL OTU, Part 3
RSLogix500 Instructions, OTE
RSLogix500 Instructions, XIC XIO
RSLogix500 Instructions, ADD
RSLogix500 Instructions, COP
RSLogix500 Instructions, CPT - Part 2
RSLogix500 Instructions, CTU CTD - Part 1
RSLogix500 Instructions, CTU CTD - Part 2
RSLogix500 Instructions, CTU CTD - Part 3
RSLogix500 Instructions, CPT - Part 1
RSLogix500 - Comparison - Part1
RSLogix500 - Comparison - Part 2
RSLogix500 Instructions, DIV
RSLogix500 - FIFO - FFL and FFU - Part 1
RSLogix500 - FIFO - FFL and FFU - Part 2
RSLogix500 Instructions, FLL
RSLogix500 Instructions, JMP and LBL
RSLogix500 Instructions, Masking and MEQ
RSLogix500 Instructions, MUL
RSLogix500 Instructions, MOV
RSLogix500 Instructions, LIM
RSLogix500 Instructions, NEG
RSLogix500 Instructions, OSR
RSLogix500 Instructions, RTO
RSLogix500 Instructions, SQO sequencer - Part 1 of 3
RSLogix500 Instructions, SQO sequencer - Part 2 of 3
RSLogix500 Instructions, SQO sequencer - Part 3 of 3
RSLogix500 Instructions, SUB
RSLogix500 Instructions, TOF
RSLogix500 Instructions, JSR and RET
RSLogix500 Shift registers
RSLogix500 Instructions, SQR
RSLogix500 Instructions, TON - Part 1
RSLogix500 Instructions, TON - Part 2
RSLogix500 Instructions, TON - Part 3
Introduction to Ladder Logic