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

Stepper Driver SPI (MAX31865 module) does not work when LCD SD is connected on EXP2 #31

Open
ansonl opened this issue May 29, 2023 · 2 comments

Comments

@ansonl
Copy link

ansonl commented May 29, 2023

Hi,

I am trying to use a PT1000 with the MAX31865 module plugged into Motor7 slot on the Octopus Pro 1.0.1. The printer reports a MINTEMP error for the temperature when I have the LCD controller EXP2 is connected to the Octopus Pro EXP2.

The printer can successfully read the temperature ONLY if I disconnect the EXP2. I am using the ULTICONTROLLER LCD with my board and it's EXP2 pin out is the same as the standard LCD EXP2.

My pins configs is below. I commented out the MAX31865_CS_PIN listed in the BTT MAX31865 manual because it seems that TEMP_1_CS_PIN is now used in the latest Marlin instead of MAX6675_SS_PIN. Is my configuration correct and is there a solution to use the LCD mounted SD SPI and stepper motor SPI at the same time?

//Define E3 or TEMP_SENSOR_1 on MOTOR 7
#if TEMP_SENSOR_1 == -5
  #define TEMP_1_CS_PIN                     PD3   // Max31865 CS MOTOR 7
  #define TEMP_1_SCK_PIN                    PA5
  #define TEMP_1_MISO_PIN                   PA6
  #define TEMP_1_MOSI_PIN                   PA7
  #define SOFTWARE_SPI                            // Max31865 and LCD SD share a set of SPIs, Set SD to softwareSPI for Max31865
  #define FORCE_SOFT_SPI

  /*
  #ifndef MAX31865_CS_PIN
    #define MAX31865_MISO_PIN PA6
    #define MAX31865_SCK_PIN PA5
    #define MAX31865_MOSI_PIN PA7
    #define MAX6675_SS_PIN PD3
    //#define MAX31865_CS_PIN PD3
  #endif
  */
#else
  #define TEMP_1_PIN                        PF5   // TH1

  //Define E3 if MOTOR 7 not used for TEMP_SENSOR_1 MAX module
  #define E3_STEP_PIN                         PE6   // MOTOR 7
  #define E3_DIR_PIN                          PA14
  #define E3_ENABLE_PIN                       PE0
  #ifndef E3_CS_PIN
    #define E3_CS_PIN                         PD3
  #endif
#endif

Based on the other issues reported, I assume that this is related to
#23

@ansonl
Copy link
Author

ansonl commented May 29, 2023

I read MarlinFirmware/Marlin#25774 and used some clues with TEMP_SENSOR_FORCE_HW_SPI to get SPI MAX31865 on motor driver to work correctly when EXP2 (LCD SD SPI) is connected to the EXP2 on the board.

SOFTWARE_SPI for both temp sensors must be commented out. If it is not disabled, the SPI connection for MAX31865 fails when the SD card is used. As soon as the card is inserted into the LCD SD slot and the SD is read from, the MAX31865 SPI fails with a temp error even though it worked fine before any SD was inserted. I have 2 2 wire PT1000s connected to both the onboard MAX31865 and stepper driver MAX31865. The temp error is first thrown on the onboard MAX31865 so I assume that SPI to both MAX31865 is failing. The onboard MAX31865 used to work fine with the LCD SD SPI in the past so there is an issue where the onboard MAX31865 works with SOFTWARE_SPI and fails with HW_SPI while the stepper driver SPI works with HW_SPI and fails with SOFTWARE_SPI.

It's not clear why there are separate defines for SOFTWARE_SPI and TEMP_SENSOR_FORCE_HW_SPI when it comes to temp sensors. Since they can be enabled and disabled independent of each other, it is not self explanatory whether soft or hard SPI take precedence for temp sensor without viewing the code.

@bigtreetech Hopefully the below config helps with the immediate SPI issue but I don't know why software spi does not work for stepper driver SPI and EXP2 (LCD SD) SPI at the same time.

#if TEMP_SENSOR_0 == -5
  #define TEMP_0_CS_PIN                     PF8   // Max31865 CS
  #define TEMP_0_SCK_PIN                    PA5
  #define TEMP_0_MISO_PIN                   PA6
  #define TEMP_0_MOSI_PIN                   PA7
  //#define SOFTWARE_SPI                            // Max31865 and LCD SD share a set of SPIs, Set SD to softwareSPI for Max31865
  #define FORCE_SOFT_SPI
#else
  #define TEMP_0_PIN                        PF4   // TH0
#endif


//Define E3 or TEMP_SENSOR_1 on MOTOR 7
#if TEMP_SENSOR_1 == -5
  #define TEMP_1_CS_PIN                     PD3   // Max31865 CS MOTOR 7
  #define TEMP_1_SCK_PIN                    PA5
  #define TEMP_1_MISO_PIN                   PA6
  #define TEMP_1_MOSI_PIN                   PA7
  //#define SOFTWARE_SPI                            // Max31865 and LCD SD share a set of SPIs, Set SD to softwareSPI for Max31865
  #define FORCE_SOFT_SPI

  /*
  #ifndef MAX31865_CS_PIN
    #define MAX31865_MISO_PIN PA6
    #define MAX31865_SCK_PIN PA5
    #define MAX31865_MOSI_PIN PA7
    #define MAX6675_SS_PIN PD3
    //#define MAX31865_CS_PIN PD3
  #endif
  */
#else
  #define TEMP_1_PIN                        PF5   // TH1

  //Define E3 if MOTOR 7 not used for TEMP_SENSOR_1 MAX module
  #define E3_STEP_PIN                         PE6   // MOTOR 7
  #define E3_DIR_PIN                          PA14
  #define E3_ENABLE_PIN                       PE0
  #ifndef E3_CS_PIN
    #define E3_CS_PIN                         PD3
  #endif
#endif


/**
 * Thermocouple Options — for MAX6675 (-2), MAX31855 (-3), and MAX31865 (-5).
 */
#define TEMP_SENSOR_FORCE_HW_SPI                // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus.
#define MAX31865_SENSOR_WIRES_0 2               // (2-4) Number of wires for the probe connected to a MAX31865 board.
#define MAX31865_SENSOR_WIRES_1 2
//#define MAX31865_SENSOR_WIRES_2 2

@ansonl ansonl changed the title Stepper Driver SPI (MAX31865 module) does not work when LCD is connected on EXP2 Stepper Driver SPI (MAX31865 module) does not work when LCD SD is connected on EXP2 May 29, 2023
@ansonl
Copy link
Author

ansonl commented May 31, 2023

Update: The printer fails to read temp via SPI from both the onboard and stepper module MAX31865 when SD card is inserted into the LCD SD reader that uses SPI. This happens randomly so it's basically not possible to use the LCD SD slot right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant