MKS Gen L V1.0 - Ramps 1.4 - Heater1 not working

I upgraded a GEEETech M201 with mixing extruder to a dual extruder. I’m using the MKS Gen L V1.0 board and Marlin 2.0.9.3. When I define motherboard as BOARD_MKS_GEN_L it loads Ramps 1.4 configuration. However, Heater 1 pin in Ramps 1.4 is D9 whereas on the board it is D7. Consequently the second extruder heater doesn’t work. How can I fix this?

Thanks in advance for any help.

The pin assignment works by loading pins_MKS_GEN_L.h which defines almost nothing, and then loading pins_RAMPS.h. The latter checks if pins are defined, and if so it does not redefine them, but instead uses the ones already defined. So if you define pins within pins_MKS_GEN_L.h, it will take precedence over the pins_RAMPS.h values.

Specifically, pins_MKS_GEN_L.h contains:
image

And the relevant portion of pins_RAMPS.h is:

(Note that on line 209, RAMPS_D9_PIN is only assigned if it hasn’t already been assigned, meaning pins_MKS_GEN_L.h can override it.)

According to my reading, what “should” be happening is since pins_MKS_GEN_L.h defines MOSFET_D_PIN, you should not be getting RAMPS EFB, EEF, EEB, EFF, or SF, so the clause in line 227 should take effect, and with more than one hotend, it should define HEATER_1_PIN to MOSFET_D_PIN, which is pin 7 like you are wanting.

I can’t say why it wouldn’t work, and I haven’t configured MKS Gen L 1.0 for dual extruders, but if you wanted to try swapping D7 and D9 you could do that within pins_MKS_GEN_L.h by setting

#define MOSFET_D_PIN 9
#define RAMPS_D9_PIN 7

Then within pins_RAMPS.h, since RAMPS_D9_PIN is already defined, it won’t redefine it and it will be 7 instead of 9 (and confusing to your future self when you review it a year from now).

You can see if that fixes it, and if not, then it could be something else related to the mixing extruder configuration.

Thank you so much! I was confused as to which .h files do what. Also, I thought MOSFET D was for the Fan and MOSFET B was for Heater1.

Thanks again.