Compiling Marlin - dual endstops, probe

Hi there,

I’m trying to get Marlin to compile. I started with V1CNC_Ramps_DualLR-2.0.9.2 and tried to modify to suit my situation (for whatever reason I’ve got X with dual motors going left-right and Y with the single motor going away from me).

I have dual endstops at Z max to get the gantry levelled, and a Z min probe.

My configuration.h is at Configuration.h - Pastebin.com
My configuration_adv.h is at Configuration_adv.h - Pastebin.com

I get a compile error:

Marlin\src\module\endstops.cpp:932:60: error: 'Z2_MIN' was not declared in this scope
     #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX)

I think this is because I’ve had to declare dual endstops for Z max, but only the one for Z min (the probe, plugged into Z_MIN).

Any ideas on how to have dual Z max endstops, but only the single probe for Z min?

I think that you are misunderstanding the coordinate system that the LR uses.

The Y axis should be the long one with 2 motors, the X axis should be the axis along the gantry with 1 motor. Your build will be MUCH easier if you follow that setup.

For the LowRider3, swapping the X and Y like that can still end up with a useable machine, however, the provisions for the switches will mean that it wants to home to the lower right, and your coordinate system should start from the lower left. (Low being defines at closer to you as you stand at the side of the table.) This means that you will either have to jog the machine to the other side of the table to start your job after homing, or else you will need to re-do the homing switches with a different setup, because this is where the switches exist.

Now, it doesn’t matter where you physically sit at the table, but it’s much more convenient if you just use the DualLR firmware as-is and configure the X axis to follow the gantry, and have the Y axis follow the wheels. I don’t see anything that you’ve said there that changes from the default V1 firmware.

Whether I call the various side to side axes X or Y is immaterial to the question. Which is about why I can’t compile, and where the compilation error is about the Z axis, which goes up and down vertically on my machine as most others.

Any ideas about that?

We make the config files for MarlinBuilder releases from some scripts. We have a script for dual on Y, Z:

And one (which isn’t really used anywhere) for dual on X, Z:

Marlin gets confused when dealing with dual Z up. When I switched direction to up, it started using Zmax for Z1. It won’t let me use Zmin for Z2max, so I configure it for “Xmax”. Then we jump through all the hoops to configure Zmin to be a probe.

In my head, these are the steps you would take from Dual YZ to Dual XZ:

  • change Z2 endstop from Xmax to Ymax in configuration_adv.h
  • change dual Y to be false/undefined
  • change dual X to be true/defined.
  • set the X2 endstop to Xmax, if it isn’t already.

Then wire Z2 endstop to the Ymax port on the board.

Thanks Jeff. I followed those scripts when modding the two files, they were a great help.

I’ve done exactly what’s in your head. Here’s teh dual stepper bit:

#define X_DUAL_STEPPER_DRIVERS // MDK was: //
#if ENABLED(X_DUAL_STEPPER_DRIVERS)
  #define INVERT_X2_VS_X_DIR    // Enable if X2 direction signal is opposite to X // MDK was: //
  #define X_DUAL_ENDSTOPS // MDK was: //
  #if ENABLED(X_DUAL_ENDSTOPS)
    #define X2_USE_ENDSTOP _XMAX_
    #define X2_ENDSTOP_ADJUSTMENT  0
  #endif
#endif

//#define Y_DUAL_STEPPER_DRIVERS // MDK was: 
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
  #define INVERT_Y2_VS_Y_DIR     // Enable if Y2 direction signal is opposite to Y
  #define Y_DUAL_ENDSTOPS  
  #if ENABLED(Y_DUAL_ENDSTOPS)
    #define Y2_USE_ENDSTOP _YMAX_
    #define Y2_ENDSTOP_ADJUSTMENT  0
  #endif
#endif

//
// For Z set the number of stepper drivers
//
#define NUM_Z_STEPPER_DRIVERS 2 // 1   // (1-4) Z options change based on how many

#if NUM_Z_STEPPER_DRIVERS > 1
  // Enable if Z motor direction signals are the opposite of Z1
  #define INVERT_Z2_VS_Z_DIR
  //#define INVERT_Z3_VS_Z_DIR
  //#define INVERT_Z4_VS_Z_DIR

  #define Z_MULTI_ENDSTOPS
  #if ENABLED(Z_MULTI_ENDSTOPS)
    #define Z2_USE_ENDSTOP          _YMAX_ // MDK was: _XMAX_
    #define Z2_ENDSTOP_ADJUSTMENT   0
    #if NUM_Z_STEPPER_DRIVERS >= 3
      #define Z3_USE_ENDSTOP        _YMAX_
      #define Z3_ENDSTOP_ADJUSTMENT 0
    #endif
    #if NUM_Z_STEPPER_DRIVERS >= 4
      #define Z4_USE_ENDSTOP        _ZMAX_
      #define Z4_ENDSTOP_ADJUSTMENT 0
    #endif
  #endif
#endif

And in Configuration.h I’ve got: #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN

Same compile error. See any issues with what I’ve got above?

Why did you change this? Seems like 2 was right.

Isn’t it set at 2? And 1 (and (1-4) are commented out? This is unchanged from the file at https://github.com/V1EngineeringInc/MarlinBuilder/releases/download/513/V1CNC_Ramps_DualLR-2.0.9.2.zip

I can get it to compile if I do // #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN and change pins_RAMPS.h so that #define Z_MIN_PROBE_PIN points to pin 18 (which is the Z_MIN pin).

I’ll test and report back.

As far as this error goes, it looks like you’re trying to define 2 Z_MIN stops somewhere, and the Z probe will only be one of them. I’d have to guess that something was changed from the compiled version. All I see in your Configuration_adv.h in the Z section is changing the Z2 from XMAX to YMAX, but I haven’t chased down all of the probe references.

For me, I’ll start by compiling the code as provided, exactly as provided. Then I start making changes. Make the changes one by one, compile. (I often also test at this stage, depending on the scope of needed changes.)

I compiled the stock firmware, and flashed it to my MKS Gen L v1.0 board just to see, but I don’t have the spare drivers and motors to test it, but it compiles and flashes OK.

I suppose that my point from earlier was that I saw no reason from your stated configuration why you should need to change the firmware, and there are some (IMO) good reasons not to.

Thanks Dan, that’s exactly what I did. Started from scratch, changing little bits and compiling.

All was fine until i uncommented #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN. After this I get the compile error above. It seems where dual Z endstops are defined, when you define the Z_MIN as the probe pin, it wants to find a Z2_MIN pin.

I stuffed around trying to find where it needs that Z2 definition, but couldn’t find it.

I get that changing the proven firmware is undesirable. My machine has painfully limited access to the endstop plugs, so changing in software is (or was) easier than changing the hardware.

Yes. I am not good at reading, I guess :slight_smile:

I will have to look at this from my keyboard.

/**
 * Z_MIN_PROBE_PIN
 *
 * Define this pin if the probe is not connected to Z_MIN_PIN.
 * If not defined the default pin for the selected MOTHERBOARD
 * will be used. Most of the time the default is what you want.
 *
 *  - The simplest option is to use a free endstop connector.
 *  - Use 5V for powered (usually inductive) sensors.
 *
 *  - RAMPS 1.3/1.4 boards may use the 5V, GND, and Aux4->D32 pin:
 *    - For simple switches connect...
 *      - normally-closed switches to GND and D32.
 *      - normally-open switches to 5V and D32.
 */
#define Z_MIN_PROBE_PIN Z_MIN_PIN // 32 // Pin 32 is the RAMPS default

You want to comment that, because this is defined right below that. The default firmware already had the probe enabled, but has to use G38.2 gcode to use it, because the homing direction is defined as up.