Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2020-04-03 13:08:45 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-04-03 13:08:45 +0300
commita797f44b5fef66e4960e987ac302955466f68b44 (patch)
tree3d24e2d7a6629ba39b388c3c78e19c41026e5a6f
parent53a30e1ab360e8ea3dbb292a3f860395d055f388 (diff)
Changed thermistor H and L parameter scaling to match Duet 3 tool board3.01-RC6
-rw-r--r--src/CAN/CanMessageGenericConstructor.cpp14
-rw-r--r--src/Heating/Sensors/Thermistor.cpp9
-rw-r--r--src/Heating/Sensors/Thermistor.h10
-rw-r--r--src/Version.h2
4 files changed, 17 insertions, 18 deletions
diff --git a/src/CAN/CanMessageGenericConstructor.cpp b/src/CAN/CanMessageGenericConstructor.cpp
index 31cbafd2..ac48fe9e 100644
--- a/src/CAN/CanMessageGenericConstructor.cpp
+++ b/src/CAN/CanMessageGenericConstructor.cpp
@@ -64,15 +64,19 @@ void CanMessageGenericConstructor::PopulateFromCommand(GCodeBuffer& gb)
break;
case ParamDescriptor::uint16:
- StoreValue((uint16_t)gb.GetUIValue());
+ StoreValue((uint16_t)min<uint32_t>(gb.GetUIValue(), std::numeric_limits<uint16_t>::max()));
break;
case ParamDescriptor::int16:
- StoreValue((int16_t)gb.GetIValue());
+ StoreValue((int16_t)constrain<int32_t>(gb.GetIValue(), std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()));
break;
case ParamDescriptor::uint8:
- StoreValue((uint8_t)gb.GetUIValue());
+ StoreValue((uint8_t)min<uint32_t>(gb.GetUIValue(), std::numeric_limits<uint8_t>::max()));
+ break;
+
+ case ParamDescriptor::int8:
+ StoreValue((int8_t)constrain<int32_t>(gb.GetIValue(), std::numeric_limits<int8_t>::min(), std::numeric_limits<int8_t>::max()));
break;
case ParamDescriptor::localDriver:
@@ -82,10 +86,6 @@ void CanMessageGenericConstructor::PopulateFromCommand(GCodeBuffer& gb)
}
break;
- case ParamDescriptor::int8:
- StoreValue((int8_t)gb.GetIValue());
- break;
-
case ParamDescriptor::float_p:
StoreValue(gb.GetFValue());
break;
diff --git a/src/Heating/Sensors/Thermistor.cpp b/src/Heating/Sensors/Thermistor.cpp
index f8421e64..ad8723fc 100644
--- a/src/Heating/Sensors/Thermistor.cpp
+++ b/src/Heating/Sensors/Thermistor.cpp
@@ -57,15 +57,14 @@ GCodeResult Thermistor::Configure(GCodeBuffer& gb, const StringRef& reply, bool&
}
#if !HAS_VREF_MONITOR || defined(DUET3)
- constexpr int maxOffset = (int)(30u << (AdcBits + AdcOversampleBits - 12));
if (gb.Seen('L'))
{
- adcLowOffset = (int16_t)constrain<int>(gb.GetIValue(), -maxOffset, maxOffset);
+ adcLowOffset = (int8_t)constrain<int>(gb.GetIValue(), std::numeric_limits<int8_t>::min(), std::numeric_limits<int8_t>::max());
changed = true;
}
if (gb.Seen('H'))
{
- adcHighOffset = (int16_t)constrain<int>(gb.GetIValue(), -maxOffset, maxOffset);
+ adcHighOffset = (int8_t)constrain<int>(gb.GetIValue(), std::numeric_limits<int8_t>::min(), std::numeric_limits<int8_t>::max());
changed = true;
}
#endif
@@ -129,11 +128,11 @@ void Thermistor::Poll() noexcept
// Version 1.01 and later boards have the series resistors connected to VrefMon.
const int32_t rawAveragedVssaReading = vssaFilter.GetSum()/(vssaFilter.NumAveraged() >> Thermistor::AdcOversampleBits);
const int32_t rawAveragedVrefReading = vrefFilter.GetSum()/(vrefFilter.NumAveraged() >> Thermistor::AdcOversampleBits);
- const int32_t averagedVssaReading = rawAveragedVssaReading + adcLowOffset;
+ const int32_t averagedVssaReading = rawAveragedVssaReading + (adcLowOffset * (1 << (AdcBits - 12 + Thermistor::AdcOversampleBits - 1)));
const int32_t averagedVrefReading = ((reprap.GetPlatform().GetBoardType() == BoardType::Duet3_v06_100)
? ((rawAveragedVrefReading - rawAveragedVssaReading) * (4715.0/4700.0)) + rawAveragedVssaReading
: rawAveragedVrefReading
- ) + adcHighOffset;
+ ) + (adcHighOffset * (1 << (AdcBits - 12 + Thermistor::AdcOversampleBits - 1)));
# else
const int32_t averagedVssaReading = vssaFilter.GetSum()/(vssaFilter.NumAveraged() >> Thermistor::AdcOversampleBits);
const int32_t averagedVrefReading = vrefFilter.GetSum()/(vrefFilter.NumAveraged() >> Thermistor::AdcOversampleBits);
diff --git a/src/Heating/Sensors/Thermistor.h b/src/Heating/Sensors/Thermistor.h
index 53ea5197..66605e07 100644
--- a/src/Heating/Sensors/Thermistor.h
+++ b/src/Heating/Sensors/Thermistor.h
@@ -31,22 +31,22 @@ public:
private:
// For the theory behind ADC oversampling, see http://www.atmel.com/Images/doc8003.pdf
- static constexpr unsigned int AdcOversampleBits = 2; // we use 2-bit oversampling
+ static constexpr unsigned int AdcOversampleBits = 2; // we use 2-bit oversampling
void CalcDerivedParameters() noexcept; // calculate shA and shB
// The following are configurable parameters
- float r25, beta, shC, seriesR; // parameters declared in the M305 command
+ float r25, beta, shC, seriesR; // parameters declared in the M305 command
int8_t adcFilterChannel;
- bool isPT1000; // true if it is a PT1000 sensor, not a thermistor
+ bool isPT1000; // true if it is a PT1000 sensor, not a thermistor
// Duet 3 VRef calibration doesn't work well on the MB6HC v0.6 or v1.0 so provide calibration adjustment
#if !HAS_VREF_MONITOR || defined(DUET3)
- int16_t adcLowOffset, adcHighOffset;
+ int8_t adcLowOffset, adcHighOffset;
#endif
// The following are derived from the configurable parameters
- float shA, shB; // derived parameters
+ float shA, shB; // derived parameters
static constexpr int32_t OversampledAdcRange = 1u << (AdcBits + AdcOversampleBits); // The readings we pass in should be in range 0..(AdcRange - 1)
};
diff --git a/src/Version.h b/src/Version.h
index 2a061c8a..1679d2a3 100644
--- a/src/Version.h
+++ b/src/Version.h
@@ -19,7 +19,7 @@
#endif
#ifndef DATE
-# define DATE "2020-04-03b2"
+# define DATE "2020-04-03b3"
#endif
#define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman, printm3d"