Need help with Marlin setup - MIN/MAX confusion and home pos

Here is the place to discuss software and related tools for Slice generation, machine control, & etc...
Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Need help with Marlin setup - MIN/MAX confusion and home pos

Postby Kilh » Sun Mar 29, 2015 11:41 pm

Hey guys,
I really wanted to solve this myself and spent almost two days trying to get everything to work, but now I'm finally devastated, trying to find the problem.

I'm using a Mega 2560 with RAMPS 1.4. Bottom-up build, one endstop. Here's a picture for reference (the endstop is marked with yellow tape):
http://teptec.net/wp-content/uploads/20 ... 051548.jpg

The motor is sitting at the bottom, I've set the steps per mm to 320 (as suggested in my other thread). When I hit the move 1/10/50 mm up/down buttons in CW or Pronterface it moves accordingly, so far so good.

Now for the actual problem. I can't seem to setup the movements, endstop and home position correctly.
The optical endstop is currently connected to Z-MIN and with the current mechanical setup (see blow) it seems to be ignored... occasionally. I'm not even sure how to describe it other than "weird stuff going on" which obviously won't help with the diagnosis.
With all the trial and error I had a kind of working setup a few hours ago where the endstop was connected to Z-MAX, hitting the home button made it stop there and everything was cool... except for the little problem that everything except for the axis was upside down. So it tried printing upwards from the home position and of course that made it crash into the endstop.

I'm probably just overseeing something dumb here, but after all this thinking and cursing I feel like asking someone to point me in the right direction. Here's the "Mechanical Setting" part from my config (assuming other parts of the config don't matter right now as the communication, etc seems to work fine).

Code: Select all

//===========================================================================
//============================= Mechanical Settings =========================
//===========================================================================

// Uncomment this option to enable CoreXY kinematics
// #define COREXY

// Enable this option for Toshiba steppers
// #define CONFIG_STEPPERS_TOSHIBA

// The pullups are needed if you directly connect a mechanical endstop between the signal and ground pins.
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN

// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.

#define DISABLE_MAX_ENDSTOPS
// #define DISABLE_MIN_ENDSTOPS

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders

// Disables axis when it's not being used.
#define DISABLE_X true
#define DISABLE_Y true
#define DISABLE_Z false
#define DISABLE_E true // For all extruders
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled

// If you motor turns to wrong direction, you can invert it here:
#define INVERT_X_DIR false
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false

// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR 1

#define min_software_endstops false // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true  // If true, axis won't move to coordinates greater than the defined lengths below.

// Travel limits after homing (units are in mm)
#define X_MAX_POS 200
#define X_MIN_POS 0
#define Y_MAX_POS 200
#define Y_MIN_POS 0
#define Z_MAX_POS 111
#define Z_MIN_POS 0

#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)



Summarized: I want the platform to have it's home position at the upper endstop, move down X millimeters where it's supposed to be in the VAT and move back towards home during printing. Is that even the right way around? Should MIN be at the top or at the bottom? What would be the most obvious way for someone less confused to set this up based on the build?

Thanks in advance!

Navstevnik
Posts: 4
Joined: Wed Nov 26, 2014 8:08 pm

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Navstevnik » Mon Mar 30, 2015 4:05 am

You have disabled max endstops - #define DISABLE_MAX_ENDSTOPS if you want use both endstops.
I recommend checking endstop status using M119 command and manually trigger them and check status.
For this I recommend download printrun https://github.com/kliment/Printrun or other package maybe creation workshop can do it too I can't check it as I don't have it with me now.

For your home position you can probably set
// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
#define Z_HOME_DIR 1

And experiment with it or you can set in creation workshop post gcode to go x mm in z or just some big number so top endstop will stop it.

Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Kilh » Mon Mar 30, 2015 10:54 am

Should the MAX endstop be at the top or the bottom? I disabled one as I only wanted to use one hardware endstop and the software endstop for the bottom.

I tried setting the Z_HOME_DIR to 1 (max), but that's basically what I described above; it would try to print from the home position upwards.

Where does everyone have their MIN/MAX endstops? Top or bottom? I'd assume that it doesnt matter, but I can't get it to work correctly :|

Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Kilh » Mon Mar 30, 2015 12:03 pm

The way it's working right now is that I can hit the home button and it will move upwards until it reaches the MAX endstop I put there. After that I can move it down 111mm (just a value for testing reasons) where the software endstop kicks in. That looks absolutely right to me, but when I try to print it starts at the home position (max endstop at the top) instead of going down to MIN first.
What did I do wrong?

The curerent Mechanical Settings:

Code: Select all

//===========================================================================
//============================= Mechanical Settings =========================
//===========================================================================

// Uncomment this option to enable CoreXY kinematics
// #define COREXY

// Enable this option for Toshiba steppers
// #define CONFIG_STEPPERS_TOSHIBA

// The pullups are needed if you directly connect a mechanical endstop between the signal and ground pins.
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN

// Mechanical endstop with COM to ground and NC to Signal uses "false" here (most common setup).
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.

// #define DISABLE_MAX_ENDSTOPS
#define DISABLE_MIN_ENDSTOPS

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0 // For all extruders

// Disables axis when it's not being used.
#define DISABLE_X true
#define DISABLE_Y true
#define DISABLE_Z false
#define DISABLE_E true // For all extruders
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled

// If you motor turns to wrong direction, you can invert it here:
#define INVERT_X_DIR false
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define INVERT_E3_DIR false

// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR 1

#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops false  // If true, axis won't move to coordinates greater than the defined lengths below.

// Travel limits after homing (units are in mm)
#define X_MAX_POS 200
#define X_MIN_POS 0
#define Y_MAX_POS 200
#define Y_MIN_POS 0
#define Z_MAX_POS 111
#define Z_MIN_POS 0

#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)

Phife
Posts: 239
Joined: Fri Jan 17, 2014 5:24 pm

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Phife » Mon Mar 30, 2015 12:47 pm

Try flipping your motor wire around, I think I had a similar problem to you and that was what fixed it for me.

My machine, I home to Max which is at the top, farthest away from the vat, and then the machine moves down to 0 which is where I start my print. Un invert your Z axis. Oh and if you have a gcode window you can type in M114 to get the current position of the axis, should be helpful for debugging which direction is which.

Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Kilh » Mon Mar 30, 2015 12:53 pm

Maybe I should put the basic question this way:

When I hit the "Home" button, do I want the platform to move to the first layer (in the VAT) or to the topmost position (at least in my logic that sounds right).

The motor moves just as it should, I can't see what should be wrong with the wiring.

Phife
Posts: 239
Joined: Fri Jan 17, 2014 5:24 pm

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Phife » Mon Mar 30, 2015 12:54 pm

I edited my post.. have a look

as for your motor moving correctly, so was mine.. couldnt hurt to try it..

As for how the home should work, Its up to you. But for me, I have my home at the top, farthest away from the vat and then it moves down into the vat with a command from the start gcode.

Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Kilh » Mon Mar 30, 2015 12:59 pm

Ah I see, thanks for clearing that up. So just to confirm what you're suggesting:
Plug in the motor to basically spin in the wrong direction (Green/Black/Red/Blue instead of Red/Blue/Green/Black) and invert the axis movement to compensate for that and to trick the firmware into thinking up is down and down is up?

I'll definitely give that a try, thanks a lot!

edit: Ah no, one moment... Now that I read your reply several times I think I'd just have to put that move downwards into the pre gcode, that might already solve everything! Is there a command to go right to the min software endstop?

Phife
Posts: 239
Joined: Fri Jan 17, 2014 5:24 pm

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Phife » Mon Mar 30, 2015 1:45 pm

The homing procedure should move to the endstop you have set (max or min) and then move off the endstop, mine then goes back and touches off the endstop again and then moves off a little. My machine is set to home to Max, so after the homing my Z axis is now at my max travel (in my case 280mm) so if I type M114 my Z axis shows a position of 280.

In my start gcode I have the home command then a G1 Z-280 which brings my build plate down to 0.05-0.1mm above my FEP film vat bottom. The rest of my Gcode is all in the Z+ direction. For example some of my code.
********** Header Start ********
;Here you can set any G or M-Code which should be executed BEFORE the build process
G21 ;Set units to be mm
G91 ;Relative Positioning
M17 ;Enable motors
G28 Z0 ;Home
G1 Z-250 F700
G1 Z-30 F100

;********** Lift Sequence ********
G1 Z5 F200 ;Peel
G4 P200 ;Pause 0.2sec
G1 Z-7.9 F500 ;Lower for next layer (0.1mm layer)
G4 P500 ;Pause .5sec
;********** Lift Sequence *******

Im not tricking my machine, if I hit the up arrow in CW the Z moves up.


Its now sounds like you have your slice gcode not set correctly. Post up your Start, Pre-slice, lift and End Gcode.

Kilh
Posts: 30
Joined: Sat Aug 16, 2014 10:32 am
Location: Berlin, Germany

Re: Need help with Marlin setup - MIN/MAX confusion and home

Postby Kilh » Mon Mar 30, 2015 1:47 pm

So... I've put
G28 Z (home Z to the top)
and
G1 Z0.01 (move to pos 0.01)
in the start Gcode, but CW seems to ignore the G1 Z0.01 command. When I use the manual Gcode in CW it only seems to work 10% of the time. The command works 100% of the time in Pronterface.

I checked the positions via M114 and it seems to be correct. 111mm is located at the top home position and Z 0.00 is 111mm below that.

Any obvious reason why CW ignores the G1 Z0.01 command and starts projecting right after the homing move?

This is the current start code:

Code: Select all

;********** Header Start ********
;Here you can set any G or M-Code which should be executed BEFORE the build process
G21 ;Set units to be mm
G91 ;Relative Positioning
M17 ;Enable motors

G1 Z0.01 ;Move Z to 0.01

;********** Header End **********