changed to max31855
This commit is contained in:
BIN
CAD/Datasheet/MAX31855.pdf
Normal file
BIN
CAD/Datasheet/MAX31855.pdf
Normal file
Binary file not shown.
@@ -18,8 +18,7 @@ monitor_speed = 115200
|
||||
lib_deps =
|
||||
bodmer/TFT_eSPI@^2.3.70
|
||||
br3ttb/PID@^1.2.1
|
||||
;siruli/MAX6675@^2.1.0
|
||||
zhenek-kreker/MAX6675 with hardware SPI@^1.0.0
|
||||
robtillaart/MAX31855@^0.2.5
|
||||
lib_ldf_mode = deep+
|
||||
build_flags =
|
||||
-D USER_SETUP_LOADED=1
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
// #define LCD_CS PB0
|
||||
|
||||
#define THERM_SS PB12
|
||||
#define THERM_MISO PB13
|
||||
#define THERM_CLK PB14
|
||||
#define THERM_MISO PB14
|
||||
#define THERM_CLK PB13
|
||||
#define THERM_MOSI PB15 //not used
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ uint32_t calcTime(uint32_t timeMs)
|
||||
return map((timeMs / 1000), 0, CHART_TIME_MAX, 0, CHART_W - CHART_Y_AXIS_OFFSET);
|
||||
}
|
||||
|
||||
std::vector<double> temperatureReading;
|
||||
std::vector<float> temperatureReading;
|
||||
uint32_t lastReading = 0;
|
||||
#define TEMPINTERVAL 1000
|
||||
|
||||
|
||||
@@ -1,40 +1,48 @@
|
||||
#include "thermo.h"
|
||||
#include "controlloop.h"
|
||||
|
||||
MAX6675 thermocouple(THERM_SS, THERM_MISO, THERM_CLK);
|
||||
//MAX6675 thermocouple(THERM_SS, THERM_MISO, THERM_CLK);
|
||||
MAX31855 thermocouple(THERM_CLK, THERM_SS, THERM_MISO); //uint8_t CS, uint8_t MISO);
|
||||
|
||||
// initialize the Thermocouple
|
||||
//Adafruit_MAX31855 thermocouple(THERM_CLK, THERM_SS, THERM_MISO);
|
||||
|
||||
uint32_t thermo_lastTime = 0;
|
||||
|
||||
double lastTemperature = 0;
|
||||
float lastTemperature = 0;
|
||||
float internal = 0;
|
||||
|
||||
bool simulation = true;
|
||||
bool simulation = false;
|
||||
#define SIM_TEMP_STEP 1
|
||||
#define SIM_TEMP_COOL 0.08
|
||||
#define SIM_INTERVAL 100
|
||||
uint32_t simTimer = 0;
|
||||
uint32_t sampleTimer = 0;
|
||||
|
||||
void initThermo()
|
||||
{
|
||||
if(simulation)
|
||||
thermocouple.begin();
|
||||
if (simulation)
|
||||
{
|
||||
lastTemperature = TEMPERATURE_ROOM-20;
|
||||
lastTemperature = TEMPERATURE_ROOM - 20;
|
||||
}
|
||||
}
|
||||
|
||||
void handleThermo(void)
|
||||
{
|
||||
if(simulation)
|
||||
{
|
||||
uint32_t timeNow = millis();
|
||||
if(timeNow - simTimer > SIM_INTERVAL)
|
||||
if (simulation)
|
||||
{
|
||||
if(getOutputState())
|
||||
|
||||
if (timeNow - simTimer > SIM_INTERVAL)
|
||||
{
|
||||
if (getOutputState())
|
||||
{
|
||||
lastTemperature += SIM_TEMP_STEP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(lastTemperature > TEMPERATURE_ROOM-20)
|
||||
if (lastTemperature > TEMPERATURE_ROOM - 20)
|
||||
{
|
||||
lastTemperature -= SIM_TEMP_COOL;
|
||||
}
|
||||
@@ -44,33 +52,22 @@ void handleThermo(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
lastTemperature = thermocouple.readTempC();
|
||||
|
||||
if (timeNow - sampleTimer > THERMO_INTERVAL)
|
||||
{
|
||||
int state = thermocouple.read();
|
||||
lastTemperature = thermocouple.getTemperature();
|
||||
internal = thermocouple.getInternal();
|
||||
sampleTimer = timeNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double getTemperature(void)
|
||||
float getTemperature(void)
|
||||
{
|
||||
return lastTemperature; //lastTemperature;
|
||||
}
|
||||
|
||||
bool getThermoCoupleFault(void)
|
||||
{
|
||||
#ifdef MAX31856
|
||||
uint8_t fault = thermocouple.readFault();
|
||||
if (fault)
|
||||
{
|
||||
if (fault & MAX6675_FAULT_CJRANGE) //Serial.println("Cold Junction Range Fault");
|
||||
if (fault & MAX31856_FAULT_TCRANGE) //Serial.println("Thermocouple Range Fault");
|
||||
if (fault & MAX31856_FAULT_CJHIGH) //Serial.println("Cold Junction High Fault");
|
||||
if (fault & MAX31856_FAULT_CJLOW) //Serial.println("Cold Junction Low Fault");
|
||||
if (fault & MAX31856_FAULT_TCHIGH) //Serial.println("Thermocouple High Fault");
|
||||
if (fault & MAX31856_FAULT_TCLOW) //Serial.println("Thermocouple Low Fault");
|
||||
if (fault & MAX31856_FAULT_OVUV) //Serial.println("Over/Under Voltage Fault");
|
||||
if (fault & MAX31856_FAULT_OPEN) //Serial.println("Thermocouple Open Fault");
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
return thermocouple.genericError();
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
#include "Arduino.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "max6675.h"
|
||||
//#include "max6675.h"
|
||||
#include "MAX31855.h"
|
||||
|
||||
#define THERMO_INTERVAL 200
|
||||
#define SMOOTHING_FACTOR 2
|
||||
|
||||
void initThermo(void);
|
||||
void handleThermo(void);
|
||||
double getTemperature(void);
|
||||
float getTemperature(void);
|
||||
bool getThermoCoupleFault(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user