Commit 128f956d authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents 8254ca74 1e7265b6
......@@ -268,17 +268,37 @@
#define THERMAL_PROTECTION_PERIOD 40 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius
// Whenever an M104 or M109 increases the target temperature the firmware will wait for the
// WATCH TEMP PERIOD to expire, and if the temperature hasn't increased by WATCH TEMP INCREASE
// degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109,
//but only if the current temperature is far enough below the target for a reliable test.
#define WATCH_TEMP_PERIOD 16 // Seconds
#define WATCH_TEMP_INCREASE 4 // Degrees Celsius
/**
* Whenever an M104 or M109 increases the target temperature the firmware will wait for the
* WATCH TEMP PERIOD to expire, and if the temperature hasn't increased by WATCH TEMP INCREASE
* degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109,
* but only if the current temperature is far enough below the target for a reliable test.
*
* If you get false positives for "Heating failed" increase WATCH TEMP PERIOD and/or decrease WATCH TEMP INCREASE
* WATCH TEMP INCREASE should not be below 2.
*/
#define WATCH_TEMP_PERIOD 20 // Seconds
#define WATCH_TEMP_INCREASE 2 // Degrees Celsius
/**
* Thermal Protection parameters for the bed are just as above for hotends.
*/
//#define THERMAL_PROTECTION_BED
#define THERMAL_PROTECTION_BED_PERIOD 20 // Seconds
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius
/**
* Whenever an M140 or M190 increases the target temperature the firmware will wait for the
* WATCH BED TEMP PERIOD to expire, and if the temperature hasn't increased by WATCH BED TEMP INCREASE
* degrees, the machine is halted, requiring a hard reset. This test restarts with any M140/M190,
* but only if the current temperature is far enough below the target for a reliable test.
*
* If you get too many "Heating failed" errors, increase WATCH BED TEMP PERIOD and/or decrease
* WATCH BED TEMP INCREASE. (WATCH BED TEMP INCREASE should not be below 2.)
*/
#define WATCH_BED_TEMP_PERIOD 60 // Seconds
#define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius
/********************************************************************************/
......@@ -563,9 +583,21 @@
*****************************************************************************************/
//#define ADVANCE
#define EXTRUDER_ADVANCE_K .0
#define EXTRUDER_ADVANCE_K 0.0
#define D_FILAMENT 1.75
#define STEPS_PER_CUBIC_MM_E 0.85
/*****************************************************************************************/
/*****************************************************************************************
****************** Extruder Advance Linear Pressure Control *****************************
*****************************************************************************************
* *
* Assumption: advance = k * (delta velocity) *
* K=0 means advance disabled. A good value for a gregs wade extruder will be around K=75*
* *
*****************************************************************************************/
//#define ADVANCE_LPC
#define ADVANCE_LPC_K 75
/*****************************************************************************************/
......
......@@ -354,8 +354,29 @@ void delay_ms(millis_t ms) {
void plan_arc(float target[NUM_AXIS], float* offset, uint8_t clockwise);
void gcode_M114();
static void report_current_position();
void print_xyz(const char* prefix, const float x, const float y, const float z) {
ECHO_T(prefix);
ECHO_MV(": (", x);
ECHO_MV(", ", y);
ECHO_MV(", ", z);
ECHO_M(")");
ECHO_E;
}
void print_xyz(const char* prefix, const float xyz[]) {
print_xyz(prefix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
}
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void print_xyz(const char* prefix, const vector_3 &xyz) {
print_xyz(prefix, xyz.x, xyz.y, xyz.z);
}
#endif
#define DEBUG_POS(PREFIX, VAR) do{ ECHO_SM(INFO,PREFIX); print_xyz(" > " STRINGIFY(VAR), VAR); }while(0)
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
float extrude_min_temp = EXTRUDE_MINTEMP;
#endif
......@@ -1137,20 +1158,6 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#endif //DUAL_X_CARRIAGE
void print_xyz(const char* prefix, const float x, const float y, const float z) {
ECHO_T(prefix);
ECHO_MV(": (", x);
ECHO_MV(", ", y);
ECHO_MV(", ", z);
ECHO_M(")");
ECHO_E;
}
void print_xyz(const char* prefix, const float xyz[]) {
print_xyz(prefix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
}
#define DEBUG_POS(PREFIX, VAR) do{ ECHO_SM(INFO,PREFIX); print_xyz(" > " STRINGIFY(VAR), VAR); }while(0)
/**
* Software endstops can be used to monitor the open end of
......@@ -1587,7 +1594,11 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio
#if HAS(SERVO_ENDSTOPS) && HASNT(Z_PROBE_SLED)
void raise_z_for_servo() {
float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_PROBING;
z_dest += TEST(axis_was_homed, Z_AXIS) ? zprobe_zoffset : zpos;
/**
* The zprobe_zoffset is negative any switch below the nozzle, so
* multiply by Z_HOME_DIR (-1) to move enough away from bed for the probe
*/
z_dest += axis_homed[Z_AXIS] ? zprobe_zoffset * Z_HOME_DIR : zpos;
if (zpos < z_dest) do_blocking_move_to_z(z_dest); // also updates current_position
}
#endif
......@@ -5345,7 +5356,7 @@ inline void gcode_M92() {
#endif
/**
* M104: Set hot end temperature
* M104: Set hotend temperature
*/
inline void gcode_M104() {
if (setTargetedExtruder(104)) return;
......@@ -6357,7 +6368,7 @@ inline void gcode_M226() {
* M363: SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree)
*/
inline bool gcode_M363() {
ECHO_LM(DB,"Cal: Psi 90 ");
ECHO_LM(DB, "Cal: Psi 90 ");
return SCARA_move_to_cal(50, 90);
}
......@@ -7219,6 +7230,17 @@ inline void gcode_M503() {
}
#endif
#if ENABLED(ADVANCE_LPC)
/**
* M905: Set advance factor
*/
inline void gcode_M905() {
st_synchronize();
if (code_seen('K')) extruder_advance_k = code_value();
ECHO_LMV(DB, "Advance factor = ", extruder_advance_k);
}
#endif
#if MB(ALLIGATOR)
/**
* M906: Set motor currents
......@@ -7855,14 +7877,14 @@ void process_next_command() {
case 112: // M112 Emergency Stop
gcode_M112(); break;
case 114: // M114 Report current position
gcode_M114(); break;
#if ENABLED(HOST_KEEPALIVE_FEATURE)
case 113: // M113: Set Host Keepalive interval
gcode_M113(); break;
#endif
case 114: // M114 Report current position
gcode_M114(); break;
case 115: // M115 Report capabilities
gcode_M115(); break;
......@@ -8079,7 +8101,7 @@ void process_next_command() {
#endif
#if ENABLED(FILAMENTCHANGEENABLE)
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
case 600: // Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
gcode_M600(); break;
#endif
......@@ -8093,6 +8115,11 @@ void process_next_command() {
gcode_M666(); break;
#endif
#if ENABLED(ADVANCE_LPC)
case 905: // M905 Set advance factor.
gcode_M905(); break;
#endif
#if MB(ALLIGATOR)
case 906: // M906 Set motor currents XYZ T0-4 E
gcode_M906(); break;
......
......@@ -36,6 +36,10 @@ void idle(
void manage_inactivity(bool ignore_stepper_queue = false);
#if ENABLED(DUAL_X_CARRIAGE)
extern bool extruder_duplication_enabled;
#endif
void FlushSerialRequestResend();
void ok_to_send();
......@@ -134,6 +138,10 @@ extern bool axis_known_position[3];
extern bool axis_homed[3];
extern float zprobe_zoffset;
#if ENABLED(ADVANCE_LPC)
extern int extruder_advance_k;
#endif
#if HEATER_USES_AD595
extern float ad595_offset[HOTENDS];
extern float ad595_gain[HOTENDS];
......
......@@ -505,7 +505,7 @@
*/
#if ENABLED(ADVANCE)
#define EXTRUSION_AREA (0.25 * (D_FILAMENT) * (D_FILAMENT) * M_PI)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS + active_extruder] / EXTRUSION_AREA)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS + active_extruder] / (EXTRUSION_AREA))
#endif
/**
......
......@@ -221,7 +221,7 @@
#define SERIAL_HEATER_BED "bed"
#define SERIAL_STOPPED_HEATER ", system stopped! Heater_ID: "
//#define SERIAL_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !"
#define SERIAL_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !"
#define SERIAL_T_HEATING_FAILED "Heating failed"
#define SERIAL_T_THERMAL_RUNAWAY "Thermal Runaway"
#define SERIAL_T_MAXTEMP "MAXTEMP triggered"
......
......@@ -151,13 +151,13 @@
#define MSG_BABYSTEP_Z MSG_BABYSTEP " " MSG_Z
#define MSG_ENDSTOP_ABORT "Finecorsa abort."
#define MSG_HEATING_FAILED_LCD "Riscaldamento fallito"
#define MSG_ERR_REDUNDANT_TEMP "REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_ERR_REDUNDANT_TEMP "Err: TEMP RIDONDANTI"
#define MSG_THERMAL_RUNAWAY "TEMP FUORI CONTROLLO"
#define MSG_AD595 "AD595 Offset & Gain"
#define MSG_ERR_MAXTEMP "MAXTEMP ERROR"
#define MSG_ERR_MINTEMP "MINTEMP ERROR"
#define MSG_ERR_MAXTEMP_BED "MAXTEMP BED ERROR"
#define MSG_ERR_MINTEMP_BED "MINTEMP BED ERROR"
#define MSG_ERR_MAXTEMP "Err: TEMP MASSIMA"
#define MSG_ERR_MINTEMP "Err: TEMP MINIMA"
#define MSG_ERR_MAXTEMP_BED "Err: TEMP MASSIMA PIATTO"
#define MSG_ERR_MINTEMP_BED "Err: TEMP MINIMA PIATTO"
#define MSG_END_DAY "giorni"
#define MSG_END_HOUR "ore"
#define MSG_END_MINUTE "minuti"
......
......@@ -1126,7 +1126,20 @@ float junction_deviation = 0.1;
ECHO_SMV(OK, "advance :", block->advance/256);
ECHO_EMV("advance rate :", block->advance_rate/256);
*/
#endif // ADVANCE
#elif ENABLED(ADVANCE_LPC) // ADVANCE_LPC
// bse == allsteps: A problem occurs when there's a very tiny move before a retract.
// In this case, the retract and the move will be executed together.
// This leads to an enormous number of advance steps due to a huge e_acceleration.
// The math is correct, but you don't want a retract move done with advance!
// So this situation is filtered out here.
if (!bse || (!bsx && !bsy && !bsz) || extruder_advance_k == 0 || bse == allsteps) {
block->use_advance_lead = false;
}
else {
block->use_advance_lead = true;
block->e_speed_multiplier8 = (block->steps[E_AXIS] << 8) / block->step_event_count;
}
#endif
calculate_trapezoid_for_block(block, block->entry_speed / block->nominal_speed, safe_speed / block->nominal_speed);
......
......@@ -49,25 +49,32 @@
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active.
typedef struct {
unsigned char active_driver; // Selects the active driver
// Fields used by the bresenham algorithm for tracing the line
unsigned long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block
#if ENABLED(COLOR_MIXING_EXTRUDER)
unsigned long mix_event_count[DRIVER_EXTRUDERS]; // Step count for each stepper in a mixing extruder
#endif
unsigned long step_event_count; // The number of step events required to complete this block
long accelerate_until; // The index of the step event on which to stop acceleration
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_driver; // Selects the active driver
// Advance extrusion
#if ENABLED(ADVANCE)
long advance_rate;
volatile long initial_advance;
volatile long final_advance;
float advance;
#elif ENABLED(ADVANCE_LPC)
bool use_advance_lead;
int e_speed_multiplier8;
#endif
// Fields used by the motion planner to manage acceleration
......
This diff is collapsed.
......@@ -232,7 +232,6 @@
#define NORM_E_DIR() { switch(current_block->active_driver) { case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; }}
#define REV_E_DIR() { switch(current_block->active_driver) { case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; }}
#else
extern bool extruder_duplication_enabled;
#define E_STEP_WRITE(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
#define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
#define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E1_DIR); } else if(current_block->active_driver == 1) { E1_DIR_WRITE( INVERT_E1_DIR); } else { E0_DIR_WRITE( INVERT_E0_DIR); }}
......
......@@ -391,6 +391,12 @@
#endif
#endif
/**
* Advance Extrusion
*/
#if ENABLED(ADVANCE) && ENABLED(ADVANCE_LPC)
#error You can enable ADVANCE or ADVANCE_LPC, but not both.
#endif
#if ENABLED(ADVANCE)
#if DISABLED(EXTRUDER_ADVANCE_K)
#error DEPENDENCY ERROR: Missing setting EXTRUDER_ADVANCE_K
......
......@@ -200,6 +200,11 @@ static void updateTemperaturesFromRawValues();
millis_t watch_heater_next_ms[HOTENDS] = { 0 };
#endif
#if ENABLED(THERMAL_PROTECTION_BED)
int watch_target_bed_temp = 0;
millis_t watch_bed_next_ms = 0;
#endif
#if DISABLED(SOFT_PWM_SCALE)
#define SOFT_PWM_SCALE 0
#endif
......@@ -286,12 +291,12 @@ void autotempShutdown() {
#if HAS(AUTO_FAN)
if (ms > next_auto_fan_check_ms) {
checkExtruderAutoFans();
next_auto_fan_check_ms = ms + 2500;
next_auto_fan_check_ms = ms + 2500UL;
}
#endif
if (heating && input > temp) {
if (ms > t2 + 5000) {
if (ms > t2 + 5000UL) {
heating = false;
if (hotend < 0)
soft_pwm_bed = (bias - d) >> 1;
......@@ -304,7 +309,7 @@ void autotempShutdown() {
}
if (!heating && input < temp) {
if (ms > t1 + 5000) {
if (ms > t1 + 5000UL) {
heating = true;
t2 = ms;
t_low = t2 - t1;
......@@ -699,7 +704,7 @@ void manage_heater() {
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || DISABLED(PIDTEMPBED) || HAS(AUTO_FAN)
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED) || DISABLED(PIDTEMPBED) || HAS(AUTO_FAN)
millis_t ms = millis();
#endif
......@@ -733,9 +738,27 @@ void manage_heater() {
#endif // THERMAL_PROTECTION_HOTENDS
// Check if the temperature is failing to increase
#if ENABLED(THERMAL_PROTECTION_BED)
// Is it time to check the bed?
if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
// Has it failed to increase enough?
if (degBed() < watch_target_bed_temp) {
// Stop!
_temp_error(-1, PSTR(SERIAL_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
}
else {
// Start again if the target is still far off
start_watching_bed();
}
}
#endif // THERMAL_PROTECTION_HOTENDS
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
_temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
_temp_error(0, PSTR(SERIAL_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
}
#endif
......@@ -791,7 +814,7 @@ void manage_heater() {
soft_pwm_bed = 0;
WRITE_HEATER_BED(LOW);
}
#else // BED_LIMIT_SWITCHING
#else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
// Check if temperature is within the correct range
if (current_temperature_bed > BED_MINTEMP && current_temperature_bed < BED_MAXTEMP) {
soft_pwm_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
......@@ -1226,6 +1249,22 @@ void tp_init() {
}
#endif
#if ENABLED(THERMAL_PROTECTION_BED)
/**
* Start Heating Sanity Check for bed that are below
* their target temperature by a configurable margin.
* This is called when the temperature is set. (M140, M190)
*/
void start_watching_bed() {
if (degBed() < degTargetBed() - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
watch_target_bed_temp = degBed() + WATCH_BED_TEMP_INCREASE;
watch_bed_next_ms = millis() + (WATCH_BED_TEMP_PERIOD) * 1000UL;
}
else
watch_bed_next_ms = 0;
}
#endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || ENABLED(THERMAL_PROTECTION_BED)
void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
......@@ -1268,7 +1307,7 @@ void tp_init() {
if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc)
*timer = millis();
// If the timer goes too long without a reset, trigger shutdown
else if (millis() > *timer + period_seconds * 1000UL)
else if (ELAPSED(millis(), *timer + period_seconds * 1000UL))
*state = TRRunaway;
break;
case TRRunaway:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment