4.5.5 Macros
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.
- 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.
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 |
|
SETPARXU |
XU |
X-axis units |
|
SETPARXS |
XS |
X-axis steps per rotation |
|
SETPARXT |
XT |
X-axis travel in millimeters |
|
SETPARXD |
XD |
X-axis degrees per step |
|
SETPARYU/ZU/UU |
YU / ZU / UU |
Units for the Y, Z, or U axis |
|
SETPARYS/ZS/US |
YS / ZS / US |
Steps per rotation for the Y, Z, or U axis |
|
SETPARYT/ZT/UT |
YT / ZT / UT |
Travel in millimeters for the Y, Z, or U axis |
|
SETPARYD/ZD/UD |
YD / ZD / UD |
Degrees per step for the Y, Z, or U axis |