Fluid Spindle Setup - Longus/FluidNC GitHub Wiki

Spindles

FluidNC supports multiple spindles on one machine. Spindles can be controlled by different hardware interfaces like relays, PWM, DACs, or RS485 serial interfaces to VFDs. Lasers are treated as spindles.

Each spindle is assigned a range of tool numbers. You change spindles by issuing the GCode command "M6 Tn", where n is the tool number. Tool numbers within the assigned range for a given spindle will activate that spindle - and the detailed number within the range could be used to select the specific tool on the spindle. This lets you have, for example, a single machine with an ATC spindle and a laser. A single GCode file could allow you to etch and cutout a part. Most CAM programs support tool numbers. You could also have a gantry with both a low-speed high-torque pulley spindle and also a high-speed direct drive spindle.

List of spindles on this page

0-10V

0-10V control is designed for VFD type spindles that have a 0-10V control input. The signal out of FluidNC is PWM at the pin voltage (typically 3.3v). You must use an adapter to scale it to the voltage you need (typically 10V). The reason for this special case of PWM control is that the VFDs typically have a separate signal input for forward and reverse directions.

10V:
  forward_pin: gpio.13
  reverse_pin: gpio.17
  pwm_hz: 5000
  output_pin: gpio.4
  enable_pin: NO_PIN
  direction_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 0
  speed_map: 0=0.000% 1000=0.000% 24000=100.000%

BESC

The BESC spindle is designed for use with RC hobby type Brushless Electronic Speed Controllers. These use the same type of PWM signal as an RC servo. These typically only use one I/O pin, but other standard spindle pins can be used. The PWM signal ranges from a min value to a max value, so it is generally outputting at all times.

Special settings

  • pwm_hz: Most BESC use a 50Hz frequency. Some can go a little higher, but rarely more than 200.
  • min_pulse_us: This is the pulse length in microseconds used for spindle off. This can be used to fine tune the range.
  • max_pwm_us: This is the pulse length in microseconds used for max speed.
besc:
  pwm_hz: 50
  output_pin: gpio.4
  enable_pin: NO_PIN
  direction_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 100
  speed_map: 0=0.000% 0=20.000% 4000=20.000% 20000=100.000%
  min_pulse_us: 900
  max_pulse_us: 2200

DAC

The DAC uses the ESP32's build in DAC hardware. This can only be used on gpio.25 and gpio.26. It outputs a 0-3.3V analog voltage (not PWM). In most cases a PWM will be better. The DAC resolution is only 8bit (0-255) and a PWM can be up to 16bit (0-65535).

example

DAC:
  output_pin: gpio.25
  enable_pin: NO_PIN
  direction_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 100
  speed_map: 0=0.000% 255=100.000%

H2A (RS485)

Coming soon, The documentation team does not have one of these yet :-)

Huanyang (RS485)

This is the standard Huanyang VFD (all power levels). Part numbers start with Hy, like HY02D223B-T. The control is via RS485.

The VFD registers need to be setup prior to use. FluidNC will not change any of the registers. Read your VDF documentation on how to do that. Here are some typical values that work for most spindles.

Register Value Description
PD001 2 RS485 Control of run command
PD002 2 RS485 Control of frequency
PD004 400 Base frequency as rated on spindle
PD005 400 Maximum frequency Hz (400Hz * 60sec/min = 24000rpm)
PD011 100 Minimum speed in Hz (Typ. Air cooled 120, Water cooled 100)
PD014 6 Acceleration time in seconds
PD015 6 Deceleration time
PD023 1 Enable reverse
PD141 220 Spindle Voltage
PD142 3.7 Max current (typ. 0.8kw=3.7)
PD143 2 Poles
PD144 3000 Revolutions at 50Hz
PD163 1 RS485 Modbus address
PD164 1 Baud rate of 9600
PD165 3 RS485 Mode RTU, *N!

The min and max speeds set in the VFD will be displayed in the startup messages. They might be spread out through the messages, because they are coming from a separate task.

[MSG:INFO: VFD: Max speed:24000rpm]
[MSG:INFO: VFD: Min speed:6000rpm]

A minimum speed is typical with VFD spindles because they lack power and can overheat at lower speeds. A good speed linearization setting for the values above would be...

speed_map: 0=0% 0=25% 6000=25% 24000=100%

The minimum speed of 6000 is 25% of the max speed of 24000. This setting would mean all values between 0-6000 would still result in 6000 RPM.

Check your RS485 adapter documentation for proper wiring methods and connections. Here is some information on the RS485 module.

Huanyang:
  uart:
    txd_pin: gpio.26
    rxd_pin: gpio.16
    rts_pin: gpio.4
    baud: 9600
    mode: 8N1
  modbus_id: 1
  tool_num: 0
  speed_map: 0=0% 0=25% 6000=25% 24000=100%

Important notes The VFD provides feedback to FluidNC. We use this to make sure the spindle is running at the right speed. If it is not running at the speed requested, it will shut down with an alarm after a few seconds. This could be due to many reasons. One reason is that the Haunyang VFD has a max and min frequency setting. If you request a speed lower than the min it will run at the minimum. The same condition applies to the maximum. Therefore, if you request a speed above 0, but outside the range. The reported speed will not match your requested speed and will shut down. You will get a warning message at the serial console why this is happening. This issue can be fixed by using the correct type of speed_map.

YL620 (RS485)

Coming soon, The documentation team does not have one of these yet :-)

Laser

Laser is considered a spindle because gcode does not have laser specific codes. It uses the RPM value as a power level. Lasers also have special requirements. They must turn off when the machine is idle or doing a rapid move.

  • speed_map: final xxx=100% can be whatever you want, but it is typically 255 or 1000. This would need to be used in the CAM software as the max power number.
Laser:
  pwm_hz: 5000
  output_pin: gpio.4
  enable_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  tool_num: 0
  speed_map: 0=0.000% 255=100.000%

NoSpindle

This is automatically created if you did not specify a spindle in your config file.

Relay

This is like a PWM signal except that the pin will be full on for any speed above 0 that you select. PWM signals can quickly destroy a relay.

relay:
  output_pin: gpio.4
  enable_pin: NO_PIN
  direction_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 100
  speed_map: 0=0.000% 0=100.000%

PWM

The M4 (spindle reverse on) command will only be accepted if a direction pin is assigned to an I/O pin.

PWM:
  pwm_hz: 5000
  output_pin: gpio.2
  enable_pin: gpio.22
  direction_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 0
  spindown_ms: 0
  tool_num: 0
  speed_map: 0=0% 10000=100%

Troubleshooting

  • I get Error 20 Unsupported command for M4 M4 will only work on spindles that support reversing or lasers. If there is a direction pin for the spindle type you are using it must be assigned a pin