-
-
Notifications
You must be signed in to change notification settings - Fork 555
Spindle Types
Spindles in Grbl_ESP32 are coded a lot differently in Grbl_ESP 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. Based on the spindle selected many of these may not be used. For example, if you are using a relay to control spindle, the RPM related settings are ignored. See below for details on each type
Note: Soon all spindle types and features will able to be changed dynamically without recompile.
The word spindle in Grbl can mean many things. Standard gcode does not support things like lasers, so Grbl_ESP32 uses the M3 (spindle on clockwise) , M4 (spindle on counter clockwise), M5 (spindle off) and Snnnnn (set rpm to nnnnn) to control a lot of tools. These can be On/Off relay based spindles, PWM speed controlled spindles, RC type brushless speed controllers, RS485 VFDs, lasers and more. We could easily add additional things like hot wire and other things.
Note: Currently when you see RPM anywhere, it is referring to the gcode Snnnnn value. When used for lasers, etc it might mean something different. Just think of it as the proportional power power of the tool you are using.
Spindles are defined in your machine definition file. The I/O pins you need to define depends on the spindle type you choose. The spindle type is selected by a #define SPINDLE_TYPE xxxx
statement. Grbl_ESP32 will default to #define SPINDLE_TYPE SPINDLE_TYPE_PWM
which is the most common type. Here are the current types allowed.
- #define SPINDLE_TYPE SPINDLE_TYPE_NONE
- #define SPINDLE_TYPE SPINDLE_TYPE_PWM
- #define SPINDLE_TYPE SPINDLE_TYPE_RELAY
- #define SPINDLE_TYPE SPINDLE_TYPE_LASER
- #define SPINDLE_TYPE SPINDLE_TYPE_DAC
- #define SPINDLE_TYPE SPINDLE_TYPE_HUANYANG
- #define SPINDLE_TYPE SPINDLE_TYPE_BESC
When Grbl_ESP32 boots, it will send some messages to the USB/Serial port. It will tell you what spindle type was defined. If there are any pin definitions missing from from your machine definition file, it will send error messages about that too.
Below are the details for each spindle type.
If your machine does not require a spindle, like a pen plotter, choose this type. #define SPINDLE_TYPE SPINDLE_TYPE_NONE
It will not use any I/O.
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 SPIDLE_TYPE SPINDLE_TYPE_RELAY
- 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. - $30 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.
- $31 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.
- $33 Spindle PWM Freq. This sets the frequency of the PWM signal.
- $34 Spindle PWM Off Value. Typically set to 0. The PWM values are set in percentage of duty cycle.
- $35 Spindle PWM Min Value Typically set to 0.
- $36 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 SPIDLE_TYPE SPINDLE_TYPE_PWM
- 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.
- Required
#define SPIDLE_TYPE SPINDLE_TYPE_LASER
- Required
#define SPINDLE_PWM_PIN GPIO_NUM_nn
where nn is the pin number. - Optional
#define SPINDLE _ENABLE_PIN GPIO_NUM_nn
If you want an enable signal. - $30, $31,$33, $34 $35, $36 See PWM spindle
- $32 Laser mode. Set $32=1 for laser mode
Some spindle speed controller have an analog input. This mode uses the DAC (digital to analog) on the ESP32 to output an analog signal. You will probably need to run the output through an opamp to amplify the ESP32's 0-3.3V range to the 0-5V or 0-10V range the speed controller needs.
- Required
#define SPIDLE_TYPE SPINDLE_TYPE_DAC
- 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. - $30, $31 See PWM mode
- $33,$34 and $35 Do not apply.
This spindle mode talks to a Huanyang VFD (a very popular Chinese VFD) using an RS485 serial connection. It can control the speed and which direction the spindle should turn. The ESP32 can create the signals, but not the differential voltages required for the RS485. A 3.3V TTL to RS485 needs to be used. The MAX485CSA works well for this.
- Required
#define SPIDLE_TYPE SPINDLE_TYPE_PWM
- Required
#define HUANYANG_TXD_PIN GPIO_NUM_nn
This is the transmit data pin. - Optional
#define SPINDLE_RXD_PIN GPIO_NUM_nn
This is the receive data pin. - Optional
#define HUANYANG_RTS_PIN GPIO_NUM_nn
This pin controls whether data is being transmit or received. - $30 and $31. See PWM mode
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.
- Required
#define SPIDLE_TYPE SPINDLE_TYPE_LASER
- Required
#define SPINDLE_PWM_PIN GPIO_NUM_nn
where nn is the pin number. - $30 and $31 See PWM Mode
- Home
- Hardware
- ESP32 Dev Kit Versions
- Compiling with Arduino IDE
- Compiling with PlatformIO
- Using the Serial Port
- Grbl_ESP32 Settings
- Controlling Grbl_ESP32
- Setting Up the I/O pins
- Spindle Types
- Basic Kinematics
- Custom Machine Functions
- Home/Limit Switches
- Machine Work Space
- Stepper Motor Drivers
- Trinamic Drivers
- Axis Squaring and Ganging
- Settings
- SD Card
- Bluetooth
- Wifi
- WebUI
- Using Telnet
- Servo Axis
- Push notifications
- Switches
- Stepper Drivers
- Spindle options
- Other Ouputs
Testing public edit