Skip to content

Commit 54a517b

Browse files
Merge pull request #464 from blurfl/fix-G38.2-for-reversed-z-motor-
If zEncoderSteps is negative, use that same sign in G38.2 gcode
2 parents 91ce159 + 4e4649e commit 54a517b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cnc_ctrl_v1/GCode.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,9 @@ void G38(const String& readString) {
781781

782782

783783
float currentZPos = zAxis.read();
784+
int zDirection = sysSettings.zEncoderSteps<0 ? -1 : 1;
784785

785-
zgoto = sys.inchesToMMConversion * extractGcodeValue(readString, 'Z', currentZPos / sys.inchesToMMConversion);
786+
zgoto = zDirection * sys.inchesToMMConversion * extractGcodeValue(readString, 'Z', currentZPos / sys.inchesToMMConversion);
786787
sys.feedrate = sys.inchesToMMConversion * extractGcodeValue(readString, 'F', sys.feedrate / sys.inchesToMMConversion);
787788
sys.feedrate = constrain(sys.feedrate, 1, sysSettings.maxZRPM * abs(zAxis.getPitch()));
788789

0 commit comments

Comments
 (0)