Subprograms or Subroutines are self-contained sections of code within a larger program that can be called upon to perform a specific task.
Subprograms are typically used to reduce code duplication and make programs more modular, allowing developers to break complex problems down into smaller, more manageable pieces.
Subprograms can be called from anywhere within the larger program and can return a value or modify data as needed.
Macros are similar to subprograms in that they are reusable sections of code that can be called upon to perform a specific task.
However, macros are typically used to automate repetitive tasks or to simplify complex code through the use of logical functions.
Additionally, macros can be used in CNC manufacturing to automate non-standard machine tasks and functions.
Generally speaking, there are two types of Macros:
Machine/Default Macros - Typically uneditable and specific to each machine, which controls common complex functions/actions of machines (ex: tool changes)
User/Custom Macros - Editable, and user-defined to control complex functions/actions beyond the base functionality of the machine
Subprograms and Macros fall under one of two categories: Local or Global
Local subprograms/macros are defined and used within a specific code/program and cannot be called/used outside that code/program.
Because of this, functions relegated to local subprograms/macros should program/part-specific, examples include:
Custom toolpath operations for machining complex geometries
Non-standard toolpaths/operations that utilize custom tooling
Global subprograms/macros are separate, standalone codes/programs and can be called from any other program in the same memory storage location.
Because of this, the only functions that should be given Global functionality should be universal operations that pertain or are used by most/all programs/parts, examples include:
Tool/Work Offset Calibration
Part/Feature Measuring Operations
Common, general toolpaths that can be easily defined by a few variables
Read the following Chapters of the Peter Smid book, "FANUC CNC Custom Macros: Programming Resources for FANUC Custom Macro B users":
Chapter 3: Review of Subprograms
After reading, do the following:
Analyze your understanding of the concepts discussed in the book's chapters and throughout this submodule
Identify your key takeaways from the chapters - what did you learn that you didn't know previously, how does what you learned affect your perspective going forward, etc.