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 CNC microscope, choose this type. It will not use any I/O. It will default to this type if no I/O is defined.

#define SPINDLE_TYPE SpindleType::NONE

SpindleType::PWM

#define SPINDLE_TYPE            SpindleType::PWM  // Required
#define SPINDLE_OUTPUT_PIN      GPIO_NUM_XX       // Required. This is the pin connected to the PWM input on the speed controller.
#define SPINDLE_ENABLE_PIN      GPIO_NUM_XX       // Optional. If you want a spindle enable signal.
#define SPINDLE_DIRECTION_PIN   GPIO_NUM_XX       // 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

#define SPINDLE_TYPE            SpindleType::RELAY // Required
#define SPINDLE_OUTPUT_PIN      GPIO_NUM_XX        // Required. This is the pin connected to the relay circuit.
#define SPINDLE_ENABLE_PIN      GPIO_NUM_XX        // Optional. If you want a spindle enable signal.
#define SPINDLE_DIRECTION_PIN   GPIO_NUM_XX        // Optional. If you want a spindle direction signal.

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.

#define SPINDLE_TYPE            SpindleType::LASER // Required
#define LASER_OUTPUT_PIN        GPIO_NUM_XX        // Required. This is the pin connected to the PWM input of the laser power controller.
#define LASER_ENABLE_PIN        GPIO_NUM_XX        // Optional. If you want an enable signal.

SpindleType::BESC

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.

Example machine definition

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