我目前正在使用Adafruit_MAX31855 IC和K型热电偶。出于某种原因,我在串行监视器中得到这个......
Internal Temp = 32.44
nan // printed from thermocouple.readCelcius()
Internal Temp = 32.44
nan
Internal Temp = 32.44
nan
Internal Temp = 32.44
nan
Internal Temp = 32.38
nan
Internal Temp = 32.38
nan
Internal Temp = 32.38
nan
Internal Temp = 32.38
nan
Internal Temp = 32.31
现在我知道所有接线都正确,因为我正在获得内部温度。除此之外,.readCelcius()命令有时会返回正确的读数。我一开始认为最大温度可能超出了芯片的性能,但是当在40摄氏度下运行时,我有时会得到这个。
#include <SPI.h>
#include "Adafruit_MAX31855.h"
int HeaterPWM = 12;
int LEDPin = 13;
long _startTime;
long _currentTime;
#define MAXDO 3
#define MAXCS 4
#define MAXCLK 5
Adafruit_MAX31855 thermocouple(MAXCLK, MAXCS, MAXDO);
void setup() {
while (!Serial); // wait for Serial on Leonardo/Zero, etc
Serial.begin(9600);
pinMode(HeaterPWM, OUTPUT);
pinMode(LEDPin, OUTPUT);
Serial.println("MAX31855 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
_startTime = millis();
while (_currentTime - _startTime < 3000) // heater on for 3 seconds at a time
{
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
_currentTime = millis();
analogWrite(HeaterPWM, 150);
digitalWrite(LEDPin, HIGH);
double c = sampleCelcius(1);
Serial.println(c);
delay(10);
}
_startTime = millis();
while (_currentTime - _startTime < 10000) // heater on for 3 seconds at a time
{
Serial.print("Internal Temp = ");
Serial.println(thermocouple.readInternal());
_currentTime = millis();
analogWrite(HeaterPWM, 0);
digitalWrite(LEDPin, LOW);
double c = sampleCelcius(1);
Serial.println(c);
delay(10);
}
}
double sampleCelcius(int maxSamples)
{
double result = NAN;
for (int i = 0; i < maxSamples; i++)
{
result = thermocouple.readCelsius();
if (!isnan(result)) // exit on first good reading.
break;
delay(10);
}
return result;
}
我检查了所有电压和PWM输出等,以及对热电偶进行基准测试。当它在室温下工作时是正确的。当加热器打开时,我确实得到了读数而不是楠,我似乎得到了数以千计的非常高的数字,这显然是不正确的。它应该在65摄氏度左右。
有什么想法吗?
答案 0 :(得分:0)
事实证明,Adafruit_MAX31855 IC与导电表面不兼容,“加热”也会向热电偶发送电压,从而丢失读数。