%%%
  VERSION:1
  LANGUAGE:ENGLISH
%%%

MODULE CAL340
  !COPYRIGHT 1997 ABB ROBOTICS PRODUCTS AB
  !1998-09-01/SLT SEROP/PU

  !#################################################################
  !     Revision notes:
  !     RW3.1 or better required
  !     NEW IRB340 calibration program  1998-09-01/SLT
  !     stand_norm_pos updated    1999-04-07/SLT
  !
  !#################################################################

  ! Definition of global variables
  VAR num answer;
  VAR bool flag;
  VAR string irbtype;

  ! Definition of robtargets
  VAR jointtarget stand_norm_pos;
  VAR jointtarget del_pos;

  PROC Haupt()
    !Routine used when German is booted
    main;
  ENDPROC

  PROC Principale()
    !Routine used when Italian is booted
    main;
  ENDPROC

  PROC main()
    TPErase;
    TPWrite "CALIBRATION POSITION PROGRAM";
    TPReadFK answer,"IRB340","Start","","","","EXIT";
    TEST answer
    CASE 1:
      irbtype:="IRB340";
      stand_norm_pos:=[[-13.1899,-13.1899,-13.1899,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
      del_pos:=[[0,0,0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    CASE 5:
      TPWrite "Exit program";
      EXIT;
    ENDTEST
    flag:=TRUE;
    WHILE flag DO
      TPErase;
      TPWrite "Calibration program for ";
      TPWrite irbtype;
      TPReadFK answer,"Select operation ...","","Cal.pos","Del.pos","","Quit";
      TEST answer
      CASE 2:
        cal_pos;
      CASE 3:
        deliv_pos;
      CASE 5:
        flag:=FALSE;
      ENDTEST
    ENDWHILE
  ENDPROC

  PROC cal_pos()
    flag:=TRUE;
    WHILE flag DO
      TPErase;
      TPWrite "Calibration routines for ";
      TPWrite irbtype;
      TPReadFK answer,"Go to calibration position ","Yes","","","","Quit";
      TEST answer
      CASE 1:
        home_stand_norm;
      CASE 5:
        flag:=FALSE;
      ENDTEST
    ENDWHILE
  ENDPROC

  PROC home_stand_norm()
    TPErase;
    TPWrite "Moving to normal position (sync.pos 0)";
    TPWrite "Axis 1      0 deg";
    TPWrite "     2      0";
    TPWrite "     3      0";
    MoveAbsJ stand_norm_pos,v200,fine,tool0;
  ENDPROC

  PROC deliv_pos()
    TPErase;
    TPReadFK answer,"Move to Deliverypos ?","Yes","","","","Quit";
    TEST answer
    CASE 1:
      TPWrite "Moving to delivery position";
      MoveAbsJ del_pos,v200,fine,tool0;
    CASE5:
      RETURN;
    ENDTEST
  ENDPROC
ENDMODULE
