Skip to content

Commit abac250

Browse files
committed
testing multi ntc
1 parent d682f11 commit abac250

File tree

3 files changed

+102
-7
lines changed

3 files changed

+102
-7
lines changed

max31855.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <ktypelinear.h>
77
// #include <quickstats.h> // @todo test quickstats, add child class for container
88
// #include <Statistics.h> // https://github.com/provideyourown/statistics
9-
#include <ntc.h>
9+
#include <ntc_multi.h>
1010
#include <Average.h>
1111
#include <number_format.h>
1212

@@ -17,9 +17,10 @@
1717
// HW cs D8 15
1818

1919
// #define MAXDO 5 // HWMISO
20-
#define MAXCS 15 // 2
21-
// #define MAXCLK 4 // HWSLK
22-
Adafruit_MAX31855 tc(MAXCS);
20+
#define MAXCS 16 // 2
21+
#define MAXCLK 14 // HWSLK
22+
#define MAXMISO 4
23+
Adafruit_MAX31855 tc(MAXCLK,MAXCS,MAXMISO);
2324

2425
#ifdef TC2
2526
Adafruit_MAX31855 tcB(1);

ntc_multi.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#ifndef ntc_h
2+
#define ntc_h
3+
4+
#include "thermistor.h"
5+
/**
6+
* Author: Daniel Berenguer
7+
* Creation date: 11/05/2014
8+
*
9+
* Basic library that reads a NTC thermistor from an analog pin. Calculations relie on
10+
* Steinhart–Hart equation: *
11+
*
12+
* https://en.wikipedia.org/wiki/Thermistor#Steinhart.E2.80.93Hart_equation *
13+
*
14+
* See the example for more information. *
15+
*
16+
* Example of use with panStamp:
17+
* https://github.com/panStamp/panstamp/wiki/Temperature-measurement-with-cheap-NTC's
18+
*/
19+
20+
// Analog pin used to read the NTC
21+
#define NTC_PIN 36
22+
#define NTC_BPIN 39
23+
#define NTC_CPIN 33
24+
25+
// #define VERBOSE_SENSOR_ENABLED 1
26+
27+
// 100000 / (320000 +RT) * 3.3
28+
int V = 3.3;
29+
int rt = 330000/V - 320000;
30+
31+
// Thermistor object
32+
// THERMISTOR ntc(NTC_PIN, // Analog pin
33+
// 10000, // Nominal resistance at 25 ºC
34+
// 3950, // thermistor's beta coefficient
35+
// 10000); // Value of the series resistor
36+
37+
uint16_t resist = 100000;
38+
uint16_t betaco = 3950;
39+
bool lowside = true;
40+
41+
THERMISTOR ntc(NTC_PIN,resist,betaco,resist,lowside);
42+
THERMISTOR ntcB(NTC_BPIN,resist,betaco,resist,!lowside);
43+
THERMISTOR ntcC(NTC_CPIN,resist,betaco,resist,lowside);
44+
45+
// Global temperature reading
46+
float ntc_temp;
47+
float ntc_temp_b;
48+
float ntc_temp_c;
49+
50+
/**
51+
* setup
52+
*
53+
* Arduino setup function
54+
*/
55+
void init_ntc()
56+
{
57+
58+
}
59+
60+
float get_ntc(){
61+
return ntc_temp;
62+
}
63+
64+
float get_ntc_B(){
65+
return ntc_temp_b;
66+
}
67+
68+
float get_ntc_C(){
69+
return ntc_temp_c;
70+
}
71+
/**
72+
* loop
73+
*
74+
* Arduino main loop
75+
*/
76+
void read_ntc()
77+
{
78+
ntc_temp = ntc.read(); // Read temperature
79+
ntc_temp_b = ntcB.read();
80+
ntc_temp_c = ntcC.read();
81+
// Serial.print("Temp in 1/10 ºC : ");
82+
// Serial.println(ntc_temp);
83+
// Serial.print("Temp in ºF : ");
84+
// Serial.println((((ntc_temp/10)*1.8)+32));
85+
}
86+
87+
void printNTC(){
88+
read_ntc();
89+
float tempf = (((ntc_temp/10)*1.8)+32);
90+
Serial.println("[NTC]: " + (String)(get_ntc()/10) + "ºC " + tempf + "ºF");
91+
}
92+
93+
#endif

reflow.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BarGraph bar0;
3939

4040
// #define USENTC // use thermistor
4141
#ifdef USENTC
42-
#include <ntc.h>
42+
#include <ntc_multi.h>
4343
#endif
4444

4545
// symbol glyph font for icons
@@ -126,7 +126,7 @@ int SCREENHEIGHT = 240; // TFT_WIDTH
126126
int GRAPHHEIGHT = SCREENHEIGHT-(FOOTERH); //padding 200px
127127
int GRAPHWIDTH = SCREENWIDTH;
128128

129-
int graphInterval = 1000; // graph update rate ms
129+
int graphInterval = 400; // graph update rate ms
130130

131131
TFT_eSprite spr = TFT_eSprite(&tft);
132132

@@ -146,6 +146,7 @@ int reflowStepTaskID = -1;
146146
int PIDTaskID = -1;
147147
int coolAbortTaskID = -1; // -1 empty
148148

149+
uint16_t NTC_TEMP = 0;
149150

150151
// REFLOW STATES
151152
#define RS_IDLE 0
@@ -888,7 +889,7 @@ void updateIcons(){
888889

889890
void dispReflowStats(){
890891
String str = "";
891-
str = "NTC: "+(String)(int)(round(get_ntc()/10));
892+
str = "NTC: "+(String)(int)(round(NTC_TEMP/10));
892893
str += " CJ: " + (String)(int)(round(internalTemp));
893894
setFooterBL1(str);
894895
str = "";

0 commit comments

Comments
 (0)