diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-19 10:45:55 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-19 10:45:55 +0300 |
commit | c40817d09ed3b3eaff0efcfbf63ea40696b41ce7 (patch) | |
tree | 215fabcd71ff15e0104a4be1f2447d717321550f /src | |
parent | 0ab7dc2419caad45461a011697549f95350cba7b (diff) |
Z probe trigger height is now the negative of the probe Z offset
Diffstat (limited to 'src')
-rw-r--r-- | src/Endstops/ZProbe.cpp | 21 | ||||
-rw-r--r-- | src/Endstops/ZProbe.h | 7 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/Endstops/ZProbe.cpp b/src/Endstops/ZProbe.cpp index 47fa542f..95853119 100644 --- a/src/Endstops/ZProbe.cpp +++ b/src/Endstops/ZProbe.cpp @@ -78,7 +78,7 @@ constexpr ObjectModelTableEntry ZProbe::objectModelTable[] = { "threshold", OBJECT_MODEL_FUNC((int32_t)self->adcValue), ObjectModelEntryFlags::none }, { "tolerance", OBJECT_MODEL_FUNC(self->tolerance, 3), ObjectModelEntryFlags::none }, { "travelSpeed", OBJECT_MODEL_FUNC(self->travelSpeed, 1), ObjectModelEntryFlags::none }, - { "triggerHeight", OBJECT_MODEL_FUNC(self->triggerHeight, 3), ObjectModelEntryFlags::none }, + { "triggerHeight", OBJECT_MODEL_FUNC(-self->offsets[Z_AXIS], 3), ObjectModelEntryFlags::none }, { "type", OBJECT_MODEL_FUNC((int32_t)self->type), ObjectModelEntryFlags::none }, { "value", OBJECT_MODEL_FUNC_NOSELF(&valueArrayDescriptor), ObjectModelEntryFlags::live }, }; @@ -102,7 +102,7 @@ void ZProbe::SetDefaults() noexcept { offset = 0.0; } - triggerHeight = DefaultZProbeTriggerHeight; + offsets[Z_AXIS] = -DefaultZProbeTriggerHeight; calibTemperature = DefaultZProbeTemperature; for (float& tc : temperatureCoefficients) { @@ -128,10 +128,10 @@ float ZProbe::GetActualTriggerHeight() const noexcept if (err == TemperatureError::success) { const float dt = temperature - calibTemperature; - return (dt * temperatureCoefficients[0]) + (fsquare(dt) * temperatureCoefficients[1]) + triggerHeight; + return (dt * temperatureCoefficients[0]) + (fsquare(dt) * temperatureCoefficients[1]) - offsets[Z_AXIS]; } } - return triggerHeight; + return -offsets[Z_AXIS]; } #if HAS_MASS_STORAGE @@ -149,7 +149,7 @@ bool ZProbe::WriteParameters(FileStore *f, unsigned int probeNumber) const noexc scratchString.catf(" %c%.1f", axisLetters[i], (double)offsets[i]); } } - scratchString.catf(" Z%.2f\n", (double)triggerHeight); + scratchString.catf(" Z%.2f\n", (double)-offsets[Z_AXIS]); return f->Write(scratchString.c_str()); } @@ -327,7 +327,14 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC gb.TryGetFValue(axisLetters[i], offsets[i], seen); } } - gb.TryGetFValue(axisLetters[Z_AXIS], triggerHeight, seen); + + { + float triggerHeight; + if (gb.TryGetFValue(axisLetters[Z_AXIS], triggerHeight, seen)) + { + offsets[Z_AXIS] = -triggerHeight; // logically, the Z offset of the Z probe is the negative of the trigger height + } + } if (gb.Seen('P')) { @@ -353,7 +360,7 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC { reply.catf(" (%d)", v1); } - reply.catf(", threshold %d, trigger height %.3f", adcValue, (double)triggerHeight); + reply.catf(", threshold %d, trigger height %.3f", adcValue, (double)-offsets[Z_AXIS]); if (temperatureCoefficients[0] != 0.0) { reply.catf(" at %.1f" DEGREE_SYMBOL "C, temperature coefficients [%.1f/" DEGREE_SYMBOL "C, %.1f/" DEGREE_SYMBOL "C^2]", diff --git a/src/Endstops/ZProbe.h b/src/Endstops/ZProbe.h index 9f5e9d7e..8cda06c9 100644 --- a/src/Endstops/ZProbe.h +++ b/src/Endstops/ZProbe.h @@ -35,7 +35,7 @@ public: ZProbeType GetProbeType() const noexcept { return type; } float GetOffset(size_t axisNumber) const noexcept { return offsets[axisNumber]; } - float GetConfiguredTriggerHeight() const noexcept { return triggerHeight; } + float GetConfiguredTriggerHeight() const noexcept { return -offsets[Z_AXIS]; } float GetActualTriggerHeight() const noexcept; float GetDiveHeight() const noexcept { return diveHeight; } float GetStartingHeight() const noexcept { return diveHeight + GetActualTriggerHeight(); } @@ -55,7 +55,7 @@ public: void SetProbingAway(const bool probingAway) noexcept { misc.parts.probingAway = probingAway; } GCodeResult HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); - void SetTriggerHeight(float height) noexcept { triggerHeight = height; } + void SetTriggerHeight(float height) noexcept { offsets[Z_AXIS] = -height; } void SetSaveToConfigOverride() noexcept { misc.parts.saveToConfigOverride = true; } void SetDeployedByUser(bool b) noexcept { isDeployedByUser = b; } void SetLastStoppedHeight(float h) noexcept; @@ -88,8 +88,7 @@ protected: } parts; uint16_t all; } misc; - float offsets[MaxAxes]; // the offset of the probe relative to the print head - float triggerHeight; // the nozzle height at which the target ADC value is returned + float offsets[MaxAxes]; // the offset of the probe relative to the print head. The Z offset is the negation of the trigger height. float calibTemperature; // the temperature at which we did the calibration float temperatureCoefficients[2]; // the variation of height with bed temperature and with the square of temperature float diveHeight; // the dive height we use when probing |