Merge remote-tracking branch 'upstream/Mk3' into MK3_Dcodes_fix1

This commit is contained in:
3d-gussner 2020-04-07 11:03:21 +02:00
commit e635ce49d9
9 changed files with 345 additions and 279 deletions

View File

@ -635,6 +635,98 @@ void dcode_12()
} }
#ifdef HEATBED_ANALYSIS
/*!
### D80 - Bed check <a href="https://reprap.org/wiki/G-code#D80:_Bed_check">D80: Bed check</a>
This command will log data to SD card file "mesh.txt".
#### Usage
D80 [ E | F | G | H | I | J ]
#### Parameters
- `E` - Dimension X (default 40)
- `F` - Dimention Y (default 40)
- `G` - Points X (default 40)
- `H` - Points Y (default 40)
- `I` - Offset X (default 74)
- `J` - Offset Y (default 34)
*/
void dcode_80()
{
float dimension_x = 40;
float dimension_y = 40;
int points_x = 40;
int points_y = 40;
float offset_x = 74;
float offset_y = 33;
if (code_seen('E')) dimension_x = code_value();
if (code_seen('F')) dimension_y = code_value();
if (code_seen('G')) {points_x = code_value(); }
if (code_seen('H')) {points_y = code_value(); }
if (code_seen('I')) {offset_x = code_value(); }
if (code_seen('J')) {offset_y = code_value(); }
printf_P(PSTR("DIM X: %f\n"), dimension_x);
printf_P(PSTR("DIM Y: %f\n"), dimension_y);
printf_P(PSTR("POINTS X: %d\n"), points_x);
printf_P(PSTR("POINTS Y: %d\n"), points_y);
printf_P(PSTR("OFFSET X: %f\n"), offset_x);
printf_P(PSTR("OFFSET Y: %f\n"), offset_y);
bed_check(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
}
/*!
### D81 - Bed analysis <a href="https://reprap.org/wiki/G-code#D81:_Bed_analysis">D80: Bed analysis</a>
This command will log data to SD card file "wldsd.txt".
#### Usage
D81 [ E | F | G | H | I | J ]
#### Parameters
- `E` - Dimension X (default 40)
- `F` - Dimention Y (default 40)
- `G` - Points X (default 40)
- `H` - Points Y (default 40)
- `I` - Offset X (default 74)
- `J` - Offset Y (default 34)
*/
void dcode_81()
{
float dimension_x = 40;
float dimension_y = 40;
int points_x = 40;
int points_y = 40;
float offset_x = 74;
float offset_y = 33;
if (code_seen('E')) dimension_x = code_value();
if (code_seen('F')) dimension_y = code_value();
if (code_seen("G")) { strchr_pointer+=1; points_x = code_value(); }
if (code_seen("H")) { strchr_pointer+=1; points_y = code_value(); }
if (code_seen("I")) { strchr_pointer+=1; offset_x = code_value(); }
if (code_seen("J")) { strchr_pointer+=1; offset_y = code_value(); }
bed_analysis(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
}
#endif //HEATBED_ANALYSIS
/*!
### D106 - Print measured fan speed for different pwm values <a href="https://reprap.org/wiki/G-code#D106:_Print_measured_fan_speed_for_different_pwm_values">D106: Print measured fan speed for different pwm values</a>
*/
void dcode_106()
{
for (int i = 255; i > 0; i = i - 5) {
fanSpeed = i;
//delay_keep_alive(2000);
for (int j = 0; j < 100; j++) {
delay_keep_alive(100);
}
printf_P(_N("%d: %d\n"), i, fan_speed[1]);
}
}
#ifdef TMC2130 #ifdef TMC2130
#include "planner.h" #include "planner.h"

View File

@ -2,19 +2,33 @@
#define DCODES_H #define DCODES_H
extern void dcode__1(); //D-1 - Endless loop (to simulate deadlock) extern void dcode__1(); //D-1 - Endless loop (to simulate deadlock)
extern void dcode_0(); //D0 - Reset extern void dcode_0(); //D0 - Reset
extern void dcode_1(); //D1 - Clear EEPROM extern void dcode_1(); //D1 - Clear EEPROM
extern void dcode_2(); //D2 - Read/Write RAM extern void dcode_2(); //D2 - Read/Write RAM
#ifdef DEBUG_DCODE3
extern void dcode_3(); //D3 - Read/Write EEPROM extern void dcode_3(); //D3 - Read/Write EEPROM
#endif //DEBUG_DCODE3
extern void dcode_4(); //D4 - Read/Write PIN extern void dcode_4(); //D4 - Read/Write PIN
#ifdef DEBUG_DCODE5
extern void dcode_5(); //D5 - Read/Write FLASH extern void dcode_5(); //D5 - Read/Write FLASH
#endif //DEBUG_DCODE5
extern void dcode_6(); //D6 - Read/Write external FLASH extern void dcode_6(); //D6 - Read/Write external FLASH
extern void dcode_7(); //D7 - Read/Write Bootloader extern void dcode_7(); //D7 - Read/Write Bootloader
extern void dcode_8(); //D8 - Read/Write PINDA extern void dcode_8(); //D8 - Read/Write PINDA
extern void dcode_9(); //D9 - Read/Write ADC (Write=enable simulated, Read=disable simulated) extern void dcode_9(); //D9 - Read/Write ADC (Write=enable simulated, Read=disable simulated)
extern void dcode_10(); //D10 - XYZ calibration = OK extern void dcode_10(); //D10 - XYZ calibration = OK
extern void dcode_12(); //D12 - Log time. Writes the current time in the log file.
#ifdef HEATBED_ANALYSIS
extern void dcode_80(); //D80 - Bed check. This command will log data to SD card file "mesh.txt".
extern void dcode_81(); //D81 - Bed analysis. This command will log data to SD card file "wldsd.txt".
#endif //HEATBED_ANALYSIS
extern void dcode_106(); //D106 - Print measured fan speed for different pwm values
#ifdef TMC2130 #ifdef TMC2130
extern void dcode_2130(); //D2130 - TMC2130 extern void dcode_2130(); //D2130 - TMC2130

View File

@ -310,9 +310,9 @@ extern int8_t lcd_change_fil_state;
extern float default_retraction; extern float default_retraction;
#ifdef TMC2130 #ifdef TMC2130
bool homeaxis(int axis, bool doError = true, uint8_t cnt = 1, uint8_t* pstep = 0); void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
#else #else
bool homeaxis(int axis, bool doError = true, uint8_t cnt = 1); void homeaxis(int axis, uint8_t cnt = 1);
#endif //TMC2130 #endif //TMC2130

View File

@ -2197,9 +2197,24 @@ bool calibrate_z_auto()
#endif //TMC2130 #endif //TMC2130
#ifdef TMC2130 #ifdef TMC2130
bool homeaxis(int axis, bool doError, uint8_t cnt, uint8_t* pstep) static void check_Z_crash(void)
{
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash
FORCE_HIGH_POWER_END;
current_position[Z_AXIS] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder);
st_synchronize();
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
}
}
#endif //TMC2130
#ifdef TMC2130
void homeaxis(int axis, uint8_t cnt, uint8_t* pstep)
#else #else
bool homeaxis(int axis, bool doError, uint8_t cnt) void homeaxis(int axis, uint8_t cnt)
#endif //TMC2130 #endif //TMC2130
{ {
bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homing bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homing
@ -2312,13 +2327,7 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize(); st_synchronize();
#ifdef TMC2130 #ifdef TMC2130
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash check_Z_crash();
FORCE_HIGH_POWER_END;
if (doError) kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
current_position[axis] = -5; //assume that nozzle crashed into bed
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
return 0;
}
#endif //TMC2130 #endif //TMC2130
current_position[axis] = 0; current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
@ -2330,13 +2339,7 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
st_synchronize(); st_synchronize();
#ifdef TMC2130 #ifdef TMC2130
if (READ(Z_TMC2130_DIAG) != 0) { //Z crash check_Z_crash();
FORCE_HIGH_POWER_END;
if (doError) kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
current_position[axis] = -5; //assume that nozzle crashed into bed
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
return 0;
}
#endif //TMC2130 #endif //TMC2130
axis_is_at_home(axis); axis_is_at_home(axis);
destination[axis] = current_position[axis]; destination[axis] = current_position[axis];
@ -2348,7 +2351,6 @@ bool homeaxis(int axis, bool doError, uint8_t cnt)
#endif #endif
} }
enable_endstops(endstops_enabled); enable_endstops(endstops_enabled);
return 1;
} }
/**/ /**/
@ -8982,28 +8984,7 @@ Sigma_Exit:
- `J` - Offset Y (default 34) - `J` - Offset Y (default 34)
*/ */
case 80: case 80:
{ dcode_80(); break;
float dimension_x = 40;
float dimension_y = 40;
int points_x = 40;
int points_y = 40;
float offset_x = 74;
float offset_y = 33;
if (code_seen('E')) dimension_x = code_value();
if (code_seen('F')) dimension_y = code_value();
if (code_seen('G')) {points_x = code_value(); }
if (code_seen('H')) {points_y = code_value(); }
if (code_seen('I')) {offset_x = code_value(); }
if (code_seen('J')) {offset_y = code_value(); }
printf_P(PSTR("DIM X: %f\n"), dimension_x);
printf_P(PSTR("DIM Y: %f\n"), dimension_y);
printf_P(PSTR("POINTS X: %d\n"), points_x);
printf_P(PSTR("POINTS Y: %d\n"), points_y);
printf_P(PSTR("OFFSET X: %f\n"), offset_x);
printf_P(PSTR("OFFSET Y: %f\n"), offset_y);
bed_check(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
}break;
/*! /*!
### D81 - Bed analysis <a href="https://reprap.org/wiki/G-code#D81:_Bed_analysis">D80: Bed analysis</a> ### D81 - Bed analysis <a href="https://reprap.org/wiki/G-code#D81:_Bed_analysis">D80: Bed analysis</a>
@ -9021,24 +9002,7 @@ Sigma_Exit:
- `J` - Offset Y (default 34) - `J` - Offset Y (default 34)
*/ */
case 81: case 81:
{ dcode_81(); break;
float dimension_x = 40;
float dimension_y = 40;
int points_x = 40;
int points_y = 40;
float offset_x = 74;
float offset_y = 33;
if (code_seen('E')) dimension_x = code_value();
if (code_seen('F')) dimension_y = code_value();
if (code_seen("G")) { strchr_pointer+=1; points_x = code_value(); }
if (code_seen("H")) { strchr_pointer+=1; points_y = code_value(); }
if (code_seen("I")) { strchr_pointer+=1; offset_x = code_value(); }
if (code_seen("J")) { strchr_pointer+=1; offset_y = code_value(); }
bed_analysis(dimension_x,dimension_y,points_x,points_y,offset_x,offset_y);
} break;
#endif //HEATBED_ANALYSIS #endif //HEATBED_ANALYSIS
#ifdef DEBUG_DCODES #ifdef DEBUG_DCODES
@ -9047,17 +9011,7 @@ Sigma_Exit:
### D106 - Print measured fan speed for different pwm values <a href="https://reprap.org/wiki/G-code#D106:_Print_measured_fan_speed_for_different_pwm_values">D106: Print measured fan speed for different pwm values</a> ### D106 - Print measured fan speed for different pwm values <a href="https://reprap.org/wiki/G-code#D106:_Print_measured_fan_speed_for_different_pwm_values">D106: Print measured fan speed for different pwm values</a>
*/ */
case 106: case 106:
{ dcode_106(); break;
for (int i = 255; i > 0; i = i - 5) {
fanSpeed = i;
//delay_keep_alive(2000);
for (int j = 0; j < 100; j++) {
delay_keep_alive(100);
}
printf_P(_N("%d: %d\n"), i, fan_speed[1]);
}
}break;
#ifdef TMC2130 #ifdef TMC2130
/*! /*!

View File

@ -994,7 +994,7 @@ bool tmc2130_home_calibrate(uint8_t axis)
uint8_t step[16]; uint8_t step[16];
uint8_t cnt[16]; uint8_t cnt[16];
uint8_t val[16]; uint8_t val[16];
homeaxis(axis, true, 16, step); homeaxis(axis, 16, step);
bubblesort_uint8(step, 16, 0); bubblesort_uint8(step, 16, 0);
printf_P(PSTR("sorted samples:\n")); printf_P(PSTR("sorted samples:\n"));
for (uint8_t i = 0; i < 16; i++) for (uint8_t i = 0; i < 16; i++)

View File

@ -168,10 +168,10 @@ static void reset_crash_det(unsigned char axis);
static bool lcd_selfcheck_axis_sg(unsigned char axis); static bool lcd_selfcheck_axis_sg(unsigned char axis);
static bool lcd_selfcheck_axis(int _axis, int _travel); static bool lcd_selfcheck_axis(int _axis, int _travel);
#else #else
static bool lcd_selfcheck_endstops();
static bool lcd_selfcheck_axis(int _axis, int _travel); static bool lcd_selfcheck_axis(int _axis, int _travel);
static bool lcd_selfcheck_pulleys(int axis); static bool lcd_selfcheck_pulleys(int axis);
#endif //TMC2130 #endif //TMC2130
static bool lcd_selfcheck_endstops();
static bool lcd_selfcheck_check_heater(bool _isbed); static bool lcd_selfcheck_check_heater(bool _isbed);
enum class TestScreen : uint_least8_t enum class TestScreen : uint_least8_t
@ -7667,11 +7667,7 @@ bool lcd_selftest()
if (_result) if (_result)
{ {
_progress = lcd_selftest_screen(TestScreen::FansOk, _progress, 3, true, 2000); _progress = lcd_selftest_screen(TestScreen::FansOk, _progress, 3, true, 2000);
#ifndef TMC2130 _result = lcd_selfcheck_endstops(); //With TMC2130, only the Z probe is tested.
_result = lcd_selfcheck_endstops();
#else
_result = true;
#endif
} }
if (_result) if (_result)
@ -7738,7 +7734,7 @@ bool lcd_selftest()
set_destination_to_current(); set_destination_to_current();
_progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500); _progress = lcd_selftest_screen(TestScreen::AxisZ, _progress, 3, true, 1500);
#ifdef TMC2130 #ifdef TMC2130
_result = homeaxis(Z_AXIS, false); homeaxis(Z_AXIS); //In case of failure, the code gets stuck in this function.
#else #else
_result = lcd_selfcheck_axis(Z_AXIS, Z_MAX_POS); _result = lcd_selfcheck_axis(Z_AXIS, Z_MAX_POS);
#endif //TMC2130 #endif //TMC2130
@ -8137,31 +8133,42 @@ static bool lcd_selfcheck_pulleys(int axis)
} }
return(true); return(true);
} }
#endif //not defined TMC2130
static bool lcd_selfcheck_endstops() static bool lcd_selfcheck_endstops()
{ {
bool _result = true; bool _result = true;
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) || if (
#ifndef TMC2130
((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) || ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ||
#endif //!TMC2130
((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1)) ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1))
{ {
#ifndef TMC2130
if ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) current_position[0] += 10; if ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) current_position[0] += 10;
if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) current_position[1] += 10; if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) current_position[1] += 10;
#endif //!TMC2130
if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) current_position[2] += 10; if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) current_position[2] += 10;
} }
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder); plan_buffer_line_curposXYZE(manual_feedrate[0] / 60, active_extruder);
_delay(500); st_synchronize();
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) || if (
#ifndef TMC2130
((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) || ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ||
#endif //!TMC2130
((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1)) ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1))
{ {
_result = false; _result = false;
char _error[4] = ""; char _error[4] = "";
#ifndef TMC2130
if ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "X"); if ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "X");
if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Y"); if ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Y");
#endif //!TMC2130
if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Z"); if ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Z");
lcd_selftest_error(TestError::Endstops, _error, ""); lcd_selftest_error(TestError::Endstops, _error, "");
} }
@ -8169,7 +8176,6 @@ static bool lcd_selfcheck_endstops()
manage_inactivity(true); manage_inactivity(true);
return _result; return _result;
} }
#endif //not defined TMC2130
static bool lcd_selfcheck_check_heater(bool _isbed) static bool lcd_selfcheck_check_heater(bool _isbed)
{ {

View File

@ -21,7 +21,7 @@
- For MK3 --> skip to step 3. - For MK3 --> skip to step 3.
- If you have a different printer model, follow step [2.b](#2b) from Windows build - If you have a different printer model, follow step [2.b](#2b) from Windows build
3. Run `sudo ./build.sh` 3. Run `./build.sh`
- Output hex file is at `"PrusaFirmware/lang/firmware.hex"` . In the same folder you can hex files for other languages as well. - Output hex file is at `"PrusaFirmware/lang/firmware.hex"` . In the same folder you can hex files for other languages as well.
4. Connect your printer and flash with PrusaSlicer ( Configuration --> Flash printer firmware ) or Slic3r PE. 4. Connect your printer and flash with PrusaSlicer ( Configuration --> Flash printer firmware ) or Slic3r PE.

View File

@ -20,7 +20,7 @@
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode" "WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"ATTENTION:\x0aDetection de crash\x0adesactivee en\x0amode feutre" "ATTENTION:\x0aDetection de crash\x0adesactivee en\x0amode furtif"
# #
">Cancel" ">Cancel"
@ -550,7 +550,7 @@
#MSG_SILENT #MSG_SILENT
"Silent" "Silent"
"Feutre" "Furtif"
# #
"MMU needs user attention." "MMU needs user attention."