This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Temp_probes_RTD.ino
148 lines (136 loc) · 4.72 KB
/
Temp_probes_RTD.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
Machine Control - Temperature probes RTD example
This example provides a way to test the 3-wire RTDs
on the Machine control Carrier. It is possible to
acquire 2-wire RTD simply by shorting the RTDx pin
to the TPx pin. The Machine control carrier has on
board a precise 400 ohm 0.1% reference resistor which
is used as a reference by the MAX31865.
The circuit:
- Portenta H7
- Portenta Machine Control Carrier
- 3-wire RTD or 2-wire RTD
*/
#include <Arduino_MachineControl.h>
using namespace machinecontrol;
// The value of the Rref resistor. Use 430.0 for PT100 and 4300.0 for PT1000
#define RREF 400.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100, 1000.0 for PT1000
#define RNOMINAL 100.0
void setup() {
Serial.begin(9600);
Serial.println("MAX31865 PT100 Sensor Test!");
temp_probes.rtd.begin(THREE_WIRE);
temp_probes.enableRTD();
}
void loop() {
temp_probes.selectChannel(0);
Serial.println("CHANNEL 0 SELECTED");
uint16_t rtd = temp_probes.rtd.readRTD();
float ratio = rtd;
ratio /= 32768;
// Check and print any faults
uint8_t fault = temp_probes.rtd.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (temp_probes.rtd.getHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (temp_probes.rtd.getLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (temp_probes.rtd.getLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (temp_probes.rtd.getHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
temp_probes.rtd.clearFault();
} else {
Serial.print("RTD value: "); Serial.println(rtd);
Serial.print("Ratio = "); Serial.println(ratio, 8);
Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
Serial.print("Temperature = "); Serial.println(temp_probes.rtd.readTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(100);
temp_probes.selectChannel(1);
Serial.println("CHANNEL 1 SELECTED");
rtd = temp_probes.rtd.readRTD();
ratio = rtd;
ratio /= 32768;
// Check and print any faults
fault = temp_probes.rtd.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (temp_probes.rtd.getHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (temp_probes.rtd.getLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (temp_probes.rtd.getLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (temp_probes.rtd.getHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
temp_probes.rtd.clearFault();
} else {
Serial.print("RTD value: "); Serial.println(rtd);
Serial.print("Ratio = "); Serial.println(ratio, 8);
Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
Serial.print("Temperature = "); Serial.println(temp_probes.rtd.readTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(100);
temp_probes.selectChannel(2);
Serial.println("CHANNEL 2 SELECTED");
rtd = temp_probes.rtd.readRTD();
ratio = rtd;
ratio /= 32768;
// Check and print any faults
fault = temp_probes.rtd.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (temp_probes.rtd.getHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (temp_probes.rtd.getLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (temp_probes.rtd.getLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (temp_probes.rtd.getHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (temp_probes.rtd.getVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
temp_probes.rtd.clearFault();
} else {
Serial.print("RTD value: "); Serial.println(rtd);
Serial.print("Ratio = "); Serial.println(ratio, 8);
Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
Serial.print("Temperature = "); Serial.println(temp_probes.rtd.readTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(1000);
}