Robot arm misbehaves when used #TOOL with LIN_REL in KRL

  • Hello,


    I am very new to KUKA Programming, therefore sorry for bad explanation. The project I am working on has requirement that my Gripper should operate relative to tool. Therefore, I have used LIN_REL with #TOOL. But sometimes the Arm misbehaves and goes downwards and collide with the ground. I don't know what mistake I have done. I am using TWINCAT for most of my logic. Only positons is given by KUKA.


    Any help is very much appreciated.


    My code is below:


    &ACCESS RVO

    DEF MoveWithLINPTPandREL ( )

    DECL INT velCut

    DECL E6POS zielPosition, istPosition, zielPositionRelativ

    DECL FRAME zielFrame


    zielPosition = {X 1000,Y -540,Z 1500}

    zielPositionRelativ = {X 0,Y -200,Z 0}

    ;$PAL_MODE = TRUE ; schaut senkrecht runter


    ;FOLD PTP HOME Vel= 100 % DEFAULT;%{PE}%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:HOME, 3:, 5:100, 7:DEFAULT

    $BWDSTART = FALSE

    PDAT_ACT=PDEFAULT

    FDAT_ACT=FHOME

    BAS (#PTP_PARAMS,100 )

    $H_POS=XHOME

    PTP XHOME

    ;ENDFOLD




    RelPosReached = 0


    LOOP


    INTERRUPT ON 1


    SWITCH moveType

    CASE 0 ; PTP

    RelPosReached = 0

    ;FOLD Input Zuweisung

    zielPosition.x = xEingaenge

    zielPosition.Y = yEingaenge

    zielPosition.Z = zEingaenge

    zielPosition.A = aEingaenge / 10

    zielPosition.B = bEingaenge / 10

    zielPosition.C = cEingaenge / 10

    ;ENDFOLD


    BAS(#VEL_PTP, velocity) ; in %

    PTP zielPosition


    CASE 1 ; LIN

    RelPosReached = 0

    ;FOLD Input Zuweisung

    zielPosition.x = xEingaenge

    zielPosition.Y = yEingaenge

    zielPosition.Z = zEingaenge

    zielPosition.A = aEingaenge / 10

    zielPosition.B = bEingaenge / 10

    zielPosition.C = cEingaenge / 10

    ;ENDFOLD

    BAS(#VEL_CP, velocity) ; in %

    LIN zielPosition


    CASE 2 ; LIN_REL

    RelPosReached = 0

    zielPositionRelativ.x = xEingaenge

    zielPositionRelativ.Y = yEingaenge

    zielPositionRelativ.Z = zEingaenge

    zielPositionRelativ.A = aEingaenge / 10

    zielPositionRelativ.B = bEingaenge / 10

    zielPositionRelativ.C = cEingaenge / 10

    BAS(#VEL_CP, velocity) ; in %

    ;RelPosReached = 0 ; nichts mehr Empfangen

    LIN_REL zielPositionRelativ #TOOL

    RelPosReached = 1


    CASE 3 ;idle

    RelPosReached = 0


    DEFAULT

    zielPosition.x = xEingaenge

    zielPosition.Y = yEingaenge

    zielPosition.Z = 2000

    BAS(#VEL_CP, velocity) ; in %

    LIN zielPosition

    ENDSWITCH



    INTERRUPT OFF 1


    ;FOLD IstPosition Abspeichern

    istPosition = $POS_ACT_MES

    xAusgaenge = istPosition.x

    yAusgaenge = istPosition.y

    zAusgaenge = istPosition.z

    aAusgaenge = istPosition.A * 10

    bAusgaenge = istPosition.B * 10

    cAusgaenge = istPosition.C * 10

    ;ENDFOLD



    ENDLOOP

  • Hi hermann,

    maybe it sounds dumb, as I am new in KUKA Prg. But the code I have attached is the complete one. What you asked is not there in the running programm. Do I need to do that?

    also when I run the programm from the SmartPAD, there I am selecting my tool and base.


    Did I correctly got your point?

  • Hi,

    it is configured in .dat file. Anything should be changed there?

    First: Use quoting. Especially when replying to a post over a month old.


    Second: What is "configured in a .dat file"? $TOOL is not set in a .DAT file, because $TOOL is a system variable and is not part of any .DAT file. $TOOL can only be set by executable code (generally only located in .SRC files).


    Inline Form (ILF) motion commands (in other words, those programmed using the pendant menus, instead of writing "raw" KRL) include code snippets to call BAS.SRC, and send it variables that set $TOOL (also $BASE, and other system variable for motion speed, approximation, acceleration, etc).


    If you write a "raw" KRL program without explicitly specifying $BASE, $TOOL, and these other variables, then you have no control over what Tool/Base/etc data are active when you run your program.



  • Thanks for elaboration. I will now look more into that.

Advertising from our partners