Create a subprogram with input parameters¶
What you will learn
- Place a Subprogram block inside a program
- Loop For usage
- Assign inputs to a program
- Run a subprogram with changed input values
-
Create a new program and name it.
-
Add a
Loop For
block from the Control Structures. -
Add a
Move Cartesian
block from "Robot" Function Blocks inside the loop. -
Add two waypoints to the
Move Cartesian
block. -
Select
at the top. -
In the "input parameters" you will be able to create, modify and delete input parameters. Create a new one and select type as integer, 'No of Loops' as title and write 3 as default value.
-
Now we will connect the number of interations with this input parameter. For this purpose, select
of the loop block. -
Select the link button of Turns parameter and select 'No of Loops' from parent program input by clicking the tick . This will connect the value introduced in the program to the for loop.
-
Save the program. Now we can use this program inside another programs.
-
Now create another new program.
-
Look for the created program in the subprograms tab and add it to the program sequence.
-
Select
of the program. -
Change the 'No of Loops' to 2 instead of leaving the default value.
-
Now the program can be started. The program will execute the given number of iterations.