Wait Statement
Causes the program to Wait for a specified amount of time or until the specified input condition (using MemSw or Sw) is met. (Oport may also be used in the place of Sw to check hardware outputs.)
Also waits for the values of global variables to change.
Syntax
(1) Wait time
(2) Wait inputcondition
(3) Wait inputcondition, time
Parameters
- time
- Specify the wait time as a real number from 0 to 2147483 (unit: second). The smallest increment is 0.01 seconds.
- condition
- Specify event conditions in the following format:
- [Event] Comparative operator ( =, <>, >=, >, <, <= ) [Integer expression]
- The following functions and variables can be used in the Event.
Functions: Sw, In, InW, Oport, Out, OutW, MemSw, MemIn, MemInW, Ctr,GetRobotInsideBox, GetRobotInsidePlane, MCalComplete,Motor, LOF, ErrorOn, SafetyOn, EstopOn, TeachOn , Cnv_QueLen, WindowsStatus, AtHome, LatchState, WorkQue_Len, PauseOn, AIO_In, AIO_InW, AIO_Out, AIO_OutW, Hand_On, Hand_Off, SF_Getstatus
Variables : Byte, Int32, Integer, Long , Short, UByte, UInt32, UShort global preserve variable, Global variable, module variable
- In addition, the following operators can be used to mask or combine multiple event conditionals.
Operator: And, Or, Xor, Mask
Description
(1) Wait with Time Interval
When used as a timer, the Wait instruction causes the program to pause for the amount of time specified and then continues program execution.
(2) Wait for Event Conditions without Time Interval
When used as a conditional Wait interlock, the Wait instruction causes the program to wait until specified conditions are satisfied. If after TMOut time interval has elapsed and the Wait conditions have not yet been satisfied, an error occurs. The user can check multiple conditions with a single Wait instruction by using the And, Mask, Or, or Xor instructions. (Please review the example section for Wait.)
(3) Wait with Event Condition and Time Interval
Specifies Wait condition and time interval. After either Wait condition is satisfied, or the time interval has elapsed, program control transfers to the next command. Use Tw to verify if the Wait condition was satisfied or if the time interval elapsed.
Notes
Specifying a Timeout for Use with Wait
When the Wait instruction is used without a time interval, a timeout can be specified which sets a time limit to wait for the specified condition. This timeout is set through using the TMOut instruction. Please refer to this instruction for more information. (The default setting for TMOut is “0” which means no timeout.)
Waiting for variable with Wait
- Available variables are Integer type (Byte, Int32, Integer, Long, Short, UByte, UInt32, UShort)
- Array variables are not available
- Local variables are not available
- If variables value cannot satisfy the event condition for more than 0.01 seconds, the change in variables may not be retrieved.
- Up to 64 can wait for variables in one system (including ones used in the event condition expressions such as Till). If it is over 64, an error occurs during the project build.
- If you try to transfer a variable waiting for variables as a reference with Byref, an error occurs.
- When a variable or a functions are included in the right side member of the event condition expression, the value is calculated when setting the Trap condition. We recommend not using variables or functions in an integer expression to avoid making unintended conditions.
When Using PC COM port (1001 to 1008)
You cannot use Lof Function for Wait instruction.
When the program is paused while Wait is executing
The Wait instruction does not stop even when the program is paused while the Wait instruction is executing. The Wait instruction ends when an event condition is satisfied or the specified time has passed.
If the time is set by the Wait parameter, the passed time is reset and the program waits for the specified time when the program is restarted by selecting Run Window Continue.
See Also
AtHome, Cnv_QueLen, Ctr, ErrorOn, EstopOn, GetRobotInsideBox, GetRobotInsidePlane, In, InW, LatchState, LOF, Mask, MCalComplete, MemIn, , MemInW, MemSw
Motor, Oport, Out, OutW, PauseOn, SafetyOn, Sw, TeachOn, TMOut, WindowsStatus, Tw, WorkQue_Len, SF_GetStatus
Wait Statement Example
The example shown below shows 2 tasks each with the ability to initiate motion instructions. However, a locking mechanism is used between the 2 tasks to ensure that each task gains control of the robot motion instructions only after the other task is finished using them. This allows 2 tasks to each execute motion statements as required and in an orderly predictable fashion. MemSw is used in combination with the Wait instruction to wait until the memory I/O #1 is the proper value before it is safe to move again.
Function main
Integer I
MemOff 1
Xqt !2, task2
For i = 1 to 100
Wait MemSw(1) = Off
Go P(i)
MemOn 1
Next I
Fend
Function task2
Integer i
For i = 101 to 200
Wait MemSw(1) = On
Go P(i)
MemOff 1
Next i
Fend
' Waits until input 0 turns on
Wait Sw(0) = On
' Waits 60.5 secs and then continue execution
Wait 60.5
' Waits until input 0 is off and input 1 is on
Wait Sw(0) = Off And Sw(1) = On
' Waits until memory bit 0 is on or memory bit 1 is on
Wait MemSw(0) = On Or MemSw(1) = On
' Waits one second, then turn output 1 on
Wait 1; On 1
' Waits for the lower 3 bits of input port 0 to equal 1
Wait In(0) Mask 7 = 1
' Waits until the global Integer type variable giCounter is over 10
Wait giCounter > 10
' Waits ten seconds, until the global Long type variable glCheck is 30000
Wait glCheck = 30000, 10
← W WaitNet Statement →