From d22c0fbf361885a38f83814bc5ee34488edeb00c Mon Sep 17 00:00:00 2001 From: Emanuele Caruso Date: Sun, 1 May 2011 04:36:45 +0200 Subject: Added configuration parameter for delaying steps, STEP_DELAY_RATIO. This should be manually enabled in configuration.h if you are experiencing missing steps. Please be aware that enabling it may also prevent your motor from reaching the nominal speed. --- Tonokip_Firmware/Tonokip_Firmware.pde | 27 +++++++++++++++++++++++++-- Tonokip_Firmware/configuration.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'Tonokip_Firmware') diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde index 89f8ff7..607dc76 100644 --- a/Tonokip_Firmware/Tonokip_Firmware.pde +++ b/Tonokip_Firmware/Tonokip_Firmware.pde @@ -69,6 +69,9 @@ long gcode_N, gcode_LastN; bool relative_mode = false; //Determines Absolute or Relative Coordinates bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode. long timediff=0; +#ifdef STEP_DELAY_RATIO +long long_step_delay_ratio = STEP_DELAY_RATIO * 100; +#endif // comm variables @@ -908,6 +911,9 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin do_x_step(); x_steps_remaining--; error_x = error_x + delta_y; } + #ifdef STEP_DELAY_RATIO + if(timediff >= interval) delayMicroseconds(long_step_delay_ratio * interval / 10000); + #endif } } else if (steep_x) { timediff=micros() * 100 - previous_micros_x; @@ -921,6 +927,9 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin do_y_step(); y_steps_remaining--; error_y = error_y + delta_x; } + #ifdef STEP_DELAY_RATIO + if(timediff >= interval) delayMicroseconds(long_step_delay_ratio * interval / 10000); + #endif } } } @@ -930,7 +939,14 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if(Z_MIN_PIN > -1) if(!direction_z) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) break; if(Z_MAX_PIN > -1) if(direction_z) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) break; timediff=micros() * 100-previous_micros_z; - while(timediff >= z_interval && z_steps_remaining) { do_z_step(); z_steps_remaining--; timediff-=z_interval;} + while(timediff >= z_interval && z_steps_remaining) { + do_z_step(); + z_steps_remaining--; + timediff-=z_interval; + #ifdef STEP_DELAY_RATIO + if(timediff >= z_interval) delayMicroseconds(long_step_delay_ratio * z_interval / 10000); + #endif + } } //If there are e steps remaining, check if e steps must be taken @@ -943,7 +959,14 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if (final_e_steps_remaining > 0) while(e_steps_remaining > final_e_steps_remaining) { do_e_step(); e_steps_remaining--;} else if (x_steps_to_take + y_steps_to_take > 0) while(e_steps_remaining) { do_e_step(); e_steps_remaining--;} //Else, normally check if e steps must be taken - else while (timediff >= e_interval && e_steps_remaining) { do_e_step(); e_steps_remaining--; timediff-=e_interval;} + else while (timediff >= e_interval && e_steps_remaining) { + do_e_step(); + e_steps_remaining--; + timediff-=e_interval; + #ifdef STEP_DELAY_RATIO + if(timediff >= e_interval) delayMicroseconds(long_step_delay_ratio * e_interval / 10000); + #endif + } } //If more that half second is passed since previous heating check, manage it diff --git a/Tonokip_Firmware/configuration.h b/Tonokip_Firmware/configuration.h index b8e477c..019a9fd 100644 --- a/Tonokip_Firmware/configuration.h +++ b/Tonokip_Firmware/configuration.h @@ -8,6 +8,10 @@ //Comment out to disable SD support #define SDSUPPORT 1 +//Step delay over interval ratio. If you are experiencing missing steps, try to uncomment the following line, but be aware this +//may probably prevent the motors to reach the nominal speed +//#define STEP_DELAY_RATIO 0.05 + //Acceleration settings float full_velocity_units = 10; // the units between minimum and G1 move feedrate float travel_move_full_velocity_units = 10; // used for travel moves -- cgit v1.2.1