Page 212 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 212

Main program                                  9.5 Immediate Input and Immediate
                               file 2
                                                                         Output Instructions
                                                                         The PLC input scan normally records the inputs before the
                                                                         program scan, and the output scan normally updates the
                        JSR                                              outputs after the program scan. Immediate I/O instruc-
                        JUMP-TO-SUBROUTINE                               tions allow you to update data prior to the normal input
                        SBR file number 3
                                                                         scan as illustrated in Figure 9-14.
                                                                           Immediate I/O instructions interrupt the normal pro-
                                                       Subroutine        gram scan to update the input image table file with cur-
                                                         file 3
                                                SBR                      rent input data or to update an output module group with
                                                SUBROUTINE               the current output image table file data. Allen-Bradley
                                                                         SLC 500 PLC’s immediate I/O instructions are called
                                                                         immediate input with mask (IIM)  and immediate
                                                                         output with mask (IOM).
                                                                           •  Masking is a means of selectively screening out
                                                                             data.
                                                                           •  Masking allows the programmer to specify which
                                                                             of the 16 bits are to be copied from an input module
                                                          RET                to the input image data table (or from the output
                                                          RETURN
                                                                             image table to an output module).
                   Figure 9-12  Setting up a subroutine file.              •  The other bits in the input image table or output
                                                                             module are not affected by these instructions.
                   Programming  nested  subroutines may  cause scan  time
                   problems because while the subroutine is being scanned,   The immediate input with mask (IIM) instruction is
                   the main program is not. Excessive delays in scanning the   shown in Figure 9-15. The IIM instruction operates on
                   main program may cause the outputs to operate later than   the inputs assigned to a particular word of a slot. When
                   required. This situation may be avoided by updating criti-  the IIM rung is true, the program scan is interrupted, and
                   cal I/O using immediate input and/or immediate output   data from a specific input slot are transferred through the
                   instructions.                                         mask to the input data file. These data are then available



                           Main program
                               file 2



                         JSR
                         JUMP-TO-SUBROUTINE
                         SBR file 3
                                                       Level 1                    Level 2                     Level 3
                                                        file 3                       file 4                      file 5
                                                SBR                         SBR                         SBR
                                                SUBROUTINE                  SUBROUTINE                  SUBROUTINE



                                                    JSR                         JSR
                                                    JUMP-TO-SUBROUTINE          JUMP-TO-SUBROUTINE
                                                    SBR file 4                   SBR file 5





                                                         RET                        RET                         RET
                                                         RETURN                     RETURN                      RETURN
                    Figure 9-13  Nested subroutines.



                                                                               Program Control Instructions   Chapter 9  193







          pet73842_ch09_184-206.indd   193                                                                              03/11/15   4:01 PM
   207   208   209   210   211   212   213   214   215   216   217