Flag true when Main Program is selected

  • Hello everyone,
    I have a problem on a cell that I am starting, I manage the KUKA krc2 as a slave from a PLC, I should send a bit when a specific program is selected.
    I think I should enter this function in the SPS, but I do not know which variable I have to use.
    Do you have any ideas?
    I have already tried $PRO_NAME1[], but I don't understand how I can use it.
    Thanks in advance.

    Edited once, last by MrNico ().

  • $PRO_NAME1[] is a string variable that shows the name of the currently selected program in the robot interpreter. You can simply do a string comparison on it, although you may need to use VARSTATE or STRLEN to protect against conditions where the variable is empty (when a program has been cancelled, for example).


    I don't believe $PRO_NAME1[] changes as the program pointer dives into subroutines, but I could be recalling incorrectly.

  • If I get you right, I would suggest that you create a variable inside each subprogram, set it as soon as the program is called and reset when exiting. Since PLC is the master, you can send this specific variable status to PLC in a similar way you make handshake signals between Robot-PLC .

  • I tried to make a comparison with strcomp, but it does not work.
    Have you ever used strcomp?
    If I try to read the variable $PRO_NAME1 [] I have this result "/R1/Lavorazioni.scr"
    StrComp($PRO_NAME1[], “/R1/Lavorazioni.scr”, #NOT_CASE_SENS) but strcomp is always FALSE.
    Have you an idea where I'm wrong?


  • If I get you right, I would suggest that you create a variable inside each subprogram, set it as soon as the program is called and reset when exiting. Since PLC is the master, you can send this specific variable status to PLC in a similar way you make handshake signals between Robot-PLC .


    How can I reset the variable when the program is deselected?

  • [size=2]program selected and program running are two different things.[/size]
    [size=2]is supposed to be part of interlock for robot start?[/size]


    [size=2]if you need to know program running, then something like this may do:[/size]


    [size=2]in $CONFIG.DAT[/size]

    Code
    SIGNAL PROGRAM_RUNS $OUT[1] TO $OUT[32]


    [size=2]in SPS.SUB loop add something like[/size]

    Code
    IF $PRO_STATE1==#P_FREE THEN
      PROGRAM_RUNS=0
    ENDIF




    And then at the begin of each program add line such as



    Code
    PROGRAM_RUNS=1 ; use different value in each program
    ; if you want individual bit to indicate running program, just make sure
    ;to only use values that are binary powers (1,2,4,8,16,32...)

    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


  • When I test $PROG_NAME1[], I do not get the "R1/" portion or the file extension, only the program name.
    You could probably try using STRFIND in place of STRCOMP.

  • Yes, ok I solved my problem this is the results.


    RicercaProgramma = StrFind(1,$PRO_NAME1[], "LAVORAZIONI", #NOT_CASE_SENS)
    oProgLavorazione = RicercaProgramma == 1


    where oProgLavorazione is my output for the PLC
    RicercaProgramma is an Integer declared in config.dat
    LAVORAZIONI is the Program to check


    Obviously this is wrote in the SPS.
    Thank you everyone and I hope this post can help somebody else. :dance2::toothy9:

    Edited once, last by MrNico ().

Advertising from our partners