Spindle Circuit - bdring/4_Axis_SPI_CNC GitHub Wiki

Spindle Circuit

The spindle circuit is designed to output 5V PWM, but can also be used for relay and laser control. It uses a TXS0101 chip to do the voltage level shifting from the ESP32 3.3V to 5V. Here is what that circuit looks like.

On the TXS0101 chip, the signal goes from 3.3V on (A) to 5V on (B). The TXS0101 has an output enable (OE) pin. This enables the output on (B). Without a signal on (OE), (B) will float with no determinate signal. The Grbl_ESP32 spindle enable signal is connected to that pin.

The (4) pin output connector has a set of interlock pins. The pins (1 & 2) must be connected together to get a signal to the PWM pin (3). These interlock pins can be used to externally disable the signal. You could run them through a door switch for example. You would connect the PWM (3) and Gnd (4) to your spindle or laser. This circuit assumes your device will not operate when there is no output on pin (3).

The TSX010 can pull low with about 50mA, but uses an internal 10k resistor to pull it high. This means you cannot use much of a pull down resistor anywhere in the circuit after the TXS0101.

PWM Setup

#define SPINDLE_TYPE SPINDLE_TYPE_PWM
#define SPINDLE_ENABLE_PIN GPIO_NUM_32
#define SPINDLE_OUTPUT_PIN GPIO_NUM_16

Basic Settings

  • $Spindle/Type=PWM
  • $Spindle/PWM/Frequency=5000
  • $Gcode/MaxS=12000 (The full speed out your spindle)
  • $Laser/Mode=Off

Relay Setup

#define SPINDLE_TYPE SPINDLE_TYPE_RELAY
#define SPINDLE_ENABLE_PIN GPIO_NUM_32
#define SPINDLE_OUTPUT_PIN GPIO_NUM_16

Settings

  • $Spindle/Type=Relay. This will insure the relay receive and on or off signal and not a PWM. Install the jump. The jumper should only be installed in relay mode.
  • All other spindle settings are ignored

Laser modules

Some laser modules will fire if they are not connected to a low signal. This is dangerous, because when the ESP32 is not on and functioning properly, the laser will fire. Also, if the spindle enable is not on, the laser will fire. Normal Grbl_ESP32 behavior is to turn on enable when the spindle is off

There is a fix to the spindle enable issue. If you add this to top of your machine definition file the spindle enable will stay on.

#define USE_MACHINE_INIT
#define LVL_SHIFT_ENABLE        GPIO_NUM_32
#define CUSTOM_CODE_FILENAME    "Custom/mpcnc_laser_module.cpp

Do not define a SPINDLE_ENABLE_PIN in your machine definition

Basic Settings

  • $Spindle/Type=Laser
  • $Spindle/PWM/Frequency=5000
  • $Gcode/MaxS=1000
  • $Laser/Mode=On

Note: In Laser Mode the PWM will not be present unless the machine is moving in G1 mode. This prevents burning between cuts.

Warning: The issue of the laser turning on if the ESP32 loses power or malfunctions still exists. Be sure to have a separate way to turn off the laser and never leave it unattended.