Omron FQM1-CM001 Using Subroutines That Pass Parameters, Programming, Appendix A, Overview

Models: FQM1-MMP21 FQM1-MMA21 FQM1-CM001

1 414
Download 414 pages 44.52 Kb
Page 288
Image 288
Using Subroutines That Pass Parameters

Programming

Appendix A

Using Subroutines That Pass Parameters

With these subroutines, parameters can be passed to the subroutine when it is called and then the results of processing in the subroutine can be returned to the main program. This enables using one subroutine while changing the I/O addresses that are used. One subroutine can thus be used in multiple locations with similar logic in the program to reduce the number of program steps and make the program easier to understand.

When passing parameters to a subroutine, execution is possible either with or without using Subroutine Input Condition Flags.

Execution without Subroutine Input Condition Flags

The MCRO(099) instruction is used to call subroutines without Subroutine Input Condition Flags.

MCRO(099)

Subroutine number

First input parameter word

First output parameter word

The following process is performed when MCR0(099) is executed.

1.Five words starting with the first input parameter word are copied to A510 through A514 (macro area inputs).

2.The specified subroutine is executed through RET(093).

3.When the subroutine is completed, the contents of A515 through A519 (macro area outputs) are copied to five words starting with the first output parameter word.

4.Program execution continues with the next instruction after MCRO(099).

The first input and output parameter words can be changed when executing MCRO(099) to use the same sub- routine for different purposes at different locations in the program.

As shown by the above process, using the macro function has the following limitations.

The parameters being passed must be stored in 5 continuous words.

The specified I/O parameters must be passed so that they correctly correspond to the program in the sub- routine.

Note (1) A510 through A514 (macro area inputs) and A515 through A519 (macro area outputs) can be used as work bits if MCRO(099) is not used.

(2)The words specified for the input/output parameter words can be I/O words, Auxiliary Area words, DM Area words, or words in other memory areas.

(3)The subroutines called by MCRO(099) must be written in the same way as a normal subroutine, e.g., between SBN(092) and RET(093).

Execution with Subroutine Input Condition Flags

Overview

Subroutines called with JSB(982) are always executed regardless of the input condition to the instruction. The status of the input condition, however, is stored in an Auxiliary Area bit so that the status can be used to control program execution within the subroutine.

Subroutines called with JSB(982) are executed even if their input condition is OFF and even in program sec- tions interlocked with IL(002). The status of the input condition is stored in the Subroutine Input Condition Flag corresponding to the subroutine. Subroutine Input Condition Flags are from A000 to A015 and correspond to the subroutine numbers. The Subroutine Input Condition Flag can be used within the subroutine to control pro- gram execution.

For example, a subroutine could perform jogging when the input condition is ON and perform stop processing or deceleration when the input condition is OFF, or a subroutine could execute a communications instruction when the input condition turned ON and then continue to monitor communications until a response is received after the input condition turns OFF.

265

Page 288
Image 288
Omron FQM1-CM001, FQM1-MMA21, FQM1-MMP21 Using Subroutines That Pass Parameters, Programming, Appendix A, Overview