|
Mach Modules Documentation
Lua Module API Documentation
|
Go to the source code of this file.
Functions | |
| TurnGUIModule | ScreenLoadScript () |
| Screen load script callback executed when the turning screen is first loaded. | |
| TurnGUIModule | StartUpScript () |
| Startup script callback executed once after the screen has loaded. | |
| TurnGUIModule | PLCScript () |
| PLC script callback executed on every Mach4 PLC cycle for the turning screen. | |
| TurnGUIModule | SetSpindleSpeedDRO (Speed,...) |
| Set the spindle speed DRO and execute the appropriate G96 or G97 MDI command. | |
| TurnGUIModule | SetToolOffsetData_Screen (value, offset,...) |
| Screen-level adapter to set tool offset data, remapping argument order for screen callbacks. | |
| TurnGUIModule | SetToolOffsetData (OffsetNumber, Val) |
| Set a tool offset data value for the current tool by offset number. | |
| TurnGUIModule | GetToolOffsetData (OffsetNumber) |
| Retrieve a tool offset data value for the current tool by offset number. | |
| TurnGUIModule | ChuckToggleBtn () |
| Toggle the chuck between open and closed states via PLC sequence calls. | |
| TurnGUIModule | TailstockToggleBtn () |
| Toggle the tailstock between extended and retracted states via PLC sequence calls. | |
| TurnGUIModule | ZeroDROBtn (Axis) |
| Zero a single axis DRO by computing and storing its machine position offset. | |
| TurnGUIModule | ZeroAllDROBtn () |
| Zero all axis DROs by computing and storing machine position offsets. | |
| TurnGUIModule | CalculateXToolOffset (MeasureValue) |
| Calculate and set the X-axis tool offset based on a measured diameter value. | |
| TurnGUIModule | CalculateZToolOffset (MeasureValue) |
| Calculate and set the Z-axis tool length offset based on a measured value. | |
| TurnGUIModule CalculateXToolOffset | ( | MeasureValue | ) |
Calculate and set the X-axis tool offset based on a measured diameter value.
Computes a new X-axis tool offset using the current machine position, work offset, tool slide direction, and the provided measurement value. If diameter mode is active, the measured value is halved before use. The tool slide direction is determined by the sign of the MTOOL_LATHE_TOOLSLIDE value - negative values invert the direction. After computing the new offset, the X wear offset is cleared and the tool offsets are re-activated via an MDI T-code command.
| MeasureValue | (number) The measured diameter or radius value used to calculate the new X tool offset |
| TurnGUIModule CalculateZToolOffset | ( | MeasureValue | ) |
Calculate and set the Z-axis tool length offset based on a measured value.
Computes a new Z-axis tool length offset by comparing the current axis position, the existing offset amount, and the provided measurement value. The formula used is: NewOffset = AxisPosition + CurrentOffsetAmount - MeasureValue. After computing the new offset, it clears the Z wear offset and re-activates the tool offsets via an MDI T-code command.
| MeasureValue | (number) The measured Z position value used to calculate the new tool length offset |
| TurnGUIModule ChuckToggleBtn | ( | ) |
Toggle the chuck between open and closed states via PLC sequence calls.
Reads the current chuck state using the M10_PLCSequenceNum PLC sequence bit. If the chuck is currently closed (bit is true), it triggers the M11 sequence to open it. If the chuck is currently open (bit is false), it triggers the M10 sequence to close it. This function requires the mb (ModBus) module to be available. OEM parameters M10_PLCSequenceNum and M11_PLCSequenceNum are read to determine the correct PLC sequence numbers.
| TurnGUIModule GetToolOffsetData | ( | OffsetNumber | ) |
Retrieve a tool offset data value for the current tool by offset number.
Gets the current tool number using w.GetCurrentTool() and then retrieves the specified offset data field using mc.mcToolGetData(). Returns the offset value along with a success flag and status message following the standard triple return pattern.
| OffsetNumber | (number) The tool offset data field identifier (e.g., mc.MTOOL_LATHE_X, mc.MTOOL_LATHE_Z) |
| TurnGUIModule PLCScript | ( | ) |
PLC script callback executed on every Mach4 PLC cycle for the turning screen.
Called periodically by the Mach4 PLC cycle. Updates the feedrate DRO labels via the screen module and calculates the CSS (Constant Surface Speed) to RPM conversion based on the current X-axis machine position. The CSS-to-RPM calculation accounts for the current machine units (metric or imperial).
| TurnGUIModule ScreenLoadScript | ( | ) |
Screen load script callback executed when the turning screen is first loaded.
Called during screen initialization. Sets the version strings for the TurnGUIModule using SVN URL and revision information. Initializes global variables including TIP_DIRECTION_LAST, CURRENT_DIAMETER_MODE, and sets the SV_CUR_LENGTH_INDEX pound variable to the current tool number if available.
| TurnGUIModule SetSpindleSpeedDRO | ( | Speed | , |
| ... ) |
Set the spindle speed DRO and execute the appropriate G96 or G97 MDI command.
When the machine is in IDLE state, reads the current spindle modal group (G96 or G97) and executes an MDI command to set the spindle speed to the specified value. If the machine is not in IDLE state, the function returns without executing any command. Any additional arguments passed via varargs are accepted but not used.
| Speed | (number) The spindle speed value to set (in RPM for G97, or surface speed for G96) |
| ... | (any) Additional arguments accepted but not used |
| TurnGUIModule SetToolOffsetData | ( | OffsetNumber | , |
| Val | ) |
Set a tool offset data value for the current tool by offset number.
Sets the specified tool offset data field for the current tool using mc.mcToolSetData(). The machine must be in IDLE state, Feed Hold (FRUN_FH), or Manual Feed Hold (MRUN_FH) state to modify offsets. If the machine is in any other state, a warning message is displayed and the function returns without modifying the offset.
| OffsetNumber | (number) The tool offset data field identifier (e.g., mc.MTOOL_LATHE_X, mc.MTOOL_LATHE_Z) |
| Val | (number) The value to set for the specified tool offset field |
| TurnGUIModule SetToolOffsetData_Screen | ( | value | , |
| offset | , | ||
| ... ) |
Screen-level adapter to set tool offset data, remapping argument order for screen callbacks.
Acts as a thin adapter between the screen DRO callback convention (value first, offset second) and the m.SetToolOffsetData() function. Screen DRO modify callbacks receive the new value as the first argument and the offset identifier as the second argument, which is the reverse of the direct API. Any additional arguments passed via varargs are forwarded.
| value | (number) The new value to set for the tool offset field |
| offset | (number) The tool offset data field identifier (e.g., mc.MTOOL_LATHE_X, mc.MTOOL_LATHE_Z) |
| ... | (any) Additional arguments passed through from the screen callback |
| TurnGUIModule StartUpScript | ( | ) |
Startup script callback executed once after the screen has loaded.
Called once during screen startup after ScreenLoadScript. Initializes screen objects to their default values (CommandedSpindleSpeedDRO set to "0"), runs the spindle speed check, and configures the conversational (Alexsys) button if the screen module provides a ConfigureConversationalButton function.
| TurnGUIModule TailstockToggleBtn | ( | ) |
Toggle the tailstock between extended and retracted states via PLC sequence calls.
Reads the current tailstock state using the M25_PLCSequenceNum PLC sequence bit. If the tailstock is currently extended (bit is true), it triggers the M26 sequence to retract it. If the tailstock is currently retracted (bit is false), it triggers the M25 sequence to extend it. This function requires the mb (ModBus) module to be available. OEM parameters M25_PLCSequenceNum and M26_PLCSequenceNum are read to determine the correct PLC sequence numbers.
| TurnGUIModule ZeroAllDROBtn | ( | ) |
Zero all axis DROs by computing and storing machine position offsets.
Iterates over all coordinate axes from X_AXIS to MC_MAX_COORD_AXES-1 and computes a DRO offset for each axis such that the displayed position reads zero. For the X axis, diameter mode is taken into account by doubling the machine position. Unit conversion between inches and millimeters is also applied based on MACHINE_DEFAULT_UNITS and MACHINE_CURRENT_UNITS. The computed offsets are stored in DRO_MODE_OFFSET_ARRAY. The operation is logged to the operator log.
| TurnGUIModule ZeroDROBtn | ( | Axis | ) |
Zero a single axis DRO by computing and storing its machine position offset.
Computes a DRO offset for the specified axis such that the displayed position reads zero at the current machine position. For the X axis, diameter mode is taken into account by doubling the machine position. Unit conversion between inches and millimeters is applied based on MACHINE_DEFAULT_UNITS and MACHINE_CURRENT_UNITS. The computed offset is stored in DRO_MODE_OFFSET_ARRAY at the index corresponding to the given axis. The operation is logged to the operator log.
| Axis | (number) The axis index to zero (e.g., mc.X_AXIS, mc.Z_AXIS) |