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

Thermistor.h « Sensors « Heating « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 62ee37dedbe9f9e0fa43154e734f623d940983bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Thermistor.h
 *
 *  Created on: 10 Nov 2016
 *      Author: David
 */

#ifndef SRC_HEATING_THERMISTOR_H_
#define SRC_HEATING_THERMISTOR_H_

#include "SensorWithPort.h"

// The Steinhart-Hart equation for thermistor resistance is:
// 1/T = A + B ln(R) + C [ln(R)]^3
//
// The simplified (beta) equation assumes C=0 and is:
// 1/T = A + (1/Beta) ln(R)
//
// The parameters that can be configured in RRF are R25 (the resistance at 25C), Beta, and optionally C.

class Thermistor : public SensorWithPort
{
public:
	Thermistor(unsigned int sensorNum, bool p_isPT1000);					// create an instance with default values
	GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) override; // configure the sensor from M305 parameters

	static constexpr const char *TypeNameThermistor = "thermistor";
	static constexpr const char *TypeNamePT1000 = "pt1000";

	void Poll() override;

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

	void CalcDerivedParameters();											// calculate shA and shB

	// The following are configurable parameters
	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

// 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;
#endif

	// The following are derived from the configurable 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)
};

#endif /* SRC_HEATING_THERMISTOR_H_ */