Skip to content

Commit

Permalink
🐛 Fix and improve MAX31865 (#23215)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
zeleps and thinkyhead authored Dec 8, 2021
1 parent 0a64209 commit 9e6ded3
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 142 deletions.
9 changes: 9 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,20 @@
* FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus.
* MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2
* MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz.
* MAX31865_USE_READ_ERROR_DETECTION: Detects random read errors from value spikes (a 20°C difference in less than 1sec)
* MAX31865_USE_AUTO_MODE: Faster and more frequent reads than 1-shot, but bias voltage always on, slightly affecting RTD temperature.
* MAX31865_MIN_SAMPLING_TIME_MSEC: in 1-shot mode, the minimum time between subsequent reads. This reduces the effect of bias voltage by leaving the sensor unpowered for longer intervals.
* MAX31865_WIRE_OHMS: In 2-wire configurations, manually set the wire resistance for more accurate readings
*/
//#define TEMP_SENSOR_FORCE_HW_SPI
//#define MAX31865_SENSOR_WIRES_0 2
//#define MAX31865_SENSOR_WIRES_1 2
//#define MAX31865_50HZ_FILTER
//#define MAX31865_USE_READ_ERROR_DETECTION
//#define MAX31865_USE_AUTO_MODE
//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100
//#define MAX31865_WIRE_OHMS_0 0.0f
//#define MAX31865_WIRE_OHMS_1 0.0f

/**
* Hephestos 2 24V heated bed upgrade kit.
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@
#ifndef MAX31865_SENSOR_WIRES_0
#define MAX31865_SENSOR_WIRES_0 2
#endif
#ifndef MAX31865_WIRE_OHMS_0
#define MAX31865_WIRE_OHMS_0 0.0f
#endif
#elif TEMP_SENSOR_0 == -3
#define TEMP_SENSOR_0_IS_MAX31855 1
#define TEMP_SENSOR_0_MAX_TC_TMIN -270
Expand Down Expand Up @@ -193,6 +196,9 @@
#ifndef MAX31865_SENSOR_WIRES_1
#define MAX31865_SENSOR_WIRES_1 2
#endif
#ifndef MAX31865_WIRE_OHMS_1
#define MAX31865_WIRE_OHMS_1 0.0f
#endif
#elif TEMP_SENSOR_1 == -3
#define TEMP_SENSOR_1_IS_MAX31855 1
#define TEMP_SENSOR_1_MAX_TC_TMIN -270
Expand Down
Loading

3 comments on commit 9e6ded3

@kurtis-potier-geofabrica
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have tested this commit on a system with two PT100 thermocouples. Prior to these changes, the system gives mintemp errors often. After these changes, I'm getting 998 as the temp read after startup, then the max temp error. Using software spi bus on the BTT GTR V1.0 board. Will try testing more with it over the next couple days. I like the use_read_error_detection. This looks like it could be very promising.

@thinkyhead
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kurtis-potier-geofabrica
If there are any lingering issues in the bugfix-2.0.x branch at this point, please post a bug report and we'll aim to get them patched before the 2.1 release.

@kurtis-potier-geofabrica
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been running with these changes on hardware spi on several printers with multiple heaters without issue for a few months now. I never got software spi working right, but this could be a function of my setup potentially. I did get software spi with these changes to work a completely different printer with these changes.

Please sign in to comment.