RobotStudio event

Does this line of logic work

I want to give a person 30 seconds to make a decision. Push the button and the robot will go Home, do not push the button and after 30 seconds the robot will continue its program.
I wrote this logic. Does it work?  I have not tested it. Does anyone have a better way?
---- WaitUntil GreenButton=1 or TimeFlag and Maxtime>0;
I did time flag as VAR Bool Timeflag:=False ----- VAR num MaxTime:=30

I am not sure this will start timing??
Tagged:

Answers

  • DenisFR
    DenisFR ✭✭✭
    Hello,
    You can use this code:
    VAR bool bTimeFlag;
    VAR num nMaxTime:=30;
    ...
    WaitDI GreenButton, 1, \MaxTime:=nMaxTime \TimeFlag:=bTimeFlag \Visualize 
    \Header:="Waiting for signal" \MsgArray:=["Movement will not start until", "the 
    condition below is TRUE"] \Icon:=iconError;

    ☑️2024 - RobotStudio® User Group

  • Here is what I have. The person has 30 seconds to decide to push the button or the robot will goto a label and continue to run.
    I figured this out reading the manuals however, I am not sure how "TimeFlag" works and if I used it correctly?

        VAR num MaxTime:=30;!This is the max time the robot will wait for a decision to ACCEPT the cut
        VAR bool TimeFlag := FALSE;

     WaitUntil Green_PB = 1 OR TimeFlag AND MaxTime >0; 
            IF Green_PB = 1 THEN
               GOTO CutHeightNotAccepted2;
            ELSE
               GOTO ACCEPTED2;
            ENDIF
  • a little more explanation. If a person hits the green button, the robot will go to a label that ends the routine and go home and end the program. If the button is not hit after 30 seconds, the robot will goto another label and continue to process.
  • Hi

    Using the code Denis posted with the if statement and you should probably have a separate routine for each of the options so it become a procedure call not a GoTo:
    VAR bool bTimeFlag;
    VAR num nMaxTime:=30;
    ...
    WaitDI GreenButton, 1, \MaxTime:=nMaxTime \TimeFlag:=bTimeFlag \Visualize 
    \Header:="Waiting for signal" \MsgArray:=["Movement will not start until", "the 
    condition below is TRUE"] \Icon:=iconError;
    IF bTimeFlag=True Then
       rAccepted;
    ELSE
       rNotAccepted;
    ENDIF