commit
98e96c9182
@ -127,8 +127,6 @@
|
||||
//END AUTOSET LOCATIONS OF LIMIT SWITCHES -ZP
|
||||
|
||||
|
||||
//#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
|
||||
|
||||
// A single Z stepper driver is usually used to drive 2 stepper motors.
|
||||
// Uncomment this define to utilize a separate stepper driver for each Z axis motor.
|
||||
// Only a few motherboards support this, like RAMPS, which have dual extruder support (the 2nd, often unused, extruder driver is used
|
||||
@ -318,7 +316,7 @@
|
||||
* K=0 means advance disabled.
|
||||
* See Marlin documentation for calibration instructions.
|
||||
*/
|
||||
//#define LIN_ADVANCE
|
||||
#define LIN_ADVANCE
|
||||
|
||||
#ifdef LIN_ADVANCE
|
||||
#define LIN_ADVANCE_K 0 //Try around 45 for PLA, around 25 for ABS.
|
||||
|
@ -120,7 +120,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
|
||||
//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
|
||||
//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
|
||||
#define DEBUG_DISABLE_STARTMSGS //no startup messages
|
||||
//#define DEBUG_DISABLE_STARTMSGS //no startup messages
|
||||
//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
|
||||
//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
|
||||
//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line
|
||||
@ -131,7 +131,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
//#define DEBUG_BLINK_ACTIVE
|
||||
//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled)
|
||||
//#define DEBUG_DISABLE_FSENSORCHECK //disable fsensor check (no ISR INT7, check disabled)
|
||||
#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
|
||||
//#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
|
||||
#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message.
|
||||
#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display.
|
||||
#endif /* DEBUG_BUILD */
|
||||
|
@ -142,11 +142,24 @@
|
||||
#define LOGIC_ANALYZER_CH6 17 // PH1 (TXD2)
|
||||
#define LOGIC_ANALYZER_CH7 76 // PJ5
|
||||
|
||||
#define LOGIC_ANALYZER_CH0_ENABLE SET_OUTPUT(LOGIC_ANALYZER_CH0)
|
||||
#define LOGIC_ANALYZER_CH1_ENABLE SET_OUTPUT(LOGIC_ANALYZER_CH1)
|
||||
#define LOGIC_ANALYZER_CH2_ENABLE SET_OUTPUT(LOGIC_ANALYZER_CH2)
|
||||
#define LOGIC_ANALYZER_CH3_ENABLE SET_OUTPUT(LOGIC_ANALYZER_CH3)
|
||||
#define LOGIC_ANALYZER_CH4_ENABLE do { DDRK |= 1 << 0; } while (0)
|
||||
#define LOGIC_ANALYZER_CH5_ENABLE do { cbi(UCSR2B, TXEN2); cbi(UCSR2B, RXEN2); cbi(UCSR2B, RXCIE2); SET_OUTPUT(LOGIC_ANALYZER_CH5); } while (0)
|
||||
#define LOGIC_ANALYZER_CH6_ENABLE do { cbi(UCSR2B, TXEN2); cbi(UCSR2B, RXEN2); cbi(UCSR2B, RXCIE2); SET_OUTPUT(LOGIC_ANALYZER_CH6); } while (0)
|
||||
#define LOGIC_ANALYZER_CH7_ENABLE SET_OUTPUT(LOGIC_ANALYZER_CH7)
|
||||
#define LOGIC_ANALYZER_CH0_ENABLE do { SET_OUTPUT(LOGIC_ANALYZER_CH0); WRITE(LOGIC_ANALYZER_CH0, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH1_ENABLE do { SET_OUTPUT(LOGIC_ANALYZER_CH1); WRITE(LOGIC_ANALYZER_CH1, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH2_ENABLE do { SET_OUTPUT(LOGIC_ANALYZER_CH2); WRITE(LOGIC_ANALYZER_CH2, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH3_ENABLE do { SET_OUTPUT(LOGIC_ANALYZER_CH3); WRITE(LOGIC_ANALYZER_CH3, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH4_ENABLE do { DDRK |= 1 << 0; WRITE_LOGIC_ANALYZER_CH4(false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH5_ENABLE do { cbi(UCSR2B, TXEN2); cbi(UCSR2B, RXEN2); cbi(UCSR2B, RXCIE2); SET_OUTPUT(LOGIC_ANALYZER_CH5); WRITE(LOGIC_ANALYZER_CH5, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH6_ENABLE do { cbi(UCSR2B, TXEN2); cbi(UCSR2B, RXEN2); cbi(UCSR2B, RXCIE2); SET_OUTPUT(LOGIC_ANALYZER_CH6); WRITE(LOGIC_ANALYZER_CH6, false); } while (0)
|
||||
#define LOGIC_ANALYZER_CH7_ENABLE do { SET_OUTPUT(LOGIC_ANALYZER_CH7); WRITE(LOGIC_ANALYZER_CH7, false); } while (0)
|
||||
|
||||
// Async output on channel 5 of the logical analyzer.
|
||||
// Baud rate 2MBit, 9 bits, 1 stop bit.
|
||||
#define LOGIC_ANALYZER_SERIAL_TX_ENABLE do { UBRR2H = 0; UBRR2L = 0; UCSR2B = (1 << TXEN2) | (1 << UCSZ02); UCSR2C = 0x06; } while (0)
|
||||
// Non-checked (quicker) variant. Use it if you are sure that the transmit buffer is already empty.
|
||||
#define LOGIC_ANALYZER_SERIAL_TX_WRITE_NC(C) do { if (C & 0x100) UCSR2B |= 1; else UCSR2B &= ~1; UDR2 = C; } while (0)
|
||||
#define LOGIC_ANALYZER_SERIAL_TX_WRITE(C) do { \
|
||||
/* Wait for empty transmit buffer */ \
|
||||
while (!(UCSR2A & (1<<UDRE2))); \
|
||||
/* Put data into buffer, sends the data */ \
|
||||
LOGIC_ANALYZER_SERIAL_TX_WRITE_NC(C); \
|
||||
} while (0)
|
||||
|
||||
|
@ -182,12 +182,16 @@ FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, f
|
||||
}
|
||||
}
|
||||
|
||||
// Minimum stepper rate 120Hz.
|
||||
#define MINIMAL_STEP_RATE 120
|
||||
|
||||
// Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
|
||||
void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit_speed)
|
||||
{
|
||||
// These two lines are the only floating point calculations performed in this routine.
|
||||
// initial_rate, final_rate in Hz.
|
||||
// Minimum stepper rate 120Hz, maximum 40kHz. If the stepper rate goes above 10kHz,
|
||||
// the stepper interrupt routine groups the pulses by 2 or 4 pulses per interrupt tick.
|
||||
uint32_t initial_rate = ceil(entry_speed * block->speed_factor); // (step/min)
|
||||
uint32_t final_rate = ceil(exit_speed * block->speed_factor); // (step/min)
|
||||
|
||||
@ -223,8 +227,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||
// Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will
|
||||
// have to use intersection_distance() to calculate when to abort acceleration and start braking
|
||||
// in order to reach the final_rate exactly at the end of this block.
|
||||
if (accel_decel_steps < block->step_event_count) {
|
||||
plateau_steps = block->step_event_count - accel_decel_steps;
|
||||
if (accel_decel_steps < block->step_event_count.wide) {
|
||||
plateau_steps = block->step_event_count.wide - accel_decel_steps;
|
||||
} else {
|
||||
uint32_t acceleration_x4 = acceleration << 2;
|
||||
// Avoid negative numbers
|
||||
@ -236,26 +240,26 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
|
||||
accelerate_steps = (block->step_event_count >> 1) + (final_rate_sqr - initial_rate_sqr + acceleration_x4 - 1 + (block->step_event_count & 1) * acceleration_x2) / acceleration_x4;
|
||||
#else
|
||||
accelerate_steps = final_rate_sqr - initial_rate_sqr + acceleration_x4 - 1;
|
||||
if (block->step_event_count & 1)
|
||||
if (block->step_event_count.wide & 1)
|
||||
accelerate_steps += acceleration_x2;
|
||||
accelerate_steps /= acceleration_x4;
|
||||
accelerate_steps += (block->step_event_count >> 1);
|
||||
accelerate_steps += (block->step_event_count.wide >> 1);
|
||||
#endif
|
||||
if (accelerate_steps > block->step_event_count)
|
||||
accelerate_steps = block->step_event_count;
|
||||
if (accelerate_steps > block->step_event_count.wide)
|
||||
accelerate_steps = block->step_event_count.wide;
|
||||
} else {
|
||||
#if 0
|
||||
decelerate_steps = (block->step_event_count >> 1) + (initial_rate_sqr - final_rate_sqr + (block->step_event_count & 1) * acceleration_x2) / acceleration_x4;
|
||||
#else
|
||||
decelerate_steps = initial_rate_sqr - final_rate_sqr;
|
||||
if (block->step_event_count & 1)
|
||||
if (block->step_event_count.wide & 1)
|
||||
decelerate_steps += acceleration_x2;
|
||||
decelerate_steps /= acceleration_x4;
|
||||
decelerate_steps += (block->step_event_count >> 1);
|
||||
decelerate_steps += (block->step_event_count.wide >> 1);
|
||||
#endif
|
||||
if (decelerate_steps > block->step_event_count)
|
||||
decelerate_steps = block->step_event_count;
|
||||
accelerate_steps = block->step_event_count - decelerate_steps;
|
||||
if (decelerate_steps > block->step_event_count.wide)
|
||||
decelerate_steps = block->step_event_count.wide;
|
||||
accelerate_steps = block->step_event_count.wide - decelerate_steps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -449,10 +453,10 @@ void getHighESpeed()
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
if((block_buffer[block_index].steps_x != 0) ||
|
||||
(block_buffer[block_index].steps_y != 0) ||
|
||||
(block_buffer[block_index].steps_z != 0)) {
|
||||
float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
|
||||
if((block_buffer[block_index].steps_x.wide != 0) ||
|
||||
(block_buffer[block_index].steps_y.wide != 0) ||
|
||||
(block_buffer[block_index].steps_z.wide != 0)) {
|
||||
float se=(float(block_buffer[block_index].steps_e.wide)/float(block_buffer[block_index].step_event_count.wide))*block_buffer[block_index].nominal_speed;
|
||||
//se; mm/sec;
|
||||
if(se>high)
|
||||
{
|
||||
@ -493,10 +497,10 @@ void check_axes_activity()
|
||||
while(block_index != block_buffer_head)
|
||||
{
|
||||
block = &block_buffer[block_index];
|
||||
if(block->steps_x != 0) x_active++;
|
||||
if(block->steps_y != 0) y_active++;
|
||||
if(block->steps_z != 0) z_active++;
|
||||
if(block->steps_e != 0) e_active++;
|
||||
if(block->steps_x.wide != 0) x_active++;
|
||||
if(block->steps_y.wide != 0) y_active++;
|
||||
if(block->steps_z.wide != 0) z_active++;
|
||||
if(block->steps_e.wide != 0) e_active++;
|
||||
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
@ -768,20 +772,20 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
|
||||
// Number of steps for each axis
|
||||
#ifndef COREXY
|
||||
// default non-h-bot planning
|
||||
block->steps_x = labs(target[X_AXIS]-position[X_AXIS]);
|
||||
block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]);
|
||||
block->steps_x.wide = labs(target[X_AXIS]-position[X_AXIS]);
|
||||
block->steps_y.wide = labs(target[Y_AXIS]-position[Y_AXIS]);
|
||||
#else
|
||||
// corexy planning
|
||||
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
||||
block->steps_x = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]));
|
||||
block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]));
|
||||
block->steps_x.wide = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]));
|
||||
block->steps_y.wide = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]));
|
||||
#endif
|
||||
block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
|
||||
block->steps_e = labs(target[E_AXIS]-position[E_AXIS]);
|
||||
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
|
||||
block->steps_z.wide = labs(target[Z_AXIS]-position[Z_AXIS]);
|
||||
block->steps_e.wide = labs(target[E_AXIS]-position[E_AXIS]);
|
||||
block->step_event_count.wide = max(block->steps_x.wide, max(block->steps_y.wide, max(block->steps_z.wide, block->steps_e.wide)));
|
||||
|
||||
// Bail if this is a zero-length block
|
||||
if (block->step_event_count <= dropsegments)
|
||||
if (block->step_event_count.wide <= dropsegments)
|
||||
{
|
||||
#ifdef PLANNER_DIAGNOSTICS
|
||||
planner_update_queue_min_counter();
|
||||
@ -825,21 +829,19 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
|
||||
|
||||
//enable active axes
|
||||
#ifdef COREXY
|
||||
if((block->steps_x != 0) || (block->steps_y != 0))
|
||||
if((block->steps_x.wide != 0) || (block->steps_y.wide != 0))
|
||||
{
|
||||
enable_x();
|
||||
enable_y();
|
||||
}
|
||||
#else
|
||||
if(block->steps_x != 0) enable_x();
|
||||
if(block->steps_y != 0) enable_y();
|
||||
if(block->steps_x.wide != 0) enable_x();
|
||||
if(block->steps_y.wide != 0) enable_y();
|
||||
#endif
|
||||
#ifndef Z_LATE_ENABLE
|
||||
if(block->steps_z != 0) enable_z();
|
||||
#endif
|
||||
if(block->steps_z.wide != 0) enable_z();
|
||||
|
||||
// Enable extruder(s)
|
||||
if(block->steps_e != 0)
|
||||
if(block->steps_e.wide != 0)
|
||||
{
|
||||
if (DISABLE_INACTIVE_EXTRUDER) //enable only selected extruder
|
||||
{
|
||||
@ -881,7 +883,7 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
|
||||
}
|
||||
}
|
||||
|
||||
if (block->steps_e == 0)
|
||||
if (block->steps_e.wide == 0)
|
||||
{
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
}
|
||||
@ -910,7 +912,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
#endif
|
||||
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
|
||||
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
|
||||
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
|
||||
if ( block->steps_x.wide <=dropsegments && block->steps_y.wide <=dropsegments && block->steps_z.wide <=dropsegments )
|
||||
{
|
||||
block->millimeters = fabs(delta_mm[E_AXIS]);
|
||||
}
|
||||
@ -943,7 +945,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
#endif // SLOWDOWN
|
||||
|
||||
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
||||
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
||||
block->nominal_rate = ceil(block->step_event_count.wide * inverse_second); // (step/sec) Always > 0
|
||||
|
||||
// Calculate and limit speed in mm/sec for each axis
|
||||
float current_speed[4];
|
||||
@ -988,8 +990,8 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
// Compute and limit the acceleration rate for the trapezoid generator.
|
||||
// block->step_event_count ... event count of the fastest axis
|
||||
// block->millimeters ... Euclidian length of the XYZ movement or the E length, if no XYZ movement.
|
||||
float steps_per_mm = block->step_event_count/block->millimeters;
|
||||
if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)
|
||||
float steps_per_mm = block->step_event_count.wide/block->millimeters;
|
||||
if(block->steps_x.wide == 0 && block->steps_y.wide == 0 && block->steps_z.wide == 0)
|
||||
{
|
||||
block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
|
||||
}
|
||||
@ -1000,48 +1002,48 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
#ifdef SIMPLE_ACCEL_LIMIT // in some cases can be acceleration limited inproperly
|
||||
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||
{
|
||||
if (block->steps_x || block->steps_y)
|
||||
if (block->steps_x.wide || block->steps_y.wide)
|
||||
if (block->acceleration_st > SILENT_MAX_ACCEL_ST) block->acceleration_st = SILENT_MAX_ACCEL_ST;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (block->steps_x || block->steps_y)
|
||||
if (block->steps_x.wide || block->steps_y.wide)
|
||||
if (block->acceleration_st > NORMAL_MAX_ACCEL_ST) block->acceleration_st = NORMAL_MAX_ACCEL_ST;
|
||||
}
|
||||
if (block->steps_x && (block->acceleration_st > axis_steps_per_sqr_second[X_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
|
||||
if (block->steps_y && (block->acceleration_st > axis_steps_per_sqr_second[Y_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
|
||||
if (block->steps_z && (block->acceleration_st > axis_steps_per_sqr_second[Z_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
|
||||
if (block->steps_e && (block->acceleration_st > axis_steps_per_sqr_second[E_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
|
||||
if (block->steps_x.wide && (block->acceleration_st > axis_steps_per_sqr_second[X_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
|
||||
if (block->steps_y.wide && (block->acceleration_st > axis_steps_per_sqr_second[Y_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
|
||||
if (block->steps_z.wide && (block->acceleration_st > axis_steps_per_sqr_second[Z_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
|
||||
if (block->steps_e.wide && (block->acceleration_st > axis_steps_per_sqr_second[E_AXIS])) block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
|
||||
#else // SIMPLE_ACCEL_LIMIT
|
||||
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||
{
|
||||
if ((block->steps_x > block->step_event_count / 2) || (block->steps_y > block->step_event_count / 2))
|
||||
if ((block->steps_x.wide > block->step_event_count.wide / 2) || (block->steps_y.wide > block->step_event_count.wide / 2))
|
||||
if (block->acceleration_st > SILENT_MAX_ACCEL_ST) block->acceleration_st = SILENT_MAX_ACCEL_ST;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((block->steps_x > block->step_event_count / 2) || (block->steps_y > block->step_event_count / 2))
|
||||
if ((block->steps_x.wide > block->step_event_count.wide / 2) || (block->steps_y.wide > block->step_event_count.wide / 2))
|
||||
if (block->acceleration_st > NORMAL_MAX_ACCEL_ST) block->acceleration_st = NORMAL_MAX_ACCEL_ST;
|
||||
}
|
||||
if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Z_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
|
||||
#endif // SIMPLE_ACCEL_LIMIT
|
||||
#else //TMC2130
|
||||
// Limit acceleration per axis
|
||||
//FIXME Vojtech: One shall rather limit a projection of the acceleration vector instead of using the limit.
|
||||
if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_x.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[X_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_y.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[Y_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_e.wide / (float)block->step_event_count.wide) > axis_steps_per_sqr_second[E_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
|
||||
if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
|
||||
if(((float)block->acceleration_st * (float)block->steps_z.wide / (float)block->step_event_count.wide ) > axis_steps_per_sqr_second[Z_AXIS])
|
||||
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
|
||||
#endif //TMC2130
|
||||
}
|
||||
@ -1199,10 +1201,10 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
// The math is good, but we must avoid retract moves with advance!
|
||||
// de_float > 0.0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
|
||||
//
|
||||
block->use_advance_lead = block->steps_e
|
||||
&& (block->steps_x || block->steps_y)
|
||||
block->use_advance_lead = block->steps_e.wide
|
||||
&& (block->steps_x.wide || block->steps_y.wide)
|
||||
&& extruder_advance_k
|
||||
&& (uint32_t)block->steps_e != block->step_event_count
|
||||
&& (uint32_t)block->steps_e.wide != block->step_event_count.wide
|
||||
&& de_float > 0.0;
|
||||
if (block->use_advance_lead)
|
||||
block->abs_adv_steps_multiplier8 = lround(
|
||||
@ -1217,6 +1219,9 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
block->speed_factor = block->nominal_rate / block->nominal_speed;
|
||||
calculate_trapezoid_for_block(block, block->entry_speed, safe_speed);
|
||||
|
||||
if (block->step_event_count.wide <= 32767)
|
||||
block->flag |= BLOCK_FLAG_DDA_LOWRES;
|
||||
|
||||
// Move the buffer head. From now the block may be picked up by the stepper interrupt controller.
|
||||
block_buffer_head = next_buffer_head;
|
||||
|
||||
|
@ -40,6 +40,28 @@ enum BlockFlag {
|
||||
// If set, the machine will start from a halt at the start of this block,
|
||||
// respecting the maximum allowed jerk.
|
||||
BLOCK_FLAG_START_FROM_FULL_HALT = 4,
|
||||
// If set, the stepper interrupt expects, that the number of steps to tick will be lower
|
||||
// than 32767, therefore the DDA algorithm may run with 16bit resolution only.
|
||||
// In addition, the stepper routine will not do any end stop checking for higher performance.
|
||||
BLOCK_FLAG_DDA_LOWRES = 8,
|
||||
};
|
||||
|
||||
union dda_isteps_t
|
||||
{
|
||||
int32_t wide;
|
||||
struct {
|
||||
int16_t lo;
|
||||
int16_t hi;
|
||||
};
|
||||
};
|
||||
|
||||
union dda_usteps_t
|
||||
{
|
||||
uint32_t wide;
|
||||
struct {
|
||||
uint16_t lo;
|
||||
uint16_t hi;
|
||||
};
|
||||
};
|
||||
|
||||
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
|
||||
@ -47,8 +69,8 @@ enum BlockFlag {
|
||||
typedef struct {
|
||||
// Fields used by the bresenham algorithm for tracing the line
|
||||
// steps_x.y,z, step_event_count, acceleration_rate, direction_bits and active_extruder are set by plan_buffer_line().
|
||||
long steps_x, steps_y, steps_z, steps_e; // Step count along each axis
|
||||
unsigned long step_event_count; // The number of step events required to complete this block
|
||||
dda_isteps_t steps_x, steps_y, steps_z, steps_e; // Step count along each axis
|
||||
dda_usteps_t step_event_count; // The number of step events required to complete this block
|
||||
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
|
||||
@ -72,7 +94,7 @@ typedef struct {
|
||||
float acceleration;
|
||||
|
||||
// Bit flags defined by the BlockFlag enum.
|
||||
bool flag;
|
||||
uint8_t flag;
|
||||
|
||||
// Settings for the trapezoid generator (runs inside an interrupt handler).
|
||||
// Changing the following values in the planner needs to be synchronized with the interrupt handler by disabling the interrupts.
|
||||
|
1098
Firmware/stepper.cpp
1098
Firmware/stepper.cpp
File diff suppressed because it is too large
Load Diff
@ -26,20 +26,6 @@
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
|
||||
#if EXTRUDERS > 2
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
|
||||
#elif EXTRUDERS > 1
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
|
||||
#else
|
||||
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
|
||||
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
|
||||
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
|
||||
#endif
|
||||
|
||||
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
||||
extern bool abort_on_endstop_hit;
|
||||
#endif
|
||||
|
@ -5422,14 +5422,21 @@ void stack_error() {
|
||||
|
||||
#ifdef DEBUG_STEPPER_TIMER_MISSED
|
||||
bool stepper_timer_overflow_state = false;
|
||||
uint16_t stepper_timer_overflow_max = 0;
|
||||
uint16_t stepper_timer_overflow_last = 0;
|
||||
uint16_t stepper_timer_overflow_cnt = 0;
|
||||
void stepper_timer_overflow() {
|
||||
SET_OUTPUT(BEEPER);
|
||||
WRITE(BEEPER, HIGH);
|
||||
delay(1000);
|
||||
char msg[28];
|
||||
sprintf_P(msg, PSTR("#%d %d max %d"), ++ stepper_timer_overflow_cnt, stepper_timer_overflow_last >> 1, stepper_timer_overflow_max >> 1);
|
||||
lcd_setstatus(msg);
|
||||
stepper_timer_overflow_state = false;
|
||||
if (stepper_timer_overflow_last > stepper_timer_overflow_max)
|
||||
stepper_timer_overflow_max = stepper_timer_overflow_last;
|
||||
SERIAL_ECHOPGM("Stepper timer overflow: ");
|
||||
MYSERIAL.print(msg);
|
||||
SERIAL_ECHOLNPGM("");
|
||||
|
||||
WRITE(BEEPER, LOW);
|
||||
lcd_display_message_fullscreen_P(MSG_STEPPER_TIMER_OVERFLOW_ERROR);
|
||||
//err_triggered = 1;
|
||||
while (1) delay_keep_alive(1000);
|
||||
}
|
||||
#endif /* DEBUG_STEPPER_TIMER_MISSED */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user