selftest, max endstops undefined, initialization of extruder fan, y offset from extruder

This commit is contained in:
PavelSindler 2018-02-06 17:01:09 +01:00
parent abf956b86f
commit 0c98ec5f6b
7 changed files with 117 additions and 135 deletions

View file

@ -237,8 +237,6 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
#endif
#define RPM_FANS
/*------------------------------------
PAT9125 SETTINGS
*------------------------------------*/
@ -273,7 +271,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc.
#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right
#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind
#define Y_PROBE_OFFSET_FROM_EXTRUDER 9 // Z probe to nozzle Y offset: -front +behind
#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!)
#endif
@ -463,6 +461,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define M600_TIMEOUT 600 //seconds
#define TACH0PULLUP
//#define SUPPORT_VERBOSITY
#endif //__CONFIGURATION_PRUSA_H

View file

@ -26,7 +26,7 @@
#define X_STEP_PIN 37
#define X_DIR_PIN 48
#define X_MIN_PIN 12
#define X_MAX_PIN 30
#define X_MAX_PIN -1
#define X_ENABLE_PIN 29
#define X_MS1_PIN 40
#define X_MS2_PIN 41
@ -34,7 +34,7 @@
#define Y_STEP_PIN 36
#define Y_DIR_PIN 49
#define Y_MIN_PIN 11
#define Y_MAX_PIN 24
#define Y_MAX_PIN -1
#define Y_ENABLE_PIN 28
#define Y_MS1_PIN 69
#define Y_MS2_PIN 39
@ -85,6 +85,7 @@
#define PS_ON_PIN -1
#define KILL_PIN -1 // 80 with Smart Controller LCD
#define SUICIDE_PIN -1 // PIN that has to be turned on right after start, to keep power flowing.
#define TACH_0 30 // noctua extruder fan
#ifdef ULTRA_LCD
@ -135,6 +136,3 @@
#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)
TACH_0
TACH_1

View file

@ -1056,6 +1056,13 @@ void st_init()
#endif
#endif
#if defined(TACH_0) && TACH_0 > -1
SET_INPUT(TACH_0);
#ifdef TACH0PULLUP
WRITE(TACH_0, HIGH);
#endif
#endif
//Initialize Step Pins
#if defined(X_STEP_PIN) && (X_STEP_PIN > -1)

View file

@ -454,7 +454,7 @@ void setExtruderAutoFanState(int pin, bool state)
analogWrite(pin, newFanSpeed);
}
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1)
void countFanSpeed()
{
@ -528,7 +528,7 @@ void fanSpeedError(unsigned char _fan) {
break;
}
}
#endif //(defined(TACH_0))
#endif //(defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1)
void checkExtruderAutoFans()
@ -711,10 +711,10 @@ void manage_heater()
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
if(millis() - extruder_autofan_last_check > 1000) // only need to check fan state very infrequently
{
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1)
countFanSpeed();
checkFanSpeed();
#endif //(defined(TACH_0))
#endif //(defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1)
checkExtruderAutoFans();
extruder_autofan_last_check = millis();
}
@ -1913,7 +1913,7 @@ ISR(TIMER0_COMPB_vect)
}
#endif //BABYSTEPPING
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 > -1)
check_fans();
#endif //(defined(TACH_0))
@ -1991,7 +1991,7 @@ void check_min_temp()
check_min_temp_bed();
}
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 > -1)
void check_fans() {
if (READ(TACH_0) != fan_state[0]) {
fan_edge_counter[0] ++;

View file

@ -227,7 +227,7 @@ void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans();
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 > -1)
void countFanSpeed();
void checkFanSpeed();

View file

@ -1483,6 +1483,7 @@ static void lcd_menu_extruder_info()
// Display Nozzle fan RPM
#if (defined(TACH_1))
lcd.setCursor(0, 1);
lcd_printPGM(MSG_INFO_PRINT_FAN);
@ -1491,7 +1492,7 @@ static void lcd_menu_extruder_info()
lcd.setCursor(12, 1);
lcd.print(itostr4(fan_speed_RPM[1]));
lcd.print(" RPM");
#endif
// Display X and Y difference from Filament sensor
@ -5629,7 +5630,11 @@ static bool lcd_selftest()
if (_result)
{
_progress = lcd_selftest_screen(0, _progress, 3, true, 2000);
#if (defined(TACH_1))
_result = lcd_selftest_fan_dialog(1);
#else //defined(TACH_1)
_result = lcd_selftest_manual_fan_check(1, false);
#endif //defined(TACH_1)
}
if (_result)
@ -5889,12 +5894,10 @@ static bool lcd_selfcheck_axis_sg(char axis) {
}
#endif //TMC2130
#ifndef TMC2130
static bool lcd_selfcheck_axis(int _axis, int _travel)
{
bool _stepdone = false;
bool _stepresult = false;
int _progress = 0;
@ -5902,41 +5905,39 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
int _err_endstop = 0;
int _lcd_refresh = 0;
_travel = _travel + (_travel / 10);
do {
current_position[_axis] = current_position[_axis] - 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize();
if (/*x_min_endstop || y_min_endstop || */(READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1))
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1))
{
if (_axis == 0)
{
_stepresult = (x_min_endstop) ? true : false;
_err_endstop = (y_min_endstop) ? 1 : 2;
_stepresult = ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ? true : false;
_err_endstop = ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ? 1 : 2;
}
if (_axis == 1)
{
_stepresult = (y_min_endstop) ? true : false;
_err_endstop = (x_min_endstop) ? 0 : 2;
_stepresult = ((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ? true : false;
_err_endstop = ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ? 0 : 2;
}
if (_axis == 2)
{
_stepresult = (READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1) ? true : false;
_err_endstop = (x_min_endstop) ? 0 : 1;
_stepresult = ((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) ? true : false;
_err_endstop = ((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ? 0 : 1;
/*disable_x();
disable_y();
disable_z();*/
}
_stepdone = true;
}
#ifdef TMC2130
tmc2130_home_exit();
#endif
if (_lcd_refresh < 6)
{
@ -5944,7 +5945,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
}
else
{
_progress = lcd_selftest_screen(4 + _axis, _progress, 3, false, 0);
_progress = lcd_selftest_screen(2 + _axis, _progress, 3, false, 0);
_lcd_refresh = 0;
}
@ -5983,7 +5984,6 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
}
}
return _stepresult;
}
@ -5991,10 +5991,9 @@ static bool lcd_selfcheck_pulleys(int axis)
{
float tmp_motor_loud[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD;
float tmp_motor[3] = DEFAULT_PWM_MOTOR_CURRENT;
float current_position_init, current_position_final;
float current_position_init;
float move;
bool endstop_triggered = false;
bool result = true;
int i;
unsigned long timeout_counter;
refresh_cmd_timeout();
@ -6003,112 +6002,89 @@ static bool lcd_selfcheck_pulleys(int axis)
if (axis == 0) move = 50; //X_AXIS
else move = 50; //Y_AXIS
//current_position_init = current_position[axis];
current_position_init = st_get_position_mm(axis);
current_position[axis] += 5;
current_position_init = current_position[axis];
current_position[axis] += 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
for (i = 0; i < 5; i++) {
refresh_cmd_timeout();
current_position[axis] = current_position[axis] + move;
//digipot_current(0, 850); //set motor current higher
digipot_current(0, 850); //set motor current higher
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 200, active_extruder);
st_synchronize();
//if (SilentModeMenu == 1) digipot_current(0, tmp_motor[0]); //set back to normal operation currents
//else digipot_current(0, tmp_motor_loud[0]); //set motor current back
if (SilentModeMenu == 1) digipot_current(0, tmp_motor[0]); //set back to normal operation currents
else digipot_current(0, tmp_motor_loud[0]); //set motor current back
current_position[axis] = current_position[axis] - move;
#ifdef TMC2130
tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 50, active_extruder);
st_synchronize();
if ((x_min_endstop) || (y_min_endstop)) {
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1)) {
lcd_selftest_error(8, (axis == 0) ? "X" : "Y", "");
return(false);
}
#ifdef TMC2130
tmc2130_home_exit();
#endif
}
timeout_counter = millis() + 2500;
endstop_triggered = false;
manage_inactivity(true);
while (!endstop_triggered) {
if ((x_min_endstop) || (y_min_endstop)) {
#ifdef TMC2130
tmc2130_home_exit();
#endif
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1)) {
endstop_triggered = true;
current_position_final = st_get_position_mm(axis);
SERIAL_ECHOPGM("current_pos_init:");
MYSERIAL.println(current_position_init);
SERIAL_ECHOPGM("current_pos:");
MYSERIAL.println(current_position_final);
lcd_selftest_error(8, (axis == 0) ? "X" : "Y", "");
if (current_position_init - 1 <= current_position_final && current_position_init + 1 >= current_position_final) {
if (current_position_init - 1 <= current_position[axis] && current_position_init + 1 >= current_position[axis]) {
current_position[axis] += 15;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize();
return(true);
}
else {
lcd_selftest_error(8, (axis == 0) ? "X" : "Y", "");
return(false);
}
}
else {
#ifdef TMC2130
tmc2130_home_exit();
#endif
//current_position[axis] -= 1;
current_position[axis] += 50;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
current_position[axis] -= 100;
#ifdef TMC2130
tmc2130_home_enter(X_AXIS_MASK << axis);
#endif
current_position[axis] -= 1;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder);
st_synchronize();
if (millis() > timeout_counter) {
lcd_selftest_error(8, (axis == 0) ? "X" : "Y", "");
return(false);
}
}
}
return(true);
}
static bool lcd_selfcheck_endstops()
{/*
{
bool _result = true;
if (x_min_endstop || y_min_endstop || READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1)
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1))
{
current_position[0] = (x_min_endstop) ? current_position[0] = current_position[0] + 10 : current_position[0];
current_position[1] = (y_min_endstop) ? current_position[1] = current_position[1] + 10 : current_position[1];
current_position[2] = (READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1) ? current_position[2] = current_position[2] + 10 : current_position[2];
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(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) current_position[2] += 10;
}
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[0] / 60, active_extruder);
delay(500);
if (x_min_endstop || y_min_endstop || READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1)
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1))
{
_result = false;
char _error[4] = "";
if (x_min_endstop) strcat(_error, "X");
if (y_min_endstop) strcat(_error, "Y");
if (READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING == 1) strcat(_error, "Z");
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(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) strcat(_error, "Z");
lcd_selftest_error(3, _error, "");
}
manage_heater();
manage_inactivity(true);
return _result;
*/
}
#endif //not defined TMC2130
static bool lcd_selfcheck_check_heater(bool _isbed)
{
@ -6321,7 +6297,7 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
switch (_fan)
{
case 1:
case 0:
// extruder cooling fan
lcd.setCursor(0, 1);
if(check_opposite == true) lcd_printPGM(MSG_SELFTEST_COOLING_FAN);
@ -6329,7 +6305,7 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
break;
case 2:
case 1:
// object cooling fan
lcd.setCursor(0, 1);
if (check_opposite == true) lcd_printPGM(MSG_SELFTEST_EXTRUDER_FAN);
@ -6350,12 +6326,12 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite)
{
switch (_fan)
{
case 1:
case 0:
// extruder cooling fan
SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
break;
case 2:
case 1:
// object cooling fan
SET_OUTPUT(FAN_PIN);
analogWrite(FAN_PIN, 255);
@ -6440,9 +6416,9 @@ static bool lcd_selftest_fan_dialog(int _fan)
else if (fan_speed[1] < 34) { //fan is spinning, but measured RPM are too low for print fan, it must be left extruder fan
//check fans manually
_result = lcd_selftest_manual_fan_check(2, true); //turn on print fan and check that left extruder fan is not spinning
_result = lcd_selftest_manual_fan_check(1, true); //turn on print fan and check that left extruder fan is not spinning
if (_result) {
_result = lcd_selftest_manual_fan_check(2, false); //print fan is stil turned on; check that it is spinning
_result = lcd_selftest_manual_fan_check(1, false); //print fan is stil turned on; check that it is spinning
if (!_result) _errno = 6; //print fan not spinning
}
else {
@ -6466,8 +6442,6 @@ static bool lcd_selftest_fan_dialog(int _fan)
static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay)
{
//SERIAL_ECHOPGM("Step:");
//MYSERIAL.println(_step);
lcd_next_update_millis = millis() + (LCD_UPDATE_INTERVAL * 10000);

View file

@ -36,21 +36,24 @@ void lcd_mylang();
static void lcd_selftest_v();
static bool lcd_selftest();
static bool lcd_selfcheck_endstops();
#ifdef TMC2130
static void reset_crash_det(char axis);
static bool lcd_selfcheck_axis_sg(char axis);
#endif //TMC2130
#else
static bool lcd_selfcheck_endstops();
static bool lcd_selfcheck_axis(int _axis, int _travel);
static bool lcd_selfcheck_pulleys(int axis);
#endif //TMC2130
static bool lcd_selfcheck_check_heater(bool _isbed);
static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay);
static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator);
static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite);
static bool lcd_selftest_fan_dialog(int _fan);
static bool lcd_selftest_fsensor();
static void lcd_selftest_error(int _error_no, const char *_error_1, const char *_error_2);
void lcd_menu_statistics();
static bool lcd_selfcheck_pulleys(int axis);
extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
inline const char* lcd_display_message_fullscreen_P(const char *msg)