Forum Migration Notice
We're transitioning to a more modern community platform by the end of this year. Learn about the upcoming changes and what to expect.
FOR inside another FOR
Yrb
✭
Hello,
I was wondering how it is possible to include FOR inside of another FOR routine?
I have pick & place program where I need to pick parts from pallet to another pallet with different distances between parts.
In the following program it starts DropPart from the beginning, but PickPart works just fine when there is "RETURN;" at the end of DropPart.
Is it even possible to use "FOR" to this kind of work?
Is it even possible to use "FOR" to this kind of work?
<div> CONST robtarget Pick:=[[233.88,20.36,-22],[0.0188622,0.999235,-0.0341801,-0.00240115],[1,-1,-1,4],[-176.75,9E+09,9E+09,9E+09,9E+09,9E+09]];<br> CONST robtarget Drop:=[[194.41,87.15,-13.11],[0.018849,0.999236,-0.0341648,-0.00239745],[1,-2,-1,4],[-176.745,9E+09,9E+09,9E+09,9E+09,9E+09]];<br> VAR num PickRow{8}:=[0,16,32,48,64,80,96,112];<br> VAR num PickColumn{8}:=[0,16,32,48,64,80,96,112];<br> VAR num DropRow{10}:=[0,14.5,29,54.5,69.5,88.3,103,127.3,142.5,157];<br> VAR num DropColumn{4}:=[0,-12,-27,-39];<br><br> PROC <b>PickPart</b>()<br> FOR j FROM 1 TO 8 DO<br> FOR i FROM 1 TO 5 DO<br> movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;<br> Movej offs (Pick,PickColumn{i},PickRow{j},30),v1000,z0,Alip\WObj:=PoytaO;<br> Movej offs (Pick,PickColumn{i},PickRow{j},5),v100,z0,Alip\WObj:=PoytaO;<br> g_VacuumOn1;<br> Movej offs (Pick,PickColumn{i},PickRow{j},0),v10,z0,Alip\WObj:=PoytaO;<br> Movej offs (Pick,PickColumn{i},PickRow{j},10),v10,z0,Alip\WObj:=PoytaO;<br> Movej offs (Pick,PickColumn{i},PickRow{j},20),v1000,z0,Alip\WObj:=PoytaO;<br> movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;<br> DropPart;<br> ENDFOR<br> ENDFOR<br> ENDPROC<br> <br> PROC <b>DropPart</b>()<br> FOR x FROM 1 TO 4 DO <br> FOR y FROM 1 TO 10 DO<br> Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;<br> Movej offs (Drop,DropColumn{x},DropRow{y},10),v100,z0,Alip\WObj:=PoytaO;<br> Movej offs (Drop,DropColumn{x},DropRow{y},0),v10,z0,Alip\WObj:=PoytaO;<br> g_VacuumOff1;<br> Movej offs (Drop,DropColumn{x},DropRow{y},10),v10,z0,Alip\WObj:=PoytaO;<br> Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;<br> <b>RETURN</b>;<br> ENDFOR<br> ENDFOR<br> ENDPROC</div><div></div>0
Answers
-
The way your code works without the return is that it will pick one part, then drop part 40 times in a row.
Is this your desired function?
There is no problem with nesting multiple for loops in rapid.Systemintegrator - Web / C# / Rapid / Robotstudio
If I helped, please press Vote Up
☑️2024 - RobotStudio® User Group0
Categories
- All Categories
- 5.6K RobotStudio
- 401 UpFeed
- 21 Tutorials
- 16 RobotApps
- 306 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.9K Robot Controller
- 365 IRC5
- 86 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 854 RAPID Programming
- 37 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 111 Collaborative Robots
- 5 Job listings
