Interpreter stop on KRC2

  • HI Panic Mode

    My code is:



    INT HANDLE,OFFSET,M,L

    DECL CHAR ch[2]

    DECL E6AXIS POS1

    REAL TIMEOUT

    DECL STATE_T SR_T,SW_T,SC_T

    DECL MODUS_T MR_T,MW_T


    INI

    F=FALSE

    ch[1]="0"

    GLOBAL INTERRUPT DECL 20 WHEN ch[1]=="1" DO SUB1()

    POS1.A1=0

    POS1.A2=-74

    POS1.A3=100

    POS1.A4=0

    POS1.A5=-27

    POS1.A6=0

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

    $BWDSTART = FALSE

    PDAT_ACT=PDEFAULT

    BAS(#PTP_DAT)

    FDAT_ACT=FHOME

    BAS(#FRAMES)

    BAS(#VEL_PTP,2)

    $H_POS=XHOME

    PTP XHOME

    ;ENDFOLD



    HANDLE=3

    MR_T=#ABS

    MW_T=#ABS

    OPEN_P()

    INTERRUPT ON 20

    READ_p()

    ptp POS1

    CLOSE_P()

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

    $BWDSTART = FALSE

    PDAT_ACT=PDEFAULT

    BAS(#PTP_DAT)

    FDAT_ACT=FHOME

    BAS(#FRAMES)

    BAS(#VEL_PTP,20)

    $H_POS=XHOME

    PTP XHOME

    ;ENDFOLD

    END

    ;------------------------------------------------------------------------------------------

    DEF OPEN_P()

    COPEN(:SER_3, HANDLE)

    IF (HANDLE==0) THEN

    HALT

    ENDIF

    END

    ;-----------------------------------------------------------------------

    DEF READ_P()

    INTERRUPT ON 20

    CWRITE(HANDLE,SW_T,MW_T,"%c","y")

    TIMEOUT=3

    OFFSET=0

    WAIT FOR ($DATA_SER3<>0)

    CREAD(HANDLE,SR_T,MR_T,TIMEOUT,OFFSET,"%s",ch[])

    OFFSET=0

    END

    ;-----------------------------------------------------------

    DEF SUB1()

    CWRITE(HANDLE,SW_T,MW_T,"%c","A")

    INTERRUPT OFF 20

    HALT

    BRAKE

    END

    ;-----------------------------------------------------------------------

    DEF CLOSE_P()

    CCLOSE(HANDLE,SC_T)

    IF (SC_T.RET1<>#CMD_OK) THEN

    HALT

    ENDIF

    END

  • ch[1]=="1"

    Does this even work in your interrupt declaration? I believe like this your interrupt never gets triggered. I think to compare character arrays you need strcomp function. I never tried but I do not think you can use strcomp directly as condition of the interrupt condition. Only simple conditions like true or false flags are allowed. You should evaluate your condition not in the main program but set a flag or maybe a cycflag as condition and update the condition variables the flag/cycflag depends on in submit interpreter.


    No RESUME here. Hence whenever interrupt is left robot will continue to finish the active motion when interrupt was triggered. I would test with the HALT after the break to keep advance run inside the interrupt.


    Fubini

  • hello there.


    well i will start with some criticism first. that post is a prime example of don't care attitude.


    code is not formatted (no indentations etc.), begin of code including DEF line is missing, it was posted as text instead of using code wrap, as a result there are no line numbers to refer to and offer feedback efficiently. in other words you are not making it easy to help you. not everyone will bother to waste own time to clean it up, review it, and write some suggestions.


    code is supposed to be surrounded by CODE tags or if longer than few lines, posted as an attachment that is ready to run on some robot or simulator - WITHOUT need to clean it up and supply missing parts.


    btw this is code tag:


    now lets take a look at it. this is how program code surrounded by CODE tag looks like:


    ...aaaand NOW we have a conversation piece.


    one more thing to clarify is what kind of stop is needed...

    is it temporary only? in this case program will eventually continue the original motion (which is now paused).


    if it is not a temporary stop, program is not only going to stop current motion but it will never continue with that motion - when robot moves again it will go to some other point (whatever is next). an example of this is when robot is used to determine height of some stack robot keeps lowering until sensor is on. that can be at different elevations depending on stack height. but once the stack is found - robot should NOT keep going down or there will be collision. this case requires instructions RESUME (resume main program - abort and abandon current motion)



    line 12, interrupt is declared as GLOBAL. no RESUME is possible so this interrupt can only do a temporary stop.


    line 38, motion to be stopped is not in a subprogram. like line 12 this means no RESUME is possible, only a temporary stop. after the stop is expired, robot will continue with current motion - moving to P1


    line 74, halt command prevents processing rest of the SUB1()


    line 75, brake command is what actually stops robot. but this command is only a temporary stop. note that is does stop robot motion but it does not stop program instruction pointer which keeps going to next program line!!!. and this temporary stop is only going to last until instruction pointer reaches end of SUB1() and that is ... immediately :). basically this BRAKE command has no effect whatsoever.... to see what i mean add something after BRAKE to keep instruction pointer busy inside SUB1(). do not let SUB1() end - when it ends, BRAKE has no longer any effect and robot will continue moving to P1. so your interrupt does work but pause in motion is not observable. to verify that your interrupt is processed, add some counter and increment it in SUB1(). you could use one of predefined counters too.

    for example add line

    I[1]=I[1]+1

    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

  • I'm Sorry for last post because I'm beginner in post messaging. I promise to post better from now on.

    is it temporary only? Yes. I want to test it. Start moving robot from p1 to p2 and stop that when sensor sens. just that. if you tell it stop and continue why this command not execute (LINE 72):

    Code
    CWRITE(HANDLE,SW_T,MW_T,"%c","A")

    This command turns on the hazard light.

    If you say that the interrupt is executed, then the movement continues again, then why this command is not executed like the command I[1]=I[1]+1.

    I run the program and the program does not check the interrupt until it reaches the second point and I have to go down step by step and check the sensor every time and this is a problem.


    Code
    DEF SUB1()
        CWRITE(HANDLE,SW_T,MW_T,"%c","A")
        INTERRUPT OFF 20
        HALT    
        BRAKE
    END

    In addition, The interrupt condition does not have to be true or false. Variables can also be used: ch[1]=="1"

  • well... the simple answer is i don't know with certainty because there there is more to it...


    you still did not post code that you run, i can see just part of SRC file. Not sure if anything is declared in DAT file. if the program is exactly what you posted, this cannot even work since variables used as parameters for CWRITE are not even declared.

    there are status and mode variables declared in main program (lines 6 and 7 of code in post 23) but they are not accessible from subprograms like SUB1() or READ_P().

    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

  • Code
        READ_p()
        ptp POS1

    This part can not work. Read_p() waits for a character from serial port. The movement will start after receiving a character. How should the movement be canceled when you wait for a character from serial port before initiating the movement? But after starting the movement there is no other reading of the serial port.

    In addition, The interrupt condition does not have to be true or false. Variables can also be used: ch[1]=="1"

    An interrupt condition has to be true or false, and it can work because ch[1]==“1“ is an expression that results in a true or false.

  • Dat FIle

    SRC File

  • 1. Correct everything panic_mode already told you. For example the interrupt is declared as global don't do this. Just delete 'global'.

    And so on.

    2. Change reading of the serial port. One possibility is to read it in sps.sub. Or change order of reading and movement and do the movement with approximation like c_ptp.

  • if you want to use RS232 comms as substitute for IO driver then consider making it work like IO driver. make it exchange messages cyclically and map the data to IOs (or outputs only). this can be done in SPS.


    then your other programs would not even know the difference, thy would simply access IO.

    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

  • Thank You Panic,

    This way you said it will solve my problem. Now I have to read about how to add a serial port to a SPS.SUB file. I can do this more easily if I have more accurate information.

  • Can I open,read and close the Serial Port (RS232) in SPS file?

    OR , Do I have to define variables in the CONFIG.dat file?


    PLZ Help me. everyone if can.

    Edited once, last by hassanhp82: How i can define RS232 input signal in SPS? ().

  • Hello !


    I return on my topic open here regarding I interpreter stopping suddenly when program run.

    We thought that a cable issue of E1 was the cause but did not, even I announced problem solved.

    Meanwhile we changed KPS 600-20, KCP and ESC CI3 extended with other ones, problem reappear after a short or longer period of working.

    There is no logic when stop, is other line each time, so I cannot suspect a program error.

    Cables been checked all, X11 as well. Connections in RDW too.

    It stops with no error message, Interpreter from green become red and stop as switch enable is released in T1 or T2 but now being in automatic.

    Any similar problem met anyone?

    Sugestions?


    Ty

  • The problem has been solved .

    Connector that link blue wires between top Driver N7 with top Driver N6, position 5 and 6, had an imperfect contact. I think they are feeding motors brake. Has been discovered randomly after many parts replacing.

    Even no important and relevant message appeared.

Advertising from our partners