You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uint8_t number: What temperature alert to configure. Value can range from 1-4.
238
+
bool junction: Which junction to latch the alert to. Set to 0 for the thermocouple (hot) junction, or 1 for the ambient (cold) junction
239
+
uint8_t hysteresis: How many degrees Celcius of hysteresis to use in the alert. More information on how this behaves is on pg. 33 of the datasheet
240
+
bool edge: Configures whether to trigger on the junction going from cold -> hot (rising) or from hot -> cold (falling). Set to true for rising, false for falling.
241
+
bool activity: Configures whether the output pin is active-high or active-low. Set to true for active high, false for active low.
242
+
bool mode: Configures whether the output pin acts as an interrupt or a comparator. If configured as an interrupt, the interrupt must be cleared
243
+
in software before the hardware interrupt pin is deasserted. Set to true for interrupt mode, false for comparator mode.
244
+
bool enable: Configures whether or not the alert output pin is enabled. */
245
+
246
+
MCP9600_Register config_reg; //pick the set of registers we need to write to
247
+
MCP9600_Register hysteresis_reg;
248
+
MCP9600_Register limit_reg
249
+
switch (number){
250
+
case1:
251
+
config_reg = ALERT1_CONFIG;
252
+
hysteresis_reg = ALERT1_HYSTERESIS;
253
+
limit_reg = ALERT1_LIMIT;
254
+
break;
255
+
256
+
case2:
257
+
config_reg = ALERT2_CONFIG;
258
+
hysteresis_reg = ALERT2_HYSTERESIS;
259
+
limit_reg = ALERT2_LIMIT;
260
+
break;
261
+
262
+
case3:
263
+
config_reg = ALERT3_CONFIG;
264
+
hysteresis_reg = ALERT3_HYSTERESIS;
265
+
limit_reg = ALERT3_LIMIT;
266
+
break;
267
+
268
+
case4:
269
+
config_reg = ALERT4_CONFIG;
270
+
hysteresis_reg = ALERT4_HYSTERESIS;
271
+
limit_reg = ALERT4_LIMIT;
272
+
break;
273
+
274
+
default: //if the user didn't pick a valid register, just return with error
275
+
return1;
276
+
break;
277
+
}
278
+
279
+
//convert the user's parameters to register values
Copy file name to clipboardExpand all lines: src/SparkFun_MCP9600.h
+22-1Lines changed: 22 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,18 @@ enum MCP9600_Register {
38
38
SENSOR_STATUS = 0x04,
39
39
THERMO_SENSOR_CONFIG = 0x05,
40
40
DEVICE_CONFIG = 0x06,
41
+
ALERT1_CONFIG = 0x08,
42
+
ALERT2_CONFIG = 0x09,
43
+
ALERT3_CONFIG = 0x0A,
44
+
ALERT4_CONFIG = 0x0B,
45
+
ALERT1_HYSTERESIS = 0x0C,
46
+
ALERT2_HYSTERESIS = 0x0D,
47
+
ALERT3_HYSTERESIS = 0x0E,
48
+
ALERT4_HYSTERESIS = 0x0F,
49
+
ALERT1_LIMIT = 0x10,
50
+
ALERT2_LIMIT = 0x11,
51
+
ALERT3_LIMIT = 0x12,
52
+
ALERT4_LIMIT = 0x13,
41
53
DEVICE_ID = 0x20,
42
54
};
43
55
@@ -98,12 +110,13 @@ class MCP9600{
98
110
floatambientTemp(); //Returns the ambient (IC die) temperature in degrees Celcius
99
111
floattempDelta(); //Returns the difference in temperature between the thermocouple and ambient junctions, in degrees Celcius
100
112
signedlongrawADC(); //Returns the raw contents of the raw ADC register
113
+
boolinputRangeExceeded(); //Returns true if the MCP9600's EMF range has been exceeded, and false otherwise.
101
114
102
115
//Measurement configuration
103
116
boolsetAmbientResolution(Ambient_Resolution res); //Changes the resolution on the cold (ambient) junction, for either 0.0625 or 0.25 degree C resolution. Lower resolution reduces conversion time.
104
117
Ambient_Resolution getAmbientResolution(); //Returns the resolution on the cold (ambient) junction, for either 0.0625 or 0.25 degree C resolution. Lower resolution reduces conversion time.
105
118
boolsetThermocoupleResolution(Thermocouple_Resolution res); //Changes the resolution on the hot (thermocouple) junction, for either 18, 16, 14, or 12-bit resolution. Lower resolution reduces conversion time.
106
-
Thermocouple_Resolution getThermocoupleResolution(); //Returns the resolution on the hot (thermocouple) junction, for either 18, 16, 14, or 12-bit resolution. Lower resolution reduces conversion time.
119
+
Thermocouple_Resolution getThermocoupleResolution(); //Returns the resolution on the hot (thermocouple) junction, for either 18, 16, 14, or 12-bit resolution. Lower resolution reduces conversion time.
107
120
108
121
uint8_tsetThermocoupleType(Thermocouple_Type type); //Changes the type of thermocouple connected to the MCP9600. Supported types are KJTNSEBR.
109
122
Thermocouple_Type getThermocoupleType(); //Returns the type of thermocouple connected to the MCP9600 as found in its configuration register. Supported types are KJTNSEBR.
@@ -117,6 +130,14 @@ class MCP9600{
117
130
boolsetShutdownMode(Shutdown_Mode mode); //Changes the shutdown "operating" mode of the MCP9600. Configurable to Normal, Shutdown, and Burst. Returns 0 if properly set, 1 otherwise.
118
131
Shutdown_Mode getShutdownMode(); //Returns the shutdown "operating" mode of the MCP9600. Configurable to Normal, Shutdown, and Burst.
119
132
133
+
134
+
//Temperature Alerts
135
+
boolconfigAlert(uint8_t number, float tempLimit, //Configures the alert with the number of the alert to use, whether to use the hot or cold junction, how much hysteresis to use (in degrees C),
136
+
bool junction, uint8_t hysteresis, bool edge, //which edge to trigger on (rising or falling), activity (active high or active low), mode (comparator or interrupt), and whether everything is enabled
137
+
bool activity, bool mode, bool enable);
138
+
boolclearAlert(uint8_t number); //Clears the interrupt bit on the specified alert channel
139
+
boolisAlertTriggered(uint8_t number); //Returns true if the interrupt has been triggered, false otherwise
140
+
120
141
//Internal I2C Abstraction
121
142
private:
122
143
TwoWire *_i2cPort; //Generic connection to user's chosen I2C port
0 commit comments