The Spindle is the main effector on your CNC Mill/Router. It holds the end mill or drill bit, makes it turn and remove material.
While manual control is sometimes fine ( turn it on before starting your G-code, off when you are done ), it is so much neater to have G-codes to control it automatically : simply put an ON G-code at the beginning of your G-code file, and a off G-code at the end of your G-code file, and you don't have to think about it any-more.
The spindle module supports different types of spindles which are described in the following subsections.
spindle.enable true # set this to false to disable the spindle module
Available G-code commands:
* M3 will start the spindle. M3 S5000 will start the spindle and set speed to 5000 RPM.
* M5 will stop the spindle. Last set RPM is remembered and used for next M3 command if S argument is not given.
* M957 will report the current spindle speed and PWM value. This returns not the actual value but the value that was set through M3.
* M958 will report the current PID parameters. M958 Px.xxx Ix.xxx Dx.xxx will set them (to save the new values, you need to edit config file manually).
=== PWM Spindle
spindle.type pwm # sets the spindle module to PWM mode
spindle.pwm_pin 2.5 # Big Mosfet Q7. Pin must be hardware PWM capable.
spindle.pwm_period 1000 # default 1000, sets the PWM frequency
spindle.feedback_pin 2.7 # Pin must be interrupt capable.
spindle.pulses_per_rev 1.0 # default 1. Defines the number of pulses occur for each rotation
spindle.default_rpm 5000 # default 5000. Defines a default RPM value in case no RPM value is provided.
spindle.control_P 0.1 # default 0.0001. P value for the PID controller
spindle.control_I 0.1 # default 0.0001. I value for the PID controller
spindle.control_D 0.1 # default 0.0001. D value for the PID controller
spindle.control_smoothing 0.1 # default 0.1. This value is low pass filter time constant in seconds.
switch.servo.enable true # Servo module for PWM control
switch.servo.output_pin 1.23o! # spare pin with PWM capability, 3.25 should also work from EXP2, maybe needed to set it to 1.23o!
#switch.servo.pwm_period_ms 20 #set PWM period to 20ms (50 Hz)
switch.servo.startup_state true # turn on the output to have neutral for ESC
switch.servo.startup_value 7.5 # this is default_off_value
spindle.type analog # set the spindle type to analog, can also be used for ESC spindles controlled by a PWM
spindle.max_rpm 24000 # set the max spindle speed that is achieved at 100% PWM
spindle.pwm_pin 2.4 # the pin which emits the PWM signal
spindle.pwm_period 1000 # the PWM frequency
spindle.switch_on_pin 2.6 # the pin which is used to enable the VFD (optional)
==== PWM to analog converter circuit
spindle.type modbus # set the spindle type to modbus/RS485 spindle.vfd_type huanyang # set the VFD type, this is necessary because each inverter uses its own commands spindle.rx_pin 2.6 # TX pin for the soft serial spindle.tx_pin 2.4 # RX pin for the soft serial spindle.dir_pin 2.5 # RS485 is only half-duplex, so we need a pin to switch between sending and receiving==== Huanyang VFD Modbus Parameters In order to get the Huanyang VFD accepting commands via ModBus, you need to change a few parameters: