RobotStudio event

Can the time being counted down in a WaitTime comand be displayed on the teach pendent?

Can the time being counted down in a WaitTime comand be displayed on the teach pendent?
I have several programs that have WaitTimes within them and my boss has asked if the time can be displayed. I do not know how to progran this.

Best Answer

  • Henrik Berlin
    Henrik Berlin ✭✭✭
    edited April 2013 Answer ✓

    I have created a procedure that prints out the remaining waiting time on the FlexPendant. Perhaps you can use it as a starting point.

    http://youtu.be/5Giis7fLG_c

     

    Here is the source code.

    MODULE WaitTimeModule

     PROC TPWaitTime(num waitingTime)
      CONST num timeStep:=0.2;
      VAR num currentTimeStep;
      VAR num timeLeft:=0;
      VAR string displayString;

      ! Initialization;  
      displayString:="Executing WaitTime "+NumToStr(waitingTime,1)+": Time left : ";
      timeLeft:=waitingTime;

      WHILE timeLeft>0 DO
       IF timeLeft<timeStep THEN
        ! Check if the remaining time is smaller than the time step
        currentTimeStep:=timeLeft;   
        timeLeft:=0;

       ELSE
        ! Remaining time is larger than time step.
        Add timeLeft,-timeStep;
        currentTimeStep:=timeStep;
       ENDIF
       TPErase;
       TPWrite displayString+NumToStr(timeLeft + currentTimeStep,1);
       WaitTime currentTimeStep;
      ENDWHILE
      TPErase;
      TPWrite "WaitTime completed";
     ENDPROC

     PROC main()
      TPWaitTime 5;
     ENDPROC
    ENDMODULE

    Post edited by Henrik Berlin on
    Henrik Berlin
    ABB

Answers