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

Go to the source code of this file.

Functions

GrinderCenterlessMCodeModule GetRegulatingWheelSpeed ()
 Get the current regulating wheel speed from Mach4 pound variable #516.
GrinderCenterlessMCodeModule SetRegulatingWheelSpeed (CmdSpeed,...)
 Set the regulating wheel speed by scaling the commanded RPM to the analog output range.

Function Documentation

◆ GetRegulatingWheelSpeed()

GrinderCenterlessMCodeModule GetRegulatingWheelSpeed ( )

Get the current regulating wheel speed from Mach4 pound variable #516.

Reads the regulating wheel speed stored in pound variable #516 using mc.mcCntlGetPoundVar(). This value represents the commanded RPM for the regulating wheel spindle.

Returns
(number|nil) The current regulating wheel speed in RPM, or nil on error
(boolean) Success flag - true if the value was read successfully
(string) Status message - "FunctionCompleted" on success or error message via w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ SetRegulatingWheelSpeed()

GrinderCenterlessMCodeModule SetRegulatingWheelSpeed ( CmdSpeed ,
... )

Set the regulating wheel speed by scaling the commanded RPM to the analog output range.

If CmdSpeed is provided, it writes that value to pound variable #516 and uses it as the target speed. If CmdSpeed is nil, the current value of pound variable #516 is read and used instead. The speed is clamped to the RegulatingWheelMaxRPM OEM parameter before scaling. The scaled value is then written to the RegulatingWheelRPM OEM parameter register using a 0-2047 analog range.

Parameters
CmdSpeed(number|nil) The desired regulating wheel speed in RPM. If nil, reads the current speed from pound variable #516
...(any) Additional arguments (unused, reserved for future use)
Returns
(number|nil) The actual speed value set (after clamping), or nil on error
(boolean) Success flag - true if operation completed successfully
(string) Status message - "FunctionCompleted" on success or error message via w.FunctionError()
-- Set regulating wheel to 1500 RPM
local speed, success, msg = GrinderCenterlessMCodeModule.SetRegulatingWheelSpeed(1500)
if not success then w.Error(msg) end
-- Use current pound variable #516 value as speed
local speed, success, msg = GrinderCenterlessMCodeModule.SetRegulatingWheelSpeed(nil)
if not success then w.Error(msg) end
Note
Speed is clamped to RegulatingWheelMaxRPM if the commanded value exceeds the maximum
Documentation generated by AI on 2026-03-03