RobotStudio event

How to continue cycle in automatic mode

Hello
I have a code that is getting coordinates from MATLAB for a pick and place operation. I switched to continous mode on the controller, I run the codes from MATLAB and coordinates are given to the robot but the robot does that one cycle alone. When new coordinates are found and sent, the robot is nolonger moving to the object, neither are the new coordinates written on the flex pendant. I request help on why it is not going continuously. Below is the code:

MODULE Module1
CONST robtarget home:=[[234.80,469.37,226.34],[0.0195519,-0.951851,0.0534726,-0.301227],[-1,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget home_2:=[[234.80,475.28,226.35],[0.0194946,-0.95184,0.0535081,-0.301259],[-1,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget predrop:=[[362.39,825.00,219.32],[0.0194847,-0.951856,0.0535358,-0.301205],[0,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
CONST robtarget drop:=[[362.72,826.63,117.28],[0.0193944,-0.951708,0.053578,-0.301671],[0,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    VAR robtarget cartesianTarget;
    VAR bool ok;
    VAR pos p;
    VAR rawbytes data;
    VAR socketdev server;
    VAR socketdev client;
    VAR string cartesiancoordinates;
    VAR string client_ip;
    VAR num i;
    VAR num X;
    VAR num Y;
    VAR num Z;
    
    
   
    PROC main()   
    SocketCreate server;
    SocketBind server, "192.168.125.1", 5992;
    SocketListen server;
    !SocketAccept server, client;
    ClearRawBytes data;

    WHILE TRUE DO
        SocketAccept server, client\ClientAddress:=client_ip\Time:=WAIT_MAX;
        cartesiancoordinates := "";
        ClearRawBytes data;
        SocketReceive client \Str:=cartesiancoordinates;
        p:= [X, Y, Z];
        ok:= StrToVal(cartesiancoordinates,p);
        TPWrite "cartesiancoordinates="\pos:=p;
        SocketClose client;
        cartesianTarget:= [p,[0.00951845,0.94131,-0.100202,0.322188],[0,0,-3,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
        Path_10;     
    ENDWHILE 
    
    SocketClose server;
     
     ENDPROC
     
   PROC Path_10()
       
    MoveJ home, v500, fine, VacuumTool\WObj:=Workobject_1;
MoveJ Offs(cartesianTarget,X,Y,Z), v50, fine, VacuumTool\WObj:=Workobject_1;
WaitTime 0.5;
    SetDO IOKART_DO2,0;
    SETDO IOKART_DO4,1;
    WaitTime 0.5;
!MoveL home_2, v200, fine, VacuumTool\WObj:=Workobject_1;
MoveL predrop, v150, fine, VacuumTool\WObj:=Workobject_1;
MoveL drop, v150, fine, VacuumTool\WObj:=Workobject_1;
    WaitTime 0.5;
    SetDO IOKART_DO2,1;
    SETDO IOKART_DO4,0;
    WaitTime 0.5;
MoveL predrop, v150, fine, VacuumTool\WObj:=Workobject_1;
MoveL home_2, v150, fine, VacuumTool\WObj:=Workobject_1;
     IF ERRNO>0 THEN
                            IF ERRNO=ERR_SOCK_TIMEOUT THEN

                            ELSE
                                i:=0;
                            ENDIF
                        ENDIF
                       ! WaitTime 1;
      ERROR
        IF ERRNO=ERR_SOCK_TIMEOUT THEN
            RETRY;
        ELSEIF ERRNO=ERR_SOCK_CLOSED THEN
            SocketClose server;
            WaitTime 10;
            SocketCreate server;
            SocketConnect server, "192.168.125.1", 5992;
            RETRY;
        ELSE
            TPWrite "ERRNO = "\Num:=ERRNO;
            Stop;
        ENDIF
                    
   ENDPROC
ENDMODULE
Tagged:

Comments

  • lemster68
    lemster68 ✭✭✭
    So there are no errors?  One very useful debug strategy is to use the step forward button, you can see line by line how the logic is being evaluated, what data values are changing.
    Lee Justice
  • You can change between single cycle and continuous Run Mode on the Flexpendant:


    There is also a system parameter that determines which run mode to use when switching between auto/manual modes, see "3.13.1 The Run Mode Settings type" in the Technical reference manual -System parameters document.