It is often useful to use multiple jobs within a single application. This allows for reuse of code and simplifies the main job. This can be done using the “Call” instruction. This instruction takes another Job as an argument and will open and run that job during the program’s execution. The “Call” instruction can be found under the {Control} category on the Command List.
For example, an application may have “OPENGRIPPER” and “CLOSEGRIPPER” jobs which contain the instructions needed to execute these actions. Then, the “MAIN” job could call these child jobs during its execution. When the MAIN job shown below is executing, it will run until Line 4 and then open the CLOSEGRIPPER job. When the CLOSEGRIPPER job completes, the MAIN job will continue on Line 5. Thus, the OPENGRIPPER and CLOSEGRIPPER jobs can be reused through the application whenever these actions need to take place.
It is also possible to call another job from within a child job; however, this call only be done to a depth of 12 (i.e. “Stack Level 12” on the image below).
It is also possible to pass information between jobs using Job Arguments. For example, a user may want to pass the position of a part to a subroutine (child job) that executes the picking motions. To use Job Arguments, the basic procedure is:
- Configure the child job using the Additional Settings panel
- Add the Call command with arguments in the parent job
- Add the GetArgument command in the child job to get values
- Store values in local variables
The following steps describe the basic procedure for using Job Arguments with an example. This involves a parent job (named as “PARENT_JOB1”) that will call into a child job (named as “CHILD_JOB1”) with arguments. The child job uses three arguments:
- 1 Double (D) value to be used as a Speed parameter
- 1 Integer (I) value to be used in a Timer
- 1 Position (P) value to be used as a Shift value
1. Configure the Local Variables for the job. For more information on Local Variables, see this article.
- For using these parameters in the child job, at least one LD, LI, and LP variable will need to be allocated, as shown in the following figure.
2. Configure the Job Argument Names for the child job.
- Three arguments are named:
3. Open the parent job (PARENT_JOB1) from the Job List.
4. Under Navigation Bar, press {COMMANDS}.
Add a Call command, which can be found under {Control} command group as an advanced command. Parameter names (i.e. Speed, Delay, ShiftVal) are shown on:
- the Detail Edit panel (if configured)
- the Job Contents view (if configured)
5. Select the Job Name from the list on the right.
6. Insert values into arguments. These values will be passed to the Child job's argument list.
7. Open the child job (CHILD_JOB1) from the Job List.
8. Under Navigation Bar, press {COMMANDS}.
9. Add a GetArgument, which can be found under {Control} command group as an advanced command. GetArgument has two parameters:
- “Result” parameter: stores the passed argument value. This value must be a Local Variable.
- “Argument #” parameter: refers to which Argument to get. If this is entered as a constant (i.e. 1-8), the argument name will be displayed at the end of the line in the Job Contents view (shown as “Speed” below).
- If the argument # parameter is entered as a variable, the argument name will not be shown in the Job Contents view.
Comments
0 comments
Please sign in to leave a comment.