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

Go to the source code of this file.

Functions

VFD Cleanup ()
 Clean up all resources associated with this VFD instance.
VFD CleanupCommonControls ()
 Remove all auxiliary spindle control registers and I/O points for the VFD device.
VFD VFDCollection Create ()
 Create and return an empty VFD collection object.
VFD VFDCollection Add ()
 Add a VFD object to the collection.
VFD VFDCollection Update ()
 Update all VFD instances in the collection.
VFD VFDCollection StopMotor ()
 Stop the motor on all VFD instances in the collection.
VFD VFDCollection ResetAlarms ()
 Reset alarms on all VFD instances in the collection.
VFD VFDCollection DoAll (...)
 Call a named member function on every VFD in the collection.
VFD CreateVFDs ()
 Instantiate and return all enabled VFD objects for the current machine configuration.
VFD GetSpindleControlObjects ()
 Return the table defining all spindle control register and I/O point names.
VFD CreateSpindleControls ()
 Create spindle control registers and I/O outputs for the VFD device.
VFD GetMaxMotorRPM ()
 Get the maximum motor RPM from Mach4 spindle settings or auxiliary OEM parameter.
VFD SetMotorRPM ()
 Set the commanded motor frequency/percentage on the Delta VFD drive.
VFD GetCommandedMotorRPM ()
 Get the commanded motor RPM from Mach4 or auxiliary control register.
VFD GetCommandedMotorDirection ()
 Get the commanded motor direction from Mach4 or auxiliary I/O.
VFD SetActualMotorRPMFeedback ()
 Set the actual motor RPM feedback from VFD sensor data.
VFD SetActualMotorLoadFeedbackPercentage ()
 Set the actual motor load feedback percentage in the standard feedback register.
VFD GetActualMotorLoadFeedbackPercentage ()
 Get the actual motor load feedback percentage (base VFD implementation).
VFD GetSSVRPM ()
 Compute the commanded spindle RPM with Spindle Speed Variation (SSV) applied.
Delta Create (vfd_instance, vfd_cleanup)
 Create and initialize a Delta MS3000 VFD object.
Delta StartMotorForward ()
 Start the Delta MS3000 VFD motor in the forward direction.
Delta StartMotorReverse ()
 Start the Delta MS3000 VFD motor in the reverse direction.
Delta GetActualMotorRPMFeedback ()
 Get the actual motor RPM feedback from the Delta MS3000 VFD.
Delta ReadAlarmCode ()
 Read the current alarm code from the Delta MS3000 VFD Warning_Alarm register.
Delta ReadWarningCode ()
 Read the current warning code from the Delta MS3000 VFD Warning_Alarm register.
Delta IsAlarmActive ()
 Check whether a Delta MS3000 VFD alarm is currently active.
Delta CheckForAlarms ()
 Check for active alarms on the Delta MS3000 VFD and create GMS alarm notifications.
Delta ReadWarnings ()
 Read and process warning codes from the Delta MS3000 VFD (stub).
Delta AutoTune ()
 Stop Delta VFD auto-tune if it is currently active.

Function Documentation

◆ Add()

VFD VFDCollection Add ( )

Add a VFD object to the collection.

Appends the provided VFD instance to the internal vfds array using table.insert(). The added VFD will be included in all subsequent collection-wide operations such as Update(), StopMotor(), ResetAlarms(), and DoAll().

Parameters
vfd(table) The VFD object to add to the collection
Note
Documentation generated by AI on 2026-03-03

◆ AutoTune()

Delta AutoTune ( )

Stop Delta VFD auto-tune if it is currently active.

Checks whether the Delta-05-00_0 OEM parameter is non-zero (indicating auto-tune is active). If so, waits 150 ms for the spindle to start, then writes 0 to both the OEM parameter and the modbus register "05-00" to disable auto-tune. Raises an error via w.Error() if either register write fails.

Note
This function uses an undeclared variable 'b' and 'c' from the outer scope when checking the OEM parameter write result; a bug exists where the local write result is not captured
Documentation generated by AI on 2026-03-03

◆ CheckForAlarms()

Hitachi CheckForAlarms ( )

Check for active alarms on the Delta MS3000 VFD and create GMS alarm notifications.

Check for active alarms on the Hitachi VFD and create GMS alarm notifications.

Check for active alarms on the Yaskawa VFD and create GMS alarm notifications.

Reads the alarm code via ReadAlarmCode() and compares it to the last known error code. If a new alarm is detected (and it is not the ignored "Safety torque off (STo)" alarm code 76), looks up the description in the ErrorCodes table and creates a GMS Alarm notification with instructions for clearing the fault. The motor is stopped when an alarm is detected. The LastErrorCode field is updated after each check regardless of alarm state.

Warning
This function stops the motor when a new alarm is detected
Note
Alarm code 76 ("Safety torque off") is explicitly ignored and will not trigger a GMS alarm
Documentation generated by AI on 2026-03-03

Performs two independent checks. First, if the motor is marked as running, it verifies the Drive_Ready signal is still asserted; if not, creates a GMS Alarm for lost ready signal and stops the motor. Second, reads the alarm code via ReadAlarmCode(). If a new alarm is detected, looks up the description in the ErrorCodes table and creates a GMS Alarm notification, then stops the motor and records the alarm code in LastErrorCode.

Warning
This function stops the motor when an alarm or lost-ready condition is detected
Note
Alarm codes use the format '<signal_number>.<hex_bit>' as keys into the ErrorCodes table
Documentation generated by AI on 2026-03-03

Performs several checks in sequence: first verifies control is enabled, then checks for a base frequency error on the modbus function5 channel (restarting it if needed), then checks if an alarm is currently active via IsAlarmActive(). If a new alarm is detected and not already acknowledged, it reads the alarm code, looks up the description in the ErrorCodes table, collects trip diagnostic data (output frequency, current, voltage, LAD state, trip count), and creates a GMS Alarm notification. The motor is stopped when an alarm is detected.

Warning
This function stops the motor when an alarm is detected. It also restarts the modbus function5 polling channel if a base frequency error is found.
Note
Documentation generated by AI on 2026-03-03

◆ Cleanup()

VFD Cleanup ( )

Clean up all resources associated with this VFD instance.

Calls CleanupCommonControls() to remove any auxiliary spindle control registers and I/O points that were created for this VFD device. Intended to be called when a VFD instance is being torn down or when the VFD is found to be disabled during initialization.

Note
Documentation generated by AI on 2026-03-03

◆ CleanupCommonControls()

VFD CleanupCommonControls ( )

Remove all auxiliary spindle control registers and I/O points for the VFD device.

If ControlSource is "Auxiliary", retrieves the spindle control object list via GetSpindleControlObjects() and then removes each register and each I/O point from the VFD auxiliary device using w.RemoveRegister() and w.RemoveIO(). Logs each removal operation. Does nothing if ControlSource is not "Auxiliary".

Note
Documentation generated by AI on 2026-03-03

◆ Create() [1/2]

VFD VFDCollection Create ( )

Create and return an empty VFD collection object.

Instantiates a new VFDCollection object using Lua metatables and initializes its internal vfds array to an empty table. The returned collection can be populated using Add() and then operated on using Update(), StopMotor(), ResetAlarms(), and DoAll().

Returns
(table) A new empty VFDCollection instance
Note
Documentation generated by AI on 2026-03-03

◆ Create() [2/2]

Hitachi Create ( vfd_instance ,
vfd_cleanup  )

Create and initialize a Delta MS3000 VFD object.

Create and initialize a Hitachi P1 VFD object.

Create and initialize a Yaskawa V1000 VFD object.

Instantiates a new Delta VFD object using Lua metatables. Reads all Mach-configurable string parameters (control enable, modbus names, control source, etc.) from OEM parameters using the instance suffix. If vfd_cleanup is true, returns immediately after reading basic parameters for cleanup purposes without creating spindle controls or writing to the drive.

When fully initializing, the function:

  • Creates spindle control registers and I/O via CreateSpindleControls()
  • Reads VFD-configurable numeric parameters (frequency limits, accel/decel times, etc.) scaled by their respective gain values from OEM parameters
  • Writes all configurable parameters to the drive via modbus registers
  • Sets motor_max_frequency from Delta-01-00 and motor_min_frequency from Delta-01-07
  • Writes fixed default parameters (00-20, 00-21, 02-16, 02-17, 09-30) to the drive
  • Initializes the full ErrorCodes lookup table (codes 0-144)
  • Sets CommandedRPM and CommandedDirection to nil
    Parameters
    mach_instance(number) The Mach4 instance handle
    vfd_instance(number) The VFD instance index (0-based, used to suffix OEM parameter names)
    vfd_cleanup(boolean|nil) If true, perform minimal initialization for cleanup only
    Returns
    (table) The initialized Delta VFD object with all parameters and state fields set
    Warning
    Raises an error via w.Error() if any OEM parameter read or modbus register write fails
    Note
    Documentation generated by AI on 2026-03-03
    Instantiates a new Yaskawa VFD object using Lua metatables. Reads all Mach-configurable string parameters (control enable, modbus names, control source, command type, drive capacity, etc.) from OEM parameters using the instance suffix. If vfd_cleanup is true, returns immediately after reading basic parameters for cleanup purposes without creating spindle controls or writing to the drive.

When fully initializing, the function:

  • Creates spindle control registers and I/O via CreateSpindleControls()
  • Applies a capacity_gain multiplier (100.0 for Small, 10.0 for Large) to current-related parameters
  • Reads VFD-configurable numeric parameters (frequency limits, voltage, current, pole count, accel/decel times, decel selection) scaled by their respective gain values
  • Writes all configurable parameters to the drive via modbus registers
  • Writes fixed default parameters (b1-01 through F6-14) to the drive
  • Sets motor_max_frequency from E1-04 with special scaling for Large drive capacity
  • Sets motor_min_frequency from E1-09
  • Initializes the full ErrorCodes lookup table keyed by '<signal_number>.<hex_bit>' strings
    Parameters
    mach_instance(number) The Mach4 instance handle
    vfd_instance(number) The VFD instance index (0-based, used to suffix OEM parameter names)
    vfd_cleanup(boolean|nil) If true, perform minimal initialization for cleanup only
    Returns
    (table) The initialized Yaskawa VFD object with all parameters and state fields set
    Warning
    Raises an error via w.Error() if any OEM parameter read or modbus register write fails
    Note
    Documentation generated by AI on 2026-03-03
    Instantiates a new Hitachi VFD object using Lua metatables. Reads all Mach-configurable string parameters (control enable, modbus names, control source, etc.) from OEM parameters using the instance suffix. If vfd_cleanup is true, returns immediately after reading basic parameters for cleanup purposes without creating spindle controls or writing to the drive.

When fully initializing, the function:

  • Creates spindle control registers and I/O via CreateSpindleControls()
  • Reads VFD-configurable numeric parameters (motor ratings, frequency limits, accel/decel times) with special handling for the Hb103 pole count (string-to-index conversion)
  • Writes all configurable parameters to the drive via modbus registers
  • Writes fixed default parameters (AA101, AA111, CC-01, CC-02, CC-07) to the drive
  • Sets motor_max_frequency and motor_min_frequency from Hb105 and Hb130 parameters
  • Initializes the full ErrorCodes lookup table (E001-E112)
    Parameters
    mach_instance(number) The Mach4 instance handle
    vfd_instance(number) The VFD instance index (0-based, used to suffix OEM parameter names)
    vfd_cleanup(boolean|nil) If true, perform minimal initialization for cleanup only
    Returns
    (table) The initialized Hitachi VFD object with all parameters and state fields set
    Warning
    Raises an error via w.Error() if any OEM parameter read or modbus register write fails
    Note
    Documentation generated by AI on 2026-03-03

◆ CreateSpindleControls()

VFD CreateSpindleControls ( )

Create spindle control registers and I/O outputs for the VFD device.

Creates all registers and I/O points needed for spindle control by iterating over the SpindleControls table populated by GetSpindleControlObjects(). Always creates Standard_Registers (e.g., Feedback_Load) as permanent registers. If ControlSource is "Auxiliary", additionally creates Registers (Command_RPM, Feedback_RPM) and I/O outputs (FWD, REV) as permanent objects on the VFD auxiliary device. Raises an error via w.Error() if any register or I/O creation fails.

Note
Documentation generated by AI on 2026-03-03

◆ CreateVFDs()

VFD CreateVFDs ( )

Instantiate and return all enabled VFD objects for the current machine configuration.

Reads OEM parameters to determine which VFD types and instances are enabled, then creates and collects the appropriate VFD subclass objects. Iterates instances 0-2 for each supported VFD type (DeltaMS3000, YaskawaV1000, Hitachi). For each instance, if the corresponding ControlEnabled OEM parameter is "Yes", the VFD is created and added to the collection. If not enabled, a temporary object is created and immediately cleaned up to remove any stale registers or I/O. Stops iteration for a given type as soon as a missing OEM parameter is detected.

Parameters
mach_instance(number) The Mach4 instance handle passed to each VFD constructor
Returns
(table) A VFDCollection object containing all enabled and initialized VFD instances
Note
Documentation generated by AI on 2026-03-03

◆ DoAll()

VFD VFDCollection DoAll ( ...)

Call a named member function on every VFD in the collection.

Iterates over all VFD objects in the collection and calls the method identified by fn_name on each one, forwarding all additional arguments via varargs. Useful for broadcasting any arbitrary operation to all managed VFD instances without requiring a dedicated forwarding method on VFDCollection.

Parameters
fn_name(string) The name of the method to call on each VFD object
...(any) Additional arguments forwarded to each VFD method call
Note
Documentation generated by AI on 2026-03-03

◆ GetActualMotorLoadFeedbackPercentage()

Hitachi GetActualMotorLoadFeedbackPercentage ( )

Get the actual motor load feedback percentage (base VFD implementation).

Get the actual motor load feedback as a percentage for the Hitachi VFD.

Get the actual motor load feedback as a percentage for the Yaskawa VFD.

Base class implementation that always returns 0. Subclasses (Delta, Yaskawa, Hitachi) override this method to return actual load data read from the VFD monitoring registers.

Returns
(number) Always returns 0 in the base implementation
Note
Documentation generated by AI on 2026-03-03

Reads the Output_Current register from the monitoring modbus device. The rated current reference (Yaskawa-E2-01) is halved for Small drive capacity to match the register scaling. The actual current is then scaled from [0, max_load] to [0, 100] to produce a load percentage. Returns the absolute value to handle any sign issues.

Returns
(number) The actual motor load as a percentage (0-100), always non-negative
Note
For Small drive capacity, the rated current is divided by 10 before scaling
Documentation generated by AI on 2026-03-03

Reads the Output_Current_Monitor register from the monitoring modbus device and scales it from 0 to the motor rated current (Hitachi-Hb108 parameter) to produce a load percentage from 0 to 100. Returns the absolute value to handle any sign issues.

Returns
(number) The actual motor load as a percentage (0-100), always non-negative
Note
Documentation generated by AI on 2026-03-03

◆ GetActualMotorRPMFeedback()

Hitachi GetActualMotorRPMFeedback ( )

Get the actual motor RPM feedback from the Delta MS3000 VFD.

Get the actual motor RPM feedback from the Hitachi VFD output frequency.

Get the actual motor RPM feedback from the Yaskawa VFD output frequency.

Reads the Motor_Speed_In_RPM_Estimated register from the monitoring modbus device (ModbusName_MON). Returns the absolute value of the register reading to handle reverse rotation.

Returns
(number) The estimated actual motor RPM, always non-negative
Note
Documentation generated by AI on 2026-03-03

Reads the Output_Frequencey (sic) register from the monitoring modbus device. Scales the output frequency to RPM using either the CommandTypeMaxValue (for Percentage command type) or motor_max_frequency (for Frequency command type) as the input range, mapping to [0, max_rpm]. Returns the absolute value to handle reverse rotation.

Returns
(number) The estimated actual motor RPM, always non-negative
Note
The source register name contains a typo ('Output_Frequencey') matching the modbus device definition
Documentation generated by AI on 2026-03-03

Reads the Output_Frequency_Monitor register from the monitoring modbus device, then scales it from the range [0, motor_max_frequency] to [0, max_rpm] to compute the estimated motor RPM. Returns the absolute value to handle reverse rotation.

Returns
(number) The estimated actual motor RPM, always non-negative
Note
Documentation generated by AI on 2026-03-03

◆ GetCommandedMotorDirection()

VFD GetCommandedMotorDirection ( )

Get the commanded motor direction from Mach4 or auxiliary I/O.

Determines the commanded spindle direction from one of two sources depending on the configured ControlSource. If ControlSource is "Mach", reads the spindle direction via mc.mcSpindleGetDirection() and applies the pulley reverse flag from mc.mcSpindleGetReverse() to invert the direction if needed. If ControlSource is "Auxiliary", reads the FWD and REV I/O states from the VFD device to determine direction. Raises an error via w.Error() if any API call or I/O read fails.

Returns
(number) Direction value: 1 for forward, -1 for reverse, 0 for stopped
Note
Documentation generated by AI on 2026-03-03

◆ GetCommandedMotorRPM()

VFD GetCommandedMotorRPM ( )

Get the commanded motor RPM from Mach4 or auxiliary control register.

Retrieves the commanded spindle RPM from one of two sources depending on the configured ControlSource. If ControlSource is "Mach", reads the motor RPM via mc.mcSpindleGetMotorRPM() and applies Spindle Speed Variation (SSV) via GetSSVRPM(). If ControlSource is "Auxiliary", reads the Command_RPM register from the VFD device; if the ControlSourceCommandType is "Percentage", scales the percentage value to RPM using GetMaxMotorRPM() as the upper bound. Raises an error via w.Error() if any API call or register read or scale operation fails.

Returns
(number) The commanded motor speed in RPM
Note
Documentation generated by AI on 2026-03-03

◆ GetMaxMotorRPM()

VFD GetMaxMotorRPM ( )

Get the maximum motor RPM from Mach4 spindle settings or auxiliary OEM parameter.

Retrieves the maximum motor RPM from one of two sources depending on the configured ControlSource. If ControlSource is "Mach", reads the motor max RPM via mc.mcSpindleGetMotorMaxRPM(). If ControlSource is "Auxiliary", reads the AuxiliaryControlMaxRPM OEM parameter value directly. Raises an error via w.Error() if the Mach4 API call fails.

Returns
(number) The maximum motor RPM for the current control source configuration
Note
Documentation generated by AI on 2026-03-03

◆ GetSpindleControlObjects()

VFD GetSpindleControlObjects ( )

Return the table defining all spindle control register and I/O point names.

Constructs and returns a table with three subtables describing the objects used for spindle control:

  • Registers: Command_RPM, Feedback_RPM (used when ControlSource is "Auxiliary")
  • IO: FWD, REV (used when ControlSource is "Auxiliary")
  • Standard_Registers: Feedback_Load (always created) This table is used by CreateSpindleControls() and CleanupCommonControls() to create or remove the appropriate objects on the VFD device.
    Returns
    (table) Table with keys 'Registers', 'IO', and 'Standard_Registers', each containing an array of tables with a 'Name' key
    Note
    Documentation generated by AI on 2026-03-03

◆ GetSSVRPM()

VFD GetSSVRPM ( )

Compute the commanded spindle RPM with Spindle Speed Variation (SSV) applied.

Reads OEM parameters 1940 (SSV enable), 1941 (SSV amplitude in RPM), and 1942 (SSV interval/frequency) to determine whether SSV mode should be active. If SSV is enabled and the spindle is running (CommandedDirection != 0) with valid amplitude and interval values, activates SSV mode and applies a sinusoidal variation to the commanded speed: new_rpm = amplitude * sin(period * elapsed_time) + cmd_speed The result is clamped to the current range's [min_speed, max_speed] limits. If SSV conditions are no longer met, deactivates SSV mode and returns the original cmd_speed.

Parameters
cmd_speed(number) The base commanded spindle speed in RPM before SSV is applied
Returns
(number) The SSV-modulated RPM if SSV is active, or cmd_speed unchanged if SSV is inactive
Note
SSV state (SpindleSSVMode, SpindleSSVStartTime) is stored as VFD class-level static variables
Documentation generated by AI on 2026-03-03

◆ IsAlarmActive()

Hitachi IsAlarmActive ( )

Check whether a Delta MS3000 VFD alarm is currently active.

Check whether a Hitachi VFD alarm is currently active.

Check whether a Yaskawa VFD alarm is currently active.

Calls ReadAlarmCode() and returns true if the alarm code is greater than zero and is not equal to 76 (the "Safety torque off (STo)" alarm, which is intentionally ignored). Returns early without a meaningful value if control is not enabled.

Returns
(boolean) True if an alarm is active, false if no alarm is present
Note
Alarm code 76 ("Safety torque off") is explicitly ignored
Documentation generated by AI on 2026-03-03

Calls ReadAlarmCode() and returns true if any alarm code is present (non-nil). Returns early without a meaningful value if control is not enabled.

Returns
(boolean) True if an alarm code is active, false if no alarm is present
Note
Documentation generated by AI on 2026-03-03

Reads the Output_Terminal_AL I/O state from the VFD modbus device to determine if an alarm (fault) condition is present. Returns early without a meaningful value if control is not enabled.

Returns
(boolean) True if an alarm is active, false if no alarm is present
Note
Documentation generated by AI on 2026-03-03

◆ ReadAlarmCode()

Hitachi ReadAlarmCode ( )

Read the current alarm code from the Delta MS3000 VFD Warning_Alarm register.

Read the current alarm code from the Hitachi VFD trip monitor.

Read the current alarm code from the Yaskawa VFD error signal registers.

Reads the combined Warning_Alarm register from the monitoring modbus device. The lower 8 bits (masked with 0xFF) contain the alarm code and the upper bits contain the warning code. Extracts and returns only the alarm code (lower byte).

Returns
(number) The alarm code extracted from the lower byte of the Warning_Alarm register
Note
Documentation generated by AI on 2026-03-03

Reads three error signal registers (Error_Signal_1, Error_Signal_2, Error_Signal_3) from the monitoring modbus device. For each non-zero word, scans bits 0-15 to find the first set bit and returns a formatted key string in the form '<signal_number>.<hex_bit>' (e.g., '1.5', '2.A') that indexes into the Yaskawa.ErrorCodes table. Returns nil if all three error signal registers are zero (no alarm).

Returns
(string|nil) Alarm code key string in format '<set>.<hex_bit>', or nil if no alarm is active
Note
Documentation generated by AI on 2026-03-03

Starts the modbus function1 polling cycle, reads the Trip_Monitor_1_Factor register from the monitoring modbus device to obtain the active fault code, then stops the function1 polling cycle. The returned code is a numeric key into the Hitachi.ErrorCodes table. Returns nil if no alarm is present.

Returns
(number|nil) The numeric alarm code from the trip monitor, or nil if no alarm is active
Note
Documentation generated by AI on 2026-03-03

◆ ReadWarningCode()

Delta ReadWarningCode ( )

Read the current warning code from the Delta MS3000 VFD Warning_Alarm register.

Reads the combined Warning_Alarm register from the monitoring modbus device. The lower 8 bits contain the alarm code and the upper bits contain the warning code. Extracts and returns only the warning code (upper byte, shifted right by 8 bits).

Returns
(number) The warning code extracted from the upper byte of the Warning_Alarm register
Note
Documentation generated by AI on 2026-03-03

◆ ReadWarnings()

Hitachi ReadWarnings ( )

Read and process warning codes from the Delta MS3000 VFD (stub).

Read and log warning codes from the Hitachi VFD (currently disabled).

Read and process warning codes from the Yaskawa VFD.

This function is currently a stub. It checks the DeltaControlEnabled_0 OEM parameter and returns immediately if control is not enabled. No warning data is read or processed. Intended to be expanded in a future implementation.

Note
This function performs no action in its current state
Documentation generated by AI on 2026-03-03

Reads the Operation_Error I/O state from the VFD modbus device. If a new warning is detected (different from LastWarningCode), creates a GMS Warning notification with corrective action text explaining the oPE error and steps to identify the conflicting parameter. The LastWarningCode is updated after each call regardless of whether a warning was active.

Note
This function does nothing if ControlEnabled is not "Yes"
Documentation generated by AI on 2026-03-03

This function is currently disabled via an early return and performs no action. When enabled, it reads the Operation_Error I/O state from the VFD modbus device and, if a new warning is detected, creates a Global Message System (GMS) warning with corrective action information. The LastWarningCode is updated after each call.

Note
This function returns immediately due to a hard-coded early exit at the top of the function body
Documentation generated by AI on 2026-03-03

◆ ResetAlarms()

VFD VFDCollection ResetAlarms ( )

Reset alarms on all VFD instances in the collection.

Reset active alarms on the Hitachi VFD.

Reset active alarms on the Yaskawa VFD.

Reset active alarms on the Delta MS3000 VFD.

Iterates over all VFD objects in the collection and calls ResetAlarms() on each one. Each VFD subclass implements its own alarm reset sequence, which may include pulsing reset registers or I/O outputs and displaying a blocking please-wait dialog.

Note
Documentation generated by AI on 2026-03-03

Checks whether an alarm is active via IsAlarmActive(). If so, clears the internal LastErrorCode state, pulses the Reset modbus register to value 2 and then back to 0, with a 6-second please-wait dialog in between to allow the drive time to reset.

Note
This function does nothing if ControlEnabled is not "Yes"
Warning
This function displays a blocking please-wait dialog for 6 seconds during the reset sequence
Note
Documentation generated by AI on 2026-03-03

Checks both IsAlarmActive() and the hardware Fault I/O signal. If either indicates a fault, pulses the Multi-Function_Input_4 I/O output true and then false, with a 6-second please-wait dialog in between to allow the drive time to reset. Clears the internal LastErrorCode state after the reset attempt.

Note
This function does nothing if ControlEnabled is not "Yes"
Warning
This function displays a blocking please-wait dialog for 6 seconds during the reset sequence
Note
Documentation generated by AI on 2026-03-03

First checks for a base frequency error on the modbus function5 channel and issues a Stop command to the modbus controller if found. If an alarm is active (via IsAlarmActive()), it pulses the Fault_Reset I/O output true and then false, with a 6-second please-wait dialog in between to allow the drive time to reset. Clears the internal LastErrorCode and AlarmActive state after the reset attempt.

Note
This function does nothing if ControlEnabled is not "Yes"
Warning
This function displays a blocking please-wait dialog for 6 seconds during the reset sequence
Note
Documentation generated by AI on 2026-03-03

◆ SetActualMotorLoadFeedbackPercentage()

VFD SetActualMotorLoadFeedbackPercentage ( )

Set the actual motor load feedback percentage in the standard feedback register.

Writes the provided load percentage value to the Standard_Registers Feedback_Load register on the VFD device. Only writes if the value is a non-nil number. Raises an error via w.Error() if the register write fails.

Parameters
load_pct(number) The motor load percentage to write (typically 0-100)
Note
Documentation generated by AI on 2026-03-03

◆ SetActualMotorRPMFeedback()

VFD SetActualMotorRPMFeedback ( )

Set the actual motor RPM feedback from VFD sensor data.

Writes the provided RPM value to the appropriate feedback destination depending on the configured ControlSource. If ControlSource is "Mach", calls mc.mcSpindleSetSensorRPM() to update the Mach4 spindle sensor RPM. Otherwise, writes the RPM value to the Feedback_RPM register on the VFD auxiliary device. Only writes if RPM is a non-nil number. Raises an error via w.Error() if the API call or register write fails.

Parameters
RPM(number) The actual motor RPM value to set as feedback
Note
Documentation generated by AI on 2026-03-03

◆ SetMotorRPM()

VFD SetMotorRPM ( )

Set the commanded motor frequency/percentage on the Delta VFD drive.

Updates the commanded motor speed only if the new RPM differs from the last commanded RPM. Converts the RPM value to either a percentage (scaled to CommandTypeMaxValue) or a frequency (scaled to motor_max_frequency) depending on the CommandType parameter. The computed frequency is clamped to [motor_min_frequency, motor_max_frequency] when using Frequency mode. Writes the resulting value to the "Frequency" modbus register on the VFD device. Raises an error via w.Error() if any scale or register write operation fails.

Parameters
RPM(number) The commanded motor speed in RPM to convert and write to the drive
Note
Documentation generated by AI on 2026-03-03

◆ StartMotorForward()

Hitachi StartMotorForward ( )

Start the Delta MS3000 VFD motor in the forward direction.

Start the Hitachi VFD motor in the forward direction.

Start the Yaskawa VFD motor in the forward direction.

Clears the Stop and Reverse I/O outputs, then sets Forward and Run I/O outputs to true on the VFD modbus device to command forward rotation. Also calls AutoTune() after issuing the run command. Raises an error via w.Error() if any I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Clears the Reverse I/O output and sets the Forward I/O output to true on the VFD modbus device to command forward rotation, then sets the motor_running flag to true. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Clears the Reverse I/O output and sets Run_Stop to true on the VFD modbus device to command forward rotation. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

◆ StartMotorReverse()

Hitachi StartMotorReverse ( )

Start the Delta MS3000 VFD motor in the reverse direction.

Start the Hitachi VFD motor in the reverse direction.

Start the Yaskawa VFD motor in the reverse direction.

Clears the Stop and Forward I/O outputs, then sets Reverse and Run I/O outputs to true on the VFD modbus device to command reverse rotation. Also calls AutoTune() after issuing the run command. Raises an error via w.Error() if any I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Clears the Forward I/O output and sets the Reverse I/O output to true on the VFD modbus device to command reverse rotation, then sets the motor_running flag to true. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Sets the Reverse I/O output to true and Run_Stop to true on the VFD modbus device to command reverse rotation. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

◆ StopMotor()

Hitachi StopMotor ( )

Stop the motor on all VFD instances in the collection.

Stop the Hitachi VFD motor.

Stop the Yaskawa VFD motor.

Stop the Delta MS3000 VFD motor.

Iterates over all VFD objects in the collection and calls StopMotor() on each one. Each VFD subclass implements its own motor stop sequence by writing the appropriate I/O outputs on the VFD modbus device.

Note
Documentation generated by AI on 2026-03-03

Sets the Run I/O output to false and the Stop I/O output to true on the VFD modbus device to command the motor to stop. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Sets both Forward and Reverse I/O outputs to false on the VFD modbus device to command the motor to stop, then sets the motor_running flag to false. Raises an error via w.Error() if either I/O write fails.

Note
Documentation generated by AI on 2026-03-03

Sets the Run_Stop I/O output to false on the VFD modbus device to command the motor to stop. Raises an error via w.Error() if the I/O write fails.

Note
Documentation generated by AI on 2026-03-03

◆ Update()

VFD Update ( )

Update all VFD instances in the collection.

Perform a full periodic update cycle for the VFD.

Iterates over all VFD objects in the collection and calls Update() on each one. Each VFD subclass Update() synchronizes commanded RPM, direction, RPM feedback, load feedback, alarms, and warnings with the current Mach4 or auxiliary control state.

Note
Documentation generated by AI on 2026-03-03

Called repeatedly to synchronize the VFD drive state with the commanded state from Mach4 or auxiliary controls. Performs the following steps in order:

  1. Returns immediately if Parameters, ControlEnabled, or ControlEnabled != "Yes"
  2. Reads the commanded RPM and calls SetMotorRPM()
  3. Reads the commanded direction and calls StartMotorForward(), StartMotorReverse(), or StopMotor() only if the direction has changed since the last update
  4. If UseRPMFeedback is "Yes", reads actual RPM feedback and writes it via SetActualMotorRPMFeedback()
  5. Reads and writes the actual motor load percentage via GetActualMotorLoadFeedbackPercentage() and SetActualMotorLoadFeedbackPercentage()
  6. Calls CheckForAlarms() and ReadWarnings()
    Note
    Documentation generated by AI on 2026-03-03