ABB Inline Measurement Example Program

Program Introduction

Description

You trigger Mech-Metrics from the robot side to perform measurement using Mech-MSR and return the measurement results to Mech-Metrics.

File path

You can navigate to the installation directory of Mech-MSR and Mech-Metrics by using the Mech-MSR/center/MSR_Interface/ABB/sample/MSR_Metrics_Sample path.

Resource requirements

Mech-MSR solution and Mech-Metrics project

Prerequisites

This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario.

Program Description

The following is the code of the MSR_Metrics_Sample example program and its related explanation.

MODULE MSR_Metrics_Sample
    LOCAL CONST jointtarget path1:=[[0,0,0,0,90,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
    LOCAL CONST jointtarget path2:=[[0,0,0,0,100,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
    LOCAL CONST jointtarget path3:=[[0,0,0,0,110,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
    LOCAL VAR num MSR_Status:=0;
    LOCAL VAR num outvalue:=0;
    LOCAL VAR num measure_result:=0;
    LOCAL VAR num FailedCount{3}:=[0,0,0];
    PROC MSR_Metric_Test()
        AccSet 50,50;
        !set the velocity parameters
        VelSet 50,1000;
        !Init socket! Modify IP address;
        MSR_Init_Socket "127.0.0.1",4000,300;
        MSR_Open_Socket MSR_Status;
        IF MSR_Status=-99 THEN
            TPWrite "MSR: Communication Error";
            STOP;
        ENDIF
        WaitTime 1;
        MSR_Start_Measure 1,"Piece01","ABC",2,1,2,3,4,5,6,7,8,outvalue,MSR_Status;
        IF MSR_Status<> 8100 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MSR_Set_Piece_Info 1,"ABC",MSR_Status;
        IF MSR_Status<> 8103 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MoveAbsJ path1\NoEOffs,v3000,fine,tool0;
        MSR_Measure_Feature 1,1,MSR_Status;
        IF MSR_Status<> 8101 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MoveAbsJ path2\NoEOffs,v3000,fine,tool0;
        MSR_Measure_Feature 1,1,MSR_Status;
        IF MSR_Status<> 8101 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MoveAbsJ path3\NoEOffs,v3000,fine,tool0;
        MSR_Measure_Feature 1,1,MSR_Status;
        IF MSR_Status<> 8101 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MSR_End_Measure 1,measure_result,FailedCount,MSR_Status;
        IF MSR_Status<> 8102 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MSR_View_Piece_Data 1,"ABC",MSR_Status;
        IF MSR_Status<> 8104 THEN
            TPWrite "MSR: RUN Error";
            STOP;
        ENDIF

        MSR_Close_Socket;
        stop;
    ENDPROC
ENDMODULE

The table below explains the above example program. In the above code, the lines that are commented out start with !. The following table does not explain what is commented out.

Workflow Code and description

Define variables

LOCAL CONST jointtarget path1 := [[0,0,0,0,90,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL CONST jointtarget path2 := [[0,0,0,0,100,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL CONST jointtarget path3 := [[0,0,0,0,110,0],[9E+9,9E+9,9E+9,9E+9,9E+9,9E+9]];
LOCAL VAR num MSR_Status:=0;
LOCAL VAR num outvalue:=0;
LOCAL VAR num measure_result:=0;
LOCAL VAR num FailedCount{pass:[3]}:=[0,0,0];
  • Define local variables. The above local variables are valid only in this program. MSR_Status is used to receive and determine the returned status code of each communication command. Teach several measurement positions (path1, path2, path3) in advance.

For information about how to teach the waypoint, see the Teach Calibration Start Point section in the ABB Automatic Calibration.

Set acceleration and velocity

AccSet 50, 50;
VelSet 50, 1000;
  • AccSet 50, 50: Limit the acceleration to 50% of the normal value and the acceleration rate to 50% of the normal value.

  • VelSet 50, 1000: Set the velocity to 50% of the programmed rate and the maximum TCP rate to 1000 mm/s.

Initialize the communication

MSR_Init_Socket "127.0.0.1",4000,300;
  • MSR_Init_Socket "127.0.0.1", 4000, 300: Initialize the communication by specifying the IP address (127.0.0.1), port number 4000), and timeout period (300 seconds) of the communication object (the IPC).

    Please modify the IP address and port number of the IPC according to the actual situation. The IP address and port number must be consistent with those set in Mech-MSR.

Establish the communication

MSR_Open_Socket MSR_Status;
IF MSR_Status=-99 THEN
    TPWrite "MSR: Communication Error";
    STOP;
ENDIF
WaitTime 1;
  • MSR_Open_Socket MSR_Status: Establish the communication and store the status code to MSR_Status.

  • IF MSR_Status=-99 THEN …​ ENDIF: If a status code of -99 indicates any communication error, the robot teach pendant outputs “MSR: Communication Error and stop the program.

  • WaitTime 1: Set the wait time to 1 second.

Start measurement task

MSR_Start_Measure 1,"Piece01","ABC",2,1,2,3,4,5,6,7,8,outvalue,MSR_Status;
IF MSR_Status<> 8100 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
  • MSR_Start_Measure: Indicates that robot wit ID 1 starts measuring the part named Piece01 with part SN ABC, sets the inspection mode to partial inspection (2), specifies 8 custom parameters (1, 2, 3, 4, 5, 6, 7, 8), and stores the return value in outvalue.

  • IF MSR_Status<> 8100 THEN …​ ENDIF: If the status code is not 8100, an error has occurred during the execution of the measurement command, and the teach pendant outputs “MSR: RUN Error and stop the program.

    The inspection mode and custom parameters should be consistent with those set in Mech-Metrics.

Input part to Mech-Metrics

MSR_Set_Piece_Info 1,"ABC",MSR_Status;
IF MSR_Status<> 8103 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
  • MSR_Set_Piece_Info 1,ABC",MSR_Status: Specify the part whose SN code is ABC to send to the Mech-Metrics and obtain the command status code.

  • IF MSR_Status<> 8103 THEN …​ ENDIF: If the status code is not 8103, the input part information is abnormal, and the teach pendant outputs “MSR: RUN Error and stop the program.

Move the robot to a specified position and perform feature measurement

MoveAbsJ path1\NoEOffs,v3000,fine,tool0;
MSR_Measure_Feature 1,1,MSR_Status;
IF MSR_Status<> 8101 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
MoveAbsJ path2\NoEOffs,v3000,fine,tool0;
MSR_Measure_Feature 1,1,MSR_Status;
IF MSR_Status<> 8101 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
MoveAbsJ path3\NoEOffs,v3000,fine,tool0;
MSR_Measure_Feature 1,1,MSR_Status;
IF MSR_Status<> 8101 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
  • MoveAbsJ: The absolute position motion command of the ABB robot, indicating that each joint axis of the robot moves to a specified position independently.

    • \NoEOffs: Specify that the motion is not affected by external axes.

    • v3000: Specify that the robot velocity is 3000 mm/s.

    • fine: Move the robot to the specified position.

    • tool0: The tool used by the robot when it moves.

  • MSR_Measure_Feature 1,1,MSR_Status: The robot will trigger the execution of the Mech-MSR project with part ID 1 and measurement feature ID 1, and obtain the command status code.

  • IF MSR_Status<> 8101 THEN …​ ENDIF: Check the status code after each feature measurement is triggered. If the status code is not 8101, the teach pendant outputs “MSR: RUN Error and stop the program.

    Please modify the feature ID of each call according to the actual situation.

Stop Measurement Task

MSR_End_Measure 1,measure_result,FailedCount,MSR_Status;
IF MSR_Status<> 8102 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
  • MSR_End_Measure 1,measure_result,FailedCount,MSR_Status: stops measuring, with the part judgment result stored in measure_result and the number of failed measurement items stored in FailedCount.

  • IF MSR_Status<> 8102 THEN …​ ENDIF: If the status code is not 8102, an error has occurred during the execution of the measurement command, and the teach pendant outputs “MSR: RUN Error and stop the program.

Query history data

MSR_View_Piece_Data 1,"ABC",MSR_Status;
IF MSR_Status<> 8104 THEN
    TPWrite "MSR: RUN Error";
    STOP;
ENDIF
  • MSR_View_Piece_Data 1, "ABC", MSR_Status: By externally inputting the part SN, switch the main interface of the Mech-Metrics software to the part with the input SN (ABC), and obtain the command status code.

  • IF MSR_Status<> 8104 THEN …​ ENDIF: If the status code is not 8104, an error has occurred during the query, and the teach pendant outputs “MSR: RUN Error and stop the program.

Close the communication

MSR_Close_Socket;
stop;
ENDPROC
ENDMODULE

Is this page helpful?

You can give a feedback in any of the following ways:

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.