Switch

Config

To apply any config changes make, sure to safely unmount the device and reboot the the device by sending a reset command, or powering the device off and on again

Switch

Switch is the mapping of inputs and outputs, where they can be linked in different ways

  • software input -> software output
  • software input -> hardware output
  • hardware input -> hardware output
  • hardware input -> software output

Switch parameters

Parameter Example Description
switch.[NAME].enable true enable/disable switch with true/false
switch.[NAME].input_pin 1.25 maps hardware input to switch, when input signal is on the switch will change state depending on input_pin_behavior
switch.[NAME].input_pin_behavior momentary sets input behaviour of switch, when set to momentary the switch state be the same as input, when set to toggle the switch state will toggle state when input signal is on
switch.[NAME].input_on_command M801 maps command to input, when the command is called switch state is set to on
switch.[NAME].input_off_command M800 maps command to input, when the command is called switch state is set to off
switch.[NAME].subcode 1 adds subcode to switch, example M801.1 will turn switch on, and M800.1 will turn switch off
switch.[NAME].output_on_command resume map command to switch output, when switch changes state to on the command will be executed
switch.[NAME].output_off_command suspend map command to switch output, when switch changes state to off the command will be executed
switch.[NAME].output_on_program startup.gcode map gcode program to switch output, when switch changes state to on the program will be executed
switch.[NAME].output_off_program shutdown.gcode map gcode program to switch output, when switch changes state to off the program will be executed
switch.[NAME].output_pin 2.6 map hardware output to switch output, when switch state change the output will change depending on output_type
switch.[NAME].output_type digital set mode of switch ouput, when set to digital the output mirrors the state of switch, when set to pwm the output will work as pwm where a value can be set from 0-255 with a S parameter M801 S127, when set to hwpwm a pwm supported pin must be selected, the value ranges from 0-100 and can be set with a S parameter M801 S50
switch.[NAME].startup_state false set startup state for switch
switch.[NAME].startup_value 127 set startup value for pwm or hwpwm
switch.[NAME].max_pwm 255 set maximum value for pwm output, NOTE does not apply for hwpwm
switch.[NAME].pwm_period_ms 20 set pwm period time for hwpwm default is 20mS (50Hz)
switch.[NAME].fail_safe_set_to 0 set default state when a HALT occurs '1' or '0' as on or off
switch.[NAME].ignore_on_halt true true will ignore HALT event and keep switch state

Examples

Example for valve switch where a software input is linked to a hardware output

# valve
switch.valve.enable                          true             # enable valve
switch.valve.input_on_command                M801             
switch.valve.input_off_command               M800             
switch.valve.output_pin                      2.6              
switch.valve.output_type                     digital          # on/off only
switch.valve.startup_state                   false            # default state
switch.valve.fail_safe_set_to                0                # switch off if HALT occurs

A 24V air valve can be turn on/off with M801/M800, where initial state is off, and state on HALT is off

Example for fan control switch where a hardware input is linked to a hardware output

switch.fan.enable                            true             # enable fan
switch.fan.input_pin                         1.29             
switch.fan.input_pin_behavior                toggle           
switch.fan.output_pin                        2.5              
switch.fan.output_type                       pwm              # pulse width modulation
switch.fan.startup_value                     127              # start value for pwm
switch.fan.max_pwm                           255              # set max output of pwm
switch.fan.startup_state                     false            # default state

A 24V fan that can be turned on and off with a physical switch running at half speed