From 8cb84118f1c290c0a22eb75833bbd62f81013522 Mon Sep 17 00:00:00 2001 From: gralco Date: Wed, 21 Oct 2015 15:33:52 -0600 Subject: [PATCH] Revert "Fixed endstop implementation (position is where it stops now), M601 - continue from change filament added." This reverts commit cdb021e4252009c7bbe28825f4b47e5ab479fd62. --- Marlin/Marlin_main.cpp | 122 +++--------------- Marlin/stepper.cpp | 277 +++++++---------------------------------- Marlin/stepper.h | 7 -- 3 files changed, 58 insertions(+), 348 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 10442ac3d..affb9edf2 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -169,7 +169,6 @@ // M503 - print the current settings (from memory not from EEPROM) // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] -// M601 - Resume the print from filament change // M665 - set delta configurations // M666 - set delta endstop adjustment // M605 - Set dual x-carriage movement mode: S [ X R ] @@ -244,8 +243,6 @@ float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; bool axis_known_position[3] = {false, false, false}; float zprobe_zoffset; -bool probing = false; - // Extruder offset #if EXTRUDERS > 1 #ifndef DUAL_X_CARRIAGE @@ -347,11 +344,7 @@ const char echomagic[] PROGMEM = "echo:"; //=========================================================================== //=============================Private Variables============================= //=========================================================================== -bool change_filament = false; - const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; -const uint8_t axis_max_pin[] = {X_MAX_PIN, Y_MAX_PIN, Z_MAX_PIN}; -const bool axis_max_endstop_inverting[] = {X_MAX_ENDSTOP_INVERTING, Y_MAX_ENDSTOP_INVERTING, Z_MAX_ENDSTOP_INVERTING}; static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}; #ifndef DELTA @@ -615,28 +608,9 @@ void setup() lcd_init(); _delay_ms(1000); // wait 1sec to display the splash screen -#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 - #ifdef CONTROLLERFAN_SPEED_START + #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_START); // kickstart for controller fan - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_START); - #endif //CONTROLLERFAN_SPEED_START - #endif //CONTROLLERFAN_PIN - -#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 - //SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan - // set case fan to normal speed - if (CONTROLLERFAN_SPEED_FULL <= CONTROLLERFAN_SPEED_MAX) - { - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_FULL); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_FULL); - } - else - { - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MAX); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MAX); - } - #endif //CONTROLLERFAN_PIN + #endif #ifdef DIGIPOT_I2C digipot_i2c_init(); @@ -789,9 +763,6 @@ void get_command() //If command was e-stop process now if(strcmp(cmdbuffer[bufindw], "M112") == 0) kill(); - //If command was M601 stop change filament mode - if(strcmp(cmdbuffer[bufindw], "M601") == 0) - change_filament = false; bufindw = (bufindw + 1)%BUFSIZE; buflen += 1; @@ -1094,7 +1065,7 @@ static void run_z_probe() { st_synchronize(); // move back down slowly to find bed - feedrate = homing_feedrate[Z_AXIS]/40; + feedrate = homing_feedrate[Z_AXIS]/4; zPosition -= home_retract_mm(Z_AXIS) * 2; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder); st_synchronize(); @@ -1181,17 +1152,13 @@ static void retract_z_probe() { /// Probe bed height at position (x,y), returns the measured z value static float probe_pt(float x, float y, float z_before) { // move to right place - probing = true; do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); - probing = false; #ifndef Z_PROBE_SLED engage_z_probe(); // Engage Z Servo endstop if available #endif // Z_PROBE_SLED - probing = true; run_z_probe(); - probing = false; float measured_z = current_position[Z_AXIS]; #ifndef Z_PROBE_SLED retract_z_probe(); @@ -1469,11 +1436,6 @@ void process_commands() plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING - probing = false; - - //set endstop switch trigger period to less - endstop_trig_period = HOME_PROBE_ENDSTOP_PERIOD; - saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; feedmultiply = 100; @@ -1668,26 +1630,14 @@ void process_commands() } #endif #endif - - #ifdef Z_RAISE_AFTER_HOMING - if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) { - destination[Z_AXIS] = Z_RAISE_AFTER_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - } - #endif + + if(code_seen(axis_codes[Z_AXIS])) { if(code_value_long() != 0) { current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; } } - #ifdef Z_RAISE_AFTER_HOMING - if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) { - current_position[Z_AXIS] += Z_RAISE_AFTER_HOMING + zprobe_zoffset; //Sets Z distance back to 0 for auto leveling - } - #endif #ifdef ENABLE_AUTO_BED_LEVELING if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) { current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) @@ -1709,8 +1659,6 @@ void process_commands() feedmultiply = saved_feedmultiply; previous_millis_cmd = millis(); endstops_hit_on_purpose(); - //set endstop switch trigger back to std period - endstop_trig_period = STD_ENDSTOP_PERIOD; break; #ifdef ENABLE_AUTO_BED_LEVELING @@ -1719,9 +1667,6 @@ void process_commands() #if Z_MIN_PIN == -1 #error "You must have a Z_MIN endstop in order to enable Auto Bed Leveling feature!!! Z_MIN_PIN must point to a valid hardware pin." #endif - - //set endstop switch trigger period to less - endstop_trig_period = HOME_PROBE_ENDSTOP_PERIOD; // Prevent user from running a G29 without first homing in X and Y if (! (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS]) ) @@ -1799,7 +1744,6 @@ void process_commands() { // raise extruder z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS; - LCD_MESSAGEPGM(MSG_AUTO_LEVEL); } float measured_z = probe_pt(xProbe, yProbe, z_before); @@ -1861,11 +1805,6 @@ void process_commands() apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset current_position[Z_AXIS] = z_tmp - real_z + current_position[Z_AXIS]; //The difference is added to current position and sent to planner. plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - - //set endstop switch trigger back to std period - endstop_trig_period = STD_ENDSTOP_PERIOD; - SERIAL_ECHOLNPGM("Probing done!"); - #ifdef Z_PROBE_SLED dock_sled(true, -SLED_DOCKING_OFFSET); // correct for over travel. #endif // Z_PROBE_SLED @@ -1881,9 +1820,7 @@ void process_commands() feedrate = homing_feedrate[Z_AXIS]; - probing = true; run_z_probe(); - probing = false; SERIAL_PROTOCOLPGM(MSG_BED); SERIAL_PROTOCOLPGM(" X: "); SERIAL_PROTOCOL(current_position[X_AXIS]); @@ -2284,9 +2221,7 @@ void process_commands() engage_z_probe(); setup_for_endstop_move(); - probing = true; run_z_probe(); - probing = false; current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; @@ -2358,9 +2293,7 @@ void process_commands() } setup_for_endstop_move(); - probing = true; run_z_probe(); - probing = false; sample_set[n] = current_position[Z_AXIS]; @@ -2876,10 +2809,6 @@ Sigma_Exit: SERIAL_PROTOCOLPGM(MSG_Z_MIN); SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN)); #endif - #if defined(Z2_MIN_PIN) && Z2_MIN_PIN > -1 - SERIAL_PROTOCOLPGM(MSG_Z2_MIN); - SERIAL_PROTOCOLLN(((READ(Z2_MIN_PIN)^Z2_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN)); - #endif #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1 SERIAL_PROTOCOLPGM(MSG_Z_MAX); SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN)); @@ -3622,7 +3551,6 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp #ifdef FILAMENTCHANGEENABLE case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] { - change_filament = true; float target[4]; float lastpos[4]; target[X_AXIS]=current_position[X_AXIS]; @@ -3705,7 +3633,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp delay(100); LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); uint8_t cnt=0; - while(!lcd_clicked() && change_filament){ + while(!lcd_clicked()){ cnt++; manage_heater(); manage_inactivity(true); @@ -4008,11 +3936,7 @@ void get_coordinates() for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) { - float check_destination = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; - if(i == E_AXIS || check_destination <= current_position[i] || !(digitalRead(axis_max_pin[i])^axis_max_endstop_inverting[i])/* || probing*/) - destination[i] = check_destination; - else - destination[i] = current_position[i]; + destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; seen[i]=true; } else destination[i] = current_position[i]; //Are these else lines really needed? @@ -4272,9 +4196,9 @@ void controllerFan() || !READ(E2_ENABLE_PIN) #endif #if EXTRUDER > 1 - //~ #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1 - //~ || !READ(X2_ENABLE_PIN) - //~ #endif + #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1 + || !READ(X2_ENABLE_PIN) + #endif || !READ(E1_ENABLE_PIN) #endif || !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled... @@ -4284,30 +4208,14 @@ void controllerFan() if ((millis() - lastMotor) >= (CONTROLLERFAN_SECS*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC... { - if (CONTROLLERFAN_SPEED_IDLE >= CONTROLLERFAN_SPEED_MIN) - { - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_IDLE); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_IDLE); + digitalWrite(CONTROLLERFAN_PIN, 0); + analogWrite(CONTROLLERFAN_PIN, 0); } else { - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MIN); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MIN); - } - } - else - { - if (CONTROLLERFAN_SPEED_FULL <= CONTROLLERFAN_SPEED_MAX) - { - - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_FULL); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_FULL); - } - else - { - digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MAX); - analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED_MAX); - } + // allows digital or PWM fan output to be used (see M42 handling) + digitalWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED); + analogWrite(CONTROLLERFAN_PIN, CONTROLLERFAN_SPEED); } } } diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 3dc942019..b2e7d1208 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -69,7 +69,6 @@ volatile long endstops_stepsTotal,endstops_stepsDone; static volatile bool endstop_x_hit=false; static volatile bool endstop_y_hit=false; static volatile bool endstop_z_hit=false; -static volatile bool endstop_z2_hit=false; #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED bool abort_on_endstop_hit = false; #endif @@ -77,14 +76,11 @@ bool abort_on_endstop_hit = false; int motor_current_setting[3] = DEFAULT_PWM_MOTOR_CURRENT; #endif -unsigned int endstop_trig_period = STD_ENDSTOP_PERIOD; // time in ms -static unsigned int x_min,y_min,z_min,z2_min,x_max,y_max,z_max = 0; static bool old_x_min_endstop=false; static bool old_x_max_endstop=false; static bool old_y_min_endstop=false; static bool old_y_max_endstop=false; static bool old_z_min_endstop=false; -static bool old_z2_min_endstop=false; static bool old_z_max_endstop=false; static bool check_endstops = true; @@ -195,7 +191,6 @@ void checkHitEndstops() endstop_x_hit=false; endstop_y_hit=false; endstop_z_hit=false; - endstop_z2_hit=false; #if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT) if (abort_on_endstop_hit) { @@ -215,7 +210,6 @@ void endstops_hit_on_purpose() endstop_x_hit=false; endstop_y_hit=false; endstop_z_hit=false; - endstop_z2_hit=false; } void enable_endstops(bool check) @@ -409,7 +403,7 @@ ISR(TIMER1_COMPA_vect) count_direction[Y_AXIS]=1; } - // Set direction en check limit switches + // Set direction en check limit switches #ifndef COREXY if ((out_bits & (1< -1 - //bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); - if(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING) - { - if(old_x_min_endstop) - { - //if((current_block->steps_x > 0) && (millis() > (tx_min + SWITCH_PERIOD))) { - if((current_block->steps_x > 0) && (x_min > endstop_trig_period)) { - //SERIAL_ECHOLN("X_MIN triggered!"); - endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; - if(!probing) - { - current_position[X_AXIS] = X_MIN_POS; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - } - endstop_x_hit=true; - step_events_completed = current_block->step_event_count; - } - x_min++; - } - else - { - //SERIAL_ECHOLN("Reseting X_MIN variables!"); - old_x_min_endstop = true; - //tx_min = millis(); - } - } - else - { - old_x_min_endstop = false; - //tx_min = 0; - x_min = 0; - } + bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING); + if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) { + endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; + endstop_x_hit=true; + step_events_completed = current_block->step_event_count; + } + old_x_min_endstop = x_min_endstop; #endif } } @@ -469,39 +438,14 @@ ISR(TIMER1_COMPA_vect) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) #endif { - #if defined(X_MAX_PIN) && X_MAX_PIN > -1 - //bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); - if(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING) - { - if(old_x_max_endstop) - { - //if((current_block->steps_x > 0) && (millis() > (tx_max + SWITCH_PERIOD))){ - if((current_block->steps_x > 0) && (x_max > endstop_trig_period)){ - //SERIAL_ECHOLN("X_MAX triggered!"); - endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; - if(!probing) - { - current_position[X_AXIS] = (float)endstops_trigsteps[X_AXIS]/axis_steps_per_unit[X_AXIS]; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - } - endstop_x_hit=true; - step_events_completed = current_block->step_event_count; - } - x_max++; - } - else - { - //SERIAL_ECHOLN("Reseting X_MAX variables!"); - old_x_max_endstop = true; - //tx_max = millis(); - } - } - else - { - old_x_max_endstop = false; - //tx_max = 0; - x_max = 0; - } + #if defined(X_MAX_PIN) && X_MAX_PIN > -1 + bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING); + if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){ + endstops_trigsteps[X_AXIS] = count_position[X_AXIS]; + endstop_x_hit=true; + step_events_completed = current_block->step_event_count; + } + old_x_max_endstop = x_max_endstop; #endif } } @@ -515,38 +459,13 @@ ISR(TIMER1_COMPA_vect) CHECK_ENDSTOPS { #if defined(Y_MIN_PIN) && Y_MIN_PIN > -1 - //bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING); - if(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING) - { - if(old_y_min_endstop) - { - //if((current_block->steps_y > 0) && (millis() > (ty_min + SWITCH_PERIOD))) { - if((current_block->steps_y > 0) && (y_min > endstop_trig_period)) { - //SERIAL_ECHOLN("Y_MIN triggered!"); - endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS]; - if(!probing) - { - current_position[Y_AXIS] = Y_MIN_POS; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - } - endstop_y_hit=true; - step_events_completed = current_block->step_event_count; - } - y_min++; - } - else - { - //SERIAL_ECHOLN("Reseting Y_MIN variables!"); - old_y_min_endstop = true; - //ty_min = millis(); - } + bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING); + if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) { + endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS]; + endstop_y_hit=true; + step_events_completed = current_block->step_event_count; } - else - { - old_y_min_endstop = false; - //ty_min = 0; - y_min = 0; - } + old_y_min_endstop = y_min_endstop; #endif } } @@ -554,41 +473,17 @@ ISR(TIMER1_COMPA_vect) CHECK_ENDSTOPS { #if defined(Y_MAX_PIN) && Y_MAX_PIN > -1 - //bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING); - if(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING) - { - if(old_y_max_endstop) - { - //if((current_block->steps_y > 0) && (millis() > (ty_min + SWITCH_PERIOD))){ - if((current_block->steps_y > 0) && (y_max > endstop_trig_period)){ - //SERIAL_ECHOLN("Y_MAX triggered!"); - endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS]; - if(!probing) - { - current_position[Y_AXIS] = (float)endstops_trigsteps[Y_AXIS]/axis_steps_per_unit[Y_AXIS]; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - } - endstop_y_hit=true; - step_events_completed = current_block->step_event_count; - } - y_max++; - } - else - { - //SERIAL_ECHOLN("Reseting Y_MAX variables!"); - old_y_max_endstop = true; - //ty_max = millis(); - } - } - else - { - old_y_max_endstop = false; - //ty_max = 0; - y_max = 0; - } + bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING); + if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){ + endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS]; + endstop_y_hit=true; + step_events_completed = current_block->step_event_count; + } + old_y_max_endstop = y_max_endstop; #endif } } + if ((out_bits & (1< -1 - //bool z_min_endstop=(READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING); - if(READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING) - { - if(old_z2_min_endstop) - { - //if((current_block->steps_z > 0) && (millis() > (tz_min + SWITCH_PERIOD))) { - if((current_block->steps_z > 0) && (z2_min > endstop_trig_period)) { - //SERIAL_ECHOLN("Z_MIN triggered!"); - endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - //current_position[Z_AXIS] = Z_MIN_POS; - //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - endstop_z2_hit=true; - step_events_completed = current_block->step_event_count; - } - z2_min++; - } - else - { - //SERIAL_ECHOLN("Reseting Z2_MIN variables!"); - old_z2_min_endstop = true; - //tz_min = millis(); - } - } - else - { - old_z2_min_endstop = false; - //tz_min = 0; - z2_min = 0; - } - #endif - } { #if defined(Z_MIN_PIN) && Z_MIN_PIN > -1 - //bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) - { - if(old_z_min_endstop) - { - //if((current_block->steps_z > 0) && (millis() > (tz_min + SWITCH_PERIOD))) { - if((current_block->steps_z > 0) && (z_min > endstop_trig_period)) { - //SERIAL_ECHOLN("Z_MIN triggered!"); - endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - endstop_z_hit=true; - step_events_completed = current_block->step_event_count; - } - z_min++; - } - else - { - //SERIAL_ECHOLN("Reseting Z_MIN variables!"); - old_z_min_endstop = true; - //tz_min = millis(); - } + bool z_min_endstop=(READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); + if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) { + endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; + endstop_z_hit=true; + step_events_completed = current_block->step_event_count; } - else - { - old_z_min_endstop = false; - //tz_min = 0; - z_min = 0; - } + old_z_min_endstop = z_min_endstop; #endif } } - else { // +direction WRITE(Z_DIR_PIN,!INVERT_Z_DIR); @@ -675,38 +516,13 @@ ISR(TIMER1_COMPA_vect) CHECK_ENDSTOPS { #if defined(Z_MAX_PIN) && Z_MAX_PIN > -1 - //bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING); - if(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING) - { - if(old_z_max_endstop) - { - //if((current_block->steps_z > 0) && (millis() > (tz_max + SWITCH_PERIOD))) { - if((current_block->steps_z > 0) && (z_max > endstop_trig_period)) { - //SERIAL_ECHOLN("Z_MAX triggered!"); - endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; - if(!probing) - { - current_position[Z_AXIS] = (float)endstops_trigsteps[Z_AXIS]/axis_steps_per_unit[Z_AXIS]; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - } - endstop_z_hit=true; - step_events_completed = current_block->step_event_count; - } - z_max++; - } - else - { - //SERIAL_ECHOLN("Reseting Z_MAX variables!"); - old_z_max_endstop = true; - //tz_max = millis(); - } - } - else - { - old_z_max_endstop = false; - //tz_max = 0; - z_max = 0; - } + bool z_max_endstop=(READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING); + if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) { + endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; + endstop_z_hit=true; + step_events_completed = current_block->step_event_count; + } + old_z_max_endstop = z_max_endstop; #endif } } @@ -1100,13 +916,6 @@ void st_init() WRITE(Z_MIN_PIN,HIGH); #endif #endif - - #if defined(Z2_MIN_PIN) && Z2_MIN_PIN > -1 - SET_INPUT(Z2_MIN_PIN); - #ifdef ENDSTOPPULLUP_Z2MIN - WRITE(Z2_MIN_PIN,HIGH); - #endif - #endif #if defined(X_MAX_PIN) && X_MAX_PIN > -1 SET_INPUT(X_MAX_PIN); diff --git a/Marlin/stepper.h b/Marlin/stepper.h index 94a7a261b..1477a6e03 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -48,11 +48,6 @@ extern bool abort_on_endstop_hit; #endif -// Switch endstop variables -#define STD_ENDSTOP_PERIOD 50 -#define HOME_PROBE_ENDSTOP_PERIOD 20 -extern unsigned int endstop_trig_period; - // Initialize and start the stepper motor subsystem void st_init(); @@ -71,8 +66,6 @@ long st_get_position(uint8_t axis); float st_get_position_mm(uint8_t axis); #endif //ENABLE_AUTO_BED_LEVELING -extern bool probing; - // The stepper subsystem goes to sleep when it runs out of things to execute. Call this // to notify the subsystem that it is time to go to work. void st_wake_up();