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.
This example implements the spiral as a macro. Operations implemented as macro's do result in a larger 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.
Step-by-step guide
Setup the Macro for Auto-include:
- Copy the Macro Source code into a new file in Motion Composer
- Modify the X and Y axes names in the macro to reflect the axes used to create the spiral
- Verify the use of $task0 variable does not conflict with programs that will call the macro. Change to an unused task variable index if required.
- Save the file.
- Open configuration manager.
- Click on the controller menu item and select "Program Automation->Add"
- Browse for the file saved in step 4
- Set the mode to "Include"
- Click ok and reset the controller.
Use the macro in a program
- 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.
Related articles