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

Go to the source code of this file.

Functions

PlasmaMCodeModule NeuronServoControlledPierce (ToolName)
 Execute the Neuron servo height control torch IHS (Initial Height Sensing) and arc start sequence.
PlasmaMCodeModule m3_ManualControlledPierce (ToolName)
 Execute the manual oxy-fuel controlled pierce sequence.
 name ("m3")
 Handle M3 plasma cutting start failure by reporting an alarm or error based on machine state.
PlasmaMCodeModule m3_FailCondition (LineNumber, Message)
 Handle M3 plasma cutting start failure by reporting an alarm or error based on machine state.
PlasmaMCodeModule VerifyTorchHoming ()
 Verify torch homing state and trigger re-homing if required.
PlasmaMCodeModule TorchGoToHome ()
 Command the plasma or oxy-fuel torch to return to its home position.
PlasmaMCodeModule GetControllerOnlineStatus ()
 Get the online/offline status of the Neuron THC controller.
PlasmaMCodeModule OxyToHeight (OxyCommandedPosition)
 Move oxy-fuel torch heads to a specified height position.
 FailCondition (Message, LineNumber)
 Handle oxy torch height motion failure by stopping all head outputs and reporting error.
PlasmaMCodeModule OxyWaitForPreheat ()
 Wait for the oxy-fuel preheat time to elapse with operator override support.
PlasmaMCodeModule OxyWaitForPierce ()
 Wait for the oxy-fuel pierce time to elapse.
PlasmaMCodeModule OxyWaitForPierceMotion ()
 Wait for the oxy-fuel pierce motion time to elapse or cutting gas to deactivate.
PlasmaMCodeModule OxyTorchIgnition (SkipMotion)
 Perform oxy-fuel torch ignition sequence with optional motion to safe position.
PlasmaMCodeModule OxyTorchIgnitionOff ()
 Turn off the oxy-fuel torch ignition and all associated gas outputs.
PlasmaMCodeModule OxyTorchOn ()
 Ignite and activate the oxy-fuel torch cutting sequence.
PlasmaMCodeModule OxyTorchOff ()
 Turn off all active oxy-fuel torch cutting gas outputs.
PlasmaMCodeModule GetCurrentTabOperation ()
 Get the operation name corresponding to the currently selected machine tab.

Function Documentation

◆ FailCondition()

FailCondition ( Message ,
LineNumber  )

Handle oxy torch height motion failure by stopping all head outputs and reporting error.

Local helper function defined inside OxyToHeight. On failure, iterates over all OxyFuelHeads and disables both the Up and Down outputs for each head, then resets OxyInMotion register to 0 before returning the formatted error.

Parameters
Message(string) The error message describing the failure condition
LineNumber(number) The source line number where the failure occurred, for error context
Returns
(nil) Always nil as the primary return value
(boolean) Always false indicating failure
(string) Formatted error message from w.FunctionError() with function and file context
Note
Documentation generated by AI on 2026-03-03

◆ GetControllerOnlineStatus()

PlasmaMCodeModule GetControllerOnlineStatus ( )

Get the online/offline status of the Neuron THC controller.

Reads the OnlineMode register from the Neuron.THC device. Returns true if OnlineMode equals 1 (controller is online), false otherwise. If the register read fails, returns false with a success flag of true (treats offline as non-fatal).

Returns
(boolean) True if the Neuron THC controller is online, false if offline or register unreadable
(boolean) Success flag - always true (offline state is not considered an error)
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ GetCurrentTabOperation()

PlasmaMCodeModule GetCurrentTabOperation ( )

Get the operation name corresponding to the currently selected machine tab.

Reads the CurrentMachineTab OEM register and maps its numeric value to an operation name string. Tab index 0 = "Plasma", 1 = "Oxy", 2 = "Marker", 3 = "Drill (A)". Returns an empty string if the tab index does not match any known operation.

Returns
(string) The operation name for the current tab (e.g., "Plasma", "Oxy", "Marker", "Drill (A)"), or empty string if unknown
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ m3_FailCondition()

PlasmaMCodeModule m3_FailCondition ( LineNumber ,
Message  )

Handle M3 plasma cutting start failure by reporting an alarm or error based on machine state.

Sends a "Tool Engaged Failed" macro finished command, then checks machine stop status. If the machine is not stopped, returns a formatted w.FunctionError(). If the machine is stopped, returns a w.AlarmMessage() with the error context. Both paths include the source line number and function name ("m3") for traceability.

Parameters
LineNumber(number) The source line number where the failure occurred
Message(string) The error message describing the failure condition
Returns
(nil) Always nil as the primary return value
(boolean) Always false indicating failure
(string) Formatted error or alarm message with line number and "m3" context
See also
PlasmaMCodeModule.NeuronServoControlledPierce() which uses this as its error handler
Note
Documentation generated by AI on 2026-03-03

◆ m3_ManualControlledPierce()

PlasmaMCodeModule m3_ManualControlledPierce ( ToolName )

Execute the manual oxy-fuel controlled pierce sequence.

Performs the full manual oxy-fuel pierce sequence in order:

  1. Move torch to cut height (OxyToHeight(1))
  2. Enable PreheatOxyOutput
  3. Wait for preheat to complete (OxyWaitForPreheat)
  4. Move torch to pierce height (OxyToHeight(2))
  5. Enable CuttingOxy1Output (pierce gas)
  6. Wait for pierce time to elapse (OxyWaitForPierce)
  7. Enable CuttingOxy2Output (cut gas 2) Each step is validated and returns via m3_FailCondition on error.
    Parameters
    ToolName(string) The name of the current tool (e.g., "Oxy") used for context in error reporting
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if pierce sequence completed successfully
    (string) Status message from w.FunctionCompleted()
    Warning
    This function blocks execution through multiple timed waiting and motion stages
    See also
    PlasmaMCodeModule.OxyToHeight() for torch height positioning
    PlasmaMCodeModule.OxyWaitForPreheat() for preheat timing
    PlasmaMCodeModule.OxyWaitForPierce() for pierce timing
    Note
    Documentation generated by AI on 2026-03-03

◆ name()

name ( "m3" )

Handle M3 plasma cutting start failure by reporting an alarm or error based on machine state.

Sends a "Tool Engaged Failed" macro finished command, then checks machine stop status. If the machine is not stopped, returns a formatted w.FunctionError(). If the machine is stopped, returns a w.AlarmMessage() with the error context. Both paths include the

Referenced by AddSetting(), ConvertToLegalVariableName(), CreateCommandActionOption(), CreateCommandFeedbackOption(), CreateToolSetter(), CreateUserCommandActionOption(), CreateUserCommandFeedbackOption(), DoesHaveProperty(), eGetSignalState(), eSetSignalState(), FormatDRO(), GetCachedIoHandle(), GetCachedRegisterHandle(), GetCachedSignalHandle(), GetCheckPoint(), GetCommandFeedbackIOName(), GetCommandFeedbackRegisterName(), GetCommandIOName(), GetCommandRegisterName(), GetDefaultCommand(), GetDRO(), GetDropDownSelectedIndex(), GetHidden(), GetLED(), GetMMToggleButton(), GetMMToggleButtonWidthPixel(), GetObject(), GetSignalInfo(), GetSignalState(), GetToolSetter(), IsFontName(), IsObject(), itself(), orig_SetObject(), parseINI(), PlusMinusDRO(), saveINI(), SetAxisObject(), SetButtonLED(), SetCutSequence(), SetDRO(), SetDropDownSelectedIndex(), SetFixtureSetterAutoName(), SetFixtureSetterManualName(), SetFontFamily(), SetFontName(), SetHidden(), SetLabelLED(), SetLED(), SetMMToggleButton(), SetObject(), SetSignalState(), SetToolSetterAutoName(), SetToolSetterManualName(), StartScrollDRO(), StopScrollDRO(), ValidateCycleData(), and ValidateDROValue().

◆ NeuronServoControlledPierce()

PlasmaMCodeModule NeuronServoControlledPierce ( ToolName )

Execute the Neuron servo height control torch IHS (Initial Height Sensing) and arc start sequence.

Performs the full Servo Height Control pierce sequence:

  1. Pushes a new machine state and makes a small XY jog move to activate the M62 Torch Height Freeze output, then pops state.
  2. Calls VerifyTorchHoming() to ensure the torch is homed.
  3. Sets the Mach4 last error to "Torch IHS Started".
  4. Retrieves the tool output signal via w.GetToolInfo() and enables it via w.SetSignalState().
  5. If the controller is online:
    • For "Plasma" tool: waits for Neuron.THC n_ArcOkInput to go true (Arc OK).
    • Waits for Neuron.THC n_Motion to go true (Motion Ready).
    • For "Oxy" tool with OxyFuelAllowMovementOnPierce == "No": waits for n_OxyFuelProcessSequence to reach 13.
  6. If controller is offline: sleeps 1 second and sets SimMotionReady register to 1.
  7. Sets last error to "Torch IHS Completed" on success. All failure paths route through m3_FailCondition() with line number context.
    Parameters
    ToolName(string) The name of the current tool (e.g., "Plasma", "Oxy") used to select arc-ok and sequence waits
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if IHS and arc start completed successfully
    (string) Status message "Torch IHS Completed" or error from m3_FailCondition()
    Warning
    This function blocks execution while waiting for Arc OK and Motion Ready signals (up to 100 seconds timeout)
    See also
    PlasmaMCodeModule.VerifyTorchHoming() for pre-IHS homing verification
    PlasmaMCodeModule.m3_FailCondition() for error handling
    Note
    Documentation generated by AI on 2026-03-03

◆ OxyToHeight()

PlasmaMCodeModule OxyToHeight ( OxyCommandedPosition )

Move oxy-fuel torch heads to a specified height position.


-----------------------— Oxy To Height ---------------------------—

Controls the physical up/down motion of all enabled oxy-fuel torch heads by driving the appropriate directional output signals for a calculated time duration. Position values are: 1 = cut height, 2 = pierce height, 3 = rapid/traverse height. Motion distance is computed from the difference between OxyCurrentPosition and OxyCommandedPosition using OxyPierceHeight and OxyRapidHeight register values. Motion time is calculated as MotionDistance * OxyMilliSecPerUnit. Only heads enabled in the CutOxyHeads bitmask register are activated. Waits for any in-progress motion (OxyInMotion == 2) to complete before starting new motion. Updates OxyCurrentPosition and OxyInMotion registers throughout the operation.

Parameters
OxyCommandedPosition(number) Target height position: 1 = cut height, 2 = pierce height, 3 = rapid height
Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if motion completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Warning
This function blocks execution during torch head motion
Machine must not be stopped during motion; CheckStopStatus is polled in the wait loop
See also
PlasmaMCodeModule.OxyWaitForPreheat() for the preheat stage that follows
Note
Documentation generated by AI on 2026-03-03

◆ OxyTorchIgnition()

PlasmaMCodeModule OxyTorchIgnition ( SkipMotion )

Perform oxy-fuel torch ignition sequence with optional motion to safe position.

Handles torch ignition for oxy-fuel cutting. Behavior depends on OxyFuelType and SkipMotion:

  • If torch (CuttingGasOutput) is already on, returns immediately with success.
  • For "Auto Ignition" (AutoIgnition == "Yes"): enables OxyIgnitionOutput, CuttingGasOutput, IgnitionRelayOutput, waits AutoIgnitionTime, then disables IgnitionRelayOutput.
  • For manual ignition without SkipMotion: moves torch to rapid height, moves to tool change position, pauses for operator to start ignition gas (EVT_MACRO_HOLD), then lights torch. After lighting, pauses again for operator confirmation before returning to original XY position.
  • For "Servo Height Control": uses Neuron.THC n_LightOxyFuelTorch register instead of direct outputs.
    Parameters
    SkipMotion(boolean|nil) If true, skips motion to tool change position and back. If nil or false, performs full motion sequence
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if operation completed successfully
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Warning
    This function may block execution and trigger EVT_MACRO_HOLD pauses requiring operator input
    See also
    PlasmaMCodeModule.OxyToHeight() for torch height positioning
    Note
    Documentation generated by AI on 2026-03-03

◆ OxyTorchIgnitionOff()

PlasmaMCodeModule OxyTorchIgnitionOff ( )

Turn off the oxy-fuel torch ignition and all associated gas outputs.

Shuts down the oxy-fuel torch based on OxyFuelType:

  • For "Servo Height Control": writes 1 to the Neuron.THC n_OxyTorchOffButton register and sets n_IsCutParametersModify to signal the controller.
  • For other modes (Manual Height Control): sequentially disables PreheatOxyOutput, CuttingGasOutput, CuttingOxy1Output, CuttingOxy2Output, CuttingOxy3Output, performs a 200ms purge delay, then disables OxyIgnitionOutput.
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if operation completed successfully
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Note
    Documentation generated by AI on 2026-03-03

◆ OxyTorchOff()

PlasmaMCodeModule OxyTorchOff ( )

Turn off all active oxy-fuel torch cutting gas outputs.

Disables all oxy-fuel cutting gas outputs (PreheatOxyOutput, CuttingOxy1Output, CuttingOxy2Output, CuttingOxy3Output) when operating in Manual Height Control mode. If the OxyFuelType is not "Manual Height Control", the function returns successfully without taking any action.

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

◆ OxyTorchOn()

PlasmaMCodeModule OxyTorchOn ( )

Ignite and activate the oxy-fuel torch cutting sequence.

Performs the full oxy-fuel torch activation sequence depending on OxyFuelType:

  • If torch is already ignited (CuttingGasOutput is active), returns immediately.
  • For "Manual Height Control" mode: calls OxyTorchIgnition if needed, then sequences through preheat wait, pierce gas, pierce time wait, pierce motion wait, and cut gas stages.
  • For "Servo Height Control" mode: only ensures ignition is active. Monitors PreheatOxyOutput between stages and exits early if it goes false.
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if operation completed successfully
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Warning
    This function blocks execution through multiple timed waiting stages
    See also
    PlasmaMCodeModule.OxyTorchIgnition() for initial torch ignition
    PlasmaMCodeModule.OxyWaitForPreheat() for preheat timing
    PlasmaMCodeModule.OxyWaitForPierce() for pierce timing
    PlasmaMCodeModule.OxyWaitForPierceMotion() for pierce motion timing
    Note
    Documentation generated by AI on 2026-03-03

◆ OxyWaitForPierce()

PlasmaMCodeModule OxyWaitForPierce ( )

Wait for the oxy-fuel pierce time to elapse.


-----------------------— OxyWaitForPierce ------------------------—

Blocks execution while counting down the OxyPierceTime register value using a time-based loop (os.clock()). Updates OxyGaugeName to "Timer (T2)", OxyGaugeMax, and OxyGaugeValue registers throughout the wait for UI gauge display. The wait exits early if the machine is stopped (CheckStopStatus returns false). Resets OxyGaugeValue to 0 on completion.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if pierce time elapsed, false if machine was stopped
(string) Status message from w.FunctionCompleted() or error string
Warning
This function blocks execution for the duration of OxyPierceTime
See also
PlasmaMCodeModule.OxyWaitForPreheat() for preheat timing
PlasmaMCodeModule.OxyWaitForPierceMotion() for pierce motion timing
Note
Documentation generated by AI on 2026-03-03

◆ OxyWaitForPierceMotion()

PlasmaMCodeModule OxyWaitForPierceMotion ( )

Wait for the oxy-fuel pierce motion time to elapse or cutting gas to deactivate.


-----------------------— OxyWaitForPierceMotion ------------------—

Blocks execution while counting down the OxyPierceMotionTime register value. The wait loop exits early if either:

  • The CuttingOxy2Output signal goes inactive (torch turned off externally)
  • PreheatOxyOutput goes false (preheat was terminated)
  • The machine is stopped (CheckStopStatus returns false) Updates OxyGaugeName to "Timer (T3)", OxyGaugeMax, and OxyGaugeValue registers throughout the wait for UI gauge display.
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if wait completed or early-exit condition met, false on error
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Warning
    This function blocks execution for the duration of OxyPierceMotionTime
    Note
    Documentation generated by AI on 2026-03-03

◆ OxyWaitForPreheat()

PlasmaMCodeModule OxyWaitForPreheat ( )

Wait for the oxy-fuel preheat time to elapse with operator override support.


-----------------------— OxyWaitForPreheat -----------------------—

Blocks execution while counting down the OxyPreheatTime register value using a time-based loop (os.clock()). Updates OxyGaugeName to "Timer (T1)", OxyGaugeMax, and OxyGaugeValue registers throughout the wait for UI gauge display. Supports two operator overrides during the wait:

  • OxyAddPreheatTimeButton: adds 15 seconds to the remaining preheat time when set to 1
  • OxyTerminatePreheatButton: exits the wait early; if set to 2, elapsed time is NOT saved If SaveElapsedTime is true at exit, updates OxyPreheatTime register with actual elapsed time.
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if preheat completed (timed out or terminated), false if machine was stopped
    (string) Status message from w.FunctionCompleted() or error string
    Warning
    This function blocks execution for the duration of the preheat sequence
    See also
    PlasmaMCodeModule.OxyWaitForPierce() for the following pierce timing stage
    Note
    Documentation generated by AI on 2026-03-03

◆ TorchGoToHome()

PlasmaMCodeModule TorchGoToHome ( )

Command the plasma or oxy-fuel torch to return to its home position.

Sends the torch to its home position based on the current tool and plasma type:

  • For Servo Height Control (Plasma, Marker (P), or Oxy tools) when online: writes 1 to Neuron.THC n_GoToHomePosition and n_IsCutParametersModify, sleeps 100ms, then waits up to 20 seconds for n_SystemIsBusy to clear.
  • For "Roller Head" plasma type: disables PlasmaHeadDownOutput and waits PlasmaRollerHeadDownTimeDelay milliseconds.
  • If the machine is disabled (OSIG_MACHINE_ENABLED is false), returns immediately with success. Reads PlasmaType and OxyFuelType OEM parameters to determine behavior.
    Returns
    (nil) No meaningful return value on success
    (boolean) Success flag - true if torch reached home, false on error or timeout
    (string) Status message from w.FunctionCompleted(), w.FunctionError(), or w.AlarmMessage()
    Warning
    This function blocks execution while waiting for the torch to reach home position (up to 20 seconds)
    See also
    PlasmaMCodeModule.GetControllerOnlineStatus() for online status check
    Note
    Documentation generated by AI on 2026-03-03

◆ VerifyTorchHoming()

PlasmaMCodeModule VerifyTorchHoming ( )

Verify torch homing state and trigger re-homing if required.

Checks the Neuron.THC n_HomingRequest register. If a homing request is pending (value != 0), triggers the homing sequence by writing 1 to n_HomeButton and n_IsCutParametersModify, sleeps 100ms, then waits up to 20 seconds for n_SystemIsBusy to reach 0. If the controller is offline, skips the check and returns success.

Returns
(nil) No meaningful return value on success
(boolean) Success flag - true if torch is homed or no homing was required, false on timeout or error
(string) Status message from w.FunctionCompleted() or w.AlarmMessage()
Warning
This function blocks execution for up to 20 seconds while waiting for torch homing to complete
See also
PlasmaMCodeModule.GetControllerOnlineStatus() for online status check
Note
Documentation generated by AI on 2026-03-03