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

Go to the source code of this file.

Functions

GrinderODIDKaydonScreenV01 MachineScreenLoadScript ()
 Initialize the grinder screen state, UI elements, and job file on screen load.
GrinderODIDKaydonScreenV01 MachineScreenUnloadScript ()
 Save any pending job file changes when the grinder screen is unloaded.
GrinderODIDKaydonScreenV01 MachineScreenPLCScript ()
 Execute all PLC-speed periodic screen update functions.
GrinderODIDKaydonScreenV01 MachineScreenLowPriorityLoop ()
 Execute all low-priority periodic screen update functions.
GrinderODIDKaydonScreenV01 GetWheelAttributes ()
 Return the list of grinding wheel attribute names and their corresponding pound variable numbers.
GrinderODIDKaydonScreenV01 LoadJob ()
 Load the last used job file from the MachMotion profile.
GrinderODIDKaydonScreenV01 JobOpen ()
 Open a file dialog to select and load a job file.
GrinderODIDKaydonScreenV01 JobClose ()
 Close the current job file and clear the last job name from the profile.
GrinderODIDKaydonScreenV01 JobSave ()
 Save the current job file to its existing path.
GrinderODIDKaydonScreenV01 JobSaveAs ()
 Open a file dialog to save the current job under a new name.
GrinderODIDKaydonScreenV01 UpdateWheelHeadSpeeds ()
 Calculate and apply the commanded wheel head RPM based on the current grinding state and SFM.
GrinderODIDKaydonScreenV01 UpdateWorkHeadSpeeds (WorkHeadSFM)
 Calculate and apply the commanded work head RPM based on surface feet per minute.
GrinderODIDKaydonScreenV01 SetWheelHeadRange (Range)
 Set the wheel head range pound variable and refresh the range button UI.
GrinderODIDKaydonScreenV01 UpdateWheelHeadRange ()
 Read the current wheel head range and persist it to the OEM parameter for the active wheel head.
GrinderODIDKaydonScreenV01 UpdateWheelHeadRangeButtons ()
 Update the wheel head range button colors based on the current range pound variable (#738).
GrinderODIDKaydonScreenV01 TeachDresserPosition (fieldName)
 Teach the current machine position as a dresser position for the specified field.
GrinderODIDKaydonScreenV01 UpdateXWearOffset ()
 Recalculate and apply the X axis wear offset and dress position based on current wheel geometry.
GrinderODIDKaydonScreenV01 NewGrindingWheel ()
 Update the grinding wheel diameter to a new value and recalculate the X wear offset.
GrinderODIDKaydonScreenV01 TeachSafeX ()
 Teach and save the current X axis machine position as the X safe position (#530).
GrinderODIDKaydonScreenV01 TeachSafeZ ()
 Teach and save the current Z axis machine position as the Z safe position (#531).
GrinderODIDKaydonScreenV01 TeachClearX ()
 Teach and save the current X axis machine position as the X clear position (#532).
GrinderODIDKaydonScreenV01 InitialTouchOffTeach (AxisID)
 Record the current machine position as the touch-off reference for the specified axis.
GrinderODIDKaydonScreenV01 InitialTouchOffCalibrationBtn (ctrl_name, event_source, AxisID,...)
 Calculate and apply tool offset calibration from a touch-off position and measured part dimension.
GrinderODIDKaydonScreenV01 SetFinishToTarget (AxisID)
 Set the finish target position DRO from the current workpiece dimension pound variable.
GrinderODIDKaydonScreenV01 CalculateCorrection (AxisID)
 Calculate the dimensional correction between target and actual position for an axis.
GrinderODIDKaydonScreenV01 CorrectionUpdateOffset (AxisID)
 Apply a measured correction to the current tool offset for the specified axis.
GrinderODIDKaydonScreenV01 UpdateGrindingCycleState ()
 Update the grinding cycle state LEDs and label based on pound variable #700.
GrinderODIDKaydonScreenV01 UpdateEndOfProgram ()
 Detect and process the end-of-program event to record cycle time and reset the register.
GrinderODIDKaydonScreenV01 UpdateCycleProgresBar ()
 Update the cycle progress bar gauge based on elapsed versus last known cycle time.
GrinderODIDKaydonScreenV01 UpdateSparkoutBar ()
 Update the sparkout time gauge display based on the current dwell state.
GrinderODIDKaydonScreenV01 UpdateEnableCycleButtons ()
 Update the background color of all grinding cycle enable buttons.
GrinderODIDKaydonScreenV01 UpdateDresserDirectionButtons ()
 Update the forward/reverse direction button colors for all dressing cycles.
GrinderODIDKaydonScreenV01 SetDresserDirection (CycleNumber, Direction)
 Set the dresser direction for a specific dressing cycle and refresh the UI.
GrinderODIDKaydonScreenV01 UpdateGrindDROs ()
 Update the grinding DRO displays and calculate the rough grind amount.
GrinderODIDKaydonScreenV01 SelectCycle (PoundVariable)
 Toggle the enabled/disabled state of a grinding cycle pound variable.
GrinderODIDKaydonScreenV01 SelectManualCycle (SubRoutine)
 Select and initiate a single manual grinding sub-cycle.
GrinderODIDKaydonScreenV01 CheckWheelDiameterMargin ()
 Check whether the grinding wheel has sufficient diameter to complete the next dressing cycle.
GrinderODIDKaydonScreenV01 MachineCycleStartFinal ()
 Perform final pre-cycle-start checks before allowing the grinding cycle to run.
GrinderODIDKaydonScreenV01 OnScreenJogButtonsOn ()
 Enable the on-screen jog buttons if the jog inhibit signal is not active.
GrinderODIDKaydonScreenV01 OnScreenJogButtonsOff ()
 Disable the on-screen jog buttons group and reset the jog button color.
GrinderODIDKaydonScreenV01 IsDROModeActive ()
 Return whether DRO (Digital Read Out) mode is currently active.
GrinderODIDKaydonScreenV01 UpdateCleanDressPicks ()
 Update the clean dress picks display on the LED labels for active dressing states.

Function Documentation

◆ CalculateCorrection()

GrinderODIDKaydonScreenV01 CalculateCorrection ( AxisID )

Calculate the dimensional correction between target and actual position for an axis.

Reads the target position from XTargetPositionDRO or ZTargetPositionDRO and the actual measured position from XActualPositionDRO or ZActualPositionDRO, depending on the specified axis. Computes the correction as (Target - Actual) and writes the result to the corresponding XCorrectionDRO or ZCorrectionDRO screen object.

Parameters
AxisID(number) The Mach4 axis constant (mc.X_AXIS or mc.Z_AXIS) identifying which axis to calculate
Note
Documentation generated by AI on 2026-03-03

◆ CheckWheelDiameterMargin()

GrinderODIDKaydonScreenV01 CheckWheelDiameterMargin ( )

Check whether the grinding wheel has sufficient diameter to complete the next dressing cycle.

Reads the current wheel diameter (#500) and minimum wheel diameter (#503) from pound variables and calculates the total material that will be removed from the wheel during the next cycle. For a Clean Dress cycle (#720 == 1500), it uses the clean dress loops (#680) and amount (#650). For all other cycles, it sums enabled dress cycles (Rough, Micro, Finish) using their respective enabled flags (#604-#606), loop counts (#681-#683), and amounts (#651-#653). If the remaining diameter margin is insufficient, a system global warning message is created with detailed wheel information.

Returns
(boolean) True if wheel diameter is sufficient, false if margin is too small
(boolean) Success flag - always true if function completes without error
(string) Status message from w.FunctionCompleted()
Warning
If the wheel is too small, a system notification warning is raised and false is returned
Note
Documentation generated by AI on 2026-03-03

◆ CorrectionUpdateOffset()

GrinderODIDKaydonScreenV01 CorrectionUpdateOffset ( AxisID )

Apply a measured correction to the current tool offset for the specified axis.

Reads the correction amount from the XCorrectionDRO or ZCorrectionDRO screen object depending on the axis. For the X axis, the correction is halved (radius to diameter conversion) before being added to the current tool offset via m.GetToolOffsetData() and m.SetToolOffsetData(). For the Z axis, the full correction value is applied. After updating the offset, the correction DRO is cleared to 0, a G43 tool length compensation MDI command is issued to activate the new offset, and the tool file is saved.

Parameters
AxisID(number) The Mach4 axis constant (mc.X_AXIS or mc.Z_AXIS) identifying which axis to correct
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
X-axis correction is divided by 2 because the DRO value is in diameter mode
Documentation generated by AI on 2026-03-03

◆ GetWheelAttributes()

GrinderODIDKaydonScreenV01 GetWheelAttributes ( )

Return the list of grinding wheel attribute names and their corresponding pound variable numbers.

Builds and returns a table of two-element arrays, each containing a wheel attribute name string and its associated pound variable number. The attributes cover wheel geometry, speed limits, safety clearances, and dress positions. This table is used by other functions to iterate over wheel parameters when reading from or writing to the tool table.

Attributes returned (name, pound variable): Diameter(500), EffectiveWidth(501), Overhang(502), MinimumWidth(504), WorkingAngle(505), CornerRadiusLeft(506), ReliefAngleLeft(507), ReliefHeightLeft(508), CornerRadiusRight(509), ReliefAngleRight(510), ReliefHeightRight(511), PhaseHeightLeft(512), PhaseHeightRight(513), MaxRPM(514), SurfaceFeetPerMin(515), CommandedRPM(516), SafetyClearanceCircumference(533), SafetyClearanceLeftSide(534), SafetyClearanceRightSide(535), Z1DressPosition(519), X2DressPosition(520), Z2DressPosition(521), X3DressPosition(522), Z3DressPosition(523)

Returns
(table) Array of {name, poundVariableNumber} pairs describing all wheel attributes
Note
Documentation generated by AI on 2026-03-03

◆ InitialTouchOffCalibrationBtn()

GrinderODIDKaydonScreenV01 InitialTouchOffCalibrationBtn ( ctrl_name ,
event_source ,
AxisID ,
... )

Calculate and apply tool offset calibration from a touch-off position and measured part dimension.

Performs tool offset calibration for either the X or Z axis based on a physical touch-off procedure. The operator touches the tool to the part, records the machine position via InitialTouchOffTeach(), then enters the measured part dimension. This function computes the new tool offset using the recorded machine position, work offset, tool slide direction, wear offset, and measured value.

For X axis: Reads MachinePosX from XTouchOffDRO, measured value from MeasuredXDRO. Applies diameter-mode halving and tool slide direction correction. Formula: NewOffset = (MachinePosX - WorkOffset) - (XMeasureValue * Direction) + (WearOffset/2 * -1)

For Z axis: Reads MachinePosZ from ZTouchOffDRO, measured value from MeasuredZDRO. Formula: NewOffset = (MachinePosZ - WorkOffset) - ZMeasureValue

After setting the offset, both touch-off and measured DROs are cleared, a tool activation MDI command (TxxYY) is issued, and the tool file is saved.

Parameters
ctrl_name(string) The name of the control that triggered this function (unused internally)
event_source(any) The event source object (unused internally)
AxisID(number) The Mach4 axis constant (mc.X_AXIS or mc.Z_AXIS) identifying which axis to calibrate
...(any) Additional variadic arguments passed through from the button event handler
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if calibration completed, false on error or user cancel
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Warning
Requires ConfirmationDialogs OEM parameter check before modifying tool offsets
Note
X-axis calibration assumes diameter mode is active (XMeasureValue is halved internally)
See also
GrinderODIDKaydonScreenV01.InitialTouchOffTeach() for recording the touch-off machine position
Note
Documentation generated by AI on 2026-03-03

◆ InitialTouchOffTeach()

GrinderODIDKaydonScreenV01 InitialTouchOffTeach ( AxisID )

Record the current machine position as the touch-off reference for the specified axis.

Reads the current machine position for the specified axis and writes it to the corresponding touch-off DRO screen object. For the X axis, reads mc.X_AXIS machine position and sets XTouchOffDRO. For the Z axis, reads mc.Z_AXIS machine position and sets ZTouchOffDRO. This recorded position is later used by InitialTouchOffCalibrationBtn() to compute the new tool offset.

Parameters
AxisID(number) The Mach4 axis constant (mc.X_AXIS or mc.Z_AXIS) identifying which axis to teach
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if position was recorded successfully, false on error
(string) Status message from w.FunctionCompleted() or w.FunctionError()
See also
GrinderODIDKaydonScreenV01.InitialTouchOffCalibrationBtn() for applying the recorded touch-off position
Note
Documentation generated by AI on 2026-03-03

◆ IsDROModeActive()

GrinderODIDKaydonScreenV01 IsDROModeActive ( )

Return whether DRO (Digital Read Out) mode is currently active.

Always returns false in this Kaydon screen variant, indicating DRO mode is not active. This function may be overridden in other screen variants to provide context-specific behavior.

Returns
(boolean) Always returns false - DRO mode is not active in this screen variant
Note
Documentation generated by AI on 2026-03-03

◆ JobClose()

GrinderODIDKaydonScreenV01 JobClose ( )

Close the current job file and clear the last job name from the profile.

Entry point that wraps _JobClose() in a protected call via w.pcall(). If the internal function raises an error, displays an alarm message via w.AlarmMessage(). Prompts to save unsaved changes via OptSaveChanges(), closes the job, and clears the LastJobName profile string so the job is not reloaded on the next screen load.

Returns
(nil) No meaningful return value; errors are reported via w.AlarmMessage()
Note
Documentation generated by AI on 2026-03-03

◆ JobOpen()

GrinderODIDKaydonScreenV01 JobOpen ( )

Open a file dialog to select and load a job file.

Entry point that wraps _JobOpen() in a protected call via w.pcall(). If the internal function raises an error, displays an alarm message via w.AlarmMessage(). Prompts to save unsaved changes via OptSaveChanges() before opening the file dialog. After the operator selects a job file, saves the selected file path to the MachMotion profile under "LastJobName" so it can be reloaded automatically on the next screen load.

Returns
(nil) No meaningful return value; errors are reported via w.AlarmMessage()
Note
Documentation generated by AI on 2026-03-03

◆ JobSave()

GrinderODIDKaydonScreenV01 JobSave ( )

Save the current job file to its existing path.

Entry point that wraps _JobSave() in a protected call via w.pcall(). If the internal function raises an error, displays an alarm message via w.AlarmMessage(). On success, logs the operator action and delegates to the job object's Save() method to write job data to the current file path.

Returns
(nil) No meaningful return value; errors are reported via w.AlarmMessage()
Note
Documentation generated by AI on 2026-03-03

◆ JobSaveAs()

GrinderODIDKaydonScreenV01 JobSaveAs ( )

Open a file dialog to save the current job under a new name.

Entry point that wraps _JobSaveAs() in a protected call via w.pcall(). If the internal function raises an error, displays an alarm message via w.AlarmMessage(). On success, logs operator activity and delegates to the job object's SaveAs() method to prompt for a new file name and save the job data.

Returns
(nil) No meaningful return value; errors are reported via w.AlarmMessage()
Note
Documentation generated by AI on 2026-03-03

◆ LoadJob()

GrinderODIDKaydonScreenV01 LoadJob ( )

Load the last used job file from the MachMotion profile.

Entry point that wraps _LoadJob() in a protected call via w.pcall(). If the internal function raises an error, displays an alarm message via w.AlarmMessage(). Reads the "LastJobName" string from the MachMotion profile. If the value is non-empty, loads the job file via the CurrentJob object's Load() method. This is called automatically during MachineScreenLoadScript() to restore the previously active job on screen startup.

Returns
(nil) No meaningful return value; errors are reported via w.AlarmMessage()
Note
Documentation generated by AI on 2026-03-03

◆ MachineCycleStartFinal()

GrinderODIDKaydonScreenV01 MachineCycleStartFinal ( )

Perform final pre-cycle-start checks before allowing the grinding cycle to run.

Validates that the grinding wheel has sufficient diameter remaining to complete the next cycle by calling CheckWheelDiameterMargin(). If the wheel diameter is too small, the cycle start is blocked and a completed status is returned without starting the cycle. If the machine is currently in IDLE state, the cycle progress bar gauge is reset to 0.

Returns
(boolean) True if cycle start should proceed, false if it was blocked
(boolean) Success flag - always true if function completes without error
(string) Status message from w.FunctionCompleted()
See also
GrinderODIDKaydonScreenV01.CheckWheelDiameterMargin() for wheel diameter validation
Note
Documentation generated by AI on 2026-03-03

◆ MachineScreenLoadScript()

GrinderODIDKaydonScreenV01 MachineScreenLoadScript ( )

Initialize the grinder screen state, UI elements, and job file on screen load.

Called when the grinder screen is first loaded. Performs the following initialization steps in order: resets the grinding cycle state tracker (LAST_STATE = -1), turns off all grinding cycle state LEDs (CleanDress, Idle, RoughDress, RoughGrind, MicroDress, MicroGrind, FinishDress, FinishGrind, Retract), sets the stage button color constants, switches to G-code mode via GCodeMode(), clears the touch-off and compensation DROs (XTouchOffDRO, ZTouchOffDRO, MeasuredXDRO, MeasuredZDRO, CompXOffsetDRO, CompZOffsetDRO), resets the CycleProgressBarGauge to 0, creates a new JobFile object with the configured pound variable range and header, loads the last used job file via LoadJob(), and clears pound variables #720, #700, and #550.

Note
BTN_COLOR_STAGE_1, BTN_COLOR_STAGE_2, and BTN_COLOR_STAGE_3 are set as module-level globals
Documentation generated by AI on 2026-03-03

◆ MachineScreenLowPriorityLoop()

GrinderODIDKaydonScreenV01 MachineScreenLowPriorityLoop ( )

Execute all low-priority periodic screen update functions.

Called on each low-priority loop cycle to refresh all grinder screen displays that do not require PLC-speed updates. Performs the following updates in order: job file name and path labels, grinding wheel attributes, wheel head state, rotary dresser state, active tool box, cycle progress bar, end-of-program detection, enable cycle buttons, grind DROs, wheel head speeds, dresser direction buttons, current tab register, clean dress picks display, wheel head range, and wheel head range buttons.

Note
This function is registered as the low-priority loop handler for the grinder screen
Documentation generated by AI on 2026-03-03

◆ MachineScreenPLCScript()

GrinderODIDKaydonScreenV01 MachineScreenPLCScript ( )

Execute all PLC-speed periodic screen update functions.

Called on every PLC scan cycle to perform time-critical screen updates. Executes UpdateSparkoutBar() to refresh the sparkout dwell gauge and UpdateGrindingCycleState() to synchronize the grinding cycle state LEDs and label with pound variable #700.

Note
This function is registered as the PLC script handler for the grinder screen
Keep this function's execution time minimal as it runs on every PLC cycle
Documentation generated by AI on 2026-03-03

◆ MachineScreenUnloadScript()

GrinderODIDKaydonScreenV01 MachineScreenUnloadScript ( )

Save any pending job file changes when the grinder screen is unloaded.

Called when the grinder screen is closed or navigated away from. If the CurrentJob object is not nil, calls OptSaveChanges() to prompt the operator to save any unsaved job file modifications before the screen is destroyed.

Note
This function is registered as the screen unload handler for the grinder screen
Documentation generated by AI on 2026-03-03

◆ NewGrindingWheel()

GrinderODIDKaydonScreenV01 NewGrindingWheel ( )

Update the grinding wheel diameter to a new value and recalculate the X wear offset.

Optionally prompts the operator with a confirmation dialog if ConfirmationDialogs OEM parameter is set to "Yes". Reads the new wheel diameter from pound variable #655, writes it to the tool table "Diameter" field via SetWheelData(), then calls UpdateXWearOffset() to recalculate and apply the dresser offset and wear compensation based on the new diameter.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if diameter was updated, false on error or user cancel
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.UpdateXWearOffset() for wear offset recalculation
Note
Documentation generated by AI on 2026-03-03

◆ OnScreenJogButtonsOff()

GrinderODIDKaydonScreenV01 OnScreenJogButtonsOff ( )

Disable the on-screen jog buttons group and reset the jog button color.

Disables the JogButtonsGroup UI element and sets the OnScreenJogButtonsBtn color to the standard OFF color, indicating that on-screen jogging is inactive.

Note
Documentation generated by AI on 2026-03-03

◆ OnScreenJogButtonsOn()

GrinderODIDKaydonScreenV01 OnScreenJogButtonsOn ( )

Enable the on-screen jog buttons if the jog inhibit signal is not active.

Checks the JOG_INHIBIT signal before enabling the on-screen jog buttons. If jog inhibit is not active, the JogButtonsGroup is enabled and the OnScreenJogButtonsBtn is set to green. If jog inhibit is active, no action is taken and no error is raised.

Note
The jog inhibit signal (mc.ISIG_JOG_INHIBIT) must be inactive for jogging to be enabled
Documentation generated by AI on 2026-03-03

◆ SelectCycle()

GrinderODIDKaydonScreenV01 SelectCycle ( PoundVariable )

Toggle the enabled/disabled state of a grinding cycle pound variable.

Reads the current value of the specified pound variable. If it is 0, sets it to 1 (enabled); if it is 1 (or any non-zero value), sets it to 0 (disabled). After updating the value, refreshes the enable cycle buttons UI via UpdateEnableCycleButtons().

Parameters
PoundVariable(number) The pound variable number controlling the cycle enable state
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.UpdateEnableCycleButtons() for UI refresh
Note
Documentation generated by AI on 2026-03-03

◆ SelectManualCycle()

GrinderODIDKaydonScreenV01 SelectManualCycle ( SubRoutine )

Select and initiate a single manual grinding sub-cycle.

Sets pound variable #720 to the specified subroutine number, maps the subroutine number to a human-readable cycle name, then presents a cycle start confirmation dialog. If the operator confirms by pressing Cycle Start in the dialog, the cycle is initiated via m.CycleStartBtn(). Valid subroutine numbers and their cycle names are: 1000=Rough Dress, 1500=Clean Dress, 2000=Rough Grind, 3000=Micro Dress, 4000=Micro Grind, 5000=Finish Dress, 6000=Finish Grind, 7000=Retract.

Parameters
SubRoutine(number) The subroutine number identifying which grinding cycle to run
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if pound variable was set, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ SetDresserDirection()

GrinderODIDKaydonScreenV01 SetDresserDirection ( CycleNumber ,
Direction  )

Set the dresser direction for a specific dressing cycle and refresh the UI.

Writes the specified direction value to pound variable (CycleNumber + 690) to configure the dresser rotation direction for the given cycle. After setting the value, refreshes the cycle button UI via UpdateEnableCycleButtons().

Parameters
CycleNumber(number) The cycle index (0=Clean, 1=Rough, 2=Micro, 3=Finish) used as offset to #690
Direction(number) The direction value to set (0=Forward, 1=Reverse)
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.UpdateDresserDirectionButtons() for reading direction state
Note
Documentation generated by AI on 2026-03-03

◆ SetFinishToTarget()

GrinderODIDKaydonScreenV01 SetFinishToTarget ( AxisID )

Set the finish target position DRO from the current workpiece dimension pound variable.

For the X axis, reads pound variable #616 (current workpiece X diameter) and copies its value to the XTargetPositionDRO screen object. For the Z axis, reads pound variable #618 and copies its value to the ZTargetPositionDRO screen object. This allows the operator to quickly populate the target position field with the programmed finish dimension.

Parameters
AxisID(number) The Mach4 axis constant (mc.X_AXIS or mc.Z_AXIS) identifying which axis to set
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ SetWheelHeadRange()

GrinderODIDKaydonScreenV01 SetWheelHeadRange ( Range )

Set the wheel head range pound variable and refresh the range button UI.

Writes the specified Range value to pound variable #738 to configure the active wheel head speed range, then calls UpdateWheelHeadRangeButtons() to refresh the button color states reflecting the new range selection.

Parameters
Range(number) The range value to set (0=Low Range, 1=High Range)
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if range was set, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.UpdateWheelHeadRangeButtons() for UI refresh
Note
Documentation generated by AI on 2026-03-03

◆ TeachClearX()

GrinderODIDKaydonScreenV01 TeachClearX ( )

Teach and save the current X axis machine position as the X clear position (#532).

Prompts the operator with a confirmation dialog if ConfirmationDialogs OEM parameter is set to "Yes". If confirmed, delegates to TeachPoundVarMachinePos() to read the current X axis machine position and store it in pound variable #532 (X Clear Position). The operator log is updated to record that the teach was initiated.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if position was saved, false on error or user cancel
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ TeachDresserPosition()

GrinderODIDKaydonScreenV01 TeachDresserPosition ( fieldName )

Teach the current machine position as a dresser position for the specified field.

Determines the relevant axis from the fieldName parameter (X or Z axis). Optionally prompts for operator confirmation via ConfirmationDialogs OEM parameter. Reads the current machine position for the determined axis. For X-axis fields (X1DressPosition, X2DressPosition, X3DressPosition, XDresserOffset), computes the dresser centerline offset as: |MachinePosX| + |WheelDiameter/2| + |DresserRollDiameter/2|, stores it as XDresserOffset in the tool table, and calls UpdateXWearOffset() to propagate changes. For Z-axis fields, stores the raw machine position directly into the tool table. The tool file is saved afterward.

Parameters
fieldName(string) The tool table field name identifying which dress position to teach. Valid values: "X1DressPosition", "X2DressPosition", "X3DressPosition", "XDresserOffset", "Z1DressPosition", "Z2DressPosition", "Z3DressPosition"
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if position was saved, false on error or user cancel
(string) Status message from w.FunctionCompleted() or w.FunctionError()
See also
GrinderODIDKaydonScreenV01.UpdateXWearOffset() for X axis offset propagation
Note
Documentation generated by AI on 2026-03-03

◆ TeachSafeX()

GrinderODIDKaydonScreenV01 TeachSafeX ( )

Teach and save the current X axis machine position as the X safe position (#530).

Prompts the operator with a confirmation dialog if ConfirmationDialogs OEM parameter is set to "Yes". If confirmed, delegates to TeachPoundVarMachinePos() to read the current X axis machine position and store it in pound variable #530 (X Safe Position). The operator log is updated to record that the teach was initiated.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if position was saved, false on error or user cancel
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ TeachSafeZ()

GrinderODIDKaydonScreenV01 TeachSafeZ ( )

Teach and save the current Z axis machine position as the Z safe position (#531).

Prompts the operator with a confirmation dialog if ConfirmationDialogs OEM parameter is set to "Yes". If confirmed, delegates to TeachPoundVarMachinePos() to read the current Z axis machine position and store it in pound variable #531 (Z Safe Position). The operator log is updated to record that the teach was initiated.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if position was saved, false on error or user cancel
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ UpdateCleanDressPicks()

GrinderODIDKaydonScreenV01 UpdateCleanDressPicks ( )

Update the clean dress picks display on the LED labels for active dressing states.

Reads the current picks counter from pound variable #8 and the null pound variable from #0. If the picks value equals the null pound variable, it is treated as -1 (no valid count). For each active dressing state (Clean Dress, Rough Dress, Micro Dress, Finish Dress), if the current state matches and picks are greater than 0, the LED label is updated to show the remaining pick count. Otherwise, the label is reset to the default state name.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed successfully, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateCycleProgresBar()

GrinderODIDKaydonScreenV01 UpdateCycleProgresBar ( )

Update the cycle progress bar gauge based on elapsed versus last known cycle time.

Only updates the progress bar when the machine state is MC_STATE_FRUN (program running). Reads the current run time via mc.mcCntlGetRunTime() and the last program cycle time from the MachMotion profile (key "LastProgramCycleTime"). If the last cycle time is greater than zero, calculates the percentage complete and updates the CycleProgressBarGauge display.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
Note
The last program cycle time is saved when the end-of-program register fires
See also
GrinderODIDKaydonScreenV01.UpdateEndOfProgram() for how cycle time is recorded
Note
Documentation generated by AI on 2026-03-03

◆ UpdateDresserDirectionButtons()

GrinderODIDKaydonScreenV01 UpdateDresserDirectionButtons ( )

Update the forward/reverse direction button colors for all dressing cycles.

Reads the dresser direction pound variables (#690-#693) for Clean Dress, Rough Dress, Micro Dress, and Finish Dress cycles. For each cycle, sets the FWD and REV button background colors based on the direction value: Direction==1 means Reverse (REV button ON, FWD button OFF), otherwise Forward (FWD button ON, REV button OFF).

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateEnableCycleButtons()

GrinderODIDKaydonScreenV01 UpdateEnableCycleButtons ( )

Update the background color of all grinding cycle enable buttons.

Iterates through seven grinding cycle enable pound variables (#600-#606) corresponding to: Rough Grind, Micro Grind, Finish Grind, Clean Dress, Rough Dress, Micro Dress, Finish Dress. Sets each button's background color to BTN_COLOR_ON if the pound variable equals 1, or BTN_COLOR_OFF if it equals 0.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateEndOfProgram()

GrinderODIDKaydonScreenV01 UpdateEndOfProgram ( )

Detect and process the end-of-program event to record cycle time and reset the register.

Reads the EndOfProgram OEM register. When it equals 1, indicating the program has completed, this function reads the current run time via mc.mcCntlGetRunTime(), resets the EndOfProgram register to 0, saves the cycle time to the MachMotion profile under "LastProgramCycleTime", and sets the CycleProgressBarGauge to 100%.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.UpdateCycleProgresBar() for how the saved cycle time is used
Note
Documentation generated by AI on 2026-03-03

◆ UpdateGrindDROs()

GrinderODIDKaydonScreenV01 UpdateGrindDROs ( )

Update the grinding DRO displays and calculate the rough grind amount.

Reads enabled state and amount for each grind stage from pound variables to compute the total stock removal and the micro+finish combined amount. The rough grind amount (#630) is automatically calculated as: StartDiameter - MicroAmount - FinishAmount - FinishDiameter - FinishStockAllowance. Updates the TotalStockDRO display and applies color coding to indicate invalid configurations:

  • StartDiameterDRO turns red if start diameter is <= finish diameter
  • MicroAmountDRO and FinishAmountDRO turn red if rough amount is negative while start > finish Pound variables used: ODMode(#607), enabled flags(#600-#602), amounts(#630-#632), StartDiameter(#619), FinishStockAllowance(#722), FinishDiameter(#616).
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if operation completed, false on error
    (string) Status message from w.FunctionError() on error
    Note
    Documentation generated by AI on 2026-03-03

◆ UpdateGrindingCycleState()

GrinderODIDKaydonScreenV01 UpdateGrindingCycleState ( )

Update the grinding cycle state LEDs and label based on pound variable #700.

Reads the current grind state from pound variable #700 and compares it to the previous state (LAST_STATE). Only when the state changes does the function update the UI, turning on the LED for the new state and turning off the LED for the previous state, and updating the CurrentStateLabel text. Recognized states are: IDLE(0), ROUGH_DRESS(1), ROUGH_GRIND(2), MICRO_DRESS(3), MICRO_GRIND(4), FINISH_DRESS(5), FINISH_GRIND(6), RETRACT(7), and CLEAN_DRESS(8). After processing, LAST_STATE is updated to CURRENT_STATE.

Note
This function is called from MachineScreenPLCScript() on every PLC cycle
Only updates the UI on state transitions to minimize redundant screen writes
Documentation generated by AI on 2026-03-03

◆ UpdateSparkoutBar()

GrinderODIDKaydonScreenV01 UpdateSparkoutBar ( )

Update the sparkout time gauge display based on the current dwell state.

Checks if the machine dwell signal (mc.OSIG_DWELL) is active. If dwelling, reads the remaining dwell time and the target dwell time via m.GetRemainingDwellTime() and m.GetTargetDwellTime(). Updates the SparkoutTimeGauge max value when the dwell target is greater than zero, and updates the current value when dwell target exceeds remaining time. If not dwelling, resets the SparkoutTimeGauge value to 0.0000.

Note
This function is called from MachineScreenPLCScript() on every PLC cycle
Documentation generated by AI on 2026-03-03

◆ UpdateWheelHeadRange()

GrinderODIDKaydonScreenV01 UpdateWheelHeadRange ( )

Read the current wheel head range and persist it to the OEM parameter for the active wheel head.

Reads the wheel head range from pound variable #738, then reads the current wheel head number from the WheelHeadCurrentNumber OEM parameter. Writes the range value to the OEM parameter named "WheelHeadCurrentRange_N" where N is the current wheel head number. This persists the range selection across sessions.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if range was saved, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.SetWheelHeadRange() for setting pound variable #738
Note
Documentation generated by AI on 2026-03-03

◆ UpdateWheelHeadRangeButtons()

GrinderODIDKaydonScreenV01 UpdateWheelHeadRangeButtons ( )

Update the wheel head range button colors based on the current range pound variable (#738).

Reads pound variable #738 to determine the active wheel head range. If Range equals 0, sets LowRangeBtn to BTN_COLOR_ON and HighRangeBtn to BTN_COLOR_OFF. If Range equals 1, sets LowRangeBtn to BTN_COLOR_OFF and HighRangeBtn to BTN_COLOR_ON. For any other value, sets both buttons to BTN_COLOR_OFF.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if buttons were updated, false on error
(string) Status message from w.FunctionError() on error
See also
GrinderODIDKaydonScreenV01.SetWheelHeadRange() for setting the active range
Note
Documentation generated by AI on 2026-03-03

◆ UpdateWheelHeadSpeeds()

GrinderODIDKaydonScreenV01 UpdateWheelHeadSpeeds ( )

Calculate and apply the commanded wheel head RPM based on the current grinding state and SFM.

Determines the target surface feet per minute (SFM) based on the current grind state: during dressing cycles (states 5-7), reads SFM from pound variable #541; otherwise reads from pound variable #731. Clamps the SFM to the MaxSFM limit from pound variable #737. Converts SFM to RPM using the current tool's wheel diameter: RPM = SFM * (12/pi) / Diameter. Further clamps the result to the maximum RPM for the current wheel head range obtained from GetWheelHeadCurrentRangeMaxRPM(). If the resulting RPM is greater than zero, writes it to pound variable #540 (CommandedRPM).

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if RPM was updated, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateWorkHeadSpeeds()

GrinderODIDKaydonScreenV01 UpdateWorkHeadSpeeds ( WorkHeadSFM )

Calculate and apply the commanded work head RPM based on surface feet per minute.

Converts the provided surface feet per minute (SFM) value to RPM using the current workpiece diameter from pound variable #616 via: RPM = |SFM * (12/pi) / Diameter|. Clamps the result to the spindle's current range min/max RPM limits obtained from mc.mcSpindleGetMinRPM() and mc.mcSpindleGetMaxRPM(). Only updates the spindle commanded RPM via mc.mcSpindleSetCommandRPM() if the new value differs from the current commanded RPM.

Parameters
WorkHeadSFM(number) The desired work head surface speed in surface feet per minute
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if RPM was updated, false on error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateXWearOffset()

GrinderODIDKaydonScreenV01 UpdateXWearOffset ( )

Recalculate and apply the X axis wear offset and dress position based on current wheel geometry.

Reads the current tool's wheel diameter, the dresser roll diameter (#542), and the XDresserOffset from the tool table. Determines the dresser direction from the RotaryDresserDirection OEM parameter (Positive=1, otherwise=-1). Computes: XWearOffset = ((|XDresserOffset|*2) - |WheelDiameter| - |DresserRollDiameter|) * Direction X1DressPosition = (|XDresserOffset| - |WheelDiameter/2| - |DresserRollDiameter/2|) * Direction Writes X1DressPosition to the tool table and to pound variable #518. Updates the tool's X wear offset (MTOOL_LATHE_X_W) with XWearOffset and saves the tool file.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if offsets were updated, false on error
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Warning
Modifies the active tool's wear offset directly; ensure machine is in a safe state before calling
See also
GrinderODIDKaydonScreenV01.TeachDresserPosition() for teaching the XDresserOffset
Note
Documentation generated by AI on 2026-03-03