RobotStudio event

FOR inside another FOR

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?
<div>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; VAR num PickRow{8}:=[0,16,32,48,64,80,96,112];<br>&nbsp;&nbsp;&nbsp; VAR num PickColumn{8}:=[0,16,32,48,64,80,96,112];<br>&nbsp;&nbsp;&nbsp; VAR num DropRow{10}:=[0,14.5,29,54.5,69.5,88.3,103,127.3,142.5,157];<br>&nbsp;&nbsp;&nbsp; VAR num DropColumn{4}:=[0,-12,-27,-39];<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PROC <b>PickPart</b>()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FOR j FROM 1 TO 8 DO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FOR i FROM 1 TO 5 DO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Pick,PickColumn{i},PickRow{j},30),v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Pick,PickColumn{i},PickRow{j},5),v100,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_VacuumOn1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Pick,PickColumn{i},PickRow{j},0),v10,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Pick,PickColumn{i},PickRow{j},10),v10,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Pick,PickColumn{i},PickRow{j},20),v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movej Homepoint,v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DropPart;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDFOR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDFOR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDPROC<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; PROC <b>DropPart</b>()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FOR x FROM 1 TO 4 DO <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FOR y FROM 1 TO 10 DO<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Drop,DropColumn{x},DropRow{y},10),v100,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Drop,DropColumn{x},DropRow{y},0),v10,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g_VacuumOff1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Drop,DropColumn{x},DropRow{y},10),v10,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Movej offs (Drop,DropColumn{x},DropRow{y},50),v1000,z0,Alip\WObj:=PoytaO;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>RETURN</b>;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDFOR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDFOR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDPROC</div><div></div>





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  :smile: