This plugin adds support for some VFD spindles via ModBus (RS485) and a spindle selection plugin.
VFD spindle support is enabled in my_machine.h by uncommenting \\#define VFD_SPINDLE
and changing the VFD spindle number to the desired type or -1
for all.
A list of supported VFDs and associated spindle numbers can be found here.
If all spindles or dual spindle is enabled the active spindle is configured by setting $395
.
Note that the setting value not the same as the VFD spindle number used in my_machine.h, either use a sender that supports grblHAL setting enumerations
for configuration or output a list with the $$=395
command to find the correct setting value.
If a single VFD spindle is added to the firmware its ModBus address is configured by setting $360
(default 1).
If more than one then the ModBus address is set by one of the following settings depending on the spindle number it is assigned to:
$476
- ModBus address of VFD bound to spindle 0, default 1. Available when spindle 0 is configured as a VFD spindle by $395
.
$477
- ModBus address of VFD bound to spindle 1, default 2. Available when spindle 1 is configured as a VFD spindle by $511
.
$478
- ModBus address of VFD bound to spindle 2, default 3. Available when spindle 2 is configured as a VFD spindle by $512
.
$479
- ModBus address of VFD bound to spindle 4, default 4. Available when spindle 3 is configured as a VFD spindle by $513
.
Setting $461
can be used to set the RPM to HZ relationship. Default value is 60
.
The MODVFD spindle uses different register values for the control and RPM functions. The functionality is similar to the VFDMODcomponent from LinuxCNC. The following settings are available:
$462
- Register for Run/stop, default value is 8192
.
$463
- Set Frequency Register, default value is 8193
.
$464
- Get Frequency Register, default value is 8451
.
$465
- Command word for CW, default value is 18
.
$466
- Command word for CCW, default value is 34
.
$467
- Command word for stop, default value is 1
.
$468
- RPM value multiplier for programming RPM, default value is 50
.
$469
- RPM value divider for programming RPM, default value is 60
.
$470
- RPM value multiplier for reading RPM, default value is 60
.
$471
- RPM value divider for reading RPM, default value is 100
.
Note
Settings for ModBus addresses requires a hard reset after changing spindle binding settings (see below) before becoming available.
*** Experimental, not tested in a machine ***
The stepper spindle binds to/claims the highest numbered axis > the Z-axis currently without hiding it from control by motion G-codes. Setting units for the bound axis are changed to step/rev, rev/min and rev/sec^2, note that some senders may show these in the settings UI, some may not.
Settings $30
(min. spindle speed) and $31
(max. spindle speed) is used to set the RPM range, but be aware that $31
will be capped by the max. rate set for the axis.
Since steps are used to control the motor the angular position can be calculated from the step count, thus this spindle can be used for spindle synced motion without adding an encoder. "at speed" fucntionality is also available.
Note
Keep settings within stepper motor specifications, avoid using high microstepping settings. Using a closed loop stepper may be advantageous.
Note
Some drivers use interrupts to generate steps, some use polling. If polling is used step generation might be jittery, especially at higher RPMs.
Additional spindles may be added by plugin code. If of a generic kind they might be added to this repo based on a pull request.
grblHAL can operate in three different spindle modes depending on compile time configuration:
-
Only a single spindle is allowed.
None of the settings or the M-code documented below is available. -
Up to 321 spindles can be added but only one of up to four1 can be active at a time. Spindle switching is by tool number (see below) or
M104
:
UseM104P0
andM104P1
to set the active spindle as spindle number 0 or 1 respectively.
UseM104Q<n>
where<n>
is the spindle number to set as the active spindle. -
Up to 32 spindles can be added and up to four can be active at a time.
The spindle to control is adressed by the$
gcode word followed by the spindle number, available for theS
,M3
,M4
,M5
,M51
,G33
,G76
,G96
andG97
gcode commands.
Spindle switching by tool number orM104
is not available in this mode.
Note
This mode is work in progress and functionality is not yet complete!
The spindles are dynamically assigned a spindle id at registration, starting from 0. $-settings are then used to tell grblHAL which are to be enabled, by spindle number.
$395
- bind spindle number 0 to the given spindle id. This setting is available when two or more spindles are added.
$511
- bind spindle number 1 to the given spindle id. This setting is available when two or more spindles are added.
$512
- bind spindle number 2 to the given spindle id. This setting is available when three or more spindles are added.
$513
- bind spindle number 3 to the given spindle id. This setting is available when four or more spindles are added.
Available spindles with spindle id, and spindle number if bound, can be listed by the $spindles
command. $$=<n>
where <n>
is a setting number above can be used for listing allowed values.
Note
$395
defaults to spindle id 0, this is normally the driver provided PWM spindle but can be another spindle if only one spindle can be registered. Spindle 0 cannot be disabled.
If the grblHAL is configured to handle only one active spindle at a time then $-settings can be used to assign a range of tool numbers to
each spindle number. The spindle is then activated on a M6T<n>
command where <n>
is the tool number.
$520
- lowest tool number for selecting spindle 0, ignored if 0 - normally leave at 0. If set > 0 tool numbers lower than the value will not cause a spindle change.
$521
- lowest tool number for selecting spindle 1, ignored if 0.
$522
- lowest tool number for selecting spindle 2, ignored if 0.
$523
- lowest tool number for selecting spindle 3, ignored if 0.
Tool number vs. spindle is checked from the highest to the lowest spindle number, if all are set to 0 no spindle change takes place.
Note
settings for tool number assignments requires a hard reset after changing spindle enable settings before becoming available.
Note
when switching between spindles any offset between the spindles must be handled by gcode commands, typically by applying an offset and moving the controlled point (tooltip) to the required position.
1 These numbers are defined by compile time configuration and can be lower.
Note
If laser mode is enabled by the $32
setting it will only be honoured if the current spindle is a PWM spindle capable of laser mode.
2025-01-07