Back to the Gcode Dictionary
M280: Set servo position
Set servo position absolute.
- Pnnn Servo index
- Snnn Angle (see note) or microseconds
- I1 Invert polarity (not supported in RRF3)
- M280 P1 S50
S values below 544 are treated as angles, and 544 or greater as the pulse width in microseconds.
The relationship between the S parameter and the pulse width output to the port is the same as in other 3D printer firmwares, so that devices such as BLTouch will perform the same way. However, there is no standard for servos on the relationship between pulse width and servo angle. Therefore, for most servos the value of the S parameter does not equal the servo angle. Almost all servos accept a pulse width range of at least 1us to 2us, which corresponds to an S parameter range of 44.2 to 141.2 degrees. So for many servos, values in the range 44.2 to 141.2 or alternatively 1000 to 2000 will cover the full operating range of the servo.
RRF3: Before you can use M280 you must create a GPIO port using M950. Then in the M280 command, the P parameter is the GPIO port number, not the logical pin number. Duet 2 supports up to 10 GPIO ports, numbers 0 to 9. No GPIO ports are allocated by default.
RRF3: The I parameter is no longer supported in M280. Instead, specify an inverted pin name in M950 when you create the GPIO port.
Example - old code (RRF2):
M280 P3 I1 S80 ; set Heater 3 pin to 80deg servo position, inverted
New code (RRF3):
M950 S0 C"exp.heater3" ; assign GPIO port 0 to heater3 on expansion connector, servo mode ... M280 P0 S80 ; set 80deg servo position on GPIO port 0
RRF2: The optional I1 parameter causes the polarity of the servo pulses to be inverted compared to normal for that output pin. The I parameter is not remembered between M280 commands (unlike the I parameter in M106 commands), so if you need inverted polarity then you must include I1 in every M280 command you send.
RRF2: The servo index is the same as the pin number for the M42 command. See Using servos and controlling unused IO pins for details for the Duet 2 Wifi and Ethernet or the table below for the 0.8.5.
|Duet 0.8.5 M280 P value to Expansion Port Pin Mapping|
|P||Name||Expansion Port Pin|
|Use M307 H# A-1 C-1 D-1 before using these pins|