M950 is used to create heaters, fans and GPIO ports and to assign pins to them.
Back to the Gcode Dictionary
M950: Create heater, fan, spindle or GPIO/servo pin
Supported in RepRapFirmware 3.
M950 is used to create heaters, fans and GPIO ports and to assign pins to them. Each M950 command assigns a pin or pins to a single device. So every M950 command must have exactly one of the H, F, J, P, S, or (for Duet 3 MB6HC only) D parameters.
If a M950 command has C and/or Q parameters, then the pin allocation and/or frequency will be configured accordingly. Otherwise, the current configuration will be reported.
- Hnn Heater number
- Fnn Fan number
- Jnn Input pin number (RRF 3.01RC2 and later only)
- Pnn or Snn Output/servo pin number. Servo pins are just GpOut pins with a different default PWM frequency.
- Rnn Spindle number (RRF 3.3beta2 and later only)
- Dn (Duet 3 MB6HC running RRF 3.4 or later only) SD slot number (the only value supported is 1)
- C"name" Pin name(s) and optional inversion status, see Pin Names. Pin name "nil" frees up the pin. A leading '!' character inverts the input or output. A leading '^' character enables the pullup resistor1. The '^' and '!' characters may be placed in either order.
- Qnn (optional) PWM frequency in Hz. Valid range: 0-65535, default: 500 for GpOut pins, 250 for fans and heaters
- T Temperature sensor number, required only when creating a heater. See M308.
- Lbbbor Laaa:bbb RPM values that are achieved at zero PWM and at maximum RPM. (optional and for spindles only - RRF 3.3beta2 and later)
1: Check the individual hardware pages, some IO pins have permanent pullups.
- When M950 is used to create a heater, the M950 command must come later in config.g than the M308 command that creates the sensor referred to in the T parameter
- M950 must come before any commands that refer to the device being created. For example, when M950 is used to create a heater, it must be earlier than the M307 command used to set the heater parameters, and earlier than any M563 commands that create tools that use that heater. When M950 is used to create a fan, it must come earlier than any M106 commands relating to that fan.
M950 H1 C"out1" Q100 T1 ; create heater 1 M950 H1 C"3.out0+out2" Q100 T1 ; create heater 1 using ports OUT0 and OUT1 on CAN board 3 (RRF 3.4 or later) M950 H2 C"nil" ; disable heater 2 and free up the associated pin M950 F3 C"heater2" Q100 ; Fan 3 is connected to heater 2 pin, PWM at 100Hz M950 P0 C"exp.heater3" ; create output/servo port 0 attached to heater 3 pin on expansion connector M950 F2 C"!fan2+^pb6" ; Fan 2 uses the Fan2 output, but we are using a PWM fan so the output needs to be inverted, also we are using PB6 as a tacho input with pullup resistor enabled M950 J1 C"!^e1stop" ; Input 1 uses e1Stop pin, inverted, pullup enabled M950 R0 C"!exp.heater3" L12000 ; Spindle 0 uses exp.heater3 as RPM pin and has a max RPM of 12000 M950 D1 C"spi.cs0+spi.cs2" ; on Duet 3 MB6HC support external SD card using pins spi.cs0 and spi.cs2 for the CS and Card Detect pins respectively
When using M950 to create a fan, the port name string may be either a single port, or two ports separated by the '+' sign. The second port is used to read the fan tacho. Any CAN address at the start of the port name string applies to both port names.
M950 F5 C"!out4+out4.tach" Q450 ; Create Fan 5 on the mainboard on OUT4 with a tacho input M950 F0 C"!1.out3+out3.tach" Q450 ; Create Fan 0 on expansion board 1, output OUT3 with a tacho input
When using M950 to create a heater, RRF 3.4 allows multiple port names to be provided separated by the '+' sign. The maximum number of ports that may be used depends on the board. Any CAN address at the start of the port name string applies to all the port names.
When using M950 to create a spindle (from RRF 3.3) use the following format:
M950 R0 C"pwm_pin+forward_pin+reverse_pin" Qfff Laa:bb
- C can have 1, 2 or 3 pins. The first pin defined is a pwm capable pin to set the spindle speed. If a second pin is defined it is used as spindle on/of, if three pins are defined then the second pin is spindle forward and the third is spindle reverse.
- "fff" is the PWM frequency as usual
- "Laa:bb" sets the RPM range as "aa" to "bb". "Lbb" just sets the max RPM to "bb". Default RPM values are 60 min 10000 max
Troubleshooting 2 wire fans:
Normally 2 wire fans speed is set by the voltage, and reducing the voltage causes the fan to run slower. The fan output pins on Duet have a fixed voltage, and vary the fan speeds using PWM (Pulse Width Modulation), i.e. the full voltage gets switched on/off several times per second defined by the Q parameter.
Certain fans may not work well with this "pulsing" and only work reliably at 100% fan speed. Gradual fan control requires tweaking the frequency for the fan with the Q parameter. Start with a very low value of Q5 or Q10 to see if the fan works gradually (set speed to different speeds).