Mach Modules Documentation
Lua Module API Documentation
Loading...
Searching...
No Matches
GrinderODIDKaydonGUIModule.lua File Reference

Go to the source code of this file.

Functions

GrinderODIDKaydonGUIModule PLCScript ()
 Execute the periodic PLC script update for the Kaydon OD/ID grinder screen.
GrinderODIDKaydonGUIModule MachineCycleStart ()
 Validate preconditions before allowing a machine cycle start on the Kaydon OD/ID grinder.
GrinderODIDKaydonGUIModule MachineCycleStartFinal ()
 Finalize cycle start by rewinding the G-code file when the machine is idle and no M00 is active.
GrinderODIDKaydonGUIModule MachineReset ()
 Reset all active grind state pound variables to their default cleared values.
GrinderODIDKaydonGUIModule MachineCycleStop ()
 Capture the current cycle and machine state at the moment of cycle stop.
GrinderODIDKaydonGUIModule MachineCycleStopFinal ()
 Finalize the cycle stop sequence by resetting grind state variables and retracting axes to safe positions.

Function Documentation

◆ MachineCycleStart()

GrinderODIDKaydonGUIModule MachineCycleStart ( )

Validate preconditions before allowing a machine cycle start on the Kaydon OD/ID grinder.

Performs a series of interlock and UI state checks before permitting the cycle to begin:

  1. If the DoorSwitchInterlockEnabled OEM parameter is "Yes", checks the DoorSwitchInterlockInput signal. If the door signal is active (doors open), a warning is displayed and cycle start is suppressed.
  2. Checks the CurrentTabMainWindowTabs OEM parameter. If the active tab is tab 3 (Settings or similar), cycle start is blocked with a message directing the operator to switch to Run, Grind Cycles, or Dress Cycles tabs.
  3. If tab 4 is active, pound variable 720 is checked. If it does not equal 1500 (the clean dress sentinel value), cycle start is blocked with the same tab-selection warning. Returns true only when all checks pass.
    Returns
    (boolean|nil) True if all preconditions are satisfied and cycle start may proceed, false if blocked, or nil on parameter error
    (boolean) Success flag - true if function executed without internal errors
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Warning
    Cycle start will be silently suppressed (returns false) if the door interlock is tripped or an invalid tab is active
    Note
    The clean dress sentinel value for pound variable 720 is 1500; any other value on tab 4 blocks cycle start
    See also
    GrinderODIDKaydonGUIModule.MachineCycleStartFinal() for the post-validation rewind logic
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineCycleStartFinal()

GrinderODIDKaydonGUIModule MachineCycleStartFinal ( )

Finalize cycle start by rewinding the G-code file when the machine is idle and no M00 is active.

If the machine state (MACH_STATE) is MC_STATE_IDLE and no M00 program stop is currently active, this function rewinds the loaded G-code file to the beginning using mc.mcCntlRewindFile(). This ensures the program always starts from the top when initiating a new cycle from an idle state. If an M00 is active, the rewind is skipped to allow resumption from the current position.

Returns
(boolean|nil) True if the final cycle start sequence completed, or nil on error
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
This function is intended to run after MachineCycleStart() has validated preconditions
See also
GrinderODIDKaydonGUIModule.MachineCycleStart() for pre-start validation logic
Note
Documentation generated by AI on 2026-03-03

◆ MachineCycleStop()

GrinderODIDKaydonGUIModule MachineCycleStop ( )

Capture the current cycle and machine state at the moment of cycle stop.

Records the current cycle state name via GetCycleStateName() and the Mach4 controller state into module-level variables CYCLE_STATE_AT_STOP and MACH_STATE_AT_STOP respectively. These values are later consumed by MachineCycleStopFinal() to determine the appropriate retract sequence.

Returns
(boolean) True indicating the stop event was handled successfully
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
CYCLE_STATE_AT_STOP and MACH_STATE_AT_STOP are module-level variables initialized at screen load time
See also
GrinderODIDKaydonGUIModule.MachineCycleStopFinal() which uses the captured state to perform retract moves
Note
Documentation generated by AI on 2026-03-03

◆ MachineCycleStopFinal()

GrinderODIDKaydonGUIModule MachineCycleStopFinal ( )

Finalize the cycle stop sequence by resetting grind state variables and retracting axes to safe positions.

Executes the final actions after a cycle stop is confirmed. If the machine is enabled, this function resets pound variables 550, 720, and 700 (grind state flags) to 0, retrieves safe and clear positions from pound variables 530 (X Safe), 531 (Z Safe), and 532 (X Clear), and issues MDI retract moves based on the cycle state captured at stop time (CYCLE_STATE_AT_STOP) and the machine state (MACH_STATE_AT_STOP). For grinding states (STATE_GRIND_POSITIONING, STATE_DRESS_PULLOUT, STATE_GRIND_GRINDING, STATE_GRIND_SPARKOUT, STATE_GRIND_FINISHED), the retract sequence moves to X Safe, then Z Safe, then X Clear. For dressing states (STATE_DRESS_POSITIONING, STATE_DRESS_DRESSING, STATE_DRESS_SPARKOUT, STATE_DRESS_RETURNING), the sequence moves to X Clear, then Z Safe.

Returns
(boolean|nil) True if the stop final sequence completed, or nil on error
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Relies on CYCLE_STATE_AT_STOP and MACH_STATE_AT_STOP module-level variables captured by MachineCycleStop()
Warning
Machine must be enabled (OSIG_MACHINE_ENABLED) for retract moves to execute; if disabled, returns success without retracting
See also
GrinderODIDKaydonGUIModule.MachineCycleStop() which captures state variables used by this function
Note
Documentation generated by AI on 2026-03-03

◆ MachineReset()

GrinderODIDKaydonGUIModule MachineReset ( )

Reset all active grind state pound variables to their default cleared values.

Clears the three primary grind state control variables used by the Kaydon grinder cycle: pound variable 720 (dress/clean state flag), 700 (grind cycle state flag), and 550 (auxiliary grind flag). All three are set to 0 to ensure the machine returns to a neutral state after a reset event.

Returns
(boolean) True indicating the reset was applied successfully
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
Pound variables 720, 700, and 550 are the primary state flags for the Kaydon OD/ID grinder cycle controller
Warning
This function does not move axes; it only clears state flags. Ensure axes are in a safe position before relying solely on this reset.
Note
Documentation generated by AI on 2026-03-03

◆ PLCScript()

GrinderODIDKaydonGUIModule PLCScript ( )

Execute the periodic PLC script update for the Kaydon OD/ID grinder screen.

Called on every PLC cycle to keep screen elements synchronized with machine state. Performs the following updates in order:

  1. Calls UpdateMBSequenceBitData() to refresh the state of PLC-controlled buttons driven by the Modbus sequence bit data.
  2. Calls UpdateFeedrateDROLabels() to update feedrate text labels and DRO displays.
  3. Reads the current X axis position and passes it to mc.mcSpindleCalcCSSToRPM() to compute and update the constant surface speed (CSS) RPM value based on the current X position and active unit system.
    Note
    The DRO position update call (UpdateDROPositions) is currently commented out in this implementation
    MACHINE_CURRENT_UNITS is a module-level variable; a value of 200 indicates metric mode, which is passed as a boolean to mcSpindleCalcCSSToRPM
    Documentation generated by AI on 2026-03-03