-
Notifications
You must be signed in to change notification settings - Fork 2
Spindle Types
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.
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
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.
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.
Many speed control circuits for spindles use a PWM signal to set the speed. Here are the things you need in your machine definition file.
- Required
#define SPINDLE_TYPE SpindleType::PWM
- Required
#define SPINDLE_OUTPUT_PIN GPIO_NUM_nn
where nn is the pin number. This is the pin connected to the PWM input on the speed controller. - Optional
#define SPINDLE _ENABLE_PIN GPIO_NUM_nn
If you want a spindle enable signal. - Optional
#define SPINDLE_DIRECTION_PIN GPIO_NUM_nn
if you want a direction signal. - $GCode/MaxS Maximum spindle speed. This value is used to match a PWM duty to the RPM you want. If you set this to 1000 and send S500, it will set the duty to 50%. If you send S1500, it will change clip your value to 1000.
- $GCode/MinS This is the the minimum RPM. If your spindle does not work well below 200 RPM, set $31=200. If you send an S value below 200, it will set the speed to 200.
- $Spindle/PWM/Frequency Spindle PWM Freq. This sets the frequency of the PWM signal.
- $Spindle/PWM/Off Spindle PWM Off Value. Typically set to 0. The PWM values are set in percentage of duty cycle.
- $Spindle/PWM/Min Spindle PWM Min Value Typically set to 0.
- $Spindle/PWM/Max Spindle PWM Max Value. Typically set to 100.
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.
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.
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