Revert "merging with upstream"

This reverts commit cdb4cb7864.
This commit is contained in:
PavelSindler 2017-08-15 16:27:55 +02:00
parent cdb4cb7864
commit 8685c428a6
13 changed files with 12441 additions and 12961 deletions

View File

@ -173,10 +173,6 @@
//if PREVENT_DANGEROUS_EXTRUDE is on, you can still disable (uncomment) very long bits of extrusion separately.
#define PREVENT_LENGTHY_EXTRUDE
#ifdef DEBUG_DISABLE_PREVENT_EXTRUDER
#undef PREVENT_DANGEROUS_EXTRUDE
#undef PREVENT_LENGTHY_EXTRUDE
#endif //DEBUG_DISABLE_PREVENT_EXTRUDER
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
@ -286,13 +282,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1
#ifdef DEBUG_DISABLE_SWLIMITS
#define min_software_endstops false
#define max_software_endstops false
#else
#define min_software_endstops true // If true, axis won't move to coordinates less than HOME_POS.
#define max_software_endstops true // If true, axis won't move to coordinates greater than the defined lengths below.
#endif //DEBUG_DISABLE_SWLIMITS
#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)

View File

@ -68,11 +68,7 @@
// When first starting the main fan, run it at full speed for the
// given number of milliseconds. This gets the fan spinning reliably
// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
// RP: new implementation - long pulse at 100% when starting, short pulse
#define FAN_KICK_START_TIME 800 //when starting from zero (long kick time)
#define FAN_KICK_RUN_MINPWM 25 //PWM treshold for short kicks
#define FAN_KICK_IDLE_TIME 4000 //delay between short kicks
#define FAN_KICK_RUN_TIME 50 //short kick time
#define FAN_KICKSTART_TIME 1000
@ -316,45 +312,24 @@
#endif
#endif
/**
* Implementation of linear pressure control
*
* Assumption: advance = k * (delta velocity)
* K=0 means advance disabled.
* See Marlin documentation for calibration instructions.
*/
//#define LIN_ADVANCE
// extruder advance constant (s2/mm3)
//
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2
//
// Hooke's law says: force = k * distance
// Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant
// so: v ^ 2 is proportional to number of steps we advance the extruder
//#define ADVANCE
#ifdef LIN_ADVANCE
#define LIN_ADVANCE_K 0 //Try around 45 for PLA, around 25 for ABS.
#ifdef ADVANCE
#define EXTRUDER_ADVANCE_K .006
/**
* Some Slicers produce Gcode with randomly jumping extrusion widths occasionally.
* For example within a 0.4mm perimeter it may produce a single segment of 0.05mm width.
* While this is harmless for normal printing (the fluid nature of the filament will
* close this very, very tiny gap), it throws off the LIN_ADVANCE pressure adaption.
*
* For this case LIN_ADVANCE_E_D_RATIO can be used to set the extrusion:distance ratio
* to a fixed value. Note that using a fixed ratio will lead to wrong nozzle pressures
* if the slicer is using variable widths or layer heights within one print!
*
* This option sets the default E:D ratio at startup. Use `M900` to override this value.
*
* Example: `M900 W0.4 H0.2 D1.75`, where:
* - W is the extrusion width in mm
* - H is the layer height in mm
* - D is the filament diameter in mm
*
* Example: `M900 R0.0458` to set the ratio directly.
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
// Example: 0.4 * 0.2 / ((1.75 / 2) ^ 2 * PI) = 0.033260135
#endif
#define D_FILAMENT 1.75
#define STEPS_MM_E 174.6
#define EXTRUSION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUSION_AREA)
#endif // ADVANCE
// Arc interpretation settings:
#define MM_PER_ARC_SEGMENT 1

View File

@ -96,7 +96,6 @@ void serial_echopair_P(const char *s_P, float v);
void serial_echopair_P(const char *s_P, double v);
void serial_echopair_P(const char *s_P, unsigned long v);
extern int selectedSerialPort;
//Things to write to serial from Program memory. Saves 400 to 2k of RAM.
FORCE_INLINE void serialprintPGM(const char *str)
@ -350,4 +349,4 @@ float temp_comp_interpolation(float temperature);
void temp_compensation_apply();
void temp_compensation_start();
void wait_for_heater(long codenum);
void serialecho_temperatures();
void serialecho_temperatures();

View File

@ -64,23 +64,6 @@ FORCE_INLINE void store_char(unsigned char c)
store_char(c);
}
}
SIGNAL(USART2_RX_vect)
{
if (selectedSerialPort == 1) {
// Test for a framing error.
if (UCSR2A & (1<<FE2)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = UDR2;
} else {
// Read the input register.
unsigned char c = UDR2;
store_char(c);
}
}
}
#endif
// Constructors ////////////////////////////////////////////////////////////////
@ -105,7 +88,7 @@ void MarlinSerial::begin(long baud)
useU2X = false;
}
#endif
// set up the first (original serial port)
if (useU2X) {
M_UCSRxA = 1 << M_U2Xx;
baud_setting = (F_CPU / 4 / baud - 1) / 2;
@ -121,35 +104,13 @@ void MarlinSerial::begin(long baud)
sbi(M_UCSRxB, M_RXENx);
sbi(M_UCSRxB, M_TXENx);
sbi(M_UCSRxB, M_RXCIEx);
// set up the second serial port
if (useU2X) {
UCSR2A = 1 << U2X2;
baud_setting = (F_CPU / 4 / baud - 1) / 2;
} else {
UCSR2A = 0;
baud_setting = (F_CPU / 8 / baud - 1) / 2;
}
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
UBRR2H = baud_setting >> 8;
UBRR2L = baud_setting;
sbi(UCSR2B, RXEN2);
sbi(UCSR2B, TXEN2);
sbi(UCSR2B, RXCIE2);
}
void MarlinSerial::end()
{
cbi(M_UCSRxB, M_RXENx);
cbi(M_UCSRxB, M_TXENx);
cbi(M_UCSRxB, M_RXCIEx);
cbi(UCSR2B, RXEN2);
cbi(UCSR2B, TXEN2);
cbi(UCSR2B, RXCIE2);
cbi(M_UCSRxB, M_RXCIEx);
}

View File

@ -73,7 +73,6 @@
// is the index of the location from which to read.
#define RX_BUFFER_SIZE 128
extern int selectedSerialPort;
struct ring_buffer
{
@ -111,48 +110,24 @@ class MarlinSerial //: public Stream
}
void checkRx(void)
FORCE_INLINE void checkRx(void)
{
if (selectedSerialPort == 0) {
if((M_UCSRxA & (1<<M_RXCx)) != 0) {
// Test for a framing error.
if (M_UCSRxA & (1<<M_FEx)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = M_UDRx;
} else {
unsigned char c = M_UDRx;
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer.tail) {
rx_buffer.buffer[rx_buffer.head] = c;
rx_buffer.head = i;
}
selectedSerialPort = 0;
}
}
} else if(selectedSerialPort == 1) {
if((UCSR2A & (1<<RXC2)) != 0) {
// Test for a framing error.
if (UCSR2A & (1<<FE2)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = UDR2;
} else {
unsigned char c = UDR2;
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer.tail) {
rx_buffer.buffer[rx_buffer.head] = c;
rx_buffer.head = i;
}
selectedSerialPort = 1;
if((M_UCSRxA & (1<<M_RXCx)) != 0) {
// Test for a framing error.
if (M_UCSRxA & (1<<M_FEx)) {
// Characters received with the framing errors will be ignored.
// The temporary variable "c" was made volatile, so the compiler does not optimize this out.
volatile unsigned char c = M_UDRx;
} else {
unsigned char c = M_UDRx;
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != rx_buffer.tail) {
rx_buffer.buffer[rx_buffer.head] = c;
rx_buffer.head = i;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -126,12 +126,6 @@ float extrude_min_temp=EXTRUDE_MINTEMP;
static char meas_sample; //temporary variable to hold filament measurement sample
#endif
#ifdef LIN_ADVANCE
float extruder_advance_k = LIN_ADVANCE_K,
advance_ed_ratio = LIN_ADVANCE_E_D_RATIO,
position_float[NUM_AXIS] = { 0 };
#endif
// Returns the index of the next block in the ring buffer
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
static inline int8_t next_block_index(int8_t block_index) {
@ -417,9 +411,6 @@ void plan_init() {
block_buffer_head = 0;
block_buffer_tail = 0;
memset(position, 0, sizeof(position)); // clear position
#ifdef LIN_ADVANCE
memset(position_float, 0, sizeof(position)); // clear position
#endif
previous_speed[0] = 0.0;
previous_speed[1] = 0.0;
previous_speed[2] = 0.0;
@ -506,53 +497,25 @@ void check_axes_activity()
disable_e2();
}
#if defined(FAN_PIN) && FAN_PIN > -1
#ifdef FAN_KICK_START_TIME
static bool fan_kick = false;
static unsigned long fan_kick_timer = 0;
static unsigned char prev_fan_speed = 0;
if (tail_fan_speed)
{
if (prev_fan_speed != tail_fan_speed)
{ //speed changed
if (prev_fan_speed == 0) //prev speed == 0 (starting - long kick)
fan_kick_timer = millis() + FAN_KICK_START_TIME;
else if (tail_fan_speed <= FAN_KICK_RUN_MINPWM) //speed <= max kick speed (short kick)
fan_kick_timer = millis() + FAN_KICK_RUN_TIME;
else //speed > max kick speed (no kick)
fan_kick_timer = 0;
prev_fan_speed = tail_fan_speed; //store previous value
if (fan_kick_timer)
fan_kick = true;
}
else
{
if (fan_kick)
{
if (fan_kick_timer < millis())
{
fan_kick = false;
if (tail_fan_speed <= FAN_KICK_RUN_MINPWM)
fan_kick_timer = millis() + FAN_KICK_IDLE_TIME;
}
}
else if (tail_fan_speed <= FAN_KICK_RUN_MINPWM)
{
if (fan_kick_timer < millis())
{
fan_kick_timer = millis() + FAN_KICK_RUN_TIME;
fan_kick = true;
}
}
}
if (fan_kick)
tail_fan_speed = 255;
}
#endif//FAN_KICKSTART_TIME
#ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = tail_fan_speed;
#else
analogWrite(FAN_PIN,tail_fan_speed);
#endif//!FAN_SOFT_PWM
#ifdef FAN_KICKSTART_TIME
static unsigned long fan_kick_end;
if (tail_fan_speed) {
if (fan_kick_end == 0) {
// Just starting up fan - run at full power.
fan_kick_end = millis() + FAN_KICKSTART_TIME;
tail_fan_speed = 255;
} else if (fan_kick_end > millis())
// Fan still spinning up.
tail_fan_speed = 255;
} else {
fan_kick_end = 0;
}
#endif//FAN_KICKSTART_TIME
#ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = tail_fan_speed;
#else
analogWrite(FAN_PIN,tail_fan_speed);
#endif//!FAN_SOFT_PWM
#endif//FAN_PIN > -1
#ifdef AUTOTEMP
getHighESpeed();
@ -713,22 +676,12 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
#endif // ENABLE_MESH_BED_LEVELING
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
#ifdef LIN_ADVANCE
const float mm_D_float = sqrt(sq(x - position_float[X_AXIS]) + sq(y - position_float[Y_AXIS]));
float de_float = e - position_float[E_AXIS];
#endif
#ifdef PREVENT_DANGEROUS_EXTRUDE
if(target[E_AXIS]!=position[E_AXIS])
{
if(degHotend(active_extruder)<extrude_min_temp)
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
#ifdef LIN_ADVANCE
position_float[E_AXIS] = e;
de_float = 0;
#endif
SERIAL_ECHO_START;
SERIAL_ECHOLNRPGM(MSG_ERR_COLD_EXTRUDE_STOP);
}
@ -737,10 +690,6 @@ void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
#ifdef LIN_ADVANCE
position_float[E_AXIS] = e;
de_float = 0;
#endif
SERIAL_ECHO_START;
SERIAL_ECHOLNRPGM(MSG_ERR_LONG_EXTRUDE_STOP);
}
@ -1162,38 +1111,7 @@ Having the real displacement of the head, we can calculate the total movement le
memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[]
previous_nominal_speed = block->nominal_speed;
previous_safe_speed = safe_speed;
#ifdef LIN_ADVANCE
//
// Use LIN_ADVANCE for blocks if all these are true:
//
// esteps : We have E steps todo (a printing move)
//
// block->steps[X_AXIS] || block->steps[Y_AXIS] : We have a movement in XY direction (i.e., not retract / prime).
//
// extruder_advance_k : There is an advance factor set.
//
// block->steps[E_AXIS] != block->step_event_count : A problem occurs if the move before a retract is too small.
// In that case, the retract and move will be executed together.
// This leads to too many advance steps due to a huge e_acceleration.
// 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)
&& extruder_advance_k
&& (uint32_t)block->steps_e != block->step_event_count
&& de_float > 0.0;
if (block->use_advance_lead)
block->abs_adv_steps_multiplier8 = lround(
extruder_advance_k
* ((advance_ed_ratio < 0.000001) ? de_float / mm_D_float : advance_ed_ratio) // Use the fixed ratio, if set
* (block->nominal_speed / (float)block->nominal_rate)
* axis_steps_per_unit[E_AXIS] * 256.0
);
#endif
// Precalculate the division, so when all the trapezoids in the planner queue get recalculated, the division is not repeated.
block->speed_factor = block->nominal_rate / block->nominal_speed;
calculate_trapezoid_for_block(block, block->entry_speed, safe_speed);
@ -1203,12 +1121,6 @@ Having the real displacement of the head, we can calculate the total movement le
// Update position
memcpy(position, target, sizeof(target)); // position[] = target[]
#ifdef LIN_ADVANCE
position_float[X_AXIS] = x;
position_float[Y_AXIS] = y;
position_float[Z_AXIS] = z;
position_float[E_AXIS] = e;
#endif
// Recalculate the trapezoids to maximize speed at the segment transitions while respecting
// the machine limits (maximum acceleration and maximum jerk).
@ -1266,13 +1178,7 @@ void plan_set_position(float x, float y, float z, const float &e)
#else
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
#endif // ENABLE_MESH_BED_LEVELING
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
#ifdef LIN_ADVANCE
position_float[X_AXIS] = x;
position_float[Y_AXIS] = y;
position_float[Z_AXIS] = z;
position_float[E_AXIS] = e;
#endif
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
previous_speed[0] = 0.0;
@ -1320,4 +1226,4 @@ void planner_queue_min_reset()
{
g_cntr_planner_queue_min = moves_planned();
}
#endif /* PLANNER_DIAGNOSTICS */
#endif /* PLANNER_DIAGNOSTICS */

View File

@ -88,17 +88,8 @@ typedef struct {
// Pre-calculated division for the calculate_trapezoid_for_block() routine to run faster.
float speed_factor;
#ifdef LIN_ADVANCE
bool use_advance_lead;
unsigned long abs_adv_steps_multiplier8; // Factorised by 2^8 to avoid float
#endif
} block_t;
#ifdef LIN_ADVANCE
extern float extruder_advance_k, advance_ed_ratio;
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level
extern matrix_3x3 plan_bed_level_matrix;

View File

@ -88,26 +88,6 @@ int8_t SilentMode;
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
#ifdef LIN_ADVANCE
uint16_t ADV_NEVER = 65535;
static uint16_t nextMainISR = 0;
static uint16_t nextAdvanceISR = ADV_NEVER;
static uint16_t eISR_Rate = ADV_NEVER;
static volatile int e_steps; //Extrusion steps to be executed by the stepper
static int final_estep_rate; //Speed of extruder at cruising speed
static int current_estep_rate; //The current speed of the extruder
static int current_adv_steps; //The current pretension of filament expressed in steps
#define ADV_RATE(T, L) (e_steps ? (T) * (L) / abs(e_steps) : ADV_NEVER)
#define _NEXT_ISR(T) nextMainISR = T
#else
#define _NEXT_ISR(T) OCR1A = T
#endif
//===========================================================================
//=============================functions ============================
//===========================================================================
@ -328,27 +308,24 @@ FORCE_INLINE void trapezoid_generator_reset() {
step_loops_nominal = step_loops;
acc_step_rate = current_block->initial_rate;
acceleration_time = calc_timer(acc_step_rate);
_NEXT_ISR(acceleration_time);
#ifdef LIN_ADVANCE
if (current_block->use_advance_lead) {
current_estep_rate = ((unsigned long)acc_step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
final_estep_rate = (current_block->nominal_rate * current_block->abs_adv_steps_multiplier8) >> 17;
}
#endif
OCR1A = acceleration_time;
// 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.
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
ISR(TIMER1_COMPA_vect) {
#ifdef LIN_ADVANCE
advance_isr_scheduler();
#else
isr();
#endif
}
void isr() {
ISR(TIMER1_COMPA_vect)
{
// If there is no current block, attempt to pop one from the buffer
if (current_block == NULL) {
// Anything in the buffer?
@ -366,13 +343,13 @@ void isr() {
#ifdef Z_LATE_ENABLE
if(current_block->steps_z > 0) {
enable_z();
_NEXT_ISR(2000); //1ms wait
OCR1A = 2000; //1ms wait
return;
}
#endif
}
else {
_NEXT_ISR(2000); // 1kHz.
OCR1A=2000; // 1kHz.
}
}
@ -418,7 +395,7 @@ void isr() {
CHECK_ENDSTOPS
{
{
#if defined(X_MIN_PIN) && (X_MIN_PIN > -1) && !defined(DEBUG_DISABLE_XMINLIMIT)
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
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];
@ -434,7 +411,7 @@ void isr() {
CHECK_ENDSTOPS
{
{
#if defined(X_MAX_PIN) && (X_MAX_PIN > -1) && !defined(DEBUG_DISABLE_XMAXLIMIT)
#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];
@ -454,7 +431,7 @@ void isr() {
#endif
CHECK_ENDSTOPS
{
#if defined(Y_MIN_PIN) && (Y_MIN_PIN > -1) && !defined(DEBUG_DISABLE_YMINLIMIT)
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
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];
@ -468,7 +445,7 @@ void isr() {
else { // +direction
CHECK_ENDSTOPS
{
#if defined(Y_MAX_PIN) && (Y_MAX_PIN > -1) && !defined(DEBUG_DISABLE_YMAXLIMIT)
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
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];
@ -490,7 +467,7 @@ void isr() {
count_direction[Z_AXIS]=-1;
if(check_endstops && ! check_z_endstop)
{
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
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];
@ -511,7 +488,7 @@ void isr() {
count_direction[Z_AXIS]=1;
CHECK_ENDSTOPS
{
#if defined(Z_MAX_PIN) && (Z_MAX_PIN > -1) && !defined(DEBUG_DISABLE_ZMAXLIMIT)
#if defined(Z_MAX_PIN) && Z_MAX_PIN > -1
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];
@ -524,7 +501,7 @@ void isr() {
}
// Supporting stopping on a trigger of the Z-stop induction sensor, not only for the Z-minus movements.
#if defined(Z_MIN_PIN) && (Z_MIN_PIN > -1) && !defined(DEBUG_DISABLE_ZMINLIMIT)
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1
if(check_z_endstop) {
// Check the Z min end-stop no matter what.
// Good for searching for the center of an induction target.
@ -576,15 +553,6 @@ void isr() {
#ifndef AT90USB
MSerial.checkRx(); // Check for serial chars.
#endif
#ifdef LIN_ADVANCE
counter_e += current_block->steps_e;
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
count_position[E_AXIS] += count_direction[E_AXIS];
((out_bits&(1<<E_AXIS))!=0) ? --e_steps : ++e_steps;
}
#endif
counter_x += current_block->steps_x;
if (counter_x > 0) {
@ -628,7 +596,6 @@ void isr() {
#endif
}
#ifndef LIN_ADVANCE
counter_e += current_block->steps_e;
if (counter_e > 0) {
WRITE_E_STEP(!INVERT_E_STEP_PIN);
@ -636,21 +603,9 @@ void isr() {
count_position[E_AXIS]+=count_direction[E_AXIS];
WRITE_E_STEP(INVERT_E_STEP_PIN);
}
#endif
step_events_completed += 1;
if(step_events_completed >= current_block->step_event_count) break;
}
#ifdef LIN_ADVANCE
if (current_block->use_advance_lead) {
const int delta_adv_steps = current_estep_rate - current_adv_steps;
current_adv_steps += delta_adv_steps;
e_steps += delta_adv_steps;
}
// If we have esteps to execute, fire the next advance_isr "now"
if (e_steps) nextAdvanceISR = 0;
#endif
// Calculare new timer value
unsigned short timer;
unsigned short step_rate;
@ -665,15 +620,8 @@ void isr() {
// step_rate to timer interval
timer = calc_timer(acc_step_rate);
_NEXT_ISR(timer);
OCR1A = timer;
acceleration_time += timer;
#ifdef LIN_ADVANCE
if (current_block->use_advance_lead) {
current_estep_rate = ((uint32_t)acc_step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
}
eISR_Rate = ADV_RATE(timer, step_loops);
#endif
}
else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {
MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
@ -691,25 +639,11 @@ void isr() {
// step_rate to timer interval
timer = calc_timer(step_rate);
_NEXT_ISR(timer);
OCR1A = timer;
deceleration_time += timer;
#ifdef LIN_ADVANCE
if (current_block->use_advance_lead) {
current_estep_rate = ((uint32_t)step_rate * current_block->abs_adv_steps_multiplier8) >> 17;
}
eISR_Rate = ADV_RATE(timer, step_loops);
#endif
}
else {
#ifdef LIN_ADVANCE
if (current_block->use_advance_lead)
current_estep_rate = final_estep_rate;
eISR_Rate = ADV_RATE(OCR1A_nominal, step_loops_nominal);
#endif
_NEXT_ISR(OCR1A_nominal);
OCR1A = OCR1A_nominal;
// ensure we're running at the correct step rate, even if we just came off an acceleration
step_loops = step_loops_nominal;
}
@ -722,69 +656,6 @@ void isr() {
}
}
#ifdef LIN_ADVANCE
// Timer interrupt for E. e_steps is set in the main routine.
void advance_isr() {
nextAdvanceISR = eISR_Rate;
if (e_steps) {
bool dir =
#ifdef SNMM
((e_steps < 0) == (snmm_extruder & 1))
#else
(e_steps < 0)
#endif
? INVERT_E0_DIR : !INVERT_E0_DIR; //If we have SNMM, reverse every second extruder.
WRITE(E0_DIR_PIN, dir);
for (uint8_t i = step_loops; e_steps && i--;) {
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
e_steps < 0 ? ++e_steps : --e_steps;
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
}
}
}
void advance_isr_scheduler() {
// Run main stepping ISR if flagged
if (!nextMainISR) isr();
// Run Advance stepping ISR if flagged
if (!nextAdvanceISR) advance_isr();
// Is the next advance ISR scheduled before the next main ISR?
if (nextAdvanceISR <= nextMainISR) {
// Set up the next interrupt
OCR1A = nextAdvanceISR;
// New interval for the next main ISR
if (nextMainISR) nextMainISR -= nextAdvanceISR;
// Will call Stepper::advance_isr on the next interrupt
nextAdvanceISR = 0;
}
else {
// The next main ISR comes first
OCR1A = nextMainISR;
// New interval for the next advance ISR, if any
if (nextAdvanceISR && nextAdvanceISR != ADV_NEVER)
nextAdvanceISR -= nextMainISR;
// Will call Stepper::isr on the next interrupt
nextMainISR = 0;
}
// Don't run the ISR faster than possible
if (OCR1A < TCNT1 + 16) OCR1A = TCNT1 + 16;
}
void clear_current_adv_vars() {
e_steps = 0; //Should be already 0 at an filament change event, but just to be sure..
current_adv_steps = 0;
}
#endif // LIN_ADVANCE
void st_init()
{
digipot_init(); //Initialize Digipot Motor Current
@ -972,11 +843,6 @@ void st_init()
OCR1A = 0x4000;
TCNT1 = 0;
ENABLE_STEPPER_DRIVER_INTERRUPT();
#ifdef LIN_ADVANCE
e_steps = 0;
current_adv_steps = 0;
#endif
enable_endstops(true); // Start with endstops active. After homing they can be disabled
sei();

View File

@ -44,16 +44,6 @@ extern bool abort_on_endstop_hit;
// Initialize and start the stepper motor subsystem
void st_init();
// Interrupt Service Routines
void isr();
#ifdef LIN_ADVANCE
void advance_isr();
void advance_isr_scheduler();
void clear_current_adv_vars(); //Used to reset the built up pretension and remaining esteps on filament change.
#endif
// Block until all buffered steps are executed
void st_synchronize();

View File

@ -1303,9 +1303,6 @@ void max_temp_error(uint8_t e) {
}
void min_temp_error(uint8_t e) {
#ifdef DEBUG_DISABLE_MINTEMP
return;
#endif
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
@ -1336,9 +1333,6 @@ void bed_max_temp_error(void) {
}
void bed_min_temp_error(void) {
#ifdef DEBUG_DISABLE_MINTEMP
return;
#endif
#if HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN, 0);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -820,11 +820,7 @@ static void lcd_implementation_status_screen()
lcd_printPGM(PSTR(" "));
#ifdef DEBUG_DISABLE_LCD_STATUS_LINE
return;
#endif //DEBUG_DISABLE_LCD_STATUS_LINE
//Print status line
//Print status line
lcd.setCursor(0, 3);
// If heating in progress, set flag