diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 483b8cf837..066e610058 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -223,11 +223,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker //#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 67} //sells mendel with v9 extruder -#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 200000} // (mm/sec) +#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec) #define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot. #define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves -#define DEFAULT_RETRACT_ACCELERATION 7000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts +#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts #define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate #define DEFAULT_MINTRAVELFEEDRATE 0.0 diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index f26ae101b2..1674fcc7d9 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -489,12 +489,21 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<direction_bits |= (1<active_extruder = extruder; + //enable active axes if(block->steps_x != 0) enable_x(); if(block->steps_y != 0) enable_y(); if(block->steps_z != 0) enable_z(); - if(block->steps_e != 0) enable_e(); - + if(extruder == 0) { + if(block->steps_e != 0) enable_e(); + } + #if (EXTRUDERS > 1) + if(extruder == 1) { + if(block->steps_e != 0) enable_e1(); + } + #endif + float delta_mm[4]; delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS]; delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]; @@ -713,7 +722,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa else { long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st); float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) * - (block->speed_e * block->speed_e * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536; + (current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536; block->advance = advance; if(acc_dist == 0) { block->advance_rate = 0; diff --git a/Marlin/planner.h b/Marlin/planner.h index 703bbe9fd9..53ac3d8447 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -37,11 +37,12 @@ typedef struct { long decelerate_after; // The index of the step event on which to start decelerating long acceleration_rate; // The acceleration rate used for acceleration calculation unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h) + unsigned char active_extruder; // Selects the active extruder #ifdef ADVANCE -// long advance_rate; -// volatile long initial_advance; -// volatile long final_advance; -// float advance; + long advance_rate; + volatile long initial_advance; + volatile long final_advance; + float advance; #endif // Fields used by the motion planner to manage acceleration diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index fcc0aceecd..0eabc753d7 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -383,8 +383,9 @@ ISR(TIMER1_COMPA_vect) } #endif //!ADVANCE for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) - MSerial.checkRx(); - /* + MSerial.checkRx(); // Check for serial chars. + + #ifdef ADVANCE counter_e += current_block->steps_e; if (counter_e > 0) { counter_e -= current_block->step_event_count; @@ -399,15 +400,11 @@ ISR(TIMER1_COMPA_vect) CRITICAL_SECTION_END; } } - */ - /* // Do E steps + advance steps - CRITICAL_SECTION_START; e_steps += ((advance >> 16) - old_advance); - CRITICAL_SECTION_END; old_advance = advance >> 16; - */ - + #endif //ADVANCE + counter_x += current_block->steps_x; if (counter_x > 0) { WRITE(X_STEP_PIN, HIGH); @@ -461,7 +458,9 @@ ISR(TIMER1_COMPA_vect) OCR1A = timer; acceleration_time += timer; #ifdef ADVANCE - advance += advance_rate; + for(int8_t i=0; i < step_loops; i++) { + advance += advance_rate; + } #endif } else if (step_events_completed > current_block->decelerate_after) { @@ -483,7 +482,9 @@ ISR(TIMER1_COMPA_vect) OCR1A = timer; deceleration_time += timer; #ifdef ADVANCE - advance -= advance_rate; + for(int8_t i=0; i < step_loops; i++) { + advance -= advance_rate; + } if(advance < final_advance) advance = final_advance; #endif //ADVANCE @@ -491,7 +492,7 @@ ISR(TIMER1_COMPA_vect) else { OCR1A = OCR1A_nominal; } - + // If current block is finished, reset pointer if (step_events_completed >= current_block->step_event_count) { current_block = NULL; @@ -506,22 +507,24 @@ ISR(TIMER1_COMPA_vect) // Timer 0 is shared with millies ISR(TIMER0_COMPA_vect) { - // Critical section needed because Timer 1 interrupt has higher priority. - // The pin set functions are placed on trategic position to comply with the stepper driver timing. - WRITE(E_STEP_PIN, LOW); + old_OCR0A += 25; // ~10kHz interrupt + OCR0A = old_OCR0A; // Set E direction (Depends on E direction + advance) - if (e_steps < 0) { - WRITE(E_DIR_PIN,INVERT_E_DIR); - e_steps++; - WRITE(E_STEP_PIN, HIGH); - } - if (e_steps > 0) { - WRITE(E_DIR_PIN,!INVERT_E_DIR); - e_steps--; - WRITE(E_STEP_PIN, HIGH); + for(unsigned char i=0; i<4;) { + WRITE(E_STEP_PIN, LOW); + if (e_steps == 0) break; + i++; + if (e_steps < 0) { + WRITE(E_DIR_PIN,INVERT_E_DIR); + e_steps++; + WRITE(E_STEP_PIN, HIGH); + } + if (e_steps > 0) { + WRITE(E_DIR_PIN,!INVERT_E_DIR); + e_steps--; + WRITE(E_STEP_PIN, HIGH); + } } - old_OCR0A += 25; // 10kHz interrupt - OCR0A = old_OCR0A; } #endif // ADVANCE @@ -638,6 +641,10 @@ void st_init() ENABLE_STEPPER_DRIVER_INTERRUPT(); #ifdef ADVANCE + #if defined(TCCR0A) && defined(WGM01) + TCCR0A &= ~(1<