Auto Router on/off

I followed an older post about switching the router on/off within the Gcode. I have a SSR hooked to pin 27 (mist) output on the board. It is functioning but requires using the M7 (on) and M9 (off) commands. Normally the M3/M5 Command would be used for this function. Is there a way to configure the board to switch an output pin using the M3/M5 command? Currently the M3 does not turn on any LEDs on the board.

I have not tried it, but you might look at the “Relay” section of the FluidNC Wiki “Spindle” page.

http://wiki.fluidnc.com/en/config/config_spindles

My config for relay is:-

Relay:
direction_pin: NO_PIN
output_pin: gpio.2
enable_pin: NO_PIN
disable_with_s0: false
s0_with_disable: true
spinup_ms: 2000
spindown_ms: 2000
tool_num: 0
speed_map: 0=0.00% 1000=100.00%
off_on_alarm: false
atc: atc_manual
m6_macro:

Make sure you set the correct output pin.

Does the M3 command start your spindle? The gpio .2 pin is configured for coolant on my board. The M8 Command turns on that PIN

My SSR is wired up to that pin so yeh.

I’m already using gpio.27 for laser so used gpio.2 as I don’t use coolant. There’s no hard and fast rule as to what pins to use for which function.

Did you add this to the config.yml file?

This change alone might not work with the rest of your config. Make sure you don’t already have a relay: section and also make sure that the pin you are using is not utilized anywhere else.

For instance the default config for thed Lowrider has:-

coolant:
  flood_pin: gpio.2
  mist_pin: gpio.16
  delay_ms: 0

As I don’t use coolant, to free up the pins I have:-

coolant: 
  flood_pin: NO_PIN
  mist_pin: NO_PIN
  delay_ms: 0

Does that make sense?

Yes makes sense. I’ve tried you advise, but when i add the relay: code I get an error. Is there a specific spot in the config to place the code?

What error are you getting? Do you want to paste the config?

You can’t just drop it in the middle of another bit of config. I guess I deal with yaml most days with work so I take it for granted but ideally should be in a section on it’s own and there just be one relay: section.

Do you know what version of fluidnc you are running?

Sure, thanks! When I get home from work I’ll post mine.

Here it is, the error message is “Undefined:” i’m using version 3.7.17. I only have the error when I added the relay:

board: Jackpot TMC2209
name: LowRider
meta: 03-15-2024 RyanZ

planner_blocks: 32

stepping:
  engine: I2S_STATIC
  idle_ms: 255
  pulse_us: 4
  dir_delay_us: 1
  disable_delay_us: 0

uart1:
  txd_pin: gpio.0
  rxd_pin: gpio.4
  rts_pin: NO_PIN
  baud: 115200
  mode: 8N1

axes:
  shared_stepper_disable_pin: NO_PIN

  x:
    steps_per_mm: 50.000
    max_rate_mm_per_min: 9000.000
    acceleration_mm_per_sec2: 200.000
    max_travel_mm: 1220
    soft_limits: false
    homing:
      cycle: 3
      positive_direction: false
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100
    #X
    motor0:
      limit_neg_pin: gpio.25:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 0
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        direction_pin: I2SO.1
        step_pin: I2SO.2
        disable_pin: I2SO.0

  y:
    steps_per_mm: 50.000
    max_rate_mm_per_min: 9000.000
    acceleration_mm_per_sec2: 200.000
    max_travel_mm: 2440
    soft_limits: false
    homing:
      cycle: 2
      positive_direction: false
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100
    #Y
    motor0:
      limit_neg_pin: gpio.33:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 1
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.5
        direction_pin: I2SO.4
        disable_pin: I2SO.7

    #A
    motor1:
      limit_neg_pin: gpio.35:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 3
        cs_pin: i2so.14
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.13
        direction_pin: I2SO.12
        disable_pin: I2SO.15

  z:
    steps_per_mm: 200.000
    max_rate_mm_per_min: 1200.000
    acceleration_mm_per_sec2: 80.000
    max_travel_mm: 300.000
    soft_limits: false
    homing:
      cycle: 1
      positive_direction: true
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 800.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.32:high
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 2
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.10
        direction_pin: I2SO.9
        disable_pin: I2SO.8

     #B
    motor1:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.34:high
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 3
        cs_pin: i2so.19
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.18
        direction_pin: I2SO.17
        disable_pin: I2SO.16

#  c:
#    steps_per_mm: 80.000
#    max_rate_mm_per_min: 5000.000
#    acceleration_mm_per_sec2: 100.000
#    max_travel_mm: 300.000
#    soft_limits: false
#    homing:
#      cycle: 0
#      positive_direction: true
#      mpos_mm: 150.000
#      feed_mm_per_min: 100.000
#      seek_mm_per_min: 800.000
#      settle_ms: 500
#      seek_scaler: 1.100
#      feed_scaler: 1.100
#
#    motor0:
#      limit_neg_pin: gpio.39:low
#      limit_pos_pin: NO_PIN
#      limit_all_pin: NO_PIN
#      hard_limits: false
#      pulloff_mm: 3.000
#      tmc_2209:
#        uart_num: 1
#        addr: 3
#        cs_pin: i2so.22
#        r_sense_ohms: 0.110
#        run_amps: .8
#        homing_amps: 0.800
#        hold_amps: 0.050
#        microsteps: 16
#        stallguard: 0
#        stallguard_debug: false
#        toff_disable: 0
#        toff_stealthchop: 5
#        toff_coolstep: 3
#        run_mode: StealthChop
#        homing_mode: StealthChop
#        use_enable: false
#        step_pin: I2SO.21
#        direction_pin: I2SO.20
#        disable_pin: I2SO.23

i2so:
  bck_pin: gpio.22
  data_pin: gpio.21
  ws_pin: gpio.17

spi:
  miso_pin: gpio.19
  mosi_pin: gpio.23
  sck_pin: gpio.18

sdcard:
  cs_pin: gpio.5
  card_detect_pin: NO_PIN
  frequency_hz: 20000000

probe:
  pin: gpio.36:low
  toolsetter_pin: NO_PIN
  check_mode_start: true

start:
  must_home: false

coolant:
  flood_pin: NO_PIN
  mist_pin: NO_PIN
  delay_ms: 0

control:
  safety_door_pin: NO_PIN
  reset_pin: NO_PIN
  feed_hold_pin: NO_PIN
  cycle_start_pin: NO_PIN
  macro0_pin: NO_PIN
  macro1_pin: NO_PIN
  macro2_pin: NO_PIN
  macro3_pin: NO_PIN

macros:
  startup_line0:
  startup_line1:
  macro0:
  macro1:
  macro2:
  macro3:

user_outputs:
  analog0_pin: NO_PIN
  analog1_pin: NO_PIN
  analog2_pin: NO_PIN
  analog3_pin: NO_PIN
  analog0_hz: 5000
  analog1_hz: 5000
  analog2_hz: 5000
  analog3_hz: 5000
  digital0_pin: gpio.26
  digital1_pin: gpio.27
  digital2_pin: NO_PIN
  digital3_pin: NO_PIN

Relay:
direction_pin: NO_PIN
output_pin: gpio.2
enable_pin: NO_PIN
disable_with_s0: false
s0_with_disable: true
spinup_ms: 2000
spindown_ms: 2000
tool_num: 0
speed_map: 0=0.00% 1000=100.00%
off_on_alarm: false
atc: atc_manual


#Laser:
#  pwm_hz: 5000
#  output_pin: gpio.27
#  enable_pin: NO_PIN
#  disable_with_s0: false
#  s0_with_disable: true
#  tool_num: 0
#  speed_map: 0=0.000% 255=100.000%
#  off_on_alarm: true

# pwm:
#  pwm_hz: 5000
#  direction_pin: gpio.26
#  output_pin: gpio.27
#  enable_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=100.000%
#  off_on_alarm: false

# 5V out gpio.26/27
# VMot out gpoi.2/16
# In's left to right gpoi.25/33/32/35/34/39/36

When you quote your config.yaml, it needs to be preformatted (the icon that is </> on the edit toolbar).

Can you edit your post, delete all of the config.yaml, use preformatted, and then re-paste your config.yaml?

What’s in there now masks and obscures a bunch of the formatting we care about.

board: Jackpot TMC2209
name: LowRider
meta: 03-15-2024 RyanZ

planner_blocks: 32

stepping:
  engine: I2S_STATIC
  idle_ms: 255
  pulse_us: 4
  dir_delay_us: 1
  disable_delay_us: 0

uart1:
  txd_pin: gpio.0
  rxd_pin: gpio.4
  rts_pin: NO_PIN
  baud: 115200
  mode: 8N1

axes:
  shared_stepper_disable_pin: NO_PIN

  x:
    steps_per_mm: 50.000
    max_rate_mm_per_min: 9000.000
    acceleration_mm_per_sec2: 200.000
    max_travel_mm: 1220
    soft_limits: false
    homing:
      cycle: 3
      positive_direction: false
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100
    #X
    motor0:
      limit_neg_pin: gpio.25:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 0
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        direction_pin: I2SO.1
        step_pin: I2SO.2
        disable_pin: I2SO.0

  y:
    steps_per_mm: 50.000
    max_rate_mm_per_min: 9000.000
    acceleration_mm_per_sec2: 200.000
    max_travel_mm: 2440
    soft_limits: false
    homing:
      cycle: 2
      positive_direction: false
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 1500.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100
    #Y
    motor0:
      limit_neg_pin: gpio.33:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 1
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.5
        direction_pin: I2SO.4
        disable_pin: I2SO.7

    #A
    motor1:
      limit_neg_pin: gpio.35:high
      limit_pos_pin: NO_PIN
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 3
        cs_pin: i2so.14
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.13
        direction_pin: I2SO.12
        disable_pin: I2SO.15

  z:
    steps_per_mm: 200.000
    max_rate_mm_per_min: 1200.000
    acceleration_mm_per_sec2: 80.000
    max_travel_mm: 300.000
    soft_limits: false
    homing:
      cycle: 1
      positive_direction: true
      mpos_mm: 0
      feed_mm_per_min: 300.000
      seek_mm_per_min: 800.000
      settle_ms: 500
      seek_scaler: 1.100
      feed_scaler: 1.100

    motor0:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.32:high
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 2
        cs_pin: NO_PIN
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.10
        direction_pin: I2SO.9
        disable_pin: I2SO.8

     #B
    motor1:
      limit_neg_pin: NO_PIN
      limit_pos_pin: gpio.34:high
      limit_all_pin: NO_PIN
      hard_limits: false
      pulloff_mm: 4.000
      tmc_2209:
        uart_num: 1
        addr: 3
        cs_pin: i2so.19
        r_sense_ohms: 0.110
        run_amps: 0.800
        homing_amps: 0.800
        hold_amps: 0.500
        microsteps: 8
        stallguard: 0
        stallguard_debug: false
        toff_disable: 0
        toff_stealthchop: 5
        toff_coolstep: 3
        run_mode: StealthChop
        homing_mode: StealthChop
        use_enable: false
        step_pin: I2SO.18
        direction_pin: I2SO.17
        disable_pin: I2SO.16

#  c:
#    steps_per_mm: 80.000
#    max_rate_mm_per_min: 5000.000
#    acceleration_mm_per_sec2: 100.000
#    max_travel_mm: 300.000
#    soft_limits: false
#    homing:
#      cycle: 0
#      positive_direction: true
#      mpos_mm: 150.000
#      feed_mm_per_min: 100.000
#      seek_mm_per_min: 800.000
#      settle_ms: 500
#      seek_scaler: 1.100
#      feed_scaler: 1.100
#
#    motor0:
#      limit_neg_pin: gpio.39:low
#      limit_pos_pin: NO_PIN
#      limit_all_pin: NO_PIN
#      hard_limits: false
#      pulloff_mm: 3.000
#      tmc_2209:
#        uart_num: 1
#        addr: 3
#        cs_pin: i2so.22
#        r_sense_ohms: 0.110
#        run_amps: .8
#        homing_amps: 0.800
#        hold_amps: 0.050
#        microsteps: 16
#        stallguard: 0
#        stallguard_debug: false
#        toff_disable: 0
#        toff_stealthchop: 5
#        toff_coolstep: 3
#        run_mode: StealthChop
#        homing_mode: StealthChop
#        use_enable: false
#        step_pin: I2SO.21
#        direction_pin: I2SO.20
#        disable_pin: I2SO.23

i2so:
  bck_pin: gpio.22
  data_pin: gpio.21
  ws_pin: gpio.17

spi:
  miso_pin: gpio.19
  mosi_pin: gpio.23
  sck_pin: gpio.18

sdcard:
  cs_pin: gpio.5
  card_detect_pin: NO_PIN
  frequency_hz: 20000000

probe:
  pin: gpio.36:low
  toolsetter_pin: NO_PIN
  check_mode_start: true

start:
  must_home: false

coolant:
  flood_pin: NO_PIN
  mist_pin: NO_PIN
  delay_ms: 0

control:
  safety_door_pin: NO_PIN
  reset_pin: NO_PIN
  feed_hold_pin: NO_PIN
  cycle_start_pin: NO_PIN
  macro0_pin: NO_PIN
  macro1_pin: NO_PIN
  macro2_pin: NO_PIN
  macro3_pin: NO_PIN

macros:
  startup_line0:
  startup_line1:
  macro0:
  macro1:
  macro2:
  macro3:

user_outputs:
  analog0_pin: NO_PIN
  analog1_pin: NO_PIN
  analog2_pin: NO_PIN
  analog3_pin: NO_PIN
  analog0_hz: 5000
  analog1_hz: 5000
  analog2_hz: 5000
  analog3_hz: 5000
  digital0_pin: gpio.26
  digital1_pin: gpio.27
  digital2_pin: NO_PIN
  digital3_pin: NO_PIN

Relay:
direction_pin: NO_PIN
output_pin: gpio.2
enable_pin: NO_PIN
disable_with_s0: false
s0_with_disable: true
spinup_ms: 2000
spindown_ms: 2000
tool_num: 0
speed_map: 0=0.00% 1000=100.00%
off_on_alarm: false
atc: atc_manual


#Laser:
#  pwm_hz: 5000
#  output_pin: gpio.27
#  enable_pin: NO_PIN
#  disable_with_s0: false
#  s0_with_disable: true
#  tool_num: 0
#  speed_map: 0=0.000% 255=100.000%
#  off_on_alarm: true

# pwm:
#  pwm_hz: 5000
#  direction_pin: gpio.26
#  output_pin: gpio.27
#  enable_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=100.000%
#  off_on_alarm: false

# 5V out gpio.26/27
# VMot out gpoi.2/16
# In's left to right gpoi.25/33/32/35/34/39/36
type or paste code here

YAML files are very particular about spacing. Those lines need to be like this. I’m not sure it’s case sensitive, but I’d change that as well:

relay:
  direction_pin: NO_PIN
  output_pin: gpio.2
  enable_pin: NO_PIN
  disable_with_s0: false
  s0_with_disable: true
  spinup_ms: 2000
  spindown_ms: 2000
  tool_num: 0
  speed_map: 0=0.00% 1000=100.00%
  off_on_alarm: false
  atc: atc_manual

I spaced every thing as you suggested and replaced the capital w/ lowercase but I still am having the same error.

Can you provide all the text around the error? That doesn’t tell me much by itself.

I’d also try getting rid of that “atc: atc_manual” line. The FluidNC wiki page doesn’t show that as an option for a relay and you’re not using an ATC. I’m also not sure if that exists in 3.7.17.

ERROR:152
Configuration is invalid. Check boot messages for ERR’s.
Error : undefined :undefined
[MSG:ERR: Configuration is invalid. Check boot messages for ERR’s.]
<Alarm|MPos:0.000,0.000,0.000|FS:0,0>

ERROR:152
Configuration is invalid. Check boot messages for ERR’s.
Error : undefined :undefined
[MSG:ERR: Configuration is invalid. Check boot messages for ERR’s.]
<Alarm|MPos:0.000,0.000,0.000|FS:0,0>

What is the output of $SS?

Removing the “atc: atc_manual” line solved the problem. Thank you for the help

2 Likes