Approximate a spiral with constant radius arc segments. This implementation uses the G2/G3 starting angle-ending angle-radius arc method. To approximate the spiral the radius is changed every 180 degrees. By changing the radius at the 0/180 or 90/270 angles the location of center of the arc remains fixed along the X or Y axis of the spiral. For the 0/180 angles the center is always on the X axis of the spiral. For 90/270 the center is always on the Y axis of the spiral. The
This example implements the spiral as a macro. Operations implemented as macro's do result in a larger program programs than the same operation implemented as a subroutine. The macro can be changed to a subroutine to reduce the program size. Program automation is used to access the macro or subroutine from user programs.
...
- Copy the "Calling Program" code into a new file in Motion Composer
- Modify the axis names to reflect the axes used to create the spiral
- Save as a PGM file.
- Open scope and configure to collect the position command of the X/Y axes.
- Compile and run the file
- Change scope display mode to 2D to view the path of the X/Y axes commanded position.
...
Info | ||||
---|---|---|---|---|
| ||||
// Macro Implementation // Spiral($x,$y,$rad,$count,$speed) //$x and $y are the location of the center of the spiral. This implementation changes the radius at the 0 and 180 degree points. //the starting angle is 0 so the starting location of the X axis is offset from the circle center by the radius //$rad is the maximum radius of the spiral //$count is the number of iterations of the spiral //$speed is the velocity used along the spiral path
//Comments: //A critical section is used to ensure continuous motion through the "For-Next" loop. Otherwise the motion could stop during the //variable increment and test //Macro's cannot declare variables so a task variable ($task0) is used as the index variable for the loop //Change to a different task or global variable if the $task0 is used in the calling program for other purposes #MACRO Spiral($x,$y,$rad,$count,$speed) G0 X $x+$rad Y $y \ CRITICAL START 600 \ for $task0=$count To 1 STEP -1 \ G2 P0 Q180 R $task0*$rad/$count \ G2 P180 Q0 R ($task0-0.5)*$rad/$count \ next $task0 \ CRITICAL END \ //END
|
Info | ||||
---|---|---|---|---|
| ||||
//Calling the Macro //Enable and home the axes. //The G16 command defines the coordinate system for G2/G3 motion and the direction of motion in each of the planes (X/Y, Y/Z, Z/X) //This example programs motion on the X/Y axes. G17 selects the X/Y plane //VELOCITY ON enables contouring (constant velocity) between G1/G2/G3 moves ENABLE X Y HOME X Y G16 X Y Z G17 VELOCITY ON SCOPETRIG //Place spiral with center at X=0, Y=0, radius=10, speednumber of turns=5 and number of turnsspeed=10 Spiral(0,0,10,5,10) |
Info | ||||
---|---|---|---|---|
| ||||
Screen capture of output from example program. Motion starts at angle=0 on the X axis and moves in the clockwise direction (G2) for 5 iterations. |
...