major reorg
This commit is contained in:
parent
0c111dd818
commit
15cc422fc1
@ -25,6 +25,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/arduino/variant}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/arduino/variant}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/SPI}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/SPI}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/NilRTOS}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/NilRTOS}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/Metro}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="it.baeyens.arduino.compiler.cpp.sketch.input.244106961" name="CPP source files" superClass="it.baeyens.arduino.compiler.cpp.sketch.input"/>
|
<inputType id="it.baeyens.arduino.compiler.cpp.sketch.input.244106961" name="CPP source files" superClass="it.baeyens.arduino.compiler.cpp.sketch.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -34,6 +35,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/arduino/variant}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/arduino/variant}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/SPI}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/SPI}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/NilRTOS}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/NilRTOS}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/ThermometerPro/Libraries/Metro}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="it.baeyens.arduino.compiler.c.sketch.input.1503729033" name="C Source Files" superClass="it.baeyens.arduino.compiler.c.sketch.input"/>
|
<inputType id="it.baeyens.arduino.compiler.c.sketch.input.1503729033" name="C Source Files" superClass="it.baeyens.arduino.compiler.c.sketch.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
|
5
.project
5
.project
@ -26,6 +26,11 @@
|
|||||||
<nature>it.baeyens.arduinonature</nature>
|
<nature>it.baeyens.arduinonature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
|
<link>
|
||||||
|
<name>Libraries/Metro</name>
|
||||||
|
<type>2</type>
|
||||||
|
<locationURI>ArduinoPivateLibPath/Metro</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>Libraries/SPI</name>
|
<name>Libraries/SPI</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
|
@ -58,13 +58,13 @@ void SPI_Init() {
|
|||||||
pinMode(AD7190_SLAVE_ID, OUTPUT);
|
pinMode(AD7190_SLAVE_ID, OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SPI_Enable(unsigned char csPin) {
|
void SPI_Enable(unsigned char csPin) {
|
||||||
if (csPin != 0) {
|
if (csPin != 0) {
|
||||||
digitalWrite(csPin, LOW);
|
digitalWrite(csPin, LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SPI_Disable(unsigned char csPin) {
|
void SPI_Disable(unsigned char csPin) {
|
||||||
if (csPin != 0) {
|
if (csPin != 0) {
|
||||||
digitalWrite(csPin, HIGH);
|
digitalWrite(csPin, HIGH);
|
||||||
}
|
}
|
||||||
|
5
AD7190.h
5
AD7190.h
@ -210,5 +210,10 @@ unsigned long AD7190_TemperatureRead(void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SPI_Init();
|
||||||
|
void SPI_Enable(unsigned char csPin);
|
||||||
|
void SPI_Disable(unsigned char csPin);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __AD7190_H__ */
|
#endif /* __AD7190_H__ */
|
||||||
|
@ -1,125 +1,30 @@
|
|||||||
#include "ThermometerPro.h"
|
#include "ThermometerPro.h"
|
||||||
|
|
||||||
#include "AD7190.h"
|
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "uptime.h"
|
#include "uptime.h"
|
||||||
|
#include "thermometer.h"
|
||||||
|
|
||||||
|
|
||||||
static CmdServer cmdServer(&Serial);
|
static CmdServer cmdServer(&Serial);
|
||||||
static TestCmd testCmd;
|
static TestCmd testCmd;
|
||||||
static Uptime uptime;
|
static Uptime uptime;
|
||||||
|
static Thermometer thermometer;
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
cmdServer.begin();
|
cmdServer.begin();
|
||||||
testCmd.registerYourself(&cmdServer);
|
testCmd.registerYourself(&cmdServer);
|
||||||
uptime.begin(&cmdServer);
|
uptime.begin(&cmdServer);
|
||||||
|
thermometer.begin(&cmdServer);
|
||||||
Serial.begin(9600);
|
|
||||||
|
|
||||||
delay(5000);
|
delay(5000);
|
||||||
Serial.print("Hello world\n");
|
Serial.println("Start");
|
||||||
|
|
||||||
unsigned char ad7190Status = AD7190_Init();
|
|
||||||
Serial.print(String("ad7190Status: ") + ad7190Status + "\n");
|
|
||||||
|
|
||||||
AD7190_RangeSetup(1, AD7190_CONF_GAIN_1);
|
|
||||||
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN4P_AINCOM);
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN4P_AINCOM);
|
|
||||||
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN3P_AINCOM);
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN3P_AINCOM);
|
|
||||||
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN2P_AINCOM);
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN2P_AINCOM);
|
|
||||||
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN1P_AINCOM);
|
|
||||||
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN1P_AINCOM);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long T() {
|
|
||||||
AD7190_ChannelSelect(AD7190_CH_AIN4P_AINCOM);
|
|
||||||
unsigned long t = AD7190_SingleConversion();
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
float pt1000(float r) {
|
|
||||||
const float PT1000_R0 = 1000.0;
|
|
||||||
const float PT1000_Coeff = 3.85e-3;
|
|
||||||
float t = (r / PT1000_R0 - 1) / PT1000_Coeff;
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
cmdServer.exec();
|
cmdServer.exec();
|
||||||
uptime.exec();
|
uptime.exec();
|
||||||
|
thermometer.exec();
|
||||||
|
|
||||||
Serial.print("Tick\n");
|
|
||||||
|
|
||||||
AD7190_ChannelSelect(AD7190_CH_AIN4P_AINCOM);
|
|
||||||
unsigned long n4 = AD7190_SingleConversion();
|
|
||||||
n4 &= 0xffff00;
|
|
||||||
AD7190_ChannelSelect(AD7190_CH_AIN3P_AINCOM);
|
|
||||||
unsigned long n3x = AD7190_SingleConversion();
|
|
||||||
n3x &= 0xffff00;
|
|
||||||
AD7190_ChannelSelect(AD7190_CH_AIN2P_AINCOM);
|
|
||||||
unsigned long n2x = AD7190_SingleConversion();
|
|
||||||
n2x &= 0xffff00;
|
|
||||||
AD7190_ChannelSelect(AD7190_CH_AIN1P_AINCOM);
|
|
||||||
unsigned long n1x = AD7190_SingleConversion();
|
|
||||||
n1x &= 0xffff00;
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long n_max = 0xffffff;
|
|
||||||
float r_ref = 6000.0;
|
|
||||||
|
|
||||||
|
|
||||||
float r_m4 = (((float)n4) / ((float)n_max)) * r_ref * 1.0010705;
|
|
||||||
float t4 = pt1000(r_m4);
|
|
||||||
Serial.print(n4); Serial.print(", "); Serial.print(r_m4, 4); Serial.print(", "); Serial.print(t4, 2);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
unsigned long n3 = n3x - n4;
|
|
||||||
float r_m3 = (((float)n3) / ((float)n_max)) * r_ref * 1.000794;
|
|
||||||
float t3 = pt1000(r_m3);
|
|
||||||
Serial.print(n3x); Serial.print(", "); Serial.print(n3); Serial.print(", "); Serial.print(r_m3, 4); Serial.print(", "); Serial.print(t3, 2);
|
|
||||||
// float d = r_m4 - r_m3;
|
|
||||||
// Serial.print(", "); Serial.print(d, 2);
|
|
||||||
// unsigned long dd = n4 - n3;
|
|
||||||
// Serial.print(", "); Serial.print(dd);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
unsigned long n2 = n2x - n3x;
|
|
||||||
float r_m2 = (((float)n2) / ((float)n_max)) * r_ref * 1.001804;
|
|
||||||
float t2 = pt1000(r_m2);
|
|
||||||
Serial.print(n2x); Serial.print(", "); Serial.print(n2); Serial.print(", "); Serial.print(r_m2, 4); Serial.print(", "); Serial.print(t2, 2);
|
|
||||||
// d = r_m3 - r_m2;
|
|
||||||
// Serial.print(", "); Serial.print(d, 2);
|
|
||||||
// dd = n3 - n2;
|
|
||||||
// Serial.print(", "); Serial.print(dd);
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
unsigned long n1 = n1x - n2x;
|
|
||||||
float r_m1 = (((float)n1) / ((float)n_max)) * r_ref * 1.002999;
|
|
||||||
float t1 = pt1000(r_m1);
|
|
||||||
Serial.print(n1x); Serial.print(", "); Serial.print(n1); Serial.print(", "); Serial.print(r_m1, 4); Serial.print(", "); Serial.print(t1, 2);
|
|
||||||
// d = r_m2 - r_m1;
|
|
||||||
// Serial.print(", "); Serial.print(d, 2);
|
|
||||||
// dd = n2 - n1;
|
|
||||||
// Serial.print(", "); Serial.print(dd);
|
|
||||||
Serial.println();
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
3
fatal.h
3
fatal.h
@ -8,6 +8,9 @@ const uint8_t FATAL_NOT_ENOUGH_CMD_SLOTS = 2;
|
|||||||
|
|
||||||
const uint8_t FATAL_BUFFER_OVERFLOW = 10;
|
const uint8_t FATAL_BUFFER_OVERFLOW = 10;
|
||||||
|
|
||||||
|
const uint8_t FATAL_ADC_NOTFOUND = 20;
|
||||||
|
const uint8_t FATAL_ILLEGAL_STATE = 21;
|
||||||
|
|
||||||
|
|
||||||
void fatal(uint8_t code);
|
void fatal(uint8_t code);
|
||||||
|
|
||||||
|
177
thermometer.cpp
Normal file
177
thermometer.cpp
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
|
||||||
|
#include "thermometer.h"
|
||||||
|
#include "fatal.h"
|
||||||
|
#include "AD7190.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Thermometer::Thermometer() : m_period(DEFAULT_PERIOD),
|
||||||
|
m_timeOutFailureCnt(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float pt1000(float r) {
|
||||||
|
return (r / PT1000_R0 - 1) / PT1000_Coeff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Thermometer::setTemperature(unsigned int index, float t) {
|
||||||
|
if (DEBUG || INFO) { Serial.print("setTemperature: i="); Serial.print(index); Serial.print(", t="); Serial.print(t); Serial.println(); }
|
||||||
|
m_temperature[index] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void prepareAdc() {
|
||||||
|
unsigned long oldRegValue = AD7190_GetRegisterValue(AD7190_REG_CONF, 3, 1);
|
||||||
|
oldRegValue &= ~(AD7190_CONF_CHAN(0xFF));
|
||||||
|
unsigned long newRegValue = oldRegValue |
|
||||||
|
AD7190_CONF_CHAN(1 << AD7190_CH_AIN1P_AINCOM) |
|
||||||
|
AD7190_CONF_CHAN(1 << AD7190_CH_AIN2P_AINCOM) |
|
||||||
|
AD7190_CONF_CHAN(1 << AD7190_CH_AIN3P_AINCOM) |
|
||||||
|
AD7190_CONF_CHAN(1 << AD7190_CH_AIN4P_AINCOM);
|
||||||
|
if (DEBUG) { Serial.print("CONF: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||||
|
AD7190_SetRegisterValue(AD7190_REG_CONF, newRegValue, 3, 1);
|
||||||
|
|
||||||
|
newRegValue = AD7190_MODE_SEL(AD7190_MODE_IDLE) |
|
||||||
|
AD7190_MODE_CLKSRC(AD7190_CLK_INT) |
|
||||||
|
AD7190_MODE_REJ60 |
|
||||||
|
AD7190_MODE_DAT_STA |
|
||||||
|
AD7190_MODE_RATE(0x060);
|
||||||
|
if (DEBUG) { Serial.print("MODE: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||||
|
|
||||||
|
AD7190_SetRegisterValue(AD7190_REG_MODE, newRegValue, 3, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void startSingleConv() {
|
||||||
|
unsigned long oldRegValue = AD7190_GetRegisterValue(AD7190_REG_MODE, 3, 0);
|
||||||
|
oldRegValue &= ~(AD7190_MODE_SEL(0x07));
|
||||||
|
unsigned long newRegValue = oldRegValue | AD7190_MODE_SEL(AD7190_MODE_SINGLE);
|
||||||
|
if (DEBUG) { Serial.print("MODE: "); Serial.print(newRegValue, 16); Serial.println(); }
|
||||||
|
AD7190_SetRegisterValue(AD7190_REG_MODE, newRegValue, 3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Thermometer::begin(CmdServer *cmdServer) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char ad7190Status = AD7190_Init();
|
||||||
|
if (ad7190Status != 1)
|
||||||
|
fatal(FATAL_ADC_NOTFOUND);
|
||||||
|
|
||||||
|
AD7190_RangeSetup(1, AD7190_CONF_GAIN_1);
|
||||||
|
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN4P_AINCOM);
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN4P_AINCOM);
|
||||||
|
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN3P_AINCOM);
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN3P_AINCOM);
|
||||||
|
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN2P_AINCOM);
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN2P_AINCOM);
|
||||||
|
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_ZERO, AD7190_CH_AIN1P_AINCOM);
|
||||||
|
AD7190_Calibrate(AD7190_MODE_CAL_INT_FULL, AD7190_CH_AIN1P_AINCOM);
|
||||||
|
|
||||||
|
m_calibrateFactor[0] = 1.002999;
|
||||||
|
m_calibrateFactor[1] = 1.001804;
|
||||||
|
m_calibrateFactor[2] = 1.000794;
|
||||||
|
m_calibrateFactor[3] = 1.001071;
|
||||||
|
|
||||||
|
// prepare
|
||||||
|
prepareAdc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Thermometer::exec() {
|
||||||
|
static uint8_t state = 0;
|
||||||
|
|
||||||
|
static unsigned long timeOutCnt;
|
||||||
|
unsigned long command;
|
||||||
|
float r;
|
||||||
|
static unsigned int channelCnt;
|
||||||
|
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case 0:
|
||||||
|
if (DEBUG) { Serial.println(); }
|
||||||
|
if (DEBUG) { Serial.println("State 0"); }
|
||||||
|
// start conversion
|
||||||
|
SPI_Enable(AD7190_SLAVE_ID);
|
||||||
|
startSingleConv();
|
||||||
|
|
||||||
|
state = 1;
|
||||||
|
if (DEBUG) { Serial.println("Switching to State 1"); }
|
||||||
|
|
||||||
|
timeOutCnt = CONV_TIMEOUT;
|
||||||
|
channelCnt = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (timeOutCnt == 0) {
|
||||||
|
state = 9;
|
||||||
|
} else if (digitalRead(MISO) != HIGH) {
|
||||||
|
unsigned long n = AD7190_GetRegisterValue(AD7190_REG_DATA, 4, 0);
|
||||||
|
unsigned int channelIndex = (n & 0xff) - 4;
|
||||||
|
unsigned long adcValue = (n & 0xffffff00) >> 8;
|
||||||
|
|
||||||
|
m_n[channelIndex] = adcValue;
|
||||||
|
|
||||||
|
if (DEBUG) { Serial.print("m_n["); Serial.print(channelIndex); Serial.print("]="); Serial.print(m_n[channelIndex], 16); Serial.println(); }
|
||||||
|
|
||||||
|
channelCnt++;
|
||||||
|
if (channelCnt >= 4) {
|
||||||
|
state = 10;
|
||||||
|
if (DEBUG) { Serial.println("Switching to State 10"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
timeOutCnt = CONV_TIMEOUT;
|
||||||
|
}
|
||||||
|
timeOutCnt--;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
if (DEBUG) { Serial.println("State 9"); }
|
||||||
|
|
||||||
|
// end cycle
|
||||||
|
SPI_Disable(AD7190_SLAVE_ID);
|
||||||
|
|
||||||
|
// increase failure counter
|
||||||
|
m_timeOutFailureCnt++;
|
||||||
|
|
||||||
|
state = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
if (DEBUG) { Serial.println("State 10"); }
|
||||||
|
|
||||||
|
SPI_Disable(AD7190_SLAVE_ID);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < NUM_OF_CHANNELS; i++) {
|
||||||
|
if (DEBUG) { Serial.print("i="); Serial.print(i); Serial.print(", "); }
|
||||||
|
if (DEBUG) { Serial.print("m_n="); Serial.print(m_n[i]); Serial.print(", "); }
|
||||||
|
if (DEBUG) { Serial.print(""); Serial.print((m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))); Serial.print(", "); }
|
||||||
|
if (DEBUG) { Serial.print("m_calibrateFactor="); Serial.print(m_calibrateFactor[i], 6); Serial.print(", "); }
|
||||||
|
float r = (((float)(m_n[i] - ((i == 3) ? 0 : m_n[i + 1]))) / ((float)N_MAX)) * R_REF * m_calibrateFactor[i];
|
||||||
|
if (DEBUG) { Serial.print("r="); Serial.print(r); Serial.print(", "); }
|
||||||
|
float t = pt1000(r);
|
||||||
|
if (DEBUG) { Serial.print("t="); Serial.print(t); Serial.print(", "); }
|
||||||
|
if (DEBUG) { Serial.println(); }
|
||||||
|
setTemperature(i, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DEBUG) { Serial.println("Switching to state 11"); }
|
||||||
|
state = 11;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 11:
|
||||||
|
if (m_period.check() == 1)
|
||||||
|
state = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fatal(FATAL_ILLEGAL_STATE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
44
thermometer.h
Normal file
44
thermometer.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* thermometer.h
|
||||||
|
*
|
||||||
|
* Created on: 24.02.2014
|
||||||
|
* Author: wn
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef THERMOMETER_H_
|
||||||
|
#define THERMOMETER_H_
|
||||||
|
|
||||||
|
#include <Metro.h>
|
||||||
|
#include "cmd.h"
|
||||||
|
|
||||||
|
const bool DEBUG = false;
|
||||||
|
const bool INFO = true;
|
||||||
|
|
||||||
|
const unsigned long DEFAULT_PERIOD = 10000;
|
||||||
|
const unsigned int NUM_OF_CHANNELS = 4;
|
||||||
|
const unsigned long N_MAX = 0xffffff;
|
||||||
|
const float R_REF = 6000.0;
|
||||||
|
const float PT1000_R0 = 1000.0;
|
||||||
|
const float PT1000_Coeff = 3.85e-3;
|
||||||
|
const unsigned long CONV_TIMEOUT = 0xfffff;
|
||||||
|
|
||||||
|
|
||||||
|
class Thermometer {
|
||||||
|
public:
|
||||||
|
Thermometer();
|
||||||
|
void begin(CmdServer *cmdServer);
|
||||||
|
void exec();
|
||||||
|
private:
|
||||||
|
Metro m_period;
|
||||||
|
|
||||||
|
unsigned long m_n[NUM_OF_CHANNELS];
|
||||||
|
float m_calibrateFactor[NUM_OF_CHANNELS];
|
||||||
|
float m_temperature[NUM_OF_CHANNELS];
|
||||||
|
unsigned long m_timeOutFailureCnt;
|
||||||
|
|
||||||
|
void setTemperature(unsigned int index, float t);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* THERMOMETER_H_ */
|
Loading…
x
Reference in New Issue
Block a user