Lookahead Synchronization

For some advanced motion features, the controller must execute additional program lines before it generates motion so that it can look ahead and precalculate positions and speeds, modify the geometry of your part program, or limit acceleration.

When lookahead is active, the move that the controller is currently executing does not always correspond to the program line that commanded the motion. While developing an AeroScript program in the Programming module in Automation1 Studio, a green highlighted line and a yellow line show when doing lookahead. The green line shows what move the controller is currently executing, and the yellow line shows what program line the controller is looking ahead at. If you see only the yellow line in Automation1 Studio, it means that the current move that controller is executing and the program line that the controller is looking ahead at are the same.

During lookahead, some AeroScript operations look as if they occur out of sequence because the controller must execute program lines before it does the motion. A few examples of this are: 

  • Variables that the controller assigns after a MoveRapid(), MoveLinear(), MoveCw(), and MoveCcw() can sometimes update before the move occurs. This is because the controller assigns global variables and task variables while the AeroScript program is precalculating moves. Thus, the controller can use global variables and task variables as move targets during a lookahead sequence.
  • The controller reads I/O while the AeroScript program is precalculating the moves. This means that the controller reads I/O immediately during program execution. I/O reads are not always synchronized to motion during lookahead.

The figure that follows shows both examples above where the controller is currently doing the first G1 move (green line) but had to look ahead additional lines (yellow line) to find another coordinated move to blend velocity. Because variable assignments and I/O reads are executed immediately during lookahead, these occur even if the controller is doing the first G1 move.

To configure the maximum number of program lines that the controller can put into the lookahead buffer before generating motion, use the MaxLookaheadMoves Parameter. If the coordinated ramp rate is low or if the coordinated speed is very high, it might be necessary for you to increase the value of this parameter.

The controller uses lookahead when the features that follow are used by a program:

  • Corner Rounding

  • Cutter Radius Compensation

  • Velocity Blending

Function Synchronization During Lookahead

While lookahead is active and the controller encounters functions, it does one of the four behaviors that follow:

  • Execute the function immediately. This occurs if lookahead is active or inactive. This has no effect on velocity.

  • Buffer the function into the lookahead buffer, always synchronized with motion. Depending on the function, the velocity will or will not decelerate to zero.

  • Pause program execution temporarily while the contents of the lookahead buffer stay as is. The geometry of the part will not change, but the velocity will decelerate to zero.

  • Block Lookahead by emptying the lookahead buffer and decelerating to zero velocity.

Based on how a function is handled, it may or may not be necessary for the controller to slow velocity to a complete stop. The velocity behavior of a function is as follows: 

  • No effect on Velocity when executed.

  • Blend or maintain velocity when buffered.

  • Decelerate to Zero Velocity when buffered.

The behavior of a function can change based on system settings. For example, the CornerRoundingOff() function blocks lookahead by default. But if Cutter Radius Compensation is active, then the controller buffers this function. Refer to AeroScript Lookahead Behavior to see how functions behave when lookahead is active.

Mostly, only functions that the controller can buffer are always synchronized with motion and can blend velocity in between lines because the controller uses only the elements in the lookahead buffer to blend or maintain velocity. If program execution pauses or blocks lookahead, which prevents new elements from entering the buffer, then velocity will decelerate to zero.

For user-defined functions that require more than 4,096 stack values on the program stack, the controller also blocks lookahead. See the StackSize Parameter page for more information on the program stack and how to determine the number of stack values an AeroScript function requires.

For features that require lookahead to modify the geometry of a part program, but the controller encounters a function that will block lookahead, the controller behaves as follows:

  • While Corner Rounding is active, the controller does not round the corner.

  • While Cutter Radius Compensation is active, the controller does not put an arc at the end of the move, but it does end the move at the cutter offsets and tries to put a correction arc at the start of the next move. If the intersection of the two moves makes an outside corner, the correction continues and the controller applies an arc. If the intersection of the two moves makes an inside corner, overcut occurs and the controller applies the cutter offsets by blending them across the length of the second move.

For features that must have lookahead modify or limit the velocity of a program but the controller encounters a function that will decelerate to zero velocity, motion decelerates to zero velocity while velocity blending is active.

Tip: Use the sync() statement to synchronize functions with motion that otherwise are not. For more information, see Synchronizing Function Calls with Motion.

How To Prevent Problems During Lookahead

Lookahead can cause incorrect part geometry, unwanted slowdowns, or controller performance problems if it is configured incorrectly or if specific conditions occur in your AeroScript program.

Preventing Problems with Incorrect Geometry or Unwanted Slowdowns

Incorrect part geometry can occur when blocking lookahead. To prevent blocking lookahead, use the suggestions that follow:

  • Do not use functions that block lookahead. Refer to AeroScript Lookahead Behavior.

  • Do not issue immediate commands that take more than a millisecond to complete. This causes lookahead to stop until the command is complete.

  • Do not have too many non-motion program lines between moves. This can cause the MaxLookaheadMoves Parameter to limit the controller and slow program execution. If you cannot stop lookahead, move large sections of non-motion lines into a subroutine and use the sync() statement to call the subroutine.

  • Do not use more than 4,096 stack values in an AeroScript block between moves in a lookahead sequence. Doing so causes the controller to block lookahead. See the StackSize Parameter page for more information about how to determine the number of stack values an AeroScript block requires.

    • If possible, move large variables into the program global scope. If you cannot move large variables into the program global scope, move AeroScript blocks with more than 4,096 stack values into a subroutine and use the sync() statement to call the subroutine.

Unwanted slowdowns can occur when blocking lookahead. To prevent unwanted slowdowns, use the suggestions that follow:

Preventing Problems with Controller Performance

IMPORTANT: If you use a PC-based controller, Aerotech suggests that you first do Performance Optimization to optimize the real-time behavior of your PC.

If there too many moves during a lookahead sequence, the computational load of the controller can get too high, causing unwanted motion problems. If possible, do the tasks that follow to decrease the computational load during lookahead:

  • Replace groups of short distance coordinated moves with one or more long distance coordinated moves that are the same or similar in geometry. This gives the controller fewer moves to look ahead at, which decreases computation time.

  • Decrease the coordinated speed or increase the ramp rates used during a lookahead sequence. This causes the controller to look ahead at fewer moves, which decreases computation time. As an alternative, use the CoordinatedMoveDurationMinimum Parameter to automatically reduce the coordinated speed of short duration moves.

  • Insert conditions that block lookahead or cause a slowdown to zero velocity. This lets the controller divide long lookahead sequences into more manageable sequences at locations that you specify.

  • Decrease the value of the MotionUpdateRate Parameter. This causes the controller to calculate fewer points each millisecond.

  • Use a capable software package to compute the Corner Rounding or Cutter Radius Compensation geometry offline. This helps decrease the controller load.

You can see how many moves that the controller examined with the LookaheadMovesExamined task status item. If you are having controller performance problems, try to reduce the value of this status item in areas of the part program where this value is high by using one or more of the suggestions above.