FOR Loop with increments

  • hello all, i'm trying to further my knowledge of robotics programming and i am not sure where i can edit lines of cose in fanuc. but the restrictions of these loops isn't letting me quite get to where i want.


    the code:


    1: UTOOL_NUM = 8
    2: UFRAME_NUM = 6
    3:
    4:
    5: FOR R[1]= 0 TO 4 (so it repeats 4 times)
    6:
    7: PR[3] = PR[1]
    8: PR[4] = PR[2]
    9: PR[3,2]=PR[1,2]-80-R[1] (the 80 is representing the increment i need it to do -y 80mm, but its automatically negating the register when i want it to multiply it just changes both)
    10: PR[4,2]=PR[2,2]-80-R[1]
    11:
    12: FOR R[2]= 0 TO 4
    13:
    14: PR[3,1]=PR[1,1]+100+R[1] (again i want positive 100mm in X then to times it by R)
    15: PR[4,1]=PR[2,1]+100+R[1]
    16:
    17:
    18:L PR[1] 1000mm/sec FINE
    19:L PR[2] 30 mm/sec FINE
    20:
    21: ENDFOR
    22: ENDFOR



    can anyone help me figure out a different way of doing this or if i can override the changing signs so they don't both equal +/- and i can * [R] 1 or 2 so then my loop will work



    if anyone is interested i got a grid plate at 0,0,0 and then im wanting to add on 100mm in x 4 times then 80mm once and 4 x 100mm and so on... to cover the grid

  • got it working with mixed logic, if you ever have a problem try mixed logic :uglyhammer2:


    also make sure that your registers you want to move aren't the ones that are your defaults lol

  • Welcome to the discussion forum MxStun,



    I hope that you can accept the idea that just because you got it to work, doesnt meant he approach is always the correct one. I'd be glad to help, but first i need you to look over the code you posted... I dont see where you are trying to multiply anything. Thanks


    -Hope to help -Eric

  • 1: UTOOL_NUM = 8
    2: UFRAME_NUM = 6
    3:
    4:
    5: FOR R[1]= 0 TO 4 (so it repeats 4 times)
    6:
    7: PR[3] = PR[1]
    8: PR[4] = PR[2]
    9: PR[3,2]=PR[1,2]-80*R[1]
    10: PR[4,2]=PR[2,2]-80*R[1]
    11:
    12: FOR R[2]= 0 TO 4
    13:
    14: PR[3,1]=PR[1,1]+100*R[1]
    15: PR[4,1]=PR[2,1]+100*R[1]
    16:
    17:
    18:L PR[3] 1000mm/sec FINE
    19:L PR[4] 30 mm/sec FINE
    20:
    21: ENDFOR
    22: ENDFOR


    this is the new code, as i stated in my first message without mixed logic it was changing the second sign automatically. this new code now works and the grid gets scanned then comes out of the Loop
    if there is any information to make this easier or a different way to do it i am all ears.


    thanks for your response i hope to learn a lot from these forums and share my advice where i can

Advertising from our partners