Skip to content
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

[BUG] MINTEMP on SKR 1.3 with MAX31865 #22526

Closed
pietja5 opened this issue Aug 5, 2021 · 16 comments
Closed

[BUG] MINTEMP on SKR 1.3 with MAX31865 #22526

pietja5 opened this issue Aug 5, 2021 · 16 comments

Comments

@pietja5
Copy link

pietja5 commented Aug 5, 2021

Did you test the latest bugfix-2.0.x code?

Yes, and the problem still exists.

Bug Description

MAX31865 is not working Marlin-bugfix-2.0.x 2021-08-05
SKR1.3 +TFT35
Case 1
conf.h :

#define SERIAL_PORT -1
#define SERIAL_PORT_2 0 
#define MOTHERBOARD BOARD_BTT_SKR_V1_3 
#define TEMP_SENSOR_0 -5
#define MAX31865_SENSOR_OHMS_0      100   // (Ω) Typically 100 or 1000 (PT100 or PT1000)
#define MAX31865_CALIBRATION_OHMS_0 430   // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000

#define SDSUPPORT
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER

conf_adv.h

  //#define SDCARD_CONNECTION LCD

MAX31865.h:
SPI_MODE1

pins_BTT_SKR_common:

#define TEMP_0_CS_PIN   P0_16
// #ifndef TEMP_0_PIN
//   #define TEMP_0_PIN                    P0_24_A1  // A1 (T1) - (68) - TEMP_0_PIN
// #endif

   #define SDCARD_CONNECTION            ONBOARD

MAX31865 connected to:

SDI  P0.18
CS    P0.16
CLK  P0.15
SDO P0.17 
VCC and GND 

Compilation - no errors
file .bin >> sd card>> SKR>> restart >> no printer attached on TFT35

Case 2 >>

#define TEMP_SENSOR_0  1 
//#define TEMP_0_CS_PIN   P0_16
 #ifndef TEMP_0_PIN
   #define TEMP_0_PIN                    P0_24_A1  // A1 (T1) - (68) - TEMP_0_PIN
 #endif

Compilation - no errors
file .bin >> sd card>> SKR>> restart >> READY

case 3 :
after some changes .... MINTEMP triggered HEATER_ID: E0

Some suggestions?

Expected behavior

MAX 31865 work with SKR 1.3

Actual behavior

no communication / freeze of mainboard

Version of Marlin Firmware

bugfix-2.0.x

Printer model

SKR 1.3

Electronics

SKR 1.3

@thinkyhead thinkyhead changed the title SKR 1.3 MAX31865 H SPI MINTEMP triggered HEATHER_ID: E0 [BUG] MINTEMP on SKR 1.3 with MAX31865 Aug 6, 2021
@thinkyhead
Copy link
Member

There are some new options in Configuration_adv.h that you might also try adjusting…

/**
 * Configuration options for MAX Thermocouples (-2, -3, -5).
 *   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.
 */
//#define TEMP_SENSOR_FORCE_HW_SPI
//#define MAX31865_SENSOR_WIRES_0 2
//#define MAX31865_SENSOR_WIRES_1 2
//#define MAX31865_50HZ_FILTER

@pietja5
Copy link
Author

pietja5 commented Aug 6, 2021

Conf.adv.h

#define TEMP_SENSOR_FORCE_HW_SPI
#define MAX31865_SENSOR_WIRES_0 2

###pins_BTT_SKR_common.h

#ifndef TEMP_0_PIN
 #define TEMP_0_PIN                   P0_16  // A1 (T1) - (68) - TEMP_0_PIN'
#endif

#define TEMP_0_CS_PIN   P0_16

// SD Support
//
#ifndef SDCARD_CONNECTION
  #if HAS_WIRED_LCD
    #define SDCARD_CONNECTION                LCD
  #else
   #define SDCARD_CONNECTION     LCD
  #endif
#endif 

file .bin >> sd card>> SKR>> restart >> ###MINTEMP triggered HEATER_ID: E0

@thinkyhead
Copy link
Member

You can set SDCARD_CONNECTION to LCD in your configuration instead of editing pins_BTT_SKR_common.h.

@thinkyhead
Copy link
Member

It looks like support for MAX Thermocouples is not set up yet for BTT SKR boards. I don't know what else would be required to make it work. Maybe you can sign on to the Marlin Discord and ask some other smart people for help. https://discord.gg/n5NJ59y

@qrstu
Copy link

qrstu commented Aug 8, 2021

@pietja5
I also could not get working on EXT2 CS (MAX31855) BTT SKR 1.4, I used SPI Pins (doesn't exist on BTT SKR 1.3)
Try to connect to SDCARD_CONNECTION ONBOARD
Use this as help:
https://github.com/GadgetAngel/MAX31865-SKR-V1-3-GUIDE

In the last 4 weeks some changes took place on bugfix 2.0.x for MAX318155 and MAX318165 which make the setup much easier.

Check -->
#if HAS_MAX_TC --> pins_BTT_SKR_common.h
#define TEMP_SENSOR_FORCE_HW_SPI --> Configuration_adv.h
#define MAX31865_SENSOR_WIRES_0 2 --> Configuration_adv.h

Regards,
Martin

@jinhong-
Copy link
Contributor

@pietja5 I struggled for a day to get this to work as well. I noticed @GadgetAngel's guide is quite outdated as compared to the new code changes in marlin's bugfix 2.0 branch. I will share with you how I got mine working, though I have a different skr board (SKR E3 Turbo), hopefully this will help you successfully setup yours as well

Here is @GadgetAngel's original guide for SKR 1.3. I recommend reading it to look for the correct pins to use to connect your MAX31865. Note that I am using software SPI. Also, I believe this only works with 2 wire PT100 out of the box

Here are the changes I did to get mine working

Changes made to pins_*.h (find your appropriate board). In here you will define the pins you are using to connect the SKR board to your MAX31865

#if HAS_MAX_TC
  #define TEMP_0_CS_PIN   P1_21
  #define TEMP_0_MISO_PIN P0_11
  #define TEMP_0_MOSI_PIN P0_10
  #define TEMP_0_SCK_PIN  P1_20
#endif

Changes made to Configuration.h

#define MAX31865_SENSOR_OHMS_0      100   // (Ω) Typically 100 or 1000 (PT100 or PT1000)
#define MAX31865_CALIBRATION_OHMS_0 430   // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000
#define LIB_MAX31865 1 // Enable custom library for MAX31865

Changes made to features.ini

Add the following line under the [features] section

LIB_MAX31865                           = https://github.com/GadgetAngel/Adafruit-MAX31865-V1.1.0-Mod-M.git

To enable 50hz filter

To enable 50hz filter in countries that have 50hz AC power frequency

Changes made to Configuration_adv.h

#define MAX31865_50HZ_FILTER

Changes made to temperature.cpp

Replace

      #if defined(LIB_INTERNAL_MAX31865) && ENABLED(MAX31865_50HZ_FILTER)
        max31865_0.enable50HzFilter(1);
      #endif

with

      #if ENABLED(MAX31865_50HZ_FILTER)
        max31865_0.enable50Hz(1);
      #endif

I am not sure why the codes baked into Marlin did not work. Perhaps @slowbro or @GadgetAngel can shed some light?

@jinhong-
Copy link
Contributor

jinhong- commented Aug 22, 2021

For some reason after I put everything back together it decides to stop working again. Seems quite strange. Must have somehow fluked it. I noticed that If i pulled out the power pin and cycled the power of the max31865 board, the temperature readings will start showing up. Somehow the max31865 needs to be reset

@jinhong-
Copy link
Contributor

jinhong- commented Aug 23, 2021

I added a PR to update MAX31865.cpp, which improves the software SPI handling. With this PR, you will no longer need to use GadgetAngel's custom library

@slowbro
Copy link
Member

slowbro commented Aug 23, 2021

Thanks for the PR, @jinhong-, it is very much appreciated! I added some notes on the changes there.

For @GadgetAngel's guide, lots of it is out of date; we use an internal MAX31865 library now, so the features.ini and LIB_MAX31865 parts are not needed. For the 50Hz filter, only MAX31865_50HZ_FILTER is needed; the calls are made on the backend. See here:

void MAX31865::enable50HzFilter(bool b) {
setConfig(MAX31856_CONFIG_FILT50HZ, b);
}

@pietja5
Copy link
Author

pietja5 commented Aug 24, 2021

Hi
Unfortunately no changes on my side
Firmware download 16:20 24.08.2021 (Marlin-bugfix-2.0.x)
changes:
platformio.ini:
default_envs = LPC1768
features.ini:
- no changes

Configuration.h

#define SERIAL_PORT -1
#define SERIAL_PORT_2 0
#define BAUDRATE_2 250000   // Enable to override BAUDRATE

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_BTT_SKR_V1_3
#endif

#define TEMP_SENSOR_0 -5

#define MAX31865_SENSOR_OHMS_0      100   // (Ω) Typically 100 or 1000 (PT100 or PT1000)
#define MAX31865_CALIBRATION_OHMS_0 430   // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000

#define SDSUPPORT
#define X_DRIVER_TYPE  TMC2208
#define Y_DRIVER_TYPE  TMC2208
#define Z_DRIVER_TYPE  TMC2208

Configuration_adv.h

//#define TEMP_SENSOR_FORCE_HW_SPI
//#define MAX31865_SENSOR_WIRES_0 2
//#define MAX31865_SENSOR_WIRES_1 2
#define MAX31865_50HZ_FILTER
#define MONITOR_DRIVER_STATUS
#define TMC_DEBUG
#define SHOW_TEMP_ADC_VALUES
#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 10

#define UTF_FILENAME_SUPPORT
#define LONG_FILENAME_HOST_SUPPORT
#define SDCARD_CONNECTION LCD

temperature.cpp:

no changes

pins_BTT_SKR_common.h

#if HAS_MAX_TC
  #define TEMP_0_CS_PIN   P1_19
  #define TEMP_0_MISO_PIN P1_18
  #define TEMP_0_MOSI_PIN P1_21
  #define TEMP_0_SCK_PIN  P1_20

MAX31865.cpp

, SPI_MODE0 // CPOL0 CPHA1 ///there was error during compilation,  I pick 0 according to MAX31865-SKR-V1-3-GUIDE

file .bin >> sd card>> SKR>> restart >> no printer attached on TFT35
Restart >> MINTEMP triggered HEATER_ID: E0

under this configuration I connect oscilloscope and check CLK, MOSI/ MISO - no signal - both sd card and max31865 not possible to check sd card

when

#define TEMP_SENSOR_0 1
regular CLK/ MOSI/ MISO signal on SD CARD
possible to check files on sd card.

@GadgetAngel
Copy link
Contributor

Thanks for the PR, @jinhong-, it is very much appreciated! I added some notes on the changes there.

For @GadgetAngel's guide, lots of it is out of date; we use an internal MAX31865 library now, so the features.ini and LIB_MAX31865 parts are not needed. For the 50Hz filter, only MAX31865_50HZ_FILTER is needed; the calls are made on the backend. See here:

void MAX31865::enable50HzFilter(bool b) {
setConfig(MAX31856_CONFIG_FILT50HZ, b);
}

If @slowbro could do what @jinhong- did above and tell me what needs to change in my guide then I will make the changes.

I am now using Klipper for my firmware on my printers, but I will be more than glad to update my guide to reflect the changes in the Marlin firmware if someone provides me with the details on how to change my guide. My repository does have a pull-request that someone can fill out (@slowbro or @jinhong- ) once the steps are known, then I can update the guide.

@thinkyhead
Copy link
Member

Merged #22618 which uses <SoftwareSPI.h> instead of direct pin control.

@jinhong-
Copy link
Contributor

@pietja5 which branch of marlin did you try? can you try this version with your configuration? I have good success getting this to work on my SKR E3 Turbo, which is the same family as what you are using

@pietja5
Copy link
Author

pietja5 commented Sep 22, 2021

Hello
I confirm that https://github.com/jinhong-/Marlin/tree/max31865-enhancements works

When I try to run the same changes on main Marin bugfix-2.0 branch (22.09.2021) :
Configuration.h

#define SERIAL_PORT -1
#define SERIAL_PORT_2 0
#define BAUDRATE_2 250000   // Enable to override BAUDRATE
  #define MOTHERBOARD BOARD_BTT_SKR_V1_3 
#define TEMP_SENSOR_0 -5
#define DUMMY_THERMISTOR_998_VALUE  25
#define DUMMY_THERMISTOR_999_VALUE 100
#define SDSUPPORT
#define X_DRIVER_TYPE  TMC2208
#define Y_DRIVER_TYPE  TMC2208
#define Z_DRIVER_TYPE  TMC2208

Configuration_ADV.h

#define MAX31865_50HZ_FILTER
#define SHOW_TEMP_ADC_VALUES
#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 10
#define UTF_FILENAME_SUPPORT
#define LONG_FILENAME_HOST_SUPPORT 
#define TMC_DEBUG
#define SDCARD_CONNECTION LCD
//#define TEMP_SENSOR_FORCE_HW_SPI
#define MAX31865_SENSOR_WIRES_0 2
//#define MAX31865_SENSOR_WIRES_1 2
#define MAX31865_50HZ_FILTER
pins_BTT_SKR_common.h
#ifndef TEMP_0_PIN
  #define TEMP_0_PIN                     P1_19 // A1 (T1) - (68) - TEMP_0_PIN
#endif

I get below definitions grealish ( not compiled ....)


#if HAS_MAX_TC
  #define TEMP_0_CS_PIN   P1_19
  #define TEMP_0_MISO_PIN P1_18
  #define TEMP_0_MOSI_PIN P1_21
  #define TEMP_0_SCK_PIN  P1_20

  //#define TEMP_1_CS_PIN   P...
  //#define TEMP_1_MISO_PIN P...
  //#define TEMP_1_MOSI_PIN P...
  //#define TEMP_1_SCK_PIN  P...
#endif

HAS_MAX_TC
depends on
TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC

and

#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
  #define TEMP_SENSOR_0_IS_MAX_TC 1

so is should normally compile if
#define TEMP_SENSOR_0 -5 ....

How?


if I move port definishions ( remove #if HAS_MAX_TC) , code complie normally ( of couse I need to change SPI_MODE_1 to SPI_MODE1 in max 31865 )

no errors on LCD byt also no changes on TEMP_SENSOR_0 , temperature on bed changes normalli if I heeat sesnsor

@github-actions
Copy link

github-actions bot commented Apr 1, 2022

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants