Some advance modifications
This commit is contained in:
parent
6b86f15686
commit
af22e9cd38
@ -278,8 +278,8 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
#define EXTRUDER_ADVANCE_K .3
|
#define EXTRUDER_ADVANCE_K .3
|
||||||
|
|
||||||
#define D_FILAMENT 1.7
|
#define D_FILAMENT 2.85
|
||||||
#define STEPS_MM_E 65
|
#define STEPS_MM_E 836
|
||||||
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
||||||
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
||||||
|
|
||||||
|
@ -198,7 +198,6 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
|||||||
|
|
||||||
// block->accelerate_until = accelerate_steps;
|
// block->accelerate_until = accelerate_steps;
|
||||||
// block->decelerate_after = accelerate_steps+plateau_steps;
|
// block->decelerate_after = accelerate_steps+plateau_steps;
|
||||||
|
|
||||||
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
|
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
|
||||||
if(block->busy == false) { // Don't update variables if block is busy.
|
if(block->busy == false) { // Don't update variables if block is busy.
|
||||||
block->accelerate_until = accelerate_steps;
|
block->accelerate_until = accelerate_steps;
|
||||||
@ -482,7 +481,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||||||
// Bail if this is a zero-length block
|
// Bail if this is a zero-length block
|
||||||
if (block->step_event_count <=dropsegments) { return; };
|
if (block->step_event_count <=dropsegments) { return; };
|
||||||
|
|
||||||
// Compute direction bits for this block
|
// Compute direction bits for this block
|
||||||
block->direction_bits = 0;
|
block->direction_bits = 0;
|
||||||
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
|
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
|
||||||
if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
|
if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
|
||||||
@ -722,7 +721,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||||||
else {
|
else {
|
||||||
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
||||||
float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) *
|
float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) *
|
||||||
(current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
|
(current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA)*256;
|
||||||
block->advance = advance;
|
block->advance = advance;
|
||||||
if(acc_dist == 0) {
|
if(acc_dist == 0) {
|
||||||
block->advance_rate = 0;
|
block->advance_rate = 0;
|
||||||
@ -731,6 +730,13 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||||||
block->advance_rate = advance / (float)acc_dist;
|
block->advance_rate = advance / (float)acc_dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
SERIAL_ECHO_START;
|
||||||
|
SERIAL_ECHOPGM("advance :");
|
||||||
|
SERIAL_ECHO(block->advance/256.0);
|
||||||
|
SERIAL_ECHOPGM("advance rate :");
|
||||||
|
SERIAL_ECHOLN(block->advance_rate/256.0);
|
||||||
|
*/
|
||||||
#endif // ADVANCE
|
#endif // ADVANCE
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ static long counter_x, // Counter variables for the bresenham line tracer
|
|||||||
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
|
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
|
||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
static long advance_rate, advance, final_advance = 0;
|
static long advance_rate, advance, final_advance = 0;
|
||||||
static short old_advance = 0;
|
static long old_advance = 0;
|
||||||
#endif
|
#endif
|
||||||
static short e_steps;
|
static long e_steps;
|
||||||
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
|
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
|
||||||
static long acceleration_time, deceleration_time;
|
static long acceleration_time, deceleration_time;
|
||||||
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
|
||||||
@ -253,6 +253,9 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
|||||||
#ifdef ADVANCE
|
#ifdef ADVANCE
|
||||||
advance = current_block->initial_advance;
|
advance = current_block->initial_advance;
|
||||||
final_advance = current_block->final_advance;
|
final_advance = current_block->final_advance;
|
||||||
|
// Do E steps + advance steps
|
||||||
|
e_steps += ((advance >>8) - old_advance);
|
||||||
|
old_advance = advance >>8;
|
||||||
#endif
|
#endif
|
||||||
deceleration_time = 0;
|
deceleration_time = 0;
|
||||||
// step_rate to timer interval
|
// step_rate to timer interval
|
||||||
@ -260,6 +263,17 @@ FORCE_INLINE void trapezoid_generator_reset() {
|
|||||||
acceleration_time = calc_timer(acc_step_rate);
|
acceleration_time = calc_timer(acc_step_rate);
|
||||||
OCR1A = acceleration_time;
|
OCR1A = acceleration_time;
|
||||||
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
||||||
|
|
||||||
|
// SERIAL_ECHO_START;
|
||||||
|
// SERIAL_ECHOPGM("advance :");
|
||||||
|
// SERIAL_ECHO(current_block->advance/256.0);
|
||||||
|
// SERIAL_ECHOPGM("advance rate :");
|
||||||
|
// SERIAL_ECHO(current_block->advance_rate/256.0);
|
||||||
|
// SERIAL_ECHOPGM("initial advance :");
|
||||||
|
// SERIAL_ECHO(current_block->initial_advance/256.0);
|
||||||
|
// SERIAL_ECHOPGM("final advance :");
|
||||||
|
// SERIAL_ECHOLN(current_block->final_advance/256.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||||
@ -382,6 +396,9 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
count_direction[E_AXIS]=-1;
|
count_direction[E_AXIS]=-1;
|
||||||
}
|
}
|
||||||
#endif //!ADVANCE
|
#endif //!ADVANCE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
|
for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
|
||||||
MSerial.checkRx(); // Check for serial chars.
|
MSerial.checkRx(); // Check for serial chars.
|
||||||
|
|
||||||
@ -390,19 +407,12 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
if (counter_e > 0) {
|
if (counter_e > 0) {
|
||||||
counter_e -= current_block->step_event_count;
|
counter_e -= current_block->step_event_count;
|
||||||
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
|
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
|
||||||
CRITICAL_SECTION_START;
|
|
||||||
e_steps--;
|
e_steps--;
|
||||||
CRITICAL_SECTION_END;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CRITICAL_SECTION_START;
|
|
||||||
e_steps++;
|
e_steps++;
|
||||||
CRITICAL_SECTION_END;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Do E steps + advance steps
|
|
||||||
e_steps += ((advance >> 16) - old_advance);
|
|
||||||
old_advance = advance >> 16;
|
|
||||||
#endif //ADVANCE
|
#endif //ADVANCE
|
||||||
|
|
||||||
counter_x += current_block->steps_x;
|
counter_x += current_block->steps_x;
|
||||||
@ -461,6 +471,11 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
for(int8_t i=0; i < step_loops; i++) {
|
for(int8_t i=0; i < step_loops; i++) {
|
||||||
advance += advance_rate;
|
advance += advance_rate;
|
||||||
}
|
}
|
||||||
|
//if(advance > current_block->advance) advance = current_block->advance;
|
||||||
|
// Do E steps + advance steps
|
||||||
|
e_steps += ((advance >>8) - old_advance);
|
||||||
|
old_advance = advance >>8;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (step_events_completed > current_block->decelerate_after) {
|
else if (step_events_completed > current_block->decelerate_after) {
|
||||||
@ -485,8 +500,10 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
for(int8_t i=0; i < step_loops; i++) {
|
for(int8_t i=0; i < step_loops; i++) {
|
||||||
advance -= advance_rate;
|
advance -= advance_rate;
|
||||||
}
|
}
|
||||||
if(advance < final_advance)
|
if(advance < final_advance) advance = final_advance;
|
||||||
advance = final_advance;
|
// Do E steps + advance steps
|
||||||
|
e_steps += ((advance >>8) - old_advance);
|
||||||
|
old_advance = advance >>8;
|
||||||
#endif //ADVANCE
|
#endif //ADVANCE
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -507,7 +524,7 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
// Timer 0 is shared with millies
|
// Timer 0 is shared with millies
|
||||||
ISR(TIMER0_COMPA_vect)
|
ISR(TIMER0_COMPA_vect)
|
||||||
{
|
{
|
||||||
old_OCR0A += 25; // ~10kHz interrupt
|
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
||||||
OCR0A = old_OCR0A;
|
OCR0A = old_OCR0A;
|
||||||
// Set E direction (Depends on E direction + advance)
|
// Set E direction (Depends on E direction + advance)
|
||||||
for(unsigned char i=0; i<4;) {
|
for(unsigned char i=0; i<4;) {
|
||||||
@ -519,7 +536,7 @@ ISR(TIMER1_COMPA_vect)
|
|||||||
e_steps++;
|
e_steps++;
|
||||||
WRITE(E_STEP_PIN, HIGH);
|
WRITE(E_STEP_PIN, HIGH);
|
||||||
}
|
}
|
||||||
if (e_steps > 0) {
|
else if (e_steps > 0) {
|
||||||
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
||||||
e_steps--;
|
e_steps--;
|
||||||
WRITE(E_STEP_PIN, HIGH);
|
WRITE(E_STEP_PIN, HIGH);
|
||||||
|
Loading…
Reference in New Issue
Block a user