FANUC Inline Measurement 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 find the file by using the Communication Component/Robot_Interface/FANUC/sample/MSR_Metrics_Sample1.LS path.

Resource requirements

Mech-MSR solution and Mech-Metrics project

Prerequisites

  • Prepare on the inline measurement system side:

    • The current part is associated with the Mech-MSR solution in Mech-Metrics.

    • The current feature is associated with the Mech-MSR project in Mech-Metrics.

    • The Mech-MSR solution and project are open in Mech-MSR.

  • Prepare the robot side:

    • The operations in Set up Standard Interface Communication with FANUC have been completed.

    • The operations in FANUC automatic calibration have been completed.

    • The measurement positions have been taught.

    • The robot has been moved to the first measurement position.

    • The robot and camera have been preheated for 30 minutes before starting the measurement.

    • External lighting and temperature are stable before starting the measurement.

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_Sample1 example program and the related explanation.

   1:  !-------------------------------- ;
   2:  !FUNCTION: MSR_Metrics_Sample1 ;
   3:  !Mech-Mind, 2024-05-27 ;
   4:  !-------------------------------- ;
   5:   ;
   6:  !set current uframe NO. to 0 ;
   7:  UFRAME_NUM=0 ;
   8:  !set current tool NO. to 1 ;
   9:  UTOOL_NUM=1 ;
  10:  !move to robot home position ;
  11:  J P[4] 100% FINE    ;
  12:  !Init Socket!Modify IP Address ;
  13:  CALL MSR_INIT_SKT('8','192.168.1.20',50000,5) ;
  14:  !Set Custom Values ;
  15:  CALL MSR_MEAS_PARM(10,20,30,40,50,60,70,80) ;
  16:  !SR:String Register; R:Register ;
  17:  !Set Robot_Id,SR No.1, ;
  18:  !SR No.2,Qc_Mode,R NO. ;
  19:  !SR No.1:Piece_Name ;
  20:  !SR No.2:Piece_Sn ;
  21:  !R No.:Continuous Mode ;
  22:  CALL MSR_ST_MEAS(1,1,2,1,10) ;
  23:  !Set Robot_Id,SR No.2 ;
  24:  !SR No.2:Piece_Sn ;
  25:  CALL MSR_SET_WP(1,2) ;
  26:  !move to 1st image-capturing ;
  27:  !position ;
  28:  J P[1] 100% FINE    ;
  29:  !Set Robot_Id,Index ;
  30:  CALL MSR_MEAS_FEAT(1,3) ;
  31:  !move to 2ed image-capturing ;
  32:  !position ;
  33:  J P[2] 100% FINE    ;
  34:  !Set Robot_Id,Index ;
  35:  CALL MSR_MEAS_FEAT(1,3) ;
  36:  !move to 3rd image-capturing ;
  37:  !position ;
  38:  J P[3] 100% FINE    ;
  39:  !Set Robot_Id,Index ;
  40:  CALL MSR_MEAS_FEAT(1,3) ;
  41:  !Set Robot_Id,R No. ;
  42:  !R No.1:Measure Result ;
  43:  !R No.2:Alarm Count1 ;
  44:  !R No.3:Alarm Count2 ;
  45:  !R No.4:Alarm Count3 ;
  46:  CALL MSR_END_MEAS(1,11,12,13,14) ;
  47:  !Set Robot_Id,SR No.2 ;
  48:  !SR No.2:Piece_Sn ;
  49:  CALL MSR_VIEW_WP(1,2) ;
  50:  WAIT   1.00(sec) ;
  51:  PAUSE ;

The table below explains the above example program. In the above code, the comment-out content starts with !. The following table does not explain the comment-out content.

Workflow Code and description

Set the reference frame

   6:  !set current uframe NO. to 0 ;
   7:  UFRAME_NUM=0 ;
   8:  !set current tool NO. to 1 ;
   9:  UTOOL_NUM=1 ;
  • UFRAME_NUM=0: Set the selected user reference frame to 0. 0 indicates the world reference frame.

  • UTOOL_NUM=1: Set the selected tool reference frame to 1. You must specify the tool reference frame represented by 1.

Move to a specified position

  10:  !move to robot home position ;
  11:  J P[4] 100% FINE    ;
  • J: The joint position motion command of the robot, indicating that the robot moves along the arc to a specified position.

  • P[4]: Specify the target position to which the robot moves.

  • 100%: The percentage of relative maximum movement velocity.

  • FINE: Reach the specified position precisely.

Initialize the communication

12:  !Init Socket!Modify IP Address ;
13:  CALL MSR_INIT_SKT('8','192.168.1.20',50000,5) ;
  • CALL MSR_INIT_SKT('8','192.168.1.20',50000,5): Establish the TCP communication between the inline measurement system and the robot.

    • '8': The port number of the robot.

    • '192.168.1.20': The IP address of the IPC.

    • 50000: The port number of the IPC.

    • 5: The connection timeout period. Unit: minutes.

      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 the Mech-MSR system.

Set custom parameters

14:  !Set Custom Values ;
15:  CALL MSR_MEAS_PARM(10,20,30,40,50,60,70,80) ;
  • CALL MSR_MEAS_PARM(10,20,30,40,50,60,70,80): Set custom parameters.

    • 10, 20, 30, 40, 50, 60, 70, 80: A set of custom parameters used only when more part information needs to be provided to Mech-Metrics.

Start measurement task

  16:  !SR:String Register; R:Register ;
  17:  !Set Robot_Id,SR No.1, ;
  18:  !SR No.2,Qc_Mode,R NO. ;
  19:  !SR No.1:Piece_Name ;
  20:  !SR No.2:Piece_Sn ;
  21:  !R No.:Continuous Mode ;
  22:  CALL MSR_ST_MEAS(1,1,2,1,10) ;
  • CALL MSR_ST_MEAS(1,1,2,1,10): Start the measurement task.

    • 1: Part ID.

    • 1: The ID of the string register for storing the part name.

    • 2: The ID of the string register for storing the SN of the part.

    • 1: The quality inspection mode. 1 stands for full inspection, and 2 stands for partial inspection.

      The quality inspection mode here should be the same as that set in the Mech-Metrics.

    • 10: The ID of the numeric register that is used to store whether the operation mode, as returned by Mech-Metrics, is a loop execution or a one-time execution.

Input part to Mech-Metrics

  23:  !Set Robot_Id,SR No.2 ;
  24:  !SR No.2:Piece_Sn ;
  25:  CALL MSR_SET_WP(1,2) ;
  • CALL MSR_SET_WP(1,2): Set the part info. The info is used to input the part SN during measurement.

    • 1: Part ID.

    • 2: The ID of the string register for storing the SN of the part to be input.

Move the robot to a specified position and perform feature measurement

  26:  !move to 1st image-capturing ;
  27:  !position ;
  28:J P[1] 100% FINE    ;
  29:  !Set Robot_Id,Index ;
  30:  CALL MSR_MEAS_FEAT(1,3) ;
  31:  !move to 2ed image-capturing ;
  32:  !position ;
  33:J P[2] 100% FINE    ;
  34:  !Set Robot_Id,Index ;
  35:  CALL MSR_MEAS_FEAT(1,3) ;
  36:  !move to 3rd image-capturing ;
  37:  !position ;
  38:J P[3] 100% FINE    ;
  39:  !Set Robot_Id,Index ;
  40:  CALL MSR_MEAS_FEAT(1,3) ;
  • J P[1] 100% FINE: Move to the first measurement position with 100% velocity.

  • CALL MSR_MEAS_FEAT (1,3): The robot triggers the execution of the Mech-MSR project. The project contains the following settings: part ID 1 and feature ID 3.

    • 1: Part ID.

    • 3: The feature ID.

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

  • J P[2] 100% FINE: Move to the second measurement position with 100% velocity.

  • J P[3] 100% FINE: Move to the third measurement position with 100% velocity.

    You need to teach the three measurement positions in advance. For information about how to teach the waypoint, see the Teach Calibration Start Point section in the FANUC Automatic Calibration.

Stop Measurement Task

  41:  !Set Robot_Id,R No. ;
  42:  !R No.1:Measure Result ;
  43:  !R No.2:Alarm Count1 ;
  44:  !R No.3:Alarm Count2 ;
  45:  !R No.4:Alarm Count3 ;
  46:  CALL MSR_END_MEAS(1,11,12,13,14) ;
  • CALL MSR_END_MEAS(1,11,12,13,14): End the measurement task, save the results, and return the measurement data.

    • 1: Part ID.

    • 11: The numeric register ID for storing the result of the part. 0 stands for OK, and 1 for NG.

    • 12,13,14: The IDs of numeric registers for storing the number of part measurement items whose value exceeds tolerance 1, 2, and 3.

Query history data

  47:  !Set Robot_Id,SR No.2 ;
  48:  !SR No.2:Piece_Sn ;
  49:  CALL MSR_VIEW_WP(1,2) ;
  • CALL MSR_VIEW_WP(1,2): Use the specified robot to send the part SN to Mech-Metrics and switch the main interface of the Mech-Metrics software to the data view of that part.

    • 1: Part ID.

    • 2: The ID of the string register for storing the SN of the part to be input.

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.