<< Prev        Next >>

ID : 5104

WaitMotion

Function

This command lets the next task stand-by until the currently-running motion command is reached to the specified state.

Syntax

WaitMotion(mode[,value] )

Guaranteed Entry

Mode
Designate a condition code as integer type data.
Value
Designate the condition value defined in mode as integer type data. Not required if the value of mode is 5 or 6.
Mode Value
Code Meaning
0

Motion ratio [%] is judged by the current position (the encoder value).

0 to 100%
1

Designated distance [mm] from motion start is judged by the current position (the encoder value).

 
2

Designated distance [mm] from motion end is judged by the current position (the encoder value).

 
3

Movement time from motion start [ms] is judged by the instruction value.

 
4

Movement time from motion end [ms] is judged by the instruction value.

 
5

Acceleration finish is judged by the instruction value.

Not required
6

Deceleration start is judged by the instruction value.

Not required

Return Value

Returns the state as integer type data.

0 Abnormal
-1 Normal
-2

"-2" is returned when one of the following condition is satisfied.

  1. Motion command is not written in immediately before the WaitMotion.
  2. Next option is not specified in the Motion command.
  3. Position components do not move when Mode 1 or 2 is selected.
    (E.g. the tool end does not move but only the posture changes)
  4. Requirements have already satisfied at the time of WaitMotion execution.
-3

"-3" is returned when one of the following condition is satisfied.

  1. A number specified in Mode 1 is larger than the total motion distance.
  2. A number specified in Mode 3 is larger than the total movement time.

Description

  • If WaitMotion is executed during the motion command execution of own task, this command let the non-motion command standby until the currently running command is reached to the specified state.
    For example, this can be used by performing I/O output before the motion finishes to prepare for work after the motion finishes.
  • The release timing of the task standby state in each mode is as follows. At the time of (A) in the graph below, the task standby state is released then the non-motion command is executed.
    Mode Without instantaneous stop With instantaneous stop
    0

    The task standby state is released when the motion distance from the motion start point reaches to the specified ratio.

    1 The task standby state is released when the motion distance from the motion start point reaches to the specified distance(mm).

    2 The task standby state is released when the motion distance from the motion finish point reaches to the specified distance(mm).
    3 The task standby state is released when the motion time from the motion start timing exceeds specified period of time. (ms) The task standby state is released when the motion time from the motion start timing (except for outage time) exceeds specified period of time. (ms)
    4 The task standby state is released when the motion time from the motion finish timing exceeds specified period of time. (ms)
    5 The task standby state is released when the acceleration completes. The task standby state is released when the instantaneous stop command turns ON and then the deceleration starts.
    WaitMotion ends once Motion command stops, and is not executed again when the Motion command resumes its remained motion or executes non-motion command.
    6

    The task standby state is released when the deceleration starts.

    The task standby state is released when the instantaneous stop command turns ON and then the deceleration starts.
    WaitMotion ends once Motion command stops, and is not executed again when the Motion command resumes its remained motion or executes non-motion command.

Related Terms

Arrive

Attention

  • Only CP motion can be used in modes 1 and 2.
  • When the optimal speed control function is set to 2 or 3, the standby task release timing is possibly changed if the WaitMotion mode is set to Mode 3 or Mode 4 (time specified) or Mode 5 or Mode 6 (acceleration end, deceleration starts).
  • If Skip command caused by MotionSkip and Interrupt in other tasks is executed during task standby state, the Skip command gets priority.
  • WaitMotion monitors the motion command that is issued the last. If the same motion command is written in sequenced two lines, these motion commands show different behaviors from when it is written in only one line.
    ' Case 1
     Move P, @0 J(0, 45, 90, 0, 45, 0)
     Move P, @P J(0, 45, 90, 0, 45, 90), Next        ' (1)
     WaitMotion 0, 90
    In Case1, WaitMotion monitors the state of the motion command of (1). Once the motion command of (1) achieves 90% of its motion, the next line of WaitMotion starts its process.
    ' Case 2
     Move P, @0 J(0, 45, 90, 0, 45, 0)
     Move P, @P J(0, 45, 90, 0, 45, 90), Next        ' (2)
     Move P, @P J(0, 45, 90, 0, 45, 90), Next        ' (3)
     WaitMotion 0, 90
    In Case2, WaitMotion monitors the state of the motion command of (3). In principle, once the motion command of (3) achieves 90% of its motion, the next line of WaitMotion starts its process. However, when WaitMotion is executed, the motion command (3) has been completed already (robot does not move anymore because it has already arrived at the destination position). Therefore, the next line of WaitMotion starts its process immediately.
    On the other hand, since the motion command of (2) is path motion, the motion of (3) starts once the path motion from (2) to (3) starts.
    That is to say, the next line of WaitMotion starts its process when the path motion from (2) to (3) starts, not when the motion command (2) achieves 90% of its motion (the same position as Case1).
  • "Arrive motion ratio" and "WaitMotion 0, motion ratio" behave the same way.

Example

'!TITLE "Wating for program"
 ' Wait until the specified motion ratio is reached.
 Sub Sample_WaitMotion

   TakeArm Keep = 1

   Dim aaa As Position

   ' Acquire the current position.
   aaa = CurPos

   'Set the internal speed to 10.
   Speed 10

   ' Start moving from the current position to P( 400, 300, 300, 180, 0, 180, -1 )
   ' and then moves to the next process.
   Move P, P( 400, 300, 300, 180, 0, 180, -1 ), Next

  bbb = WaitMotion(0,50)
     if bbb == -1 then ' If the motion ratio gets to 50% then

         ' Turn ON the I/O port number 240.
         Set IO[240]
      ' Display "1" which indicates the IO port is ON in message output window.
         PrintDbg IO[240]
     else ' If an error occurs
         ' Display S variables in message output window.
         PrintDbg S[1]
     end if
 '!TITLE "Wating for program"
 ' Wait until the acceleration finishes.
 Sub Sample_WaitMotion

   TakeArm Keep = 1

   Dim aaa As Position

   ' Acquire the current position.
   aaa = CurPos

   'Set the internal speed to 10.
   Speed 10

   ' Start moving from the current position to P( 400, 300, 300, 180, 0, 180, -1 )
   ' and then moves to the next process.
   Move L, P( 400, 300, 300, 180, 0, 180, -1 ), Next

   WaitMotion 5

   ' Turn I/O port number 240 ON if the acceleration finishes.
   Set IO[240]

   ' Display "1," representing ON, on the message output window.
   PrintDbg IO[240]

 End Sub

ID : 5104

<< Prev        Next >>