![](/img/trans.png)
[英]Boiling water (hacking into Kettle)using Arduino UNO and Ultrasonic sensor and Temperature sensor
[英]How to read temperature using arduino uno board with PT100 RTD sensor?
我是arduino编程的新手。 几乎没有经验。
我希望对我的arduino Uno板进行编程,以读取PT100 RTD传感器的2/3/4线配置(精度等级至少为0.5°C)。 温度范围为0至400°C和-50至100°C。
由于我对这个领域完全陌生,我会欣赏有关电路,图像和代码的相当描述性的信息。
我已经对这个问题进行了很多研究,但是无法解决我的问题。
此外,我不能使用热敏电阻或任何IC来读取温度,因为安装RTD的机器具有PID,但我想创建一个可以在计算机上获取温度的数据记录器。
PT100在施加热量时增加其电阻。 温度与电阻特性在pt100电阻表中描述
Arduino可以读取模拟输入的电压。 要获得摄氏度读数,我们必须:
Vin是5伏来自arduino R1是我程序中已知值的电阻它是220欧姆实际R2是pt 100 Vout必须连接到arduino模拟输入引脚(例如A0)
R2 = R1 * 1 /(Vin / Vout - 1)
电路可以根据上面的图片完成,相当简单。
我写的草图包含0C - 80C的电阻数据(可以很容易地扩展)为了从电阻值获得度数,我使用我的MultiMap函数版本 ,它使用一个浮点数作为电阻值,并使用线性插值来计算精确度
float in[] = { 100.00, 100.39, 100.78, 101.17, 101.56, 101.95, 102.34, 102.73, 103.12, 103.51,
103.90, 104.29, 104.68, 105.07, 105.46, 105.85, 106.24, 106.63, 107.02, 107.40,
107.79, 108.18, 108.57, 108.96, 109.35, 109.73, 110.12, 110.51, 110.90, 111.29,
111.67, 112.06, 112.45, 112.83, 113.22, 113.61, 114.00, 114.38, 114.77, 115.15,
115.54, 115.93, 116.31, 116.70, 117.08, 117.47, 117.86, 118.24, 118.63, 119.01,
119.40, 119.78, 120.17, 120.55, 120.94, 121.32, 121.71, 122.09, 122.47, 122.86,
123.24, 123.63, 124.01, 124.39, 124.78, 125.16, 125.54, 125.93, 126.31, 126.69,
127.08, 127.46, 127.84, 128.22, 128.61, 128.99, 129.37, 129.75, 130.13, 130.52 };
// known resistance in voltage divider
int R1 = 217;
float MultiMap(float val, float* _in, uint8_t size)
{
// calculate if value is out of range
if (val < _in[0] ) return -99.99;
if (val > _in[size-1] ) return 99.99;
// search for 'value' in _in array to get the position No.
uint8_t pos = 0;
while(val > _in[pos]) pos++;
// handles the 'rare' equality case
if (val == _in[pos]) return pos;
float r1 = _in[pos-1];
float r2 = _in[pos];
int c1 = pos-1;
int c2 = pos;
return c1 + (val - r1) / (r2-r1) * (c2-c1);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int pt100 = analogRead(A0);
float Vout = pt100 * (5.0 / 1023.0);
float R2 = R1 * 1/(5.0/Vout - 1);
float c = MultiMap(R2,in,80);
Serial.print("Resistance: ");
Serial.print(R2);
Serial.println(" Ohm");
Serial.print("Temperature: ");
Serial.print(c);
Serial.println(" C");
delay(400);
}
克里斯,虽然您的解决方案有效,但仍有一些改进空间。
1)220欧姆上拉太小。 pt100有一个明显的电流不断运行,这会干扰精度。 一种非常简约的方法是增加上拉以减小电流,并放大分压器上的电压,参见http://www.avrfreaks.net/sites/default/files/pt100.JPG
2)一旦有明显的电缆运行和标准工业环境,您可以决定采用标准测量桥接布局。 这使用四根导线,其中两根用作恒流源。 (与污染电阻不同,恒流源可确保稳定的读数范围,并具有更好的温度稳定性。简单的上拉本身可能有明显的漂移。另外两根导线用作差分输入。这些导线上没有电流流过因此,传感器的实际布线距离不会影响精度。这种方法如下所示: https : //upload.wikimedia.org/wikipedia/commons/thumb/b/bd/4wire2.svg/286px-4wire2.svg .png实际上所有工业传感器都是按照这个原则工作的。
3)您可能更喜欢使用模拟前端而不是滚动自己的模拟电路。 AD7714 http://www.seekic.com/circuit_diagram/Measuring_and_Test_Circuit/Temperature_measurement_circuit_composed_of_the_AD7714_and_Pt100.html以及更多专业解决方案: http : //www.ti.com/europe/downloads/2-%203-%204-Wire% 20RTD%20Measurement.pdf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.