|
Mach Modules Documentation
Lua Module API Documentation
|
Go to the source code of this file.
Functions | |
| GrinderCenterlessGUIModule | ScreenLoadScript () |
| Initialize the centerless grinder screen on load, configuring signals, UI, and OEM parameters. | |
| GrinderCenterlessGUIModule | GetRegulatingWheelSpeed () |
| Get the commanded regulating wheel speed from pound variable #516. | |
| GrinderCenterlessGUIModule | SetRegulatingWheelSpeed (CmdSpeed,...) |
| Set the regulating wheel speed by scaling RPM and writing to the hardware register. | |
| GrinderCenterlessGUIModule | GetRegulatingWheelDirection () |
| Get the current rotation direction of the regulating wheel from output register states. | |
| GrinderCenterlessGUIModule | SetRegulatingWheelDirection (Direction) |
| Set the regulating wheel rotation direction by writing forward/reverse output registers. | |
| GrinderCenterlessGUIModule | GetUpperLowerAxisID () |
| Get the axis ID of the currently selected upper or lower slide. | |
| GrinderCenterlessGUIModule | ResetTotalCompBtn (AxisID) |
| Reset the total compensation accumulator for a specific axis to zero. | |
| GrinderCenterlessGUIModule | ResetPartCounterBtn () |
| Reset the part counter display and pound variable to zero. | |
| GrinderCenterlessGUIModule | ResetUpperLowerTotalCompBtn () |
| Reset the total compensation accumulator for the currently selected upper/lower axis. | |
| GrinderCenterlessGUIModule | ThruFeedCompMainGrindAxis (Direction, Amount) |
| Apply a thru-feed compensation move to the currently selected main grind axis. | |
| GrinderCenterlessGUIModule | CompMainGrindAxis (Type, Direction, Amount) |
| Apply a compensation move to the currently selected main grind axis. | |
| GrinderCenterlessGUIModule | Comp (AxisID, Type, Direction, Amount) |
| Apply a compensation move to the specified axis using G-code MDI execution. | |
| GrinderCenterlessGUIModule | ThruFeedInBtn () |
| Move the active slide axis to the thru-feed in (zero) position. | |
| GrinderCenterlessGUIModule | ThruFeedOutBtn () |
| Move the active slide axis to the thru-feed retract (out) position. | |
| GrinderCenterlessGUIModule | UpperSlideBtn () |
| Select the upper slide axis as the active compensation axis. | |
| GrinderCenterlessGUIModule | LowerSlideBtn () |
| Select the lower slide axis as the active compensation axis. | |
| GrinderCenterlessGUIModule | RepeatToggleBtn () |
| Toggle the auto-loader repeat mode on or off in response to an operator button press. | |
| GrinderCenterlessGUIModule | StartHydraulics () |
| Enable the hydraulic system output signal. | |
| GrinderCenterlessGUIModule | StopHydraulics () |
| Stop the hydraulic system and shut down all dependent wheel outputs. | |
| GrinderCenterlessGUIModule | HydraulicsToggleBtn () |
| Toggle the hydraulic system on or off in response to an operator button press. | |
| GrinderCenterlessGUIModule | StartRegulatingWheel () |
| Start the regulating wheel after verifying hydraulic pressure and setting speed/direction. | |
| GrinderCenterlessGUIModule | StopRegulatingWheel () |
| Stop the regulating wheel and clear its direction outputs. | |
| GrinderCenterlessGUIModule | RegulatingWheelToggleBtn () |
| Toggle the regulating wheel on or off in response to an operator button press. | |
| GrinderCenterlessGUIModule | StartGrindingWheel () |
| Start the grinding wheel spindle after verifying hydraulic and regulating wheel interlocks. | |
| GrinderCenterlessGUIModule | StopGrindingWheel () |
| Stop the grinding wheel spindle and turn off coolant. | |
| GrinderCenterlessGUIModule | GrindingWheelToggleBtn () |
| Toggle the grinding wheel on or off in response to an operator button press. | |
| GrinderCenterlessGUIModule | GrindDressCycleStartBtn () |
| Start the grind dress cycle from the operator panel or physical button. | |
| GrinderCenterlessGUIModule | UpdateGrinderControls () |
| Update high-priority grinder UI controls for slide selection, position LEDs, and thru-feed state. | |
| GrinderCenterlessGUIModule | UpdateLowPriorityGrinderControls () |
| Update low-priority grinder UI controls including wheel buttons, counters, and comp labels. | |
| GrinderCenterlessGUIModule | PLCScript () |
| Execute the high-priority PLC update loop for the centerless grinder screen. | |
| GrinderCenterlessGUIModule | LowPriorityLoop () |
| Execute the low-priority periodic update loop for the centerless grinder screen. | |
| GrinderCenterlessGUIModule | ToggleMDI () |
| Toggle the MDI input panel visibility with password protection. | |
| GrinderCenterlessGUIModule | CycleStop () |
| Execute the centerless grinder cycle stop sequence with automatic axis retract. | |
| GrinderCenterlessGUIModule | CycleStart () |
| Execute the centerless grinder cycle start sequence with full pre-flight checks. | |
| GrinderCenterlessGUIModule | ZeroYOperatorPanelBtn () |
| Zero the Y axis position at the current location via operator panel button. | |
| GrinderCenterlessGUIModule | CoolantToggleBtn () |
| Toggle coolant on or off in response to an operator button press. | |
| GrinderCenterlessGUIModule | CoolantOff () |
| Turn off coolant output unconditionally. | |
| GrinderCenterlessGUIModule | PositionDisplayUnLocked (Password) |
| Switch the position display to unlocked (editable) mode with optional password protection. | |
| GrinderCenterlessGUIModule | UpdateStackLight () |
| Update the stack light outputs based on current machine alarm and run state. | |
| GrinderCenterlessGUIModule Comp | ( | AxisID | , |
| Type | , | ||
| Direction | , | ||
| Amount | ) |
Apply a compensation move to the specified axis using G-code MDI execution.
Performs the actual compensation move after validating the amount and determining direction. The compensation amount is read from pound variable #508 (Coarse) or #509 (Fine) based on the Amount parameter string. A safety check rejects comp values greater than 0.100 units. Two move types are supported:
| AxisID | (number) The axis constant (e.g., mc.B_AXIS, mc.C_AXIS) to compensate |
| Type | (number) Move type: 1 = adjust offset only, 2 = adjust offset and move to zero |
| Direction | (number) Direction of compensation: 1 = positive, any other value = negative |
| Amount | (string|number) Comp step size: "Coarse" reads #508, "Fine" reads #509, or a numeric value |
| GrinderCenterlessGUIModule CompMainGrindAxis | ( | Type | , |
| Direction | , | ||
| Amount | ) |
Apply a compensation move to the currently selected main grind axis.
Resolves the active upper/lower axis ID via GetUpperLowerAxisID() (pound variable #513), then delegates the compensation move to Comp() with the resolved axis ID. This function serves as the bridge between operator actions and the low-level Comp() implementation.
| Type | (number) Move type: 1 = adjust offset only, 2 = adjust offset and move to zero |
| Direction | (number) Direction of compensation: 1 = positive, any other value = negative |
| Amount | (string|number) Comp step size: "Coarse" reads #508, "Fine" reads #509 |
| GrinderCenterlessGUIModule CoolantOff | ( | ) |
Turn off coolant output unconditionally.
Sets the OSIG_COOLANTON signal to false and logs the action to the operator log. Unlike CoolantToggleBtn, this function does not check machine state or MST/Dry Run conditions. It is called internally by StopGrindingWheel to ensure coolant is always turned off when the grinding wheel stops.
| GrinderCenterlessGUIModule CoolantToggleBtn | ( | ) |
Toggle coolant on or off in response to an operator button press.
Checks MST Lock and Dry Run OEM register values before allowing coolant changes. If either is active, displays a warning and returns without changing coolant state. Additionally requires the grinding wheel spindle (OSIG_SPINDLEON) to be running before coolant can be turned on. If all checks pass, toggles OSIG_COOLANTON between true and false.
| GrinderCenterlessGUIModule CycleStart | ( | ) |
Execute the centerless grinder cycle start sequence with full pre-flight checks.
Performs a comprehensive sequence of checks and actions before starting or resuming a cycle:
| GrinderCenterlessGUIModule CycleStop | ( | ) |
Execute the centerless grinder cycle stop sequence with automatic axis retract.
Performs the following sequence on cycle stop:
| GrinderCenterlessGUIModule GetRegulatingWheelDirection | ( | ) |
Get the current rotation direction of the regulating wheel from output register states.
Reads the RegulatingWheelFWD and RegulatingWheelREV OEM parameter registers and interprets the combination to determine direction. Returns 1 if FWD=1 and REV=0, returns -1 if FWD=0 and REV=1, and returns 0 for any other combination (stopped or invalid state).
| GrinderCenterlessGUIModule GetRegulatingWheelSpeed | ( | ) |
Get the commanded regulating wheel speed from pound variable #516.
Reads pound variable #516 (Commanded Regulating Wheel RPM) which stores the last speed value written by SetRegulatingWheelSpeed(). This reflects the commanded speed, not necessarily the actual measured wheel speed.
| GrinderCenterlessGUIModule GetUpperLowerAxisID | ( | ) |
Get the axis ID of the currently selected upper or lower slide.
Reads pound variable #513 (Upper Lower Slide Selection) and validates that the value corresponds to a valid upper or lower axis (mc.B_AXIS = 4 or mc.C_AXIS = 5). If the value is not 4 or 5, returns an error indicating the axis ID is not configured.
| GrinderCenterlessGUIModule GrindDressCycleStartBtn | ( | ) |
Start the grind dress cycle from the operator panel or physical button.
Checks the current screen tab (MainWindowTabs). If the active tab is tab 5 (Grind Dress), calls m.CycleStartBtn() to begin the cycle. If any other tab is active, sets a warning message informing the operator that cycle start was ignored because they are not on the Grind Dress page.
| GrinderCenterlessGUIModule GrindingWheelToggleBtn | ( | ) |
Toggle the grinding wheel on or off in response to an operator button press.
Reads the GrindingWheelOuput OEM parameter signal to determine the current state. If the grinding wheel output is active, calls m.StopGrindingWheel(). If the output is inactive, calls m.StartGrindingWheel(). The actual interlock checks (hydraulics, regulating wheel) are performed inside StartGrindingWheel.
| GrinderCenterlessGUIModule HydraulicsToggleBtn | ( | ) |
Toggle the hydraulic system on or off in response to an operator button press.
Reads the current state of the HydraulicsOuput OEM parameter signal. If hydraulics are currently on, calls StopHydraulics() which also stops the regulating and grinding wheels before turning off the hydraulic output. If hydraulics are off, calls StartHydraulics() to enable the hydraulic output signal.
| GrinderCenterlessGUIModule LowerSlideBtn | ( | ) |
Select the lower slide axis as the active compensation axis.
Sets pound variable #513 to LOWER_SLIDE_AXIS_ID (mc.C_AXIS) to designate the lower slide as the active axis for all subsequent compensation and thru-feed operations. The UI button highlight update is handled by UpdateGrinderControls() on the next PLC cycle.
| GrinderCenterlessGUIModule LowPriorityLoop | ( | ) |
Execute the low-priority periodic update loop for the centerless grinder screen.
Delegates entirely to UpdateLowPriorityGrinderControls(). Called on a lower-frequency timer cycle than PLCScript to update controls that do not require high-frequency refresh, such as wheel button states, part counters, and comp button labels.
| GrinderCenterlessGUIModule PLCScript | ( | ) |
Execute the high-priority PLC update loop for the centerless grinder screen.
Called on every PLC cycle to refresh the screen. Performs three sequential updates:
| GrinderCenterlessGUIModule PositionDisplayUnLocked | ( | Password | ) |
Switch the position display to unlocked (editable) mode with optional password protection.
Hides the locked and DRO position display groups and shows the unlocked position display group. Enables a wide range of UI controls including fixture offsets, tool offsets, edge finder buttons, and tool table access. For grinder-specific behavior, axis position DROs (X, Y, Z, A, B, C) are set to editor mode 3 (keypad/read-only) to prevent direct operator edits, while tool diameter and length DROs are set to editor mode 1. Calls user.UserPositionDisplayUnLocked hook if defined.
| Password | (boolean) If true, requires password level 1 authentication before unlocking |
| GrinderCenterlessGUIModule RegulatingWheelToggleBtn | ( | ) |
Toggle the regulating wheel on or off in response to an operator button press.
Reads the RegulatingWheelOuput OEM parameter signal to determine the current state. If the regulating wheel output is active, calls StopRegulatingWheel() and also calls StopGrindingWheel() to enforce the interlock (grinding wheel cannot run without regulating wheel). If the output is inactive, calls StartRegulatingWheel().
| GrinderCenterlessGUIModule RepeatToggleBtn | ( | ) |
Toggle the auto-loader repeat mode on or off in response to an operator button press.
Reads pound variable #538 (Repeat flag). If the current value is 1 (repeat enabled), sets it to 0 (disabled). If the current value is not 1, sets it to 1 (enabled). The button color update reflecting the new state is handled by UpdateLowPriorityGrinderControls() on the next low-priority loop cycle.
| GrinderCenterlessGUIModule ResetPartCounterBtn | ( | ) |
Reset the part counter display and pound variable to zero.
Sets the PartCounterDRO screen object value to 0 and writes 0 to pound variable #540 (PartsFinished). This resets the auto-loader finished parts count so a new production run can begin without triggering the parts quota check in CycleStart().
| GrinderCenterlessGUIModule ResetTotalCompBtn | ( | AxisID | ) |
Reset the total compensation accumulator for a specific axis to zero.
Sets the TOTAL_COMP table entry at index (AxisID + 1) to 0, clearing the running compensation total for the specified axis. The updated value will be reflected in the corresponding DRO (TotalUCompDRO, TotalYCompDRO, or TotalUpperLowerCompDRO) on the next UpdateGrinderControls() cycle.
| AxisID | (number) The axis constant (e.g., mc.B_AXIS, mc.C_AXIS) whose total comp to reset |
| GrinderCenterlessGUIModule ResetUpperLowerTotalCompBtn | ( | ) |
Reset the total compensation accumulator for the currently selected upper/lower axis.
Resolves the active upper/lower axis ID via GetUpperLowerAxisID() (pound variable #513), then calls ResetTotalCompBtn() to zero the TOTAL_COMP entry for that axis. This clears the running compensation total displayed in TotalUpperLowerCompDRO.
| GrinderCenterlessGUIModule ScreenLoadScript | ( | ) |
Initialize the centerless grinder screen on load, configuring signals, UI, and OEM parameters.
Performs the full screen initialization sequence:
| GrinderCenterlessGUIModule SetRegulatingWheelDirection | ( | Direction | ) |
Set the regulating wheel rotation direction by writing forward/reverse output registers.
Controls the RegulatingWheelFWD and RegulatingWheelREV OEM parameter registers to establish motor direction. Three states are supported:
| Direction | (number) Desired direction: 1 = forward, -1 = reverse, 0 = neutral/stop |
| GrinderCenterlessGUIModule SetRegulatingWheelSpeed | ( | CmdSpeed | , |
| ... ) |
Set the regulating wheel speed by scaling RPM and writing to the hardware register.
If CmdSpeed is provided, writes it to pound variable #516 before processing. If CmdSpeed is nil, reads the current value from pound variable #516. The speed is then clamped to the RegulatingWheelMaxRPM OEM parameter value if it exceeds the maximum. The clamped RPM is scaled from the range [0, RegulatingWheelMaxRPM] to the DAC range [0, 2047] using w.Scale(), and the result is written to the RegulatingWheelRPM OEM parameter register.
| CmdSpeed | (number|nil) The desired speed in RPM to set, or nil to use the current #516 value |
| ... | (any) Additional arguments (accepted but unused) |
| GrinderCenterlessGUIModule StartGrindingWheel | ( | ) |
Start the grinding wheel spindle after verifying hydraulic and regulating wheel interlocks.
Performs the following sequence:
| GrinderCenterlessGUIModule StartHydraulics | ( | ) |
Enable the hydraulic system output signal.
Sets the HydraulicsOuput OEM parameter signal to true to start the hydraulic system. Does not perform any interlock checks - the caller is responsible for verifying machine state before calling this function. Typically called by HydraulicsToggleBtn().
| GrinderCenterlessGUIModule StartRegulatingWheel | ( | ) |
Start the regulating wheel after verifying hydraulic pressure and setting speed/direction.
Performs the following sequence:
| GrinderCenterlessGUIModule StopGrindingWheel | ( | ) |
Stop the grinding wheel spindle and turn off coolant.
Sets the GrindingWheelOuput OEM parameter signal to false, calls CoolantOff() to ensure coolant is also disabled, then sets the spindle direction to mc.MC_SPINDLE_OFF via mc.mcSpindleSetDirection().
| GrinderCenterlessGUIModule StopHydraulics | ( | ) |
Stop the hydraulic system and shut down all dependent wheel outputs.
Calls StopRegulatingWheel() and StopGrindingWheel() to ensure both wheels are stopped before turning off the hydraulic output. Then sets the HydraulicsOuput OEM parameter signal to false. This ensures a safe shutdown sequence where dependent systems are disabled before hydraulic pressure is removed.
| GrinderCenterlessGUIModule StopRegulatingWheel | ( | ) |
Stop the regulating wheel and clear its direction outputs.
Sets the RegulatingWheelOuput OEM parameter signal to false, then calls SetRegulatingWheelDirection(0) to clear both the forward and reverse direction output signals (RegulatingWheelFWD and RegulatingWheelREV).
| GrinderCenterlessGUIModule ThruFeedCompMainGrindAxis | ( | Direction | , |
| Amount | ) |
Apply a thru-feed compensation move to the currently selected main grind axis.
Verifies that the thru-feed in button is active (ThruFeedInBtn color is not BTN_COLOR_OFF) before allowing compensation. If the thru-feed is not engaged, shows a warning and returns without applying comp. Then determines the compensation type based on the current axis position: if the axis is within 0.001 units of zero, uses Type 2 (adjust offset and move to new zero); otherwise uses Type 1 (adjust offset only). Delegates to CompMainGrindAxis() with the resolved type.
| Direction | (number) Direction of compensation: 1 = positive (out), -1 = negative (in) |
| Amount | (string) Comp step size: "Coarse" reads pound variable #508, "Fine" reads #509 |
| GrinderCenterlessGUIModule ThruFeedInBtn | ( | ) |
Move the active slide axis to the thru-feed in (zero) position.
Executes an MDI command (G90 G00) to move the currently selected upper/lower axis to the absolute zero position. The active axis is determined by GetUpperLowerAxisID() which reads pound variable #513. This represents the fully-in thru-feed position.
| GrinderCenterlessGUIModule ThruFeedOutBtn | ( | ) |
Move the active slide axis to the thru-feed retract (out) position.
Reads the thru-feed retract distance from pound variable #507, then executes an MDI command (G90 G00) to move the currently selected upper/lower axis to that retract position in absolute coordinates. The active axis is determined by GetUpperLowerAxisID() which reads pound variable #513.
| GrinderCenterlessGUIModule ToggleMDI | ( | ) |
Toggle the MDI input panel visibility with password protection.
Requires password level 1 authentication. When the MDI group is hidden (Left = "10000"), moves it to the visible position (Left = "105") and hides the G-code group. When the MDI group is visible, reverses the swap. Updates the MdiBtn label and background color to reflect the current display mode.
| GrinderCenterlessGUIModule UpdateGrinderControls | ( | ) |
Update high-priority grinder UI controls for slide selection, position LEDs, and thru-feed state.
Refreshes the following UI elements on every PLC cycle:
| GrinderCenterlessGUIModule UpdateLowPriorityGrinderControls | ( | ) |
Update low-priority grinder UI controls including wheel buttons, counters, and comp labels.
Refreshes the following UI elements at a lower frequency than the main PLC loop:
| GrinderCenterlessGUIModule UpdateStackLight | ( | ) |
Update the stack light outputs based on current machine alarm and run state.
Checks the LightStackEnabled OEM parameter before proceeding. If the light stack is disabled, returns early. Otherwise, evaluates the current GMS alarm and warning states as well as the machine run state (MACH_STATE) to determine the correct red and green light output states.
| GrinderCenterlessGUIModule UpperSlideBtn | ( | ) |
Select the upper slide axis as the active compensation axis.
Sets pound variable #513 to UPPER_SLIDE_AXIS_ID (mc.B_AXIS) to designate the upper slide as the active axis for all subsequent compensation and thru-feed operations. The UI button highlight update is handled by UpdateGrinderControls() on the next PLC cycle.
| GrinderCenterlessGUIModule ZeroYOperatorPanelBtn | ( | ) |
Zero the Y axis position at the current location via operator panel button.
Logs the zero action, updates stop status, and checks the ToolPathAutoRegen OEM parameter. If a user.UserZeroY hook is defined it is called instead of the default behavior. The default behavior sets the Y axis position to 0.0 using mc.mcAxisSetPos(). After zeroing, regenerates the tool path if ToolPathAutoRegen is "Yes" and saves the current fixture offsets.