Example Program 11: MM_S11_Viz_Timer

Program Introduction

Description

The robot uses a timer to calculate the time taken from establishing the communication to completing picking and placing each time.

File path

You can navigate to the installation directory of Mech-Vision and Mech-Viz and find the file by using the Communication Component/Robot_Interface/FANUC/sample/MM_S11_Viz_Timer path.

Project

Mech-Vision and Mech-Viz projects

Prerequisites

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

Program Description

This part describes the MM_S11_Viz_Timer example program.

The only difference between the MM_S11_Viz_Timer example program and the MM_S2_Viz_Basic example program is that MM_S11_Viz_Timer can use a timer to calculate the required time (this code of this feature is bolded). As such, only the feature of handling errors based on the different error codes is described in the following part. For information about the parts of MM_S6_Viz_ErrorHandle that are consistent with those of MM_S2_Viz_Basic, see Example Program 2: MM_S2_Viz_Basic.
   1:  !-------------------------------- ;
   2:  !FUNCTION: trigger Mech-Viz ;
   3:  !project and get planned path, ;
   4:  !add a timer to record cycle time ;
   5:  !Mech-Mind, 2023-12-25 ;
   6:  !-------------------------------- ;
   7:   ;
   8:  !set current uframe NO. to 0 ;
   9:  UFRAME_NUM=0 ;
  10:  !set current tool NO. to 1 ;
  11:  UTOOL_NUM=1 ;
  12:  !move to robot home position ;
  13:J P[1] 100% FINE    ;
  14:  !initialize communication ;
  15:  !parameters(initialization is ;
  16:  !required only once) ;
  17:  CALL MM_INIT_SKT('8','127.0.0.1',50000,5) ;
  18:  LBL[1:LOOP] ;
  19:  !reset timer to 0 ;
  20:  TIMER[1]=RESET ;
  21:  !start timer ;
  22:  TIMER[1]=START ;
  23:  !move to image-capturing position ;
  24:L P[2] 1000mm/sec FINE    ;
  25:  !trigger Mech-Viz project ;
  26:  CALL MM_START_VIZ(2,10) ;
  27:  !get planned path, 1st argument ;
  28:  !(1) means getting pose in JPs ;
  29:  CALL MM_GET_VIZ(1,51,52,53) ;
  30:  !check whether planned path has ;
  31:  !been got from Mech-Viz ;
  32:  !successfully ;
  33:  IF R[53]<>2100,JMP LBL[99] ;
  34:  !save waypoints of the planned ;
  35:  !path to local variables one ;
  36:  !by one ;
  37:  CALL MM_GET_JPS(1,60,70,80) ;
  38:  CALL MM_GET_JPS(2,61,71,81) ;
  39:  CALL MM_GET_JPS(3,62,72,82) ;
  40:  !follow the planned path to pick ;
  41:  !move to approach waypoint ;
  42:  !of picking ;
  43:J PR[60] 50% FINE    ;
  44:  !move to picking waypoint ;
  45:J PR[61] 10% FINE    ;
  46:  !add object grasping logic here, ;
  47:  !such as "DO[1]=ON" ;
  48:  PAUSE ;
  49:  !move to departure waypoint ;
  50:  !of picking ;
  51:J PR[62] 50% FINE    ;
  52:  !move to intermediate waypoint ;
  53:  !of placing ;
  54:J P[3] 50% CNT100    ;
  55:  !move to approach waypoint ;
  56:  !of placing ;
  57:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  58:  !move to placing waypoint ;
  59:L P[4] 300mm/sec FINE    ;
  60:  !add object releasing logic here, ;
  61:  !such as "DO[1]=OFF" ;
  62:  PAUSE ;
  63:  !move to departure waypoint ;
  64:  !of placing ;
  65:L P[4] 1000mm/sec FINE Tool_Offset,PR[2]    ;
  66:  !move back to robot home position ;
  67:J P[1] 100% FINE    ;
  68:  !stop timer ;
  69:  TIMER[1]=STOP ;
  70:  !save timer value to register ;
  71:  R[99]=TIMER[1]    ;
  72:  JMP LBL[1] ;
  73:  END ;
  74:   ;
  75:  LBL[99:vision error] ;
  76:  !add error handling logic here ;
  77:  !according to different ;
  78:  !error codes ;
  79:  !e.g.: status=2038 means no ;
  80:  !point cloud in ROI ;
  81:  PAUSE ;

The workflow corresponding to the above example program code is shown in the figure below.

sample11

The table below describes the feature of using a timer to calculate the required time.

Feature Code and description

Calculate the time taken from establishing the communication to completing picking and placing each time by looping

  18:  LBL[1:LOOP] ;
  ...
  72:  JMP LBL[1] ;

The above code indicates that the program repeatedly executes the code at LBL[1].

  19:  !reset timer to 0 ;
  20:  TIMER[1]=RESET ;

The above code resets TIMER[1] to 0.

  21:  !start timer ;
  22:  TIMER[1]=START ;

The above code starts running TIMER[1].

  68:  !stop timer ;
  69:  TIMER[1]=STOP ;

The above code stops TIMER[1].

  70:  !save timer value to register ;
  71:  R[99]=TIMER[1]    ;

The above code assigns the value of TIMER[1] to the R[99] register, allowing for easy retrieval of the time tracked by the timer (i.e., the time spent from establishing communication to completing the pick-and-place operation).

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.