Skip to content

Commit 68259d9

Browse files
Merge pull request #28 from leonardocavagnis/tc_pin_fix
Fix NaN readings issue in thermocouple `TCTempProbeClass` class
2 parents a5727ca + 3294959 commit 68259d9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/TCTempProbeClass.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ uint8_t* boardInfo();
1818
TCTempProbeClass::TCTempProbeClass(PinName tc_cs_pin,
1919
PinName ch_sel0_pin,
2020
PinName ch_sel1_pin,
21-
PinName ch_sel2_pin)
22-
: MAX31855Class(tc_cs_pin), _tc_cs{tc_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel1_pin}, _ch_sel2{ch_sel2_pin}
21+
PinName ch_sel2_pin,
22+
PinName tc_th_pin)
23+
: MAX31855Class(tc_cs_pin), _tc_cs{tc_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel1_pin}, _ch_sel2{ch_sel2_pin}, _tc_th{tc_th_pin}
2324
{ }
2425

2526
TCTempProbeClass::~TCTempProbeClass()
@@ -31,6 +32,7 @@ bool TCTempProbeClass::begin() {
3132
pinMode(_ch_sel0, OUTPUT);
3233
pinMode(_ch_sel1, OUTPUT);
3334
pinMode(_ch_sel2, OUTPUT);
35+
pinMode(_tc_th, OUTPUT);
3436

3537
pinMode(_tc_cs, OUTPUT);
3638

@@ -92,10 +94,12 @@ void TCTempProbeClass::end() {
9294

9395
void TCTempProbeClass::_enable() {
9496
digitalWrite(_tc_cs, LOW);
97+
digitalWrite(_tc_th, LOW);
9598
}
9699

97100
void TCTempProbeClass::_disable() {
98101
digitalWrite(_tc_cs, HIGH);
102+
digitalWrite(_tc_th, HIGH);
99103
}
100104

101105
TCTempProbeClass MachineControl_TCTempProbe;

src/TCTempProbeClass.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class TCTempProbeClass: public MAX31855Class {
4141
TCTempProbeClass(PinName tc_cs_pin = MC_TC_CS_PIN,
4242
PinName ch_sel0_pin = MC_TC_SEL0_PIN,
4343
PinName ch_sel1_pin = MC_TC_SEL1_PIN,
44-
PinName ch_sel2_pin = MC_TC_SEL2_PIN);
44+
PinName ch_sel2_pin = MC_TC_SEL2_PIN,
45+
PinName tc_th_pin = MC_TC_TH_PIN);
4546

4647
/**
4748
* @brief Destruct the TCTempProbeClass object.
@@ -74,6 +75,7 @@ class TCTempProbeClass: public MAX31855Class {
7475
PinName _ch_sel0; // Pin for the first channel selection bit
7576
PinName _ch_sel1; // Pin for the second channel selection bit
7677
PinName _ch_sel2; // Pin for the third channel selection bit
78+
PinName _tc_th; // Pin for the TC/RTD connection
7779

7880
/**
7981
* @brief Enable the chip select (CS) of the MAX31855 digital converter.

src/pins_mc.h

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
#define MC_TC_SEL0_PIN MC_RTD_SEL0_PIN
8585
#define MC_TC_SEL1_PIN MC_RTD_SEL1_PIN
8686
#define MC_TC_SEL2_PIN MC_RTD_SEL2_PIN
87+
#define MC_TC_TH_PIN MC_RTD_TH_PIN
8788

8889
/* USB */
8990
#define MC_USB_PWR_PIN PB_14

0 commit comments

Comments
 (0)