Welcome! Log In Create A New Profile

Advanced

Marlin, Delay when homing dual Z stepper motors (Auto sync feature), using Z_DUAL_ENDSTOPS .

Posted by RepRot 
Marlin, Delay when homing dual Z stepper motors (Auto sync feature), using Z_DUAL_ENDSTOPS .
September 25, 2015 09:28PM
Hi,

I have just upgraded my CoreXY machine to have two stepper motors for the Z axis. I wanted to be able to auto sync both of the Z stepper motors when homing.
I used my unused Extruder stepper (E2) stepper driver for the Z2 motor and added a homing switch for the Z2 motor.

I activated the Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS and assigned pin numbers for both the second Z stepper driver and Z min home sensor switch. Also added some code to Marlin.


Operation:
When the printer receives a Z home, both Z stepper motors (Z1 & Z2) drive the print platform towards the home position.
When either of the Z stepper motors min home switches are triggered the corresponding stepper motor stops.
Once both stepper motors have reached home, there is a delay before they then both move the print platform a short distance away from home and then back to home again.

Current Issue:
There appears to be a set time to home both Z stepper motors regardless of their starting positions.
This is different to normal homing of the Z axis when not using Z_DUAL_ENDSTOPS. ( No delay for small homing moves).
The set time appears to be based on the Z maximum movement setting and the homing speed.
The set time appears to be good that there is a motor drive timeout if both Z1min & Z2 min aren’t triggered.

It would be good to have some code that once both the Z1min & Z2min are triggered that there is no time delay. This would overcome the delay with small home movements.
Apart from this issue, auto syncing of the two Z axis motors is an excellent feature of Marlin.


I had to make a few changes to the Marlin code as listed below.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Marlin Version: 1.1

Sketch: Configuration.h
Description: Define the Z2 homing sensor end stop pull if required.
Line 319
#define ENDSTOPPULLUP_Z2MIN

---------------------------------------------------------------------
Sketch: Configuration_adv.h
Description: 2 lines were added for Z2min and comments added for Z2max as you don’t use both min and max for Z2
Line 148

#define Z_DUAL_STEPPER_DRIVERS //uncomment if using Z dual stepper drivers
#ifdef Z_DUAL_ENDSTOPS //uncomment if using Z dual end stops

//#define Z2_MAX_PIN 5 //uncomment if using Z2MAX for homing - MAX Endstop used for Z2 axis. Define pin being used for Z2 sensor
//const bool Z2_MAX_ENDSTOP_INVERTING = true; //uncomment if using Z2MAX for homing - true to invert- for NO switches - false for N/O switches

#define Z2_MIN_PIN 5 //uncomment if using Z2MIN for homing - MIN Endstop used for Z2 axis. Define pin being used for Z2 sensor
const bool Z2_MIN_ENDSTOP_INVERTING = false; //uncomment if using Z2MIN for homing - true to invert- for NC switches - false for N/O switches

---------------------------------------------------------------------
Sketch: pins_ramps13.h
Description: Define which pins are being used – Currently using E2 extruder driver PCB for stepper Z2 on a ramps board.
Line 48

#define Z2_STEP_PIN 36
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
---------------------------------------------------------------------
Sketch: Stepper.ccp
Description: The following was added for Z2min
Line 933

#if HAS_Z2_MIN
SET_INPUT(Z2_MIN_PIN);
#ifdef ENDSTOPPULLUP_ZMIN
WRITE(Z2_MIN_PIN,HIGH);
#endif
#endif
---------------------------------------------------------------------
Sketch: Marlin_main.cpp
Description: Allows M119 to report state of Z2min sensor
Line 3877

#if HAS_Z2_MIN
SERIAL_PROTOCOLPGM(MSG_Z2_MIN);
SERIAL_PROTOCOLLN(((READ(Z2_MIN_PIN)^Z2_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
#endif

---------------------------------------------------------------------


Note:
Adding Z2min to the M119 End Switch report allows a good testing all endstop sensors.
It is also very good to show how M666 endstop adjustment works.

After a normal home you can see both Z1min and Z2min are triggered.
Give a M666 g-code with a plus or minus figure and then do a Z home and you can see how either Z1min or Z2min is trigged and the other Zmin is open.

I changed my Marlin Endstop “Open” message from ‘Open” to “ - - - “ as I think “Open” is a bit confusing as if using a switch it may in fact be closed.
Using “ Un-triggered” is more correct but I found using ‘- - - “just looked better.
Better to have switches closed when away from home as less chance to get electrical noise that may cause a false home detect.

---------------------------------------------------------------------
Sketch: language.h
Description: if using another language you may need to change that as well.
Line 155
#define MSG_ENDSTOP_OPEN "- - -"
---------------------------------------------------------------------
Attachments:
open | download - CoreXY-1.JPG (340 KB)
open | download - CoreXY-9.JPG (321 KB)
open | download - CoreXY-2.JPG (332.6 KB)
Thank you for posting this. You solved an issue related to a lack Z2 support predefined for MKS GEN v1.3. This will allow me to work around it for now.
The Z2 pins are defined by pins.h in the latest Marlin code by assigning them to the first set of unused E pins. See [github.com]

Also, for CoreXY I would recommend the most recent Marlin, which later tonight will be 1.1.0-RC6. We only just recently completed Core support for all the normal functions.

If you don't want to wait for the release, you can get the most recent code at [github.com]

Edited 1 time(s). Last edit at 04/24/2016 10:32PM by Thinkyhead.
Sorry, only registered users may post in this forum.

Click here to login