Skip to content

Spindle Types

Nikos Siatras edited this page Jan 8, 2023 · 3 revisions

Overview

Spindles in Rabbit GRBL, like in Grbl_ESP32 are coded a lot differently from Grbl (Arduino). There are classes defined for each spindle type. This allows a simple method of creating new spindles and a standard interface for Grbl to work with. There are a lot of #defines and $$ settings for spindles. The spindle you use may only use a few of them. For example, if you are using a relay to control spindle, the RPM related settings are ignored. See below for details on each type

You can change between spindles types dynamically as long as all of the required I/O is defined in your machine definition. For example: You could have a spindle and a laser on the machine and switch between without recompiling or even rebooting.

How to define Spindle on Rabbit Grbl ?

Spindles are defined in your machine definition file with the #define SPINDLE_TYPE SpindleType::XXXXX statement.
If you don't define anything, it will default to a None spindle.

Spindle types supported by Rabbit Grbl:

#define SPINDLE_TYPE     SpindleType::NONE 
#define SPINDLE_TYPE     SpindleType::PWM
#define SPINDLE_TYPE     SpindleType::RELAY
#define SPINDLE_TYPE     SpindleType::LASER 
#define SPINDLE_TYPE     SpindleType::BESC

Spindle Settings

There are many settings for spindles. See below what settings are used for each spindle type. Settings that are not used by your spindle type will be show and can be changed, but are ignored. The spindle must be off (M5) to change any spindle setting. After changing the setting it will re-initialize your spindle.

SpindleType::NONE

If your machine does not require a spindle, like a pen plotter, choose this type. #define SPINDLE_TYPE SpindleType::NONE It will not use any I/O. It will default to this type if no I/O is defined.

SpindleType::PWM

#define SPINDLE_TYPE            SpindleType::PWM  // Required
#define SPINDLE_OUTPUT_PIN      GPIO_NUM_21       // Required. This is the pin connected to the PWM input on the speed controller.
#define SPINDLE_ENABLE_PIN      GPIO_NUM_2        // Optional. If you want a spindle enable signal.
#define SPINDLE_DIRECTION_PIN   GPIO_NUM_22       // Optional. If you want a spindle direction signal.
#define DEFAULT_SPINDLE_FREQ 	1000              // Optional. If you want a to set the maximum frequency of the Spindle PWM (Default is 5000hz).

SpindleType::RELAY

If you are using a relay to turn on your spindle, you only want an on/off signal. an accidental PWM signal could destroy the relay. The ESP32 does not have enough current to directly drive a relay. You should use a driver circuit for that. Here are the settings you need in your machine definition file.

  • Required #define SPINDLE_TYPE SpindleType::RELAY
  • Required #define SPINDLE_OUTPUT_PIN GPIO_NUM_nn where nn is the pin number. This is the pin connected to the relay circuit.
  • Optional #define SPINDLE _ENABLE_PIN GPIO_NUM_nn If you want an enable signal.
  • Optional #define SPINDLE_DIRECTION_PIN GPIO_NUM_nn if you want a direction signal.

Because it is an on/off signal most of the $$ spindle settings will be ignored.

SpindleType::LASER

A laser is basically a PWM spindle with a few extra features. You want it to turn off when the machine is doing a rapid move or is paused. It can also do a speed compensation feature. If you are engraving you want the laser to proportionally reduce the power when it is accelerating or decelerating. Use the M4 command, normally used for counter clockwise rotation, to enable this feature.

  • Optional #define SPINDLE_TYPE SpindleType::LASER
  • Required #define LASER_OUTPUT_PIN GPIO_NUM_nn where nn is the pin number.
  • Optional #define LASER_ENABLE_PIN GPIO_NUM_nn If you want an enable signal.
  • Most PWM Settings also apply
  • $GCode/LaserMode Set $GCode/LaserMode=1 for laser mode
  • $Laser/FullPower=nnnn. This sets the full power number used for the PWM. $Laser/FullPower=100 means your power range is 0-100.

SpindleType::BESC

Photo Credit

This is a RC type brushless DC speed controller. It uses a special PWM signal to control the speed of a motor. The motors are very strong, and low cost. The actual speed might not be very accurate though.

See this page for more details

Example machine definition

#define SPINDLE_TYPE            SpindleType::BESC
#define SPINDLE_OUTPUT_PIN      GPIO_NUM_26
Clone this wiki locally