Is it possible to program Reference Positions to match PR's?

  • The joint move were for gross movements over the cell. Once in front of a fixture I would enter into a specific fixture program, which did include a lot of linear moves.

    The loop could be running on the robot side as a background logic program. It would take over the role of the reference position function. Disable the reference positions for a particular point, and turn on the output that was associated with the reference position with the BG program.

    Check out the Fanuc position converter I wrote here! Now open source!

    Check out my example Fanuc Ethernet/IP Explicit Messaging program here!

  • Place your Ad here!
  • Sooo...I was thinking about this: why not just do the simple, old school method of moving to a position, set an output that you are in position. If you need to actually identify which position, set a group output, as Nation mentioned. Move robot clear, set clear output, and so on.

  • I use Reference positions to indicate to the PLC when not to let something move while the robot is interacting with it. The advantage is Reference positions work independently of the program. So if E-Stopped in the press, nothing bad can happen... Programmatic bit saying I'm ready to enter the press (I call this handshaking) is for keeping the PLC and Robot in sync.

    That being said I have had need for moving to a reference position during operation. So I call this sub when the program starts:

    1: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[1] ;

    2: R[22:TEMP2]=R[22:TEMP2]*57.2958 ;

    3: PR[1,1:Ref Pos 1 PK]=R[22:TEMP2] ;

    4: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[2] ;

    5: R[22:TEMP2]=R[22:TEMP2]*57.2958 ;

    6: PR[1,2:Ref Pos 1 PK]=R[22:TEMP2] ;

    7: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[3] ;

    8: R[22:TEMP2]=R[22:TEMP2]*57.2958 ;

    9: PR[1,3:Ref Pos 1 PK]=R[22:TEMP2] ;

    10: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[4] ;

    11: R[22:TEMP2]=R[22:TEMP2]*57.2958 ;

    12: PR[1,4:Ref Pos 1 PK]=R[22:TEMP2] ;

    13: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[5] ;

    14: R[22:TEMP2]=R[22:TEMP2]*57.2958 ;

    15: PR[1,5:Ref Pos 1 PK]=R[22:TEMP2] ;

    16: R[22:TEMP2]=$REFPOS1[1].$PERCHPOS[6] ;

  • Well with all of everyone's input, I think I have it solved.

    Wrote a combination of a TP program that calls a KAREL program so I can now easily update whatever REFERENCE POSITION I want to.

    Giving credit to the other's and code references in this post - a lot of this was copied from existing programs they wrote and then I modified to fit my circumstances.

    Hopefully this will save someone else a bit of time in the future.

    It seems to work quite well for me, but as always, I'm sure there could be some improvements in the code, or a scenario where this won't work.

    KAREL Program:


    --- Section 0: Description

    --- This should be called from a TP program as:

    --- : CALL K_UpdateRefPos( 1, 2, 3, 4) ;

    --- 1 is the REFPOS number to update

    --- 2 is the POSITION register WITH the cartesian point TO convert

    --- 3 is the number OF the UFRAME

    --- 4 is the number OF the UTOOL


    --- Section 1: Program and Environment Declaration


    PROGRAM K_UpdateRefPos


    %COMMENT = 'K_UpdateRefPositions'



    --- Section 2: Variable Declaration



    cc_success = 0 -- Success status

    cc_xyzwpr = 2 -- Position Register has an XYZWPR

    cc_jntpos = 9 -- Position Regsiter has a JOINTPOS






    result :INTEGER

    data_type :INTEGER

    str_value :STRING[10]

    real_value :REAL

    xyz :POSITION

    jpos :JOINTPOS

    dummyArray :ARRAY[9] OF REAL

    indx :INTEGER


    --- Section 3: Routine Declaration



    --- Section 4: Main Program


    BEGIN -- K_UpdateRefPos

    -- Retrieve TP Arguments

    GET_TPE_PRM(1, data_type, REFPOS_NUM, real_value, str_value, result)

    GET_TPE_PRM(2, data_type, PR_NUM, real_value, str_value, result)

    GET_TPE_PRM(3, data_type, UF_NUM, real_value, str_value, result)

    GET_TPE_PRM(4, data_type, UT_NUM, real_value, str_value, result)

    -- intialize array

    FOR indx = 1 TO 9 DO

    dummyArray[indx] = 0.0


    -- make sure it is not at singularity point

    dummyArray[5] = 90.0

    -- Get Position Register in cartesian format


    -- verify register retrieved ok

    IF (result = cc_success) THEN

    -- Set user frame of reference

    -- $UFRAME=$MOR_GRP[1].$NILPOS --use this for world


    -- Set tool reference


    -- convert 'xyz' to joint position


    -- convert jpos to a REAL array


    -- convert jpos to radians and store in REF position








    WRITE('Error getting PR',CR)


    END K_UpdateRefPos

  • Thanks for posting the code

    I have a question. Let say I want to use this program, where do I call on the TP ?

    Can you post a short example ?

    His Karel comment actually explains most of it.

    You would just call it anywhere after you teach the position register specified in argument #2.


    CALL _UpdateRefPos(1,10,1,1);

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners