Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
switch [2018/06/12 00:10]
arthur
switch [2019/04/13 17:54] (current)
wolfmanjm
Line 50: Line 50:
 switch.fan1.startup_value ​                127 switch.fan1.startup_value ​                127
 </​code>​ </​code>​
 +
 +==== Input and Output Pins
 +**NOTE** a switch can have either an input pin defined or an output pin but not both.
 +If for some reason you needed an input pin to control one or more output pins you could define two (or more) switches, one input and one or more outputs. Then the input pin would define the M-codes that turn on/off the output pins in its output_on_command (and/or its output_off_command).
  
 ==== Input Pin ==== Input Pin
Line 83: Line 87:
 ==== Output type ==== Output type
  
-There are three different output types : <kbd>digital</​kbd>​<kbd>pwm</​kbd> ​and <kbd>hwpwm</​kbd>​, the default is <kbd>none</​kbd> ​so no output pin is configured.+There are four different output types : ''​digital''​''​pwm'',​ ''​swpwm'' ​and ''​hwpwm''​, the default is ''​none'' ​so no output pin is configured. 
 +(The names MUST be lower case)
  
 Note that <​kbd>​pwm</​kbd>​ is actually SigmaDelta Modulation and will allow you to set PWM intensity via the <​kbd>​S</​kbd>​ parameter to your G-codes, values between 0 and <​kbd>​max_pwm</​kbd>​ are accepted, which is usually 255. Note that <​kbd>​pwm</​kbd>​ is actually SigmaDelta Modulation and will allow you to set PWM intensity via the <​kbd>​S</​kbd>​ parameter to your G-codes, values between 0 and <​kbd>​max_pwm</​kbd>​ are accepted, which is usually 255.
  
-<​kbd>​hwpwm</​kbd>​ is PWM controlled by the Hardware, and is PWM compatible with Hobby servos and ESCs. The <​kbd>​S</​kbd>​ parameter specifies the duty cycle in percent, and for a typical servo will be between 5% and 10% (1ms to 2ms when running at 50Hz) for a 180° ​turn. the default frequency is 50Hz but can be set with the <​kbd>​pwm_period_ms</​kbd>​ config setting.+<​kbd>​hwpwm</​kbd>​ is PWM controlled by the Hardware, and is PWM compatible with Hobby servos/​bltouch ​and ESCs. The <​kbd>​S</​kbd>​ parameter specifies the duty cycle in percent, and for a typical servo will be between 5% and 10% (1ms to 2ms when running at 50Hz) for a 180° turn. the default frequency is 50Hz but can be set with the <​kbd>​pwm_period_ms</​kbd>​ config setting
 + 
 +<​kbd>​swpwm</​kbd>​ is PWM emulated by the software, and is PWM compatible with Hobby servos/​bltouch and ESCs. And is otherwise similar to hwpwm. This is useful if your hwpwm clock must be set to a very high value for example for the laser module, as this would mean a hwpwm switch would need to have the same high value which can be incompatible with some hardware. Having a lower frequency swpwm allows for both the laser module and servos/​bltouch control.
  
 ==== Commands and Gcodes ==== Commands and Gcodes
Line 129: Line 136:
  
 <​code>​ <​code>​
-# Switch module for servo control+# Switch module for servo control ​using S/W PWM
 switch.servo.enable ​                           true             # Enable this module switch.servo.enable ​                           true             # Enable this module
 switch.servo.input_on_command ​                 M280             # M280 S7.5 would be midway switch.servo.input_on_command ​                 M280             # M280 S7.5 would be midway
 switch.servo.input_off_command ​                ​M281 ​            # Same as M280 S0 0% duty cycle, effectively off switch.servo.input_off_command ​                ​M281 ​            # Same as M280 S0 0% duty cycle, effectively off
-switch.servo.output_pin ​                       3.25             # ​Must be a PWM capable ​pin +switch.servo.output_pin ​                       3.25             # ​May be any spare pin 
-switch.servo.output_type ​                      hwpwm            # ​H/W pwm output settable with S parameter in the input_on_comand+switch.servo.output_type ​                      swpwm            # ​Software ​pwm output settable with S parameter in the input_on_command
 #​switch.servo.pwm_period_ms ​                   20               # set period to 20ms (50Hz) default is 50Hz #​switch.servo.pwm_period_ms ​                   20               # set period to 20ms (50Hz) default is 50Hz
 +#​switch.servo.startup_state ​                   false            # false uses startup_value on boot true uses default_on_value
 +#​switch.servo.startup_value ​                   7.43             # On boot and HALT it will set this PWM value
 +#​switch.servo.default_on_value ​                ​3.3 ​             # This PWM value will be set if M280 doe snot have an S parameter, it is also the value used if startup_state is true
 </​code>​ </​code>​
  
 <​code>​ <​code>​
-# Switch module for a second servo control+# Switch module for a second servo control ​using H/W PWM
 switch.servo2.enable ​                           true             # Enable this module switch.servo2.enable ​                           true             # Enable this module
 switch.servo2.input_on_command ​                 M280             # M280.1 S7.5 would be midway switch.servo2.input_on_command ​                 M280             # M280.1 S7.5 would be midway
Line 145: Line 155:
 switch.servo2.subcode ​                          ​1 ​               # M280.1 will trigger this switch switch.servo2.subcode ​                          ​1 ​               # M280.1 will trigger this switch
 switch.servo2.output_pin ​                       3.26             # Must be a PWM capable pin switch.servo2.output_pin ​                       3.26             # Must be a PWM capable pin
-switch.servo2.output_type ​                      ​hwpwm ​           # H/W pwm output settable with S parameter in the input_on_comand+switch.servo2.output_type ​                      ​hwpwm ​           # H/W pwm output settable with S parameter in the input_on_command
 </​code>​ </​code>​
  
Line 218: Line 228:
 switch.spindle.enable ​               true                     # Enable this module switch.spindle.enable ​               true                     # Enable this module
 switch.spindle.input_pin ​            ​1.30^ ​                   # Pin where pause button is connected switch.spindle.input_pin ​            ​1.30^ ​                   # Pin where pause button is connected
-switch.spindle.output_on_command ​    ​M3 ​S1000                 # Command to turn the spindle ON+switch.spindle.output_on_command ​    ​M3 ​                      ​# Command to turn the spindle ON eg M3 S1000  ​
 switch.spindle.output_off_command ​   M5                       # Command to turn the spindle OFF switch.spindle.output_off_command ​   M5                       # Command to turn the spindle OFF
 switch.spindle.input_pin_behavior ​   toggle ​                  # This pin toggles between it's on and off states each time it is pressed and released switch.spindle.input_pin_behavior ​   toggle ​                  # This pin toggles between it's on and off states each time it is pressed and released
Line 376: Line 386:
  
 === Console command === Console command
-The is an escape character for Pronterface to not filter the non g-code.+**NOTE** precede with only if you are using Pronterface to not filter the non g-code.
 <​code>​ <​code>​
-@switch vac1read+switch vac1read
 </​code>​ </​code>​
  
Line 385: Line 395:
 switch vac1read is 0 switch vac1read is 0
 </​code>​ </​code>​
 +
 +Alternatively (with the very latest build) you can send
 +<​code>​
 +$S psu fan
 +switch psu is 1
 +switch fan is 0
 +</​code>​
 +
 +