Skip to content

Seperate temperature probes #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8895f39
Reformating MAX31855 class
JHSawatzki May 22, 2024
a45f5ed
Further code formating in MAX31855 class
JHSawatzki May 22, 2024
b69fd34
Minor code formating and spelling fixes
JHSawatzki May 22, 2024
07b3f95
Minor fixes and removing global object definition for MAX31855
JHSawatzki May 22, 2024
aaa8ec4
Preparation for multi probe setups and shared implementation for temp…
JHSawatzki May 22, 2024
91f1d8b
Renaming folder MAX31865 to RTD
JHSawatzki May 22, 2024
f534edf
Adding type T TC probe type
JHSawatzki May 22, 2024
f243a01
Add ability to retrieve the TC fault cause
JHSawatzki May 22, 2024
667bb15
Renaming coldTempTomv to tempTomv
JHSawatzki May 22, 2024
4fe00ca
Code formating and readability improvements
JHSawatzki May 22, 2024
4a63b8f
Added ability to read TC voltage. Also changed return type from float…
JHSawatzki May 22, 2024
952590a
Getter functions fro parameters added
JHSawatzki May 22, 2024
76f88a0
Formating of MAX31865Class
JHSawatzki May 22, 2024
6d97927
Further code formating
JHSawatzki May 22, 2024
f15e881
Changed SPI communication to be equal to MAX31855Class
JHSawatzki May 22, 2024
21175b4
Minor typo fixed
JHSawatzki May 22, 2024
11655b6
readBytes renamed to readWord
JHSawatzki May 22, 2024
f69ca1a
Changes for multi probe (different types) and shared library for TC a…
JHSawatzki May 22, 2024
f3d9cdd
Introduction of shared TempProbeClass
JHSawatzki May 29, 2024
907a450
Merge branch 'iabg' into seperate-temperature-probes
JHSawatzki May 29, 2024
383b9a4
Merge pull request #1 from JHSawatzki/seperate-temperature-probes
JHSawatzki May 29, 2024
f0eec75
Remove artifacts, Thermocouple type-t corrections and typo corrected
JHSawatzki Jun 3, 2024
dd66851
Merge branch 'iabg' into seperate-temperature-probes
JHSawatzki Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ https://www.arduino.cc/reference/en/libraries/arduino_portentamachinecontrol/
- Manages input signals, including:
- 8 digital inputs at 24Vdc
- 2 channels for encoder readings
- 3 analog inputs for PT100/J/K temperature probes
- 3 analog inputs for PT100 and TC J/K/T temperature probes
- 3 analog inputs for 4-20mA/0-10V/NTC signals

- Manages output signals, including:
Expand Down Expand Up @@ -81,6 +81,7 @@ void loop() {
- **[RTC_Alarm](../examples/RTC_Alarm):** This example demonstrates how to set up and utilize RTC alarms.
- **[Temp_probes_RTD](../examples/Temp_probes_RTD):** This example demonstrates the temperature probe readings using RTD sensors.
- **[Temp_probes_Thermocouples](../examples/Temp_probes_Thermocouples):** This example demonstrates the temperature probe readings using thermocouple sensors.
- **[Temp_probes_Mixed](../examples/Temp_probes_Mixed):** This example demonstrates the temperature probe readings using both thermocouple and RTD sensors at the same time.
- **[USB_host](../examples/USB_host):** This example shows the USB host functionality.

## API
Expand Down
24 changes: 21 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
`class` [`RTDTempProbeClass`](#class-rtdtempprobeclass) | Class for managing the Resistance Temperature Detector (RTD) temperature sensor connector of the Portenta Machine Control.
`class` [`RtcControllerClass`](#class-rtccontrollerclass) | Class for controlling the PCF8563T RTC of the Portenta Machine Control.
`class` [`TCTempProbeClass`](#class-tctempprobeclass) | Class for managing the Thermocouple (TC) temperature sensor connector of the Portenta Machine Control.
`class` [`TempProbeClass`](#class-tempprobeclass) | Class for managing the temperature sensor connector in mixed configurations of the Portenta Machine Control.
`class` [`USBClass`](#class-usbclass) | Class for managing the USB functionality of the Portenta Machine Control.

# class `AnalogInClass`
Expand Down Expand Up @@ -128,11 +129,12 @@ Class for managing RTD temperature sensor inputs of the Portenta Machine Control

Members | Descriptions
--------------------------------|---------------------------------------------
`public ` [`RTDTempProbeClass`](#public-rtdtempprobeclasspinname-rtd_cs_pin--mc_rtd_cs_pin-pinname-ch_sel0_pin--mc_rtd_sel0_pin-pinname-ch_sel1_pin--mc_rtd_sel1_pin-pinname-ch_sel2_pin--mc_rtd_sel2_pin-pinname-rtd_th_pin--mc_rtd_th_pin)`(PinName rtd_cs_pin, PinName ch_sel0_pin, PinName ch_sel1_pin, PinName ch_sel2_pin, PinName rtd_th_pin)` | Construct a RTDTempProbeClass object.
`public ` [`RTDTempProbeClass`](#public-rtdtempprobeclasspinname-rtd_cs_pin--mc_rtd_cs_pin-pinname-ch_sel0_pin--mc_tp_sel0_pin-pinname-ch_sel1_pin--mc_tp_sel1_pin-pinname-ch_sel2_pin--mc_tp_sel2_pin-pinname-rtd_th_pin--mc_rtd_th_pin)`(PinName rtd_cs_pin, PinName ch_sel0_pin, PinName ch_sel1_pin, PinName ch_sel2_pin, PinName rtd_th_pin)` | Construct a RTDTempProbeClass object.
`public ` [`~RTDTempProbeClass`](#public-rtdtempprobeclass)`()` | Destruct the RTDTempProbeClass object.
`public bool` [`begin`](#public-bool-beginuint8_t-io_address--three_wire)`(uint8_t io_address)` | Initialize the RTDTempProbeClass with the specified I/O address.
`public bool` [`begin`](#public-bool-beginuint8_t-io_address--probe_rtd_3w)`(uint8_t io_address)` | Initialize the RTDTempProbeClass with the specified I/O address.
`public void` [`end`](#public-void-end)`()` | Disable the temperature sensors and release any resources.
`public void` [`selectChannel`](#public-void-selectchannelint-channel)`(int channel)` | Select the input channel to be read (3 channels available).
`public float` [`readTemperature`](#public-float-readTemperaturefloat-rtdnominal-float-refresistor)`(float RTDnominal, float refResistor)` | Read temperature value of the connected RTD.

# class `RtcControllerClass`
Class for controlling the PCF8563T RTC.
Expand All @@ -151,11 +153,27 @@ Class for managing thermocouples temperature sensor of the Portenta Machine Cont

Members | Descriptions
--------------------------------|---------------------------------------------
`public ` [`TCTempProbeClass`](#public-tctempprobeclasspinname-tc_cs_pin--mc_tc_cs_pin-pinname-ch_sel0_pin--mc_tc_sel0_pin-pinname-ch_sel1_pin--mc_tc_sel1_pin-pinname-ch_sel2_pin--mc_tc_sel2_pin)`(PinName tc_cs_pin, PinName ch_sel0_pin, PinName ch_sel1_pin, PinName ch_sel2_pin)` | Construct a TCTempProbeClass object.
`public ` [`TCTempProbeClass`](#public-tctempprobeclasspinname-tc_cs_pin--mc_tc_cs_pin-pinname-ch_sel0_pin--mc_tp_sel0_pin-pinname-ch_sel1_pin--mc_tp_sel1_pin-pinname-ch_sel2_pin--mc_tp_sel2_pin)`(PinName tc_cs_pin, PinName ch_sel0_pin, PinName ch_sel1_pin, PinName ch_sel2_pin)` | Construct a TCTempProbeClass object.
`public ` [`~TCTempProbeClass`](#public-tctempprobeclass)`()` | Destruct the TCTempProbeClass object.
`public bool` [`begin`](#public-bool-begin)`()` | Initialize the TCTempProbeClass.
`public void` [`end`](#public-void-end)`()` | Disable the temperature sensors and release any resources.
`public void` [`selectChannel`](#public-void-selectchannelint-channel)`(int channel)` | Select the input channel to be read (3 channels available).
`public float` [`readTemperature`](#public-float-readTemperatureuint8_t-type--probe_tc_k)`(uint8_t type)` | Read temperature value of the connected thermocouple.

# class `TempProbeClass`
Class for managing Resistance Temperature Detector (RTD) and Thermocouple (TC) temperature sensor connectors of the Portenta Machine Control.

## Summary

Members | Descriptions
--------------------------------|---------------------------------------------
`public ` [`TempProbeClass`](#public-tctempprobeclasspinname-ch_sel0_pin--mc_tp_sel0_pin-pinname-ch_sel1_pin--mc_tp_sel1_pin-pinname-ch_sel2_pin--mc_tp_sel2_pin-pinname-tc_cs_pin--mc_tc_cs_pin-pinname-rtd_cs_pin--mc_rtd_cs_pin-pinname-rtd_th_pin--mc_rtd_th_pin)`(PinName ch_sel0_pin, PinName ch_sel1_pin, PinName ch_sel2_pin, PinName tc_cs_pin, PinName rtd_cs_pin, PinName rtd_th_pin)` | Construct a TempProbeClass object.
`public ` [`~TempProbeClass`](#public-tctempprobeclass)`()` | Destruct the TCTempProbeClass object.
`public bool` [`beginTC`](#public-bool-begintc)`()` | Initialize the TempProbeClass for TC measurements.
`public bool` [`beginRTD`](#public-bool-beginrtd)`()` | Initialize the TempProbeClass for RTD measurements.
`public void` [`endTC`](#public-void-endtc)`()` | Disable the TC temperature sensors and release any resources.
`public void` [`endRTD`](#public-void-endrtd)`()` | Disable the temperature sensors and release any resources.
`public void` [`selectChannel`](#public-void-selectchanneluint8_t-channel-uint8_t-uint8_t-probetype)`(uint8_t channel, uint8_t probeType)` | Select the input channel and probe type to be read (3 channels available).

# class `USBClass`
Class for managing the USB functionality of the Portenta Machine Control.
Expand Down
137 changes: 137 additions & 0 deletions examples/Temp_probes_Mixed/Temp_probes_Mixed.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Portenta Machine Control - Temperature Probes Mixed Example
*
* This example provides a method to test the RTD/TC inputs
* on the Machine Control Carrier for mixed setups.
*
* Acquisition of 2-wire RTDs is possible by shorting the RTDx pin to the TPx pin.
* The Machine Control Carrier features a precise 400 ohm 0.1% reference resistor,
* which serves as a reference for the MAX31865.
*
* Circuit:
* - Portenta H7
* - Portenta Machine Control
* - RTDs 3-wire or 2-wire
* - TCs type K/J/T
*
* This example code is in the public domain.
* Copyright (c) 2024 Arduino
* SPDX-License-Identifier: MPL-2.0
*/

#include <Arduino_PortentaMachineControl.h>

// The value of the Rref resistor.
#define RREF 400.0
// The 'nominal' 0-degrees-C resistance of the sensor
// 100.0 for PT100
#define RNOMINAL 100.0

void setup() {
Serial.begin(9600);
while (!Serial) {
;
}

// Initialize RTD temperature probes
MachineControl_TempProbe.beginRTD();
Serial.println("RTD Temperature probes initialization done");

// Initialize TC temperature probes
MachineControl_TCTempProbe.beginTC();
Serial.println("TC Temperature probes initialization done");
}

void loop() {
MachineControl_TempProbe.selectChannel(0, PROBE_RTD_3W);
Serial.println("CHANNEL 0 SELECTED");
uint16_t rtd = MachineControl_TempProbe.readRTD();
float ratio = rtd;
ratio /= 32768;

// Check and print any faults
if (!checkRTDFault()) {
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(MachineControl_TempProbe.convertRTDTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(100);

//Set CH1, has internal 150 ms delay
MachineControl_TempProbe.selectChannel(0, PROBE_TC_T);
Serial.println("CHANNEL 0 SELECTED");
//Take CH0 measurement
float temp_ch1 = MachineControl_TempProbe.readTCTemperature();
// Check and print any faults
if (!checkTCFault()) {
Serial.print("TC Temperature CH1 [°C]: ");
Serial.print(temp_ch1);
Serial.println();
}

MachineControl_TempProbe.selectChannel(2, PROBE_RTD_3W);
Serial.println("CHANNEL 2 SELECTED");
rtd = MachineControl_TempProbe.readRTD();
ratio = rtd;
ratio /= 32768;

// Check and print any faults
if (!checkRTDFault()) {
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(MachineControl_TempProbe.convertRTDTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(1000);
}

bool checkRTDFault() {
// Check and print any faults
uint8_t fault = MachineControl_TempProbe.readRTDFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (MachineControl_TempProbe.getRTDHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (MachineControl_TempProbe.getRTDLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (MachineControl_TempProbe.getRTDLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (MachineControl_TempProbe.getRTDHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_TempProbe.getRTDLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_TempProbe.getRTDVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
MachineControl_TempProbe.clearRTDFault();
return true;
} else {
return false;
}
}

bool checkTCFault() {
// Check and print any faults
uint8_t fault = MachineControl_TempProbe.getTCLastFault();
if (fault & TC_FAULT_OPEN) {
Serial.println("Thermocouple is open - no connections.");
return true;
}
if (fault & TC_FAULT_SHORT_GND) {
Serial.println("Thermocouple is short-circuited to GND.");
return true;
}
if (fault & TC_FAULT_SHORT_VCC) {
Serial.println("Thermocouple is short-circuited to VCC.");
return true;
}
return false;
}
80 changes: 24 additions & 56 deletions examples/Temp_probes_RTD/Temp_probes_RTD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* - Portenta Machine Control
* - 3-wire RTD or 2-wire RTD
*
* This example code is in the public domain.
* This example code is in the public domain.
* Copyright (c) 2024 Arduino
* SPDX-License-Identifier: MPL-2.0
*/
Expand All @@ -31,40 +31,20 @@ void setup() {
;
}

MachineControl_RTDTempProbe.begin(THREE_WIRE);
MachineControl_RTDTempProbe.begin(PROBE_RTD_3W);
Serial.println("RTD Temperature probes initialization done");
}

void loop() {
//Set CH0, has internal 75 ms delay
MachineControl_RTDTempProbe.selectChannel(0);
Serial.println("CHANNEL 0 SELECTED");
uint16_t rtd = MachineControl_RTDTempProbe.readRTD();
float ratio = rtd;
ratio /= 32768;

// Check and print any faults
uint8_t fault = MachineControl_RTDTempProbe.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (MachineControl_RTDTempProbe.getHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (MachineControl_RTDTempProbe.getLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (MachineControl_RTDTempProbe.getLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (MachineControl_RTDTempProbe.getHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_RTDTempProbe.getLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_RTDTempProbe.getVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
MachineControl_RTDTempProbe.clearFault();
} else {
if (!checkRTDFault()) {
Serial.print("RTD value: "); Serial.println(rtd);
Serial.print("Ratio = "); Serial.println(ratio, 8);
Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
Expand All @@ -73,36 +53,15 @@ void loop() {
Serial.println();
delay(100);

//Set CH1, has internal 75 ms delay
MachineControl_RTDTempProbe.selectChannel(1);
Serial.println("CHANNEL 1 SELECTED");
rtd = MachineControl_RTDTempProbe.readRTD();
ratio = rtd;
ratio /= 32768;

// Check and print any faults
fault = MachineControl_RTDTempProbe.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (MachineControl_RTDTempProbe.getHighThresholdFault(fault)) {
Serial.println("RTD High Threshold");
}
if (MachineControl_RTDTempProbe.getLowThresholdFault(fault)) {
Serial.println("RTD Low Threshold");
}
if (MachineControl_RTDTempProbe.getLowREFINFault(fault)) {
Serial.println("REFIN- > 0.85 x Bias");
}
if (MachineControl_RTDTempProbe.getHighREFINFault(fault)) {
Serial.println("REFIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_RTDTempProbe.getLowRTDINFault(fault)) {
Serial.println("RTDIN- < 0.85 x Bias - FORCE- open");
}
if (MachineControl_RTDTempProbe.getVoltageFault(fault)) {
Serial.println("Under/Over voltage");
}
MachineControl_RTDTempProbe.clearFault();
} else {
if (!checkRTDFault()) {
Serial.print("RTD value: "); Serial.println(rtd);
Serial.print("Ratio = "); Serial.println(ratio, 8);
Serial.print("Resistance = "); Serial.println(RREF * ratio, 8);
Expand All @@ -111,14 +70,27 @@ void loop() {
Serial.println();
delay(100);

//Set CH2, has internal 75 ms delay
MachineControl_RTDTempProbe.selectChannel(2);
Serial.println("CHANNEL 2 SELECTED");
rtd = MachineControl_RTDTempProbe.readRTD();
ratio = rtd;
ratio /= 32768;

// Check and print any faults
fault = MachineControl_RTDTempProbe.readFault();
if (!checkRTDFault()) {
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(MachineControl_RTDTempProbe.readTemperature(RNOMINAL, RREF));
}
Serial.println();
delay(1000);
}

bool checkRTDFault() {
// Check and print any faults
uint8_t fault = MachineControl_RTDTempProbe.readFault();
if (fault) {
Serial.print("Fault 0x"); Serial.println(fault, HEX);
if (MachineControl_RTDTempProbe.getHighThresholdFault(fault)) {
Expand All @@ -140,12 +112,8 @@ void loop() {
Serial.println("Under/Over voltage");
}
MachineControl_RTDTempProbe.clearFault();
return true;
} 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(MachineControl_RTDTempProbe.readTemperature(RNOMINAL, RREF));
return false;
}
Serial.println();
delay(1000);
}
}
Loading
Loading