RobotStudio event

lamb button..?/o unit

Hi everyone...
I have ten lamb button with input output....
1. button X+    6.button is X-
2.button Y+     7.button Y-
3.button Z+       8. button Z-   and
4.button  50 mm
5.button 100mm
9.button 200mm
10. button is start button
? have to make a program with this buttons 
when ? press 1.,4. and 10. button robot must move 50 mm X+
when ? press 7. 9. 10. robot must move 200 mm direction of Y-.......like offset...how can ? make this.....?
? need your helps ....thanksOuch
image


Comments

  • Marcel
    Marcel ✭✭
    Hi
     

    Try this.

     

    Best regards

     

    Marcel

     

    MODULE Module1

     ! data

     ! Value

     VAR num nValueX;

     VAR num nValueY;

     VAR num nValueZ;

     ! Distance

     VAR num nDistance;

     ! actual position

     PERS robtarget pActual:=[[0,0,0],[1,0,0,0],[0,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

     ! tool

     PERS tooldata tEndEffector:=[TRUE,[[0,0,0],[1,0,0,0]],[30,[0,0,0],[1,0,0,0],10,10,10]];

     

     PROC main()

     ! main program flow

     ! initialisation

     SetDO doStart,0;

     SetDO doDist050,0;

     SetDO doDist100,0;

     SetDO doDist200,0;

     SetDO doPlusX,0;

     SetDO doMinusX,0;

     SetDO doPlusY,0;

     SetDO doMinusY,0;

     SetDO doPlusZ,0;

     SetDO doMinusZ,0;

     nValueX:=0;

     nValueY:=0;

     nValueZ:=0;

     nDistance:=0;

     ! wait for start

     WaitDI diStart,1;

     SetDO doStart,1;

     ! read actual position

     pActual:=CRobT(Tool:=tEndEffectorWObj:=wobj0);

     ! read buttons

     IF diButtonDist050=1 THEN

      SetDO doDist050,1;

      nDistance:=50;

     ELSEIF diButtonDist100=1 THEN

      SetDO doDist100,1;

      nDistance:=100;

     ELSEIF diButtonDist200=1 THEN

      SetDO doDist200,1;

      nDistance:=200;

     ENDIF

     IF diButtonPlusX=1 THEN

      SetDO doPlusX,1;

      nValueX:=nDistance;

     ELSEIF diButtonMinusX=1 THEN

      SetDO doMinusX,1;

      nValueX:=-nDistance;

     ELSEIF diButtonPlusY=1 THEN

      SetDO doPlusY,1;

      nValueY:=nDistance;

     ELSEIF diButtonMinusY=1 THEN

      SetDO doMinusY,1;

      nValueY:=-nDistance;

     ELSEIF diButtonPlusZ=1 THEN

      SetDO doPlusZ,1;

      nValueZ:=nDistance;

     ELSEIF diButtonMinusZ=1 THEN

      SetDO doMinusZ,1;

      nValueZ:=-nDistance;

     ENDIF

     ! move to position

     IF nValueX<>0 OR nValueY<>0 OR nValueZ<>0 THEN

      MoveL Offs(pActual,nValueX,nValueY,nValueZ),v300,fine,tEndEffector;

     ENDIF

     ! wait for releas of start button

     WaitDI diStart,0;

     ENDPROC

    ENDMODULE
  • I really appreciated for your helps....thanks so much Thumbs Up

  • I made this thanks for your helpsClap


    MODULE MainModule
         VAR num VALX:=0;
        VAR num VALY:=0;
        VAR num VALZ:=0;
      VAR num DIST:=0;
      VAR bool TEKHIZ:=FALSE;
      VAR bool TEKX:=FALSE;
      VAR bool TEKY:=FALSE;
      VAR bool TEKZ:=FALSE;    
      CONST robtarget p10:=[[832.51,-0.02,1130.19],[0.258803,1.62466E-05,0.96593,-4.18923E-07],[-1,0,0,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];

        PROC main()
    !***************************************************    
      Init:
        WHILE TRUE DO
    !==============    
            LampChk;
    !==============    
      IF BUTONSTART=1 THEN
      MOVECHK;
      IF TEKHIZ AND (TEKX OR TEKY OR TEKZ ) OYNA;
      ENDIF      
     ENDIF
     
     ENDWHILE
    !********************************************************
    ENDPROC
    !********************************************************
    !********************************************************
    PROC OYNA()
    VALX:=0;
    VALY:=0;
    VALZ:=0;
    !======
    IF (Buton50=1 AND Buton100=0 AND Buton200=0) DIST:=50;
    IF (Buton50=0 AND Buton100=1 AND Buton200=0) DIST:=100;
    IF (Buton50=0 AND Buton100=0 AND Buton200=1) DIST:=200;
    !======
    IF (ButonXP=1 AND ButonXM=0) VALX:=DIST;
    IF (ButonXP=0 AND ButonXM=1) VALX:=-DIST;
    !======
    IF (ButonYP=1 AND ButonYM=0) VALY:=DIST;
    IF (ButonYP=0 AND ButonYM=1) VALY:=-DIST;
    !======
    IF (ButonZP=1 AND ButonZM=0) VALZ:=DIST;
    IF (ButonZP=0 AND ButonZM=1) VALZ:=-DIST;
    !===============================================
    p10:=CRobT();
    MoveL Offs(p10,VALX,VALY,VALZ),v100,z0,tool0;
    ENDPROC


    !********************************************************
    !********************************************************
    PROC MOVECHK()
    IF ((Buton50=1 AND Buton100=0 AND Buton200=0) OR (Buton50=0 AND Buton100=1 AND Buton200=0) OR (Buton50=0 AND Buton100=0 AND Buton200=1))
    THEN TEKHIZ:=TRUE;
    ELSE TEKHIZ:=FALSE;
    ENDIF
    !=========================       
    IF (ButonXP=1 AND ButonXM=0) OR (ButonXP=0 AND ButonXM=1)
    THEN TEKX:=TRUE
    ELSE TEKX:=FALSE     
    ENDIF
    !=========================       
    IF (ButonYP=1 AND ButonYM=0) OR (ButonYP=0 AND ButonYM=1)
    THEN TEKY:=TRUE
    ELSE TEKY:=FALSE     
    ENDIF
    !=========================       
    IF (ButonZP=1 AND ButonZM=0) OR (ButonZP=0 AND ButonZM=1)
    THEN TEKZ:=TRUE
    ELSE TEKZ:=FALSE     
    ENDIF
    !=========================       
    ENDPROC
    !********************************************************
    !********************************************************
    !********************************************************
    !********************************************************
        PROC LampChk()
       IF ButonXP = 1 THEN
       Set LambaXP;
       ELSE
       Reset LambaXP;
       ENDIF
    !========================
       IF ButonXM = 1 THEN
       Set LambaXM;
       ELSE
       Reset LambaXM;
       ENDIF
    !========================
       IF ButonYP = 1 THEN
       Set LambaYP;
       ELSE
       Reset LambaYP;
       ENDIF
    !========================
       IF ButonYM = 1 THEN
       Set LambaYM;
       ELSE
       Reset LambaYM;
       ENDIF
    !========================
       IF ButonZP = 1 THEN
       Set LambaZP;
       ELSE
       Reset LambaZP;
       ENDIF
    !========================
       IF ButonZM = 1 THEN
       Set LambaZM;
       ELSE
       Reset LambaZM;
       ENDIF
    !========================
       IF Buton50 = 1 THEN
       Set Lamba50;
       ELSE
       Reset Lamba50;
       ENDIF
    !========================
       IF Buton100 = 1 THEN
       Set Lamba100;
       ELSE
       Reset Lamba100;
       ENDIF
    !========================
       IF Buton200 = 1 THEN
       Set Lamba200;
       ELSE
       Reset Lamba200;
       ENDIF
    !========================
        ENDPROC
       
        PROC Init()
      ENDPROC    
     
    ENDMODULE