4.5.5 Macros
- Use macros to avoid repeating fixed values throughout a script.
- Update a value once in the set-parameter command, then reuse it wherever it is needed.
- Make scripts easier to read, maintain, and adjust for different axes or motor settings.
- Use calculations to convert values into the command format required by the motion controller.
Macros in Motion Control Scripts
Macros allow reuse of motion control parameter values inside a script instead of repeated hard-coding. Every command has a macro that can be included in a command or calculation.
Using Set Parameter Macros
A set parameter command defines a value for an axis. The matching macro stores the value so it can be reused in the script. For example, Set Par XU = 1 sets a value for the X axis, where X identifies the axis and U identifies the type of value.
Macro Names
Macro names use two characters. The first character identifies the axis, and the second character identifies the parameter value.
- Axis: X, Y, Z, or U
- Parameter: U = units, S = steps per rotation, T = travel in millimeters, D = degrees per step
Example: Reusing an axis value
Set the X-axis steps per rotation to 200. The command includes the axis and the parameter, and the matching macro can be used again in the script.
Command: Set Par XS = 200
Macro: XS (X-axis Steps)
|
Command pattern |
Matching macro |
Description |
|
Set Par XU |
XU |
X-axis units |
|
Set Par XS |
XS |
X-axis steps per rotation |
|
Set Par XT |
XT |
X-axis travel in millimeters |
|
Set Par XD |
XD |
X-axis degrees per step |
|
Set Par YU / ZU / UU |
YU / ZU / UU |
Units for the Y, Z, or U axis |
|
Set Par YS / ZS / US |
YS / ZS / US |
Steps per rotation for the Y, Z, or U axis |
|
Set Par YT / ZT / UT |
YT / ZT / UT |
Travel in millimeters for the Y, Z, or U axis |
|
Set Par YD / ZD / UD |
YD / ZD / UD |
Degrees per step for the Y, Z, or U axis |