-
-
Notifications
You must be signed in to change notification settings - Fork 532
Spindle and Laser Control
Grbl_Esp32 has a PWM output that can be used for spindle speed control or laser power control
The PWM feature uses a 80,000,000 clock. Typically you first select a base frequency for your PWM. After you determine that, you can determine what your duty cycle resolution (in bits) can be. Divide 80,000,000 by your frequency to see how many counts you have left. That remainder is what you can use for your duty cycle.
For example: If your base frequency is 5,000. 80,000,000 / 5,000 = 16,000. You need to select a resolution that is lower that that in bits. 13 bit resolution is 2^13 = 8192, which is the highest one you can use.
You typically need to define these (3) things in your machine definition file.
#define SPINDLE_PWM_PIN GPIO_NUM_27
#define SPINDLE_PWM_CHANNEL 0
#define SPINDLE_PWM_BIT_PRECISION 8 // be sure to match this with SPINDLE_PWM_MAX_VALUE
- $30: This is the max RPM. If this is set to 1000, any commanded speed of 1000 or greater will give 100% duty cycle (full speed)
- $31: This is the minimum RPM. This sets the range the PWM is mapped to. If min is 200 RPM and max is 1000 RPM, the range would be 800 RPM (1000-200), starting at 200 RPM. For 50% duty cycle it would be 600 RPM (200 + (800 * 0.5)).
- Note: Settings $32-$36 will not display with the $$ command unless you have a #define SHOW_EXTENDED_SETTINGS somewhere. This is because regular Grbl does not have these settings. You can set them in any mode with $XX=XXX.
- $32 This is the spindle PWM frequency. Default = 5000
- $33 This is the PWM off value as a percentage. Default = 0.0
- $34 This is the minimum PWM value as a percentage. Default = 0.0. Some spindles or lasers will not turn on at the minimum PWM duty cycle. They need a higher value. This is set in config.h. It is set in units of the PWM resolution. This will therefore cut into your usable resolution if you set this to 20 for example you will only have a 0 to 235 range (255-20) when using an 8 bit resolution.
- $36 This is the maximum PWM value as a percentage. Default = 100.0
If you want an On/Off signal rather than variable speed (PWM) output, you just change $30 (Maximum spindle speed) to 1. This means any requested RPM above 0 will output a 100% duty signal.
- $30=1
- $31=0
Laser mode activates several features. Use $32 to turn on and off laser mode.
- The laser will only fire during an active G1, G2 or G3 command. This means rapid moves between cuts will turn off the laser
- You can change speed on the fly without halting the move. This allows things like high speed laser engraving
- 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