简体   繁体   English

如何使用带有PT100 RTD传感器的arduino uno板读取温度?

[英]How to read temperature using arduino uno board with PT100 RTD sensor?

I am new to arduino programming. 我是arduino编程的新手。 And almost inexperienced. 几乎没有经验。

I am looking to program my arduino Uno board to read 2/3/4 wire configuration of PT100 RTD sensor (in accuracy levels of atleast 0.5°C). 我希望对我的arduino Uno板进行编程,以读取PT100 RTD传感器的2/3/4线配置(精度等级至少为0.5°C)。 The temperature range is 0 to 400°C and -50 to 100°C. 温度范围为0至400°C和-50至100°C。

Since I am totally new to this field I would appreciate a rather descriptive information with circuits and images and code. 由于我对这个领域完全陌生,我会欣赏有关电路,图像和代码的相当描述性的信息。

I have researched a lot on the subject, but couldn't get anything useful or substantial to solve my problem. 我已经对这个问题进行了很多研究,但是无法解决我的问题。

Moreover, I cannot use thermistor or any IC to read the temperatures as the machine on which the RTD is installed has PIDs, but I would like to create a datalogger that can fetch temperatures on computer itself. 此外,我不能使用热敏电阻或任何IC来读取温度,因为安装RTD的机器具有PID,但我想创建一个可以在计算机上获取温度的数据记录器。

PT100 increases its resistance as heat is applied. PT100在施加热量时增加其电阻。 The temperature vs. resistance characteristic is described in pt100 resistance table 温度与电阻特性在pt100电阻表中描述

Arduino can read voltage on analog input. Arduino可以读取模拟输入的电压。 To get celsius degree readings we must: 要获得摄氏度读数,我们必须:

  1. read analog input as voltage 读取模拟输入作为电压
  2. calculate resistance value (voltage divider) 计算电阻值(分压器)
  3. lookup celsius degree from table based on resistance 根据阻力从表中查找摄氏度

分压器

Vin is 5 volt from arduino R1 is a resistance of known value in my program it is 220 Ohm actually R2 is the pt 100 Vout has to be connected to arduino analog input pin (A0 for instance) Vin是5伏来自arduino R1是我程序中已知值的电阻它是220欧姆实际R2是pt 100 Vout必须连接到arduino模拟输入引脚(例如A0)

R2 = R1 * 1 / ( Vin / Vout - 1) R2 = R1 * 1 /(Vin / Vout - 1)

The circuit can be done based on the picture above it is fairly simple. 电路可以根据上面的图片完成,相当简单。

The sketch I wrote contains resistance data from 0C - 80C (can be extended easily) To get the degrees from resistance value I use my version of MultiMap function that uses one float array as resistance values and uses linear interpolation to calculate exact degrees 我写的草图包含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);
}

Chris, although your solution works, there is a room for some improvement. 克里斯,虽然您的解决方案有效,但仍有一些改进空间。

1) the 220 ohm pullup is too small. 1)220欧姆上拉太小。 There is a noticable current running constantly through the pt100, which can interfere with the precision. pt100有一个明显的电流不断运行,这会干扰精度。 A very minimalistic approach is to increase the pullup to reduce this current, and amplify the voltage on the divider, see http://www.avrfreaks.net/sites/default/files/pt100.JPG 一种非常简约的方法是增加上拉以减小电流,并放大分压器上的电压,参见http://www.avrfreaks.net/sites/default/files/pt100.JPG

2) once there is a noticable cable runs, and standard industrial environment, you may decide to go for a standard measurement bridge layout. 2)一旦有明显的电缆运行和标准工业环境,您可以决定采用标准测量桥接布局。 This uses four wires, from which two is used as a constant current source. 这使用四根导线,其中两根用作恒流源。 (Unlike a pollup resistor, a constant current source ensures stable readouts full range, and shall have better temperature stability. A simple pullup itself may have a significant drift. The other two wires are used as a differential input. No current flows on these wires, therefore the actual wiring distance of the sensor will not affect the precision. This approach is shown here: https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/4wire2.svg/286px-4wire2.svg.png and in fact all industrial sensors work on this principle. (与污染电阻不同,恒流源可确保稳定的读数范围,并具有更好的温度稳定性。简单的上拉本身可能有明显的漂移。另外两根导线用作差分输入。这些导线上没有电流流过因此,传感器的实际布线距离不会影响精度。这种方法如下所示: https//upload.wikimedia.org/wikipedia/commons/thumb/b/bd/4wire2.svg/286px-4wire2.svg .png实际上所有工业传感器都是按照这个原则工作的。

3) you may prefer using an analog front-end instead of rolling your own analog circuit. 3)您可能更喜欢使用模拟前端而不是滚动自己的模拟电路。 AD7714 http://www.seekic.com/circuit_diagram/Measuring_and_Test_Circuit/Temperature_measurement_circuit_composed_of_the_AD7714_and_Pt100.html and a lot more professional solutions here: http://www.ti.com/europe/downloads/2-%203-%204-Wire%20RTD%20Measurement.pdf 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM