Advertising

Interrupt and current position problem...

  • The problem is simple: the "head" of the robot moves along the main trajectory. And it has two sensors.


    Interrupt 5 is called when the first sensor is triggered and let the robot simply memorize the current value of $ POS_ACT in currentXYZ (E6POS).


    And "head" begins to move along additional trajectory.


    Interrupt 4 is activated when the second sensor is triggered, which simply should "cancel" the execution of the current additional trajectory and return the head to PTP currentXYZ, exit interrupt 4 and then immediately from 5 and continue the main trajectory.


    But I can't even store coordinates in currentXYZ = $ POS_ACT - I get error. Something like "you can't save runtime data in the main program".


    The code - I threw out everything that does not belong to the problem.


    ===

    &ACCESS RV
    DEF b01( )

    E6POS currentXYZ;

    ;FOLD INI
    ;FOLD BASISTECH INI
    GLOBAL INTERRUPT DECL 5 WHEN $MEAS_PULSE[3]==TRUE DO found()
    INTERRUPT ON 5
    GLOBAL INTERRUPT DECL 4 WHEN $MEAS_PULSE[1]==TRUE DO stop_heat()
    INTERRUPT ON 4
    BAS ( #INITMOV,0 )
    ;ENDFOLD (BASISTECH INI)
    ;FOLD USER INI
    ;ENDFOLD (USER INI)
    ;ENDFOLD (INI)

    $BASE = $NULLFRAME;
    $TOOL = $NULLFRAME;
    $IPO_MODE = #BASE;

    $OV_PRO=100

    LOOP

    PTP {A1 0, A2 -90, A3 90, A4 90, A5 0, A6 0}

    LIN_REL {Z -2000}; main trajectory
    LIN_REL {Z 2000}

    ENDLOOP

    END


    def found()
    BRAKE F
    INTERRUPT OFF 5 ; founded - 1st trigger is ON
    INTERRUPT ON 4 ; closeup check on - activate INT for 2nd trigger
    currentXYZ = $POS_ACT
    PTP_REL {X 200}; added trajectory
    INTERRUPT OFF 4
    INTERRUPT ON 5
    end

    def stop_heat()
    BRAKE F
    PTP currentXYZ
    end
    ===


    Whatz wrong? :(

  • AD
  • But I can't even store coordinates in currentXYZ = $ POS_ACT - I get error. Something like "you can't save runtime data in the main program".


    Whatz wrong? :(


    If you read the manual, you would know :)

    Interrupt routines cannot change runtime data- passed as parameters or otherwise. I suggest making currentXYZ a global variable (just declaring it in .dat file might also work) and using $pos_int instead of $pos_act.

  • No any changes - after hard-reset the $config.dat restored old info. Of course without my variable :(


    GLOBAL E6POS currentXYZ did not work too... error 2037 - unknown line...

  • :)))


    Ten minutes ago I said: "No any changes - after hard-reset the $config.dat restored old info. Of course without my variable :( "


    So I can suggest two options:

    1. $config.dat - but after reset all new info is removed from it.

    2. Declaring global variable in .SRC-file, because all the code (including all subroutines) is in one file.


    The second option looks better for me...


    Maybe i can write the BLA-BLA.DAT-file specially for my BLA-BLA.SRC manually?


    But how? ;)

  • 1. That isn't the normal behavior, the variable should exist even after a cold boot.

    2.not possible.


    Second (should be 3. :)) easiest way: create a new module on the Bof of Kuka, they create a .src and .dat, then copy your code into the new src and add variable to the dat.

  • i would rather not hide user code inside fold structures like INI or inline form instructions, since users do not casually go in there to see if something unusual is there.


    also probably not good idea to set tool and base only once before main loop, specially if this is just an forum example of the code with other code not shown (calls to subprograms etc what can alter tool and base). also i see no other motion parameters like programmed speed. in other words this has a potential to be a very unstable piece of code. you mentioned that you threw everything else out to keep the post short (and i appreciate that) so not sure if this warning is aplicable.


    the next issue is variable declaration - you declared surentXYZ inside SRC file. more specifically inside program B01(), meaning that this variable is only known inside THAT routine. code after END of that routine does not see that variable. that includes other routines like FOUND() and STOP_HEAT()

    hence recomendation on reading manual and understanding scope and life of variables. solution is to declare it in a DAT file (can be local DAT file). if the DAT file does not exist, you can just create it - simply duplicate some other DAT file. for example you can create new program module and use it as donor.


    using interrupts requires special attention. as already mentioned, $POS_ACT is not what you want to record from when using an interrupt. you should use $POS_INT.


    i am not sure i understand the process:

    1. robot is moving vertically on a straight line,

    2. encounters something that triggers interrupt,

    3. saves that position (while continues moving),

    4. then upon second trigger returns to that saved point,

    5. continues vertical motion.


    what stops it from getting stuck into loop and repeating 2-4 several times before (if ever) reaching 5?


    about post 9:

    1. this is not normal behaviour so... are you sure your changes are really saved? you did not mention used KSS version. really old ones perhaps?

    2. this is just not possible. read the manual. global variable can ONLY be declared in a DAT file.


    about post 13:

    no need to hide your declaration inside predefined folds. just create a new line before ENDDAT and insert your declaration there.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Anywhere between the DEFDAT and ENDDAT would work -- the robot doesn't really care. Those Folds are there mostly for programmer convenience.


    Generally, I would add a blank line before the ENDDAT and start adding my variables there. That keeps them from being "hidden" inside those Folds.


    Normal KRL program modules consist of an SRC and DAT file, paired by having the same filename but with different extensions. Any variable declared in the DAT file is available to any subroutine or function in the SRC file. If GLOBAL is used in the DECL, then that variable becomes available to any program located in any module in the robot. DAT file variables are static -- their memory is permanently reserved.


    Variables DECL'd anywhere in the SRC file are always "runtime" variables, only available to the subroutine they were DECL'd in, and are voltaile -- their memory is not reserved. This becomes an issue for Interrupt routines, b/c when the robot is free to recycle that memory space becomes unpredictable. So using static variables is required.

  • Seems work, but a bit buggy ;)


    panic mode:

    ===

    i am not sure i understand the process:

    1. robot is moving vertically on a straight line,

    2. encounters something that triggers interrupt,

    3. saves that position (while continues moving),

    4. then upon second trigger returns to that saved point,

    5. continues vertical motion.

    ===


    It's right!

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