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] Wrong pin mapping for MKS GEN L V2.1 (EEFB configuration) #25488

Closed
1 task done
amamchur opened this issue Mar 9, 2023 · 9 comments
Closed
1 task done

[BUG] Wrong pin mapping for MKS GEN L V2.1 (EEFB configuration) #25488

amamchur opened this issue Mar 9, 2023 · 9 comments

Comments

@amamchur
Copy link

amamchur commented Mar 9, 2023

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

Yes, and the problem still exists.

Bug Description

Default pin mapping for MKS GEN L V2.1 (EEFB, Extruder Extruder Fan and Bed) doesn't match PCB schematic (see U_MOSFET
MOSFET.SchDoc)

Bug Timeline

Unknown

Expected behavior

#define HEATER_0_PIN 10
#define HEATER_1_PIN 7
#define HEATER_BED_PIN 8
#define FAN_PIN 9

Actual behavior

#define HEATER_0_PIN 10
#define HEATER_1_PIN 9
#define HEATER_BED_PIN 8
#define FAN_PIN 4

Steps to Reproduce

No response

Version of Marlin Firmware

bugfix-2.0.x a6cc7a4

Printer model

No response

Electronics

No response

Add-ons

No response

Bed Leveling

None

Your Slicer

None

Host Software

None

Don't forget to include

  • A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

Config files here cfg.zip

Main settings:

#ifndef MOTHERBOARD
  #define MOTHERBOARD BOARD_MKS_GEN_L_V21
#endif

#define EXTRUDERS 2

#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 1
//...
#define TEMP_SENSOR_BED 5

#define PIDTEMPBED

#define NUM_M106_FANS 1
@borland1
Copy link
Contributor

borland1 commented Mar 11, 2023

Have you tried the generic motherboard ( MKS_GEN_L )? These MEGA boards are just Ramps 1.4 compatibles. All the MKS Gen L pin mapping files (V1.0, V2.0, V2.1) include...

#include "pins_RAMPS.h"

I could be wrong, but I think the only differences is, V2.0 fixed PCB pin trace routing error for Trinamic Serial control with E1 Motor Driver plug-in module, and V2.1 added 3.3V/5V Motor Driver module options for 3.3V sensor-less homing.

How is schematic pin mapping different between V1.0, V2.0, and V2.1 ?

@amamchur
Copy link
Author

Hi, borland1.

I've already invastigated this issue and I cloud fix it my self.
But first of all I would like to clarify resolution with Marlin developers.

Root of issue: Marlin doesn't support EEFB (Extruder Extruder Fan and Bed) printer configuration for RAMPS compatible boards correclty.

MKS GEN L V2.1 is RAMPS compatible PCB with additional MOSFET (classic RAMPS have 3 MOSFETs).
This extra MOSFET provides ability to setup EEFB (Extruder Extruder Fan and Bed) printer configuration.

EEFB configuration requires MOSFET_D_PIN definiation. So if RAMPS board defines MOSFET_D_PIN it means they could support EEFB.

Full list of RAMPS compatible boards with EEFB support (Ctrl+F by MOSFET_D_PIN):

  • 3Drag
  • KFB 2.0
  • ZUM Mega 3D
  • Felix 2.0+
  • MKS BASE
  • MKS GEN L V2
  • MKS GEN L V2.1
  • MKS GEN L
  • RAMPS S 1.2
  • Sainsmart

Technical details

Here is macros (pins_RAMPS.h:235) which maps MOSFETs pin.

#if FET_ORDER_EFB                                 // Hotend, Fan, Bed
  #ifndef HEATER_BED_PIN
    #define HEATER_BED_PIN          MOSFET_C_PIN
  #endif
#elif FET_ORDER_EEF                               // Hotend, Hotend, Fan
  #define HEATER_1_PIN              MOSFET_B_PIN
#elif FET_ORDER_EEB                               // Hotend, Hotend, Bed
  #define HEATER_1_PIN              MOSFET_B_PIN
  #ifndef HEATER_BED_PIN
    #define HEATER_BED_PIN          MOSFET_C_PIN
  #endif
#elif FET_ORDER_EFF                               // Hotend, Fan, Fan
  #define FAN1_PIN                  MOSFET_C_PIN
#elif DISABLED(FET_ORDER_SF)                      // Not Spindle, Fan (i.e., "EFBF" or "EFBE")
  #ifndef HEATER_BED_PIN
    #define HEATER_BED_PIN          MOSFET_C_PIN
  #endif
  #if EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL)
    #define HEATER_1_PIN            MOSFET_D_PIN
  #else
    #define FAN1_PIN                MOSFET_D_PIN
  #endif
#endif

#ifndef FAN_PIN
  #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF)        // Hotend, Fan, Bed or Hotend, Fan, Fan
    #define FAN_PIN                 MOSFET_B_PIN
  #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF)       // Hotend, Hotend, Fan or Spindle, Fan
    #define FAN_PIN                 MOSFET_C_PIN
  #elif FET_ORDER_EEB                             // Hotend, Hotend, Bed
    #define FAN_PIN                            4  // IO pin. Buffer needed
  #else                                           // Non-specific are "EFB" (i.e., "EFBF" or "EFBE")
    #define FAN_PIN                 MOSFET_B_PIN
  #endif
#endif

Unfortunately, this macro was designed for 3 MOSFETS only, that's why Marlin doesn't support EEFB correctly.

Suggested resolution.

Add additional MOSFET order FET_ORDER_EEFB into pins.h. Currently this macro looks in the folowing way:

#if NONE(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFF, FET_ORDER_EFB, FET_ORDER_SF)
  #if   MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB)
    #define FET_ORDER_EFB 1
  #elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB)
    #define FET_ORDER_EEB 1
  #elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF)
    #define FET_ORDER_EFF 1
  #elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF)
    #define FET_ORDER_EEF 1
  #elif MB(RAMPS_13_SF,  RAMPS_14_SF,  RAMPS_PLUS_SF,  RAMPS_14_RE_ARM_SF,  RAMPS_SMART_SF,  RAMPS_DUO_SF,  RAMPS4DUE_SF)
    #define FET_ORDER_SF 1
  #elif HAS_MULTI_HOTEND || (HAS_EXTRUDERS && HAS_CUTTER)
    #if TEMP_SENSOR_BED
      #define FET_ORDER_EEB 1
    #else
      #define FET_ORDER_EEF 1
    #endif
  #elif TEMP_SENSOR_BED
    #define FET_ORDER_EFB 1
  #else
    #define FET_ORDER_EFF 1
  #endif

Using FET_ORDER_EEFB definition we can assign correct pins in pins_RAMPS.h:235.

@borland1
Copy link
Contributor

Glad you made progress finding a possible solution.

Any idea why these 8-bit MCU boards need a special RAMPS EFB configuration setup, which is unlike other newer 32-bit MCU boards? Shouldn't the board's pin file be able to handle this without resorting to implementing the RAMPS pin file?

Is it the fact that the MCU Timer, that is suited for PWM control, is used for audio (Tone/Speaker)?

For this MKS_GEN_L board, I had previously reported a Timer glitch when AUTO_FAN is enabled, where any rotary dial user input would cause the extruder fan power to stop momentarily. Report was closed without solution. Other's recommended disabling SPEAKER.

@amamchur
Copy link
Author

Thx, borland1.

Any idea why these 8-bit MCU boards need a special RAMPS EFB configuration setup, which is unlike other newer 32-bit MCU boards? Shouldn't the board's pin file be able to handle this without resorting to implementing the RAMPS pin file?

MKS_GEN_L has four MOSFET vs three MOSFET comparing to classic 8-bit RAMPS. First tree MOSFET could by easly mapped using the following definitions: FET_ORDER_EFB, FET_ORDER_EEB & FET_ORDER_EFF. Unfortunately, role of the last MOSFET isn't defined in pin.h file. I suggest to define additional MOSFET order FET_ORDER_EEFB (Extruder Extruder Fan and Bed), see my push request.

Using this definition we can easily map fourth MOSFET to appropriate pin in pins_RAMPS.h

#elif FET_ORDER_EEFB
  #ifndef HEATER_0_PIN
    #define HEATER_0_PIN              MOSFET_A_PIN
  #endif
  #ifndef HEATER_1_PIN
    #define HEATER_1_PIN              MOSFET_D_PIN
  #endif
  #ifndef HEATER_BED_PIN
    #define HEATER_BED_PIN            MOSFET_C_PIN
  #endif
  #ifndef FAN_PIN
    #define FAN_PIN                   MOSFET_B_PIN
  #endif
#elif

Is it the fact that the MCU Timer, that is suited for PWM control, is used for audio (Tone/Speaker)?
I think no.

For this MKS_GEN_L board, I had previously reported a Timer glitch when AUTO_FAN is enabled, where any rotary dial user input would cause the extruder fan power to stop momentarily. Report was closed without solution. Other's recommended disabling SPEAKER.

Thx, for info. I'll keep it in mind.

@borland1
Copy link
Contributor

borland1 commented Mar 15, 2023

amamchur,

I guess I wasn't clear, as you seem to have missed my point. The MKS_GEN_L board file is located in the Marlin "RAMPS" folder. And the "pins_ramps.h" file, that the pins_MKS_GEN_L.h board file calls with #include "pins_ramps.h", has almost 1000 lines of code.

There are other Mega MCU boards that have board pin files in Marlin's "MEGA" folder. These boards do not use the same pins_ramps.h configuration, and in my view, are much simpler to configure.

I think it might be easier to generate a new board pin file for the "Mega" folder.

@amamchur
Copy link
Author

borland1,

I think it might be easier to generate a new board pin file for the "Mega" folder.

Agree. I've canceled my pull requests due to failed tests. My changes broke "Azteeg X3 Pro" configuration.
Please correct my if I'm wrong:

  • Move pins_MKS_GEN_L_V2.h & pins_MKS_GEN_L_V21.h from "ramps" to "mega" folder
  • Remove #include "pins_RAMPS.h" from pins_MKS_GEN_L_V2.h & pins_MKS_GEN_L_V21.h'
  • Fix pin mapping
  • From "Change log MKS Gen_L V2.1 change from MKS Gen_L V2.0"
    • TMC_E1_RX_PIN(SPI_CS) D21 to D12
    • Change servo1 pin D12 to D21

@borland1
Copy link
Contributor

borland1 commented Mar 17, 2023

I would search for a pin file in the MEGA folder to use as a template for creating a new pin file. Take a look at file pins_GT2560_REV_A.h you want to choose one that closely matches the hardware your using (limit switches, steppers, sensors, LCD display, speaker, encoder, etc.). You can get the actual pin numbers for your board from the current pin file, or from the wiring diagram for the MKS_GEN_L provided by MKS.

You may need to edit the inc/SanityChecks.h file to eliminate the compile errors.

@ellensp
Copy link
Contributor

ellensp commented Mar 17, 2023

You guys are way over thinking this

All you need is the following applied, tested on bugfix 2.1.x

diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h
index d508cb453f..1e4e957c43 100644
--- a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h
+++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h
@@ -35,7 +35,8 @@
 // Heaters / Fans
 //
 // Power outputs EFBF or EFBE
-#define MOSFET_D_PIN                           7
+#define MOSFET_B_PIN                           7
+#define FAN_PIN                                9
 
 //
 // CS Pins wired to avoid conflict with the LCD

Results in

> PIN:   7   Port: H4        HEATER_1_PIN                           protected 
> .                          MOSFET_B_PIN                           protected 
> PIN:   8   Port: H5        HEATER_BED_PIN                         protected 
> .                          MOSFET_C_PIN                           protected 
> PIN:   9   Port: H6        FAN_PIN                                protected 
> PIN:  10   Port: B4        HEATER_0_PIN                           protected 

@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 May 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants