RobotStudio event

PC interface Problem in Socket Recive block[MOVED]

Options
IRB_2600
IRB_2600
edited December 2013 in Robot Controller

Problem statement:

I want to Move robot(IRB 2600) to coordinates given by computer via Ethernet using PC interface(Socket messaging).

Work done so far

On computer side :

I made a program in python which sends array of real no (x, y, z coordinates) via Ethernet. I have tested this program on PLC and it works fine.

 

On robot

I made a program which is at below which connect through PC  using service Ethernet port and connects to computer

 

Problem encounter

  1. My Program is stuck on the Socket Receive statement.
  2. Socket receive have only option t receive data,rawbyte and string when I tried to use rawbyte array rd{3} it gives me error
  3.  I can connect to controller to get my program connecting via service port only

 


My Program

 

MODULE MainModule

 

    VAR socketdev server_socket;

    VAR socketdev client_socket;   

    VAR socketstatus status;

    VAR string client_ip;

   

    VAR rawbytes recive_data;

    VAR rawbytes send_data;   

 

    VAR rawbytes rd{3};

      

    PROC main () 

 

        connec;  

        data_transfer;

 

    ENDPROC

   

    PROC connec()

 

        SocketCreate server_socket;

        SocketBind server_socket,"192.168.125.1",1025;

        SocketListen server_socket;

        SocketAccept server_socket,client_socket \ClientAddress:=client_ip; 

 

 

    ENDPROC

  

    PROC data_transfer()

! My program is stuck at Socket recive statement      

 

        SocketReceive client_socket\RawData:=recive_data;

        TPWrite recive_data;     

        SocketSend client_socket\RawData:=send_data;     

 

    ENDPROC

        

ENDMODULE

 

 I will really appreciate if you can help me to solve this problem 

Thanks

 

Comments

  • IRB_2600
    Options
    Hi ABB team 

    firstly i wish you happy new year !

    I have sorted problem 1 and 2 ,now i can send and receive string and the pointer is no longer stuck at socket receive command.(the problem was on the pc side)

    but i am still struggling with  problem 2 , Previously i have worked on similar project but the robot was PLC based and i can both send and receive array of real no without any problem.

    I will appreciate if i can get any light on this subject.

    Thanks

  • IRB_2600
    IRB_2600
    edited January 2014
    Options
    Hi Abb Team,

    currently i am able to successfully transfer coordinates from PC and move my robot accordingly, the only problem is that i am receiving data in bytes so i can't get expected result.please see My code below.

    i just want your help to sort out how can i receive data in array of num. rawbyte seems an option but i am not able to crack it please help!

    Thanks 

    MODULE MainModule
     
        ! this program moves as per data received in bytes.
        ! Problem: coordinates received is in bytes.
        ! solution: data transfer should be done in array of num.

        VAR socketdev server_socket;
        VAR socketdev client_socket;    
        VAR socketstatus status;
        VAR string client_ip;  
        VAR bool  keep_listening := TRUE;
        
        VAR byte send_array{3};
        VAR byte recieve_array{3};    
            
        VAR string xstring;
        VAR string ystring;
        VAR string zstring;
        
        VAR num xnum;
        VAR num ynum;
        VAR num znum;
            
        VAR bool xok;
        VAR bool yok;
        VAR bool zok;
            
        PROC main ()      
            
            ! Move the robot to home position.
            MoveAbsJ [[0,0,0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v100, z50, tool0;
            
            !call connect function to connect to pc.
            connec;  
            
            !continus loop for data transfer function.
            WHILE keep_listening DO            
                data_transfer;                                   
            ENDWHILE        
            
        ENDPROC

         PROC connec()      
            !this function create listen and aceept socket 
            SocketCreate server_socket;
            SocketBind   server_socket,"192.168.125.1",1025;
            SocketListen server_socket;
            SocketAccept server_socket,client_socket \ClientAddress:=client_ip;  
        ENDPROC
        
        PROC data_transfer()                    
            ! this function receive the coordinates from PC.
            ! the problem in this function is it can't receive coordinates in Num so i have to:= 
            ! convert received byte to string to num.
            ! move robot as per received coordinates.        
            
            !receive data.
            SocketReceive client_socket\Data:=recieve_array;               
            
            !convert byte to string.                         
            xstring:=ByteToStr(recieve_array{1});
            ystring:=ByteToStr(recieve_array{2});
            zstring:=ByteToStr(recieve_array{3});

            !convert string to num. the received coordinates are stored in xnum, ynum and znum.       
            xok :=StrToVal(xstring,xnum);
            yok :=StrToVal(ystring,ynum); 
            zok :=StrToVal(zstring,znum);
            
            !display received value on flexpendent screen
            TPWrite "this is new data recived";
            TPWrite "x ="\Num:=xnum;             
            TPWrite "y ="\Num:=ynum;        
            TPWrite "z ="\Num:=znum;     
            TPWrite " ";
            TPWrite ".";
            TPWrite ".";
            TPWrite ".";
            
            !move robot as per received values.       
            MoveAbsJ [[ xnum,ynum,znum,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]\NoEOffs, v100, z50, tool0;    
            
            !sending the received coordinates back to pc for verification                     
            SocketSend client_socket\Data:=recieve_array;      
        
        ENDPROC
     
    ENDMODULE
  • Micky
    Micky ✭✭✭
    Options

    Hi,

     

    if you want to use rawbytes you have to use the instruction UnpackRawbytes to convert your Bytes into the expected values.

     

      VAR num nFloat;

      SocketReceive socket1 \RawData := raw_data_in;

      UnpackRawBytes raw_data_in, 5, nFloat \Float4;

     

    Please have a look into the reference Manual of the UnpackRawbyte instruction to be able to understand how is works.

     

    regards

    Micky