1
+ =======
1
2
MCP9600
2
3
=======
3
4
4
5
Contributed by Matteo Golin.
5
6
6
- The MCP9600 is a thermocouple EMF to temperature converter made by Microchip. It is also sold as a `breakout board module
7
- by Adafruit <https://learn.adafruit.com/adafruit-mcp9600-i2c-thermocouple-amplifier> `_.
7
+ The MCP9600 is a thermocouple EMF to temperature converter made by Microchip. It
8
+ is also sold as a `breakout board module by Adafruit
9
+ <https://learn.adafruit.com/adafruit-mcp9600-i2c-thermocouple-amplifier> `_.
8
10
9
11
Application Programming Interface
10
12
==================================
@@ -15,26 +17,63 @@ The header file for the MCP9600 driver interface can be included using:
15
17
16
18
#include <nuttx/sensors/mcp9600.h>
17
19
18
- The MCP9600 registration function allows the driver to be registered as a POSIX
19
- character driver.
20
+ The MCP9600 registration function allows the driver to be registered as a
21
+ :doc: `UORB </components/drivers/special/sensors/sensors_uorb >` sensor.
22
+
23
+ The MCP9600 measures three types of temperature:
24
+ * Hot junction temperature
25
+ * Cold junction temperature
26
+ * Temperature delta
27
+
28
+ Registering this sensor will create three UORB temperature topics, each with
29
+ their own unique device number. You must specify the unique device numbers for
30
+ each topic in the registration function:
31
+
32
+ .. code-block :: c
33
+
34
+ /* Registers sensor_temp1, sensor_temp2 and sensor_temp 3, where 1 is the
35
+ * hot junction topic, 2 is the cold junction topic and 3 is the delta
36
+ */
20
37
21
- The standard POSIX `read() ` operation will return the device information in
22
- plain-text, which is useful when debugging/testing the driver using `cat ` from
23
- the shell.
38
+ int err;
39
+ err = mcp9600_register(i2c_master, 0x60, 1, 2, 3);
40
+ if (err < 0) {
41
+ syslog(LOG_ERR, "Could not register MCP9600: %d\n", err);
42
+ }
24
43
25
- The `write() ` operation is not implemented for this sensor.
26
44
27
- Specific operations the sensor offers can be performed via the POSIX ` ioctl `
28
- operation. The supported commands are:
45
+ This sensor offers some additional control commands for features that are not
46
+ accessible with the standard UORB interface.
29
47
48
+ * :c:macro: `SNIOC_SET_THERMO `
30
49
* :c:macro: `SNIOC_WHO_AM_I `
31
50
* :c:macro: `SNIOC_READ_RAW_DATA `
32
51
* :c:macro: `SNIOC_CHECK_STATUS_REG `
33
52
* :c:macro: `SNIOC_CONFIGURE `
34
53
* :c:macro: `SNIOC_WRITECONF `
35
- * :c:macro: `SNIOC_READTEMP `
36
- * :c:macro: `SNIOC_SHUTDOWN `
37
- * :c:macro: `SNIOC_START `
54
+
55
+ ``SNIOC_SET_THERMO ``
56
+ --------------------
57
+
58
+ This command configures the thermocouple type of the MCP9600. The device
59
+ supports the following thermocouple types:
60
+
61
+ * K
62
+ * J
63
+ * T
64
+ * N
65
+ * E
66
+ * S
67
+ * B
68
+ * R
69
+
70
+ .. code-block :: c
71
+
72
+ int err;
73
+ err = orb_ioctl(sensor, SNIOC_SET_THERMO, SENSOR_THERMO_TYPE_J);
74
+ if (err < 0) {
75
+ syslog(LOG_ERR, "Failed to set thermocouple type: %d\n", err);
76
+ }
38
77
39
78
``SNIOC_WHO_AM_I ``
40
79
------------------
@@ -46,7 +85,7 @@ type ``struct mcp9600_devinfo_s *``.
46
85
.. code-block :: c
47
86
48
87
struct mcp9600_devinfo_s devinfo;
49
- err = ioctl (sensor, SNIOC_WHO_AM_I, &devinfo);
88
+ err = orb_ioctl (sensor, SNIOC_WHO_AM_I, &devinfo);
50
89
51
90
uint8_t revision_minor = MCP9600_REV_MINOR(devinfo.revision);
52
91
uint8_t revision_major = MCP9600_REV_MAJOR(devinfo.revision);
@@ -64,7 +103,7 @@ configured resolution; consult the data sheet.
64
103
.. code-block :: c
65
104
66
105
int32_t raw;
67
- err = ioctl (sensor, SNIOC_READ_RAW_DATA, &raw);
106
+ err = orb_ioctl (sensor, SNIOC_READ_RAW_DATA, &raw);
68
107
69
108
``SNIOC_CHECK_STATUS_REG ``
70
109
--------------------------
@@ -75,7 +114,7 @@ this command must be a pointer to type ``struct mcp9600_status_s``.
75
114
.. code-block :: c
76
115
77
116
struct mcp9600_status_s status;
78
- err = ioctl (sensor, SNIOC_CHECK_STATUS_REG, &status);
117
+ err = orb_ioctl (sensor, SNIOC_CHECK_STATUS_REG, &status);
79
118
80
119
``SNIOC_CONFIGURE ``
81
120
-------------------
@@ -93,7 +132,7 @@ mcp9600_devconf_s``.
93
132
.resolution = MCP9600_ADC_RES_18,
94
133
/* More fields ... */
95
134
};
96
- err = ioctl (sensor, SNIOC_CONFIGURE, &conf);
135
+ err = orb_ioctl (sensor, SNIOC_CONFIGURE, &conf);
97
136
98
137
``SNIOC_WRITECONF ``
99
138
-------------------
@@ -111,36 +150,4 @@ mcp9600_alertconf_s``.
111
150
.limit = 40 / 0.25,
112
151
/* More fields ... */
113
152
};
114
- err = ioctl(sensor, SNIOC_WRITECONF, &conf);
115
-
116
- ``SNIOC_READTEMP ``
117
- ------------------
118
-
119
- This command lets you read the three different types of temperature that the
120
- MCP9600 can measure. The argument to this command must be a pointer to type
121
- ``struct mcp9600_temp_s ``.
122
-
123
- .. code-block :: c
124
-
125
- struct mcp9600_temp_s temps;
126
- err = ioctl(sensor, SNIOC_READTEMP, &temps);
127
-
128
- printf("Temperature: %d C\n", temps.hot_junc);
129
-
130
- ``SNIOC_SHUTDOWN ``
131
- ------------------
132
-
133
- This command shuts down the sensor. It takes no arguments.
134
-
135
- .. code-block :: c
136
-
137
- err = ioctl(sensor, SNIOC_SHUTDOWN, NULL);
138
-
139
- ``SNIOC_START ``
140
- ---------------
141
-
142
- This command starts the sensor in normal mode. It takes no arguments.
143
-
144
- .. code-block :: c
145
-
146
- err = ioctl(sensor, SNIOC_START, NULL);
153
+ err = orb_ioctl(sensor, SNIOC_WRITECONF, &conf);
0 commit comments