100K Semitec 104GT2 NTC热敏电阻

问题描述 投票:0回答:1

首先,我是论坛新手,所以如果我在错误的地方打开了这个主题,我深表歉意。
我想使用 Arduino Nano 控制 3D 打印机的热端。经过研究,我了解到热端使用的是“100K Semitec 104GT2 NTC 热敏电阻”。据此我发现我的热敏电阻的β系数是4267K。我使用 4.7kohm 电阻连接到 A0 引脚。我使用下面分享的代码运行了系统。但每次测量的温度值都显示为368.80。可能是什么问题以及如何解决?我找不到任何解决方案。如果您能帮助我,我会很高兴。
我使用的热端:“E3D-v6 HotEnd”

`#define THERMISTOR_PIN A0
#define SERIES_RESISTOR 4700  // 4.7 kohm resistor

// Steinhart-Hart coefficients for Semitec 104GT2 NTC Thermistor
#define A 0.001129148
#define B 0.0004267
#define C 0.0000000876741

void setup() {
  Serial.begin(9600);
}

void loop() {
  // Measure the thermistor resistance
  int rawValue = analogRead(THERMISTOR_PIN);

  // Calculate the thermistor resistance
  float resistance = SERIES_RESISTOR / (1023.0 / rawValue - 1.0);

  // Calculate temperature using the Steinhart-Hart equation
  float steinhart;
  steinhart = resistance / 100000.0;     // (R/Ro)
  steinhart = log(steinhart);            // ln(R/Ro)
  steinhart /= B;                        // 1/B * ln(R/Ro)
  steinhart += 1.0 / (25 + 273.15);       // + (1/To)
  steinhart = 1.0 / steinhart;            // Invert
  steinhart -= 273.15;                    // Convert to Celsius

  // Print the obtained temperature value to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.println(steinhart);

  delay(1000);
}`
arduino
1个回答
0
投票

首先,关于设计更改的一个小建议,您有一个 100k @25 摄氏度的热敏电阻,因此最好将串联电阻设置为 100k 而不是 4.7k 的相同值,然后它将把读数放在中间ADC 在 25 度温度下的刻度范围,这不仅是 ADC 的线性范围,而且还为测量低于和高于 25 度的温度提供了良好的范围。

公式不正确。让我们一步步分解吧

由电阻(Rs,假设为 100k,而不是 4.7k)和热敏电阻 (Rt) 组成的分压器上的模拟引脚 A0 处的电压(我们称之为 Va)可以通过以下假设得出:电源电压为 5v (Vs):

voltage at Va:   Va = Vs * Rt/(Rs + Rt), or
                 Rt = Rs * Va/(Vs - Va)

根据维基百科的开尔文温度公式:

                 1
 T = ----------------------------
     1/To + (1/beta) * ln(Rt/Ro)

Where:
T: the temperature to be measured in Kelvin;
To: the reference temperature in Kelvin at 25 degree Celsius (i.e. 298.15);
Ro: the thermistor resistance at To(i.e. 100000);
B:  the Beta Coefficient provided by thermistor manufacturer(i.e. 4267).

我们现在可以定义常量并编写一些非常简单的程序。

const double Rs = 100000.0;   // voltage divider resistor value
const double Beta = 4267.0;   // Beta value
const double To = 298.15;     // Temperature in Kelvin for 25 degree Celsius
const double Ro = 100000.0;   // Resistance of Thermistor at 25 degree Celsius

const double adcMax = 1023.0; // ADC resolution 10-bit (0-1023)
const double Vs = 5.0;        // supply voltage

void setup() {
    Serial.begin(115200);
}

void loop() {
    double Va = analogRead(A0) * Vs/adcMax;
    double Rt = Rs * Va / (Vs - Va);
    double T = 1/(1/To + log(Rt/Ro)/Beta);  // Temperature in Kelvin
    double Tc = T - 273.15;                 // Celsius
    double Tf = Tc * 9 / 5 + 32;            // Fahrenheit
}

当 ADC 值为 512 时,Kevin 的温度为 298;当 ADC=1023 时,Kevin 的温度为 0k;当 ADC=1 时,Kevin 的温度为 578k。

© www.soinside.com 2019 - 2024. All rights reserved.