I’m attempting to use an incremented counter in a part laydown routine to calculate/modify an offset as I stack parts into a hopper. I need to the laydown position to shift 15mm in the +Z direction after each part, but I don’t want to use dozens of robtargets to do it. One robtarget and a calculated offset based on a counter seems much cleaner, I just can’t figure out how to do it.
Is there a way to use the counter to modify or select the offset I want?
You can just use a FOR or WHILE loop and every iteration increment the offset. With the function Offs you can modify the position.
So you can do something like this:
PERS num noParts := 5;
PERS num offset := 15;
PERS robtarget pFirst := [[1000,0,400],[0,1,0,0],[0,0,0,0],[9e9,9e9,9e9,9e9,9e9,9e9]];
PROC main()
VAR num totalOffset := 0;
FOR i FROM 1 TO noParts DO
MoveJ Offs(pFirst,0,0,totalOffset), v1000, fine, tool0;
totalOffset := totalOffset + offset;
ENDFOR
ENDPROC
That’s quite a bit cleaner than what I ended up doing. Might have to go back and modify…
Incr HopperCount;
MoveAbsJ jposHOME,v1000,z50,tGripper;
TEST HopperCount
CASE 1:
p1000Ct_PlacePos.trans.z := + 15;
p1000Ct_PlaceDepart.trans.z := + 15;
CASE 2:
p1000Ct_PlacePos.trans.z := + 30;
p1000Ct_PlaceDepart.trans.z := + 30;
CASE 3:
p1000Ct_PlacePos.trans.z := + 45;
p1000Ct_PlaceDepart.trans.z := + 45;
etc, etc…
Then reset the Z values at completion of the routine.