Programming Considerations for PLC-5 Processors F–9
Publication
65566.5.1 - October 1996
With subroutine programming, you can:
• update critical I/O within the subroutine with immediate I/O instructions
• pass data into and out of a subroutine
Using Immediate I/O Instructions
Immediate I/O instructions are output instructions that, when
enabled, interrupt the program scan to update a specified word of I/O
image table. You would program them immediately ahead of rungs
that examine I/O that are critical to the subroutine. Otherwise, all
I/O image tables are updated only after the processor has completed
scanning the main program and all enabled subroutines.
This instruction, when enabled, updates: For the local chassis, the processor: For a remote chassis, the processor:
Immediate Input (IIN) a word of input image bits sets input image bits to the current
states of inputs before continuing the
program scan
updates the input image with the latest
input states from the remote I/O buffer
(from the most recent remote I/O scan)
Immediate Output (IOT) an I/O group of outputs sets outputs to the current states of
output image bits before continuing the
program scan
updates the remote I/O buffer with the
current states of the output image bits
(makes these states immediately
available for the next remote I/O scan)
Passing Data Into and Out of a Subroutine
The jump-to-subroutine instruction JSR and return instruction RET
let you pass data to and receive data from a subroutine. You can pass
integer or floating-point numbers (program constants) or designate
addresses to/from which integer or floating-point numbers
(variables) can be passed. Examples of passing data include:
• pass variables to the subroutine for mathematical computations,
and return the result for use in the main program
• pass presets to a generic subroutine for multiple recipe operations
This instruction lets you: by specifying in the instruction:
Jumptosubroutine
(JSR)
pass Input Parameters
to the subroutine
• integer or floatingpoint constants
• addresses in the main program
from which parameter are passed
receive Return Parameters
from the subroutine
• addresses in the main program
to which parameters are returned
Subroutine (SBR) store Input Parameters
• storage addresses in the subroutine
Return (RET) return parameters
to the main program
• addresses in the subroutine
from which parameters are returned