RobotStudio event

PP skips Move Instruction

Hello guys,

i'm still learning RAPID programming and I've now been at this point multiple times which I don't understand.

I'm currently writing a procedure where I want to Move the Robot to a specific Jointtarget. After that move instruction an IF instruction should check a condition and execute another process if fulfilled. The whole code is in a FOR loop, so after the IF instruction it should move to the next position and check again. In this case the IF condition checks if the TCPs current position after the move instruction matches a predefined position.


Mentioned RAPID Code:

PROC target_selection()

     FOR g FROM 1 TO 31 DO

          MoveAbsJ E{g},v800,fine,Tooldata_1\WObj:=WO_MIKO;
          checkpos := CRobT (\TaskRef:=T_ROB1Id \Tool:=Tooldata_1\WObj:=wobj0);

          IF checkpos <> D{h} THEN
                t_mes;
          ENDIF 
 
     ENDFOR
 ENDPROC

For some reason I cant explain the program pointer skips the move instruction at the beginning of the loop, jumps directly into the IF branch and executes the process without moving to the checkpoint first. 

I've already tried to force the program pointer to execute the move instruction first before continuing by using several Wait instructions like WaitTime, WaitRob \InPos and \ZeroSpeed or StopMove and StartMove. Unfortunately I didn't find the reason for this yet. Maybe someone knows a solution for this.

Best Answer

  • grth46
    grth46
    Answer ✓
    I think I know whats going on.
    For context: I started working with RobotStudio and RAPID four weeks ago and I haven't had any experience with robot programming so far. Along learning all of the features and instructions I was working on building a station of a real room with our ABB robot. First I created some targets and paths on the RobotWare Version 6.x and a few days ago I had to create a new virtual controller with RobotWare 7.x to include a force control feature i wanted to test. I tried to move all my workobjects, tooldata, targets and paths into the new controller which didn't work really well. Some features duplicated, some couldn't get moved, I don't know if there would have been a better way for this. After moving all of the most important features to the new controller I deleted the old controller and I think there is still some old information stuck somewhere in the project, which now interferes with some changes I'm doing to my RAPID Module. So I think the project may be corrupted in a way, otherwise I can't explain this strange behavior.

Answers

  • Do you get any error messages?
    If you step through the routine (using the step forward button) to execute one line of code at a time what happens?

  • I don't get any error messages. When cycling through the code step by step the robot doesn't do anything when executing the move instruction.
    However it appears when I change the IF argument as seen below to check if the counter g of the array E has a specific value, the move instruction gets executed as intended.

    IF g=2 OR g=5 OR g=7 OR ...
         t_mes;
    ENDIF

    The problem with this is that I want to set up this IF branch to be as compact as possible for large list of condition arguments (up to 160 entries) and on the other hand to make the whole code compatible to convert into other projects.
  • graemepaulin
    edited October 2
    Try declaring the FOR variable (g) as a num at the top of your module, for example PERS num g:=0;
    Using the locally declared variable from the FOR statement should work but I have had issues in the past with using it later within the for loop.
    You can then also easily see the value of the variable when stepping through the code as it will update the value in the declaration.
  • The following may be of little value, as I succumbed to TL;DR for a lot of this chain.

    The first argument in the MoveAbsJ instruction is a jointtarget data type. 

    It seems to me that E{g} is a reference to an array element. In the past, difficulties with positions in arrays have led to some exotic coding solutions, e.g. (No data declarations included) 

    FOR arraynum to A_VALUE DO
    GetDataVal jStringTargetNames{arraynum}\TaskRef:=T_YourDataHere, jposTemp1; 
    MoveAbsJ,  posTemp1,speed, zone, etc...;

    Of course I may have completely misdiagnosed the actual problem. :*