Hey All,
I am writing a homing routine (AUTO mode..) for an LR Mate 200iD robot and am trying to implement FOR loops to make things a bit more compact, and also to expand my FANUC programming knowledge.
The problem I am having is that a register I am trying to increment at the end of the for loop is actually incrementing TWICE for some reason, causing the loop to skip over a position and fault out the robot for a limit error.
Please see the code section below;
R[4:POS_MEM] = R[4:POS_MEM] + 1
FOR R[4:POS_MEM] = R[4:POS_MEM] TO 17
L PR[R[4]] 500mm/sec CNT25
R[4:POS_MEM] = R[4:POS_MEM] + 1
ENDFOR
I could hard code every case here since it is only around 3 positions or so... but for the future I would like to know what's going on here.
I stepped through the program multiple time and here's a summary of what happens.
R[4] starts at 14, gets incremented to 15 before the FOR loop.
Once the FOR loop runs, it goes to PR[15] since I am using R[4] indirectly, no problems here.
Next, R[4] gets incremented again to 16, the next position I want to go to.
I reach the 'ENDFOR' statement, when I press step, the register R[4] increments by 1 AGAIN?!
Now on the next iteration of the loop, the robot tries to move to position 17, not 16.
Please let me know if anyone has encountered a similar issue to this, or has a hunch what the problem may be.
Best Regards,
DH