FANUC Inline Measurement Program

Program Introduction

Description

The robot triggers Mech-Metrics to perform measurement using Mech-MSR and return the measurement results to Mech-Metrics.

File path

In the installation directory of Mech-MSR and Mech-Metrics: Communication Component/Robot_Interface/FANUC/sample/MSR_Metrics_Sample1.LS.

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:

    • 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. Modify the program according to the actual scenario before use. Do not use this program directly.

Program Explanation

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 is the logical explanation of the above example program. In the above code, the commented-out content starts with !. The following table does not explain the commented-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. The tool reference frame represented by 1 must be set in advance.

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 communication timeout period, in minutes.

      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.

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

  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 part SN.

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

      The quality inspection mode here must be consistent with that set in Mech-Metrics.

    • 10: The ID of the numeric register for storing whether the operation mode returned by Mech-Metrics is continuous execution or single 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 part SN 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 precisely to the first measurement position with 100% velocity.

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

    • 1: Part ID.

    • 3: The feature measurement ID.

      Modify the feature ID of each call according to the actual situation.

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

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

    The three measurement positions need to be taught in advance. For the specific teaching method, see the Teach Calibration Start Point section in FANUC Automatic Calibration.

End measurement

  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. 1 stands for OK, and 0 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 historical 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 part SN 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.