diff --git a/docs/src/gcode/m-code.adoc b/docs/src/gcode/m-code.adoc index 253358f25f1..21a3da5d6a9 100644 --- a/docs/src/gcode/m-code.adoc +++ b/docs/src/gcode/m-code.adoc @@ -235,7 +235,7 @@ M19 R- Q- [P-] [$-] M19 is a command of modal group 7, like M3, M4 and M5. M19 is cleared by any of M3,M4,M5. -Spindle orientation requires a quadrature encoder with an index to sense the +Spindle orientation requires a quadrature encoder to sense the spindle shaft position and direction of rotation. INI Settings in the [RS274NGC] section: diff --git a/src/hal/components/orient.comp b/src/hal/components/orient.comp index fdff8714f48..e0cc93f1478 100644 --- a/src/hal/components/orient.comp +++ b/src/hal/components/orient.comp @@ -26,9 +26,7 @@ to support the M19 code. The spindle is assumed to have stopped in an arbitrary position. The spindle encoder position is linked to the *position* pin. The current value of the position pin is sampled on a positive edge on the *enable* pin, and *command* -is computed and set as follows: + -floor(number of full spindle revolutions in the *position* sampled on positive -edge) plus *angle*/360 (the fractional revolution) +1/-1/0 depending on *mode*. +is computed and set depending on *mode*. The *mode* pin is interpreted as follows: