repetier / Repetier-Firmware

Firmware for Arduino based RepRap 3D printer.
815 stars 734 forks source link

Z Endstop #35

Closed bethebeer closed 10 years ago

bethebeer commented 12 years ago

I have the Z endstop set so that the nozzle is 2.6mm above the bed for one of my hot ends. When I use it, normally I just add G92 Z2.6 in the my starting G-code. But for some reason, even after sending G92 Z2.6 I cannot lower the Z axis, once the endstop is triggered. Here is my endstop code:

// ########################################################################################## // ## Endstop configuration ## // ##########################################################################################

/* By default all endstops are pulled up to high. You need a pullup if you use a mechanical endstop connected with gnd. Set value to false for no pullup on this endstop. */

define ENDSTOP_PULLUP_X_MIN true

define ENDSTOP_PULLUP_Y_MIN true

define ENDSTOP_PULLUP_Z_MIN true

define ENDSTOP_PULLUP_X_MAX true

define ENDSTOP_PULLUP_Y_MAX true

define ENDSTOP_PULLUP_Z_MAX true

//set to true to invert the logic of the endstops

define ENDSTOP_X_MIN_INVERTING false

define ENDSTOP_Y_MIN_INVERTING false

define ENDSTOP_Z_MIN_INVERTING false

define ENDSTOP_X_MAX_INVERTING false

define ENDSTOP_Y_MAX_INVERTING false

define ENDSTOP_Z_MAX_INVERTING false

//If your axes are only moving in one direction, make sure the endstops are connected properly. //If your axes move in one direction ONLY when the endstops are triggered, set ENDSTOPS_INVERTING to true here

//// ADVANCED SETTINGS - to tweak parameters

// 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

// Disables axis when it's not being used.

define DISABLE_X false

define DISABLE_Y false

define DISABLE_Z true

define DISABLE_E false

// Inverting axis direction

define INVERT_X_DIR false

define INVERT_Y_DIR false

define INVERT_Z_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

//If true, axis won't move to coordinates less than zero.

define min_software_endstop_x false

define min_software_endstop_y false

define min_software_endstop_z false

//If true, axis won't move to coordinates greater than the defined lengths below.

define max_software_endstop_x true

define max_software_endstop_y true

define max_software_endstop_z true

// If during homing the endstop is reached, ho many mm should the printer move back for the second try

define ENDSTOP_X_BACK_MOVE 5

define ENDSTOP_Y_BACK_MOVE 5

define ENDSTOP_Z_BACK_MOVE 2

// For higher precision you can reduce the speed for the second test on the endstop // during homing operation. The homing speed is divided by the value. 1 = same speed, 2 = half speed

define ENDSTOP_X_RETEST_REDUCTION_FACTOR 2

define ENDSTOP_Y_RETEST_REDUCTION_FACTOR 2

define ENDSTOP_Z_RETEST_REDUCTION_FACTOR 2

// When you have several endstops in one circuit you need to disable it after homing by moving a // small amount back. This is also the case with H-belt systems.

define ENDSTOP_X_BACK_ON_HOME 0

define ENDSTOP_Y_BACK_ON_HOME 0

define ENDSTOP_Z_BACK_ON_HOME 0

// You can disable endstop checking for print moves. This is needed, if you get sometimes // false signals from your endstops. If your endstops don't give false signals, you // can set it on for safety.

define ALWAYS_CHECK_ENDSTOPS false

// maximum positions in mm - only fixed numbers!

define X_MAX_LENGTH 203

define Y_MAX_LENGTH 204

define Z_MAX_LENGTH 140

Thanks

repetier commented 12 years ago

That is exactly the behaviour that it should have. An endstop can not get overridden by anything. It is a hard endstop if it is reached, it is supposed to prevent further moves in that direction. The only solution is the other way around, but that would require a spot where you can lower the extruder below printbed. Or you need to adjust the endstop when swapping extruders.

One other solution would be to override the z endstop check in Repetier.pde in method bresenham_step you can use the parameter to determine if the endstop should be checked. Then only during z homing the endstop is checked, so you could go below that level with your little trick. Do this on your own risk, nothing wil prevent you from going even lower.

repetier commented 12 years ago

Here the necessary code patch. Change

// Test Z-Axis every step if necessary, otherwise it could easyly ruin your printer!

if Z_MIN_PIN>-1

if((cur->dir & 68)==64) if(READ(Z_MIN_PIN) != ENDSTOP_Z_MIN_INVERTING) {cur->dir&=~64;}

endif

into

// Test Z-Axis every step if necessary, otherwise it could easyly ruin your printer!

if Z_MIN_PIN>-1

if(cur->flags & FLAG_CHECK_ENDSTOPS) { if((cur->dir & 68)==64) if(READ(Z_MIN_PIN) != ENDSTOP_Z_MIN_INVERTING) {cur->dir&=~64;} }

endif

that should do the trick (untested).

bethebeer commented 12 years ago

Works perfectly. Thanks a bunch. This is the first time I have used repetier and it is working very nicely. It's scary to see it printing so fast.

bethebeer commented 12 years ago

Now I am trying to print parts sequentially. The parts are all lower than the endstop(they are very thin) so when the next part is started at Z=0, there is no Z movement, and the host reports that Z is already at 0, so the next part starts to print midair. As long as the endstop is triggered, Z position is reported as 0, so there report of a negative position. Thanks

repetier commented 12 years ago

I don't fully understand what you are doing. Can you give a short g-code example what you do for the first print and how you continue to the next print that does not work right. Don't understand why the same trick doesn't work any time, so I assume you do something different but without the code it is hard to say. After all you are already something that normal user even can't do at all.

bethebeer commented 12 years ago

Sorry to bother you, closing the issue for now. I am working through the g-code and I think it might be an issue with Slic3r. I am using the newest one from the git. I looked at a g-code viewer and everything looked good, but the parts I was printing are only 1.75mm, so I could not tell that something was wrong with the code; I believe 7 of 8 parts start about 1.0mm off of the bed, but were about 1mm thinner than they should be, so from above, all the parts looked the same. So the firmware is probably working properly. I'll get back to you if I get and use a gcode file that I'm positive is correct and the print still fails.

Thanks again for the fix and the great prints.

bethebeer commented 12 years ago

Yup, it's an issue with slic3r.

bethebeer commented 10 years ago

Having the same issue in 0.91. In motions.h have changed this:

if(isZNegativeMove() && Printer::isZMinEndstopHit()) setZMoveFinished();

to this:

if(isZNegativeMove() && Printer::isZMinEndstopHit() && ALWAYS_CHECK_ENDSTOPS) setZMoveFinished();

But this prevents the Z axis from homing initially. Any suggestions here?

bethebeer commented 10 years ago

Is there a variable that would return true when the printer is homing in the Z? Then I could replace ALWAYS_CHECK_ENDSTOPS with that value.

Thanks

repetier commented 10 years ago

The solution is in x/y test, isCheckEndstops() returns true if you are homing or if ALWAYS_CHECK_ENDSTOPS is enabled.

bethebeer commented 10 years ago

That works. Thank you.