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 The change in velocity as a function of time..
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.
For some functions, their behavior is conditional and depends on one or more conditions when encountered. For example, the controller buffers the CornerRoundingOff()
function by default, but if Cutter Radius Compensation is active, this function blocks lookahead.
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. For user-defined functions that require more than 4,096 stack values on the program stack, the controller will also block 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. If program execution pauses or blocks lookahead, then velocity will decelerate to zero velocity.
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 performance problems if it is configured incorrectly or if specific conditions occur in your AeroScript program.
To prevent incorrect part geometry during a corner rounding or cutter radius compensation sequence, do not use functions that block lookahead.
Use the suggestions that follow to prevent slowdowns or a Deceleration to Zero Velocity during a velocity blending sequence:
-
Do not use functions that cause decelerations to zero velocity.
-
Do not change ramp settings because it will cause a deceleration to zero velocity.
-
Do not issue immediate commands that take more than a millisecond to complete.
-
Do not use coordinated speeds that are higher than necessary, and do not use ramp rates that are lower than necessary. Do not have too many non-motion program lines between moves because this causes the controller to precalculate more moves. Precalculating more moves can cause the controller to reach the limit specified by the MaxLookaheadMoves Parameter, which then forces a deceleration to zero velocity.
-
Do the steps in Optimizing Performance in Velocity Blending.
Use the suggestions that follow to prevent performance problems during all types of lookahead sequences:
-
Do not use coordinated speeds that are higher than necessary, and do not use ramp rates that are lower than necessary. This causes the controller to precalculate more moves, which increases computation time and can decrease performance.
-
Do not have too many non-motion program lines between moves because it can decrease performance. 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 include AeroScript blocks that declare many variables that require space on the program stack between moves in a lookahead sequence. If you use over 4,096 stack values in an AeroScript block between moves in a lookahead sequence, the controller will block lookahead and decrease performance. See the StackSize Parameter page for more information on the program stack and how to determine the number of stack values an AeroScript block requires. Move large variables into the program global scope to prevent decreases in performance. If you cannot move large variables into the program global scope, move AeroScript blocks that require over 4,096 stack values into a subroutine and use the
sync()
statement to call the subroutine.
Lookahead Behavior
The table on the AeroScript Lookahead Behavior page shows how functions behave during lookahead. See Function Synchronization During Lookahead for terms used in the table.