Merge pull request #465 from PavelSindler/selftest_for_MK25

MK2.5: last changes from MK3 branch ported, selftest: initial version, max endstops not used
This commit is contained in:
XPila 2018-02-07 11:12:28 +01:00 committed by GitHub
commit 37f138ed3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 189 additions and 159 deletions

View file

@ -7,8 +7,8 @@
#define STR(x) STR_HELPER(x)
// Firmware version
#define FW_VERSION "3.1.1-RC5"
#define FW_COMMIT_NR 151
#define FW_VERSION "3.1.2-alpha"
#define FW_COMMIT_NR 201
// FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN

View file

@ -136,10 +136,12 @@ void Config_StoreSettings(uint16_t offset, uint8_t level)
}
#endif //LIN_ADVANCE
/*MYSERIAL.print("Top address used:\n");
/* MYSERIAL.print("Top address used:\n");
MYSERIAL.print(i);
MYSERIAL.print("\n");
*/
MYSERIAL.print("; (0x");
MYSERIAL.print(i, HEX);
MYSERIAL.println(")");
*/
char ver2[4]=EEPROM_VERSION;
i=offset;
EEPROM_WRITE_VAR(i,ver2); // validate data

View file

@ -271,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
@ -461,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

@ -379,6 +379,7 @@ float temp_comp_interpolation(float temperature);
void temp_compensation_apply();
void temp_compensation_start();
void show_fw_version_warnings();
void erase_eeprom_section(uint16_t offset, uint16_t bytes);
#ifdef PINDA_THERMISTOR
float temp_compensation_pinda_thermistor_offset(float temperature_pinda);
@ -391,7 +392,10 @@ bool check_commands();
void uvlo_();
void recover_print(uint8_t automatic);
void setup_uvlo_interrupt();
#if defined(TACH_1) && TACH_1 >-1
void setup_fan_interrupt();
#endif
extern void recover_machine_state_after_power_panic();
extern void restore_print_from_eeprom();

View file

@ -935,6 +935,13 @@ void show_fw_version_warnings() {
lcd_update_enable(true);
}
void erase_eeprom_section(uint16_t offset, uint16_t bytes)
{
for (int i = offset; i < (offset+bytes); i++) eeprom_write_byte((uint8_t*)i, 0xFF);
}
// "Setup" function is called by the Arduino framework on startup.
// Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code
// are initialized by the main() routine provided by the Arduino framework.
@ -1123,10 +1130,10 @@ void setup()
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
#ifdef SNMM
if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM
int _z = BOWDEN_LENGTH;
@ -1172,9 +1179,10 @@ void setup()
setup_uvlo_interrupt();
#endif //UVLO_SUPPORT
#ifndef DEBUG_DISABLE_FANCHECK
#if !defined(DEBUG_DISABLE_FANCHECK) && defined(TACH_1) && TACH_1 >-1
setup_fan_interrupt();
#endif //DEBUG_DISABLE_FANCHECK
#ifndef DEBUG_DISABLE_FSENSORCHECK
fsensor_setup_interrupt();
#endif //DEBUG_DISABLE_FSENSORCHECK
@ -1185,8 +1193,10 @@ void setup()
show_fw_version_warnings();
if (!previous_settings_retrieved) lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded
if (!previous_settings_retrieved) {
lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded
erase_eeprom_section(EEPROM_OFFSET, 156); //erase M500 part of eeprom
}
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) {
lcd_wizard(0);
}
@ -5761,6 +5771,11 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
//plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 3500 / 60, active_extruder);
target[E_AXIS] -= FILAMENTCHANGE_FINALRETRACT;
st_synchronize();
#ifdef TMC2130
uint8_t tmc2130_current_r_bckp = tmc2130_current_r[E_AXIS];
tmc2130_set_current_r(E_AXIS, TMC2130_UNLOAD_CURRENT_R);
#endif //TMC2130
target[E_AXIS] -= 45;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 5200 / 60, active_extruder);
st_synchronize();
@ -5770,7 +5785,9 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
target[E_AXIS] -= 20;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 1000 / 60, active_extruder);
st_synchronize();
#ifdef TMC2130
tmc2130_set_current_r(E_AXIS, tmc2130_current_r_bckp);
#endif //TMC2130
#endif // SNMM
@ -6182,7 +6199,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
lcd_setstatuspgm(MSG_UNLOADING_FILAMENT);
// extr_unload2();
current_position[E_AXIS] -= 45;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 5200 / 60, active_extruder);
st_synchronize();
@ -7632,6 +7649,8 @@ void uvlo_()
}
#endif //UVLO_SUPPORT
#if defined(TACH_1) && TACH_1 >-1
void setup_fan_interrupt() {
//INT7
DDRE &= ~(1 << 7); //input pin
@ -7662,6 +7681,8 @@ ISR(INT7_vect) {
EICRB ^= (1 << 6); //change edge
}
#endif
#ifdef UVLO_SUPPORT
void setup_uvlo_interrupt() {
DDRE &= ~(1 << 4); //input pin

View file

@ -478,8 +478,8 @@ const char * const MSG_DATE_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_DATE_CZ
};
const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded";
const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Nahrano vychozi nastaveni";
const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Old settings found. Default PID, Esteps etc. will be set.";
const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Neplatne hodnoty nastaveni. Bude pouzito vychozi PID, Esteps atd.";
const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_DEFAULT_SETTINGS_LOADED_EN,
MSG_DEFAULT_SETTINGS_LOADED_CZ

View file

@ -375,7 +375,7 @@
#define MSG_CHECK_IDLER "Prosim otevrete idler a manualne odstrante filament."
#define MSG_FILE_INCOMPLETE "Soubor nekompletni. Pokracovat?"
#define MSG_FILE_CNT "Nektere soubory nebudou setrideny. Maximalni pocet souboru pro setrideni je 100."
#define MSG_DEFAULT_SETTINGS_LOADED "Nahrano vychozi nastaveni"
#define MSG_DEFAULT_SETTINGS_LOADED "Neplatne hodnoty nastaveni. Bude pouzito vychozi PID, Esteps atd."
#define MSG_SORT_TIME "Trideni [Cas]"
#define MSG_SORT_ALPHA "Trideni [Abeceda]"
#define MSG_SORT_NONE "Trideni [Zadne]"

View file

@ -392,7 +392,7 @@
#define(length=20, lines=4) MSG_PULL_OUT_FILAMENT "Please pull out filament immediately"
#define(length=20, lines=2) MSG_FILE_INCOMPLETE "File incomplete. Continue anyway?"
#define(length=20, lines=4) MSG_DEFAULT_SETTINGS_LOADED "Default settings loaded"
#define(length=20, lines=4) MSG_DEFAULT_SETTINGS_LOADED "Old settings found. Default PID, Esteps etc. will be set."
#define(length=17, lines=1) MSG_SORT_TIME "Sort: [Time]"
#define(length=17, lines=1) MSG_SORT_ALPHA "Sort: [Alphabet]"
#define(length=17, lines=1) MSG_SORT_NONE "Sort: [None]"

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
@ -134,3 +135,4 @@
#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)

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()
{
@ -475,12 +475,14 @@ void checkFanSpeed()
{
fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0);
static unsigned char fan_speed_errors[2] = { 0,0 };
#if defined(TACH_0) && TACH_0 >-1
if (fan_speed[0] == 0 && (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)) fan_speed_errors[0]++;
else fan_speed_errors[0] = 0;
#endif
#if defined(TACH_1) && TACH_1 >-1
if ((fan_speed[1] == 0)&& (fanSpeed > MIN_PRINT_FAN_SPEED)) fan_speed_errors[1]++;
else fan_speed_errors[1] = 0;
#endif
if ((fan_speed_errors[0] > 5) && fans_check_enabled) fanSpeedError(0); //extruder fan
if ((fan_speed_errors[1] > 15) && fans_check_enabled) fanSpeedError(1); //print fan
@ -528,7 +530,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 +713,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 +1915,7 @@ ISR(TIMER0_COMPB_vect)
}
#endif //BABYSTEPPING
#if (defined(TACH_0))
#if (defined(TACH_0) && TACH_0 > -1)
check_fans();
#endif //(defined(TACH_0))
@ -1990,8 +1992,8 @@ void check_min_temp()
check_min_temp_heater0();
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
@ -3707,7 +3708,7 @@ void lcd_wizard(int state) {
case CALIBRATION_STATUS_CALIBRATED: end = true; eeprom_write_byte((uint8_t*)EEPROM_WIZARD_ACTIVE, 0); break;
default: state = 2; break; //if calibration status is unknown, run wizard from the beginning
}
break;
break;
case 2: //selftest
lcd_show_fullscreen_message_and_wait_P(MSG_WIZARD_SELFTEST);
wizard_event = lcd_selftest();
@ -5629,14 +5630,21 @@ 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)
{
_progress = lcd_selftest_screen(1, _progress, 3, true, 2000);
//_progress = lcd_selftest_screen(2, _progress, 3, true, 2000);
_result = true;// lcd_selfcheck_endstops();
#ifndef TMC2130
_result = lcd_selfcheck_endstops();
#else
_result = true;
#endif
}
if (_result)
@ -5885,13 +5893,11 @@ static bool lcd_selfcheck_axis_sg(char axis) {
return true;
}
#endif //TMC2130
#ifndef TMC2130
static bool lcd_selfcheck_axis(int _axis, int _travel)
{
bool _stepdone = false;
bool _stepresult = false;
int _progress = 0;
@ -5899,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)
{
@ -5941,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;
}
@ -5950,7 +5954,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
//delay(100);
(_travel_done <= _travel) ? _travel_done++ : _stepdone = true;
} while (!_stepdone);
@ -5980,7 +5984,6 @@ static bool lcd_selfcheck_axis(int _axis, int _travel)
}
}
return _stepresult;
}
@ -5988,124 +5991,100 @@ 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();
manage_inactivity(true);
if (axis == 0) move = 50; //X_AXIS
else move = 50; //Y_AXIS
else move = 50; //Y_AXIS
//current_position_init = current_position[axis];
current_position_init = st_get_position_mm(axis);
current_position[axis] += 5;
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
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
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)) {
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
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
current_position[axis] = current_position[axis] - move;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], 50, active_extruder);
st_synchronize();
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);
}
}
timeout_counter = millis() + 2500;
endstop_triggered = false;
manage_inactivity(true);
while (!endstop_triggered) {
if (((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ||
((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1)) {
endstop_triggered = true;
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);
}
#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
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);
else {
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", "");
if (current_position_init - 1 <= current_position_final && current_position_init + 1 >= current_position_final) {
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 {
return(false);
}
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
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)
{
@ -6318,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);
@ -6326,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);
@ -6347,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);
@ -6437,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 {
@ -6463,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);
void lcd_menu_statistics();
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)

View file

@ -86,7 +86,7 @@ inline bool parse_version(const char *str, uint16_t version[4])
version[3] = FIRMWARE_REVISION_ALPHA;
else if (n == strlen_P(STR_REVISION_BETA) && strncmp_P(p, STR_REVISION_BETA, n) == 0)
version[3] = FIRMWARE_REVISION_BETA;
else if ((n == 2 || n == 3) && p[0] == 'r' && p[1] == 'c') {
else if ((n == 2 || n == 3) && (p[0] == 'r' || p[0] == 'R') && (p[1] == 'c' || p[1] == 'C')) {
if (n == 2)
version[3] = FIRMWARE_REVISION_RC;
else {
@ -116,12 +116,22 @@ inline bool parse_version(const char *str, uint16_t version[4])
inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n)
{
for (; n > 0; -- n, ++ p1, ++ p2) {
if (pgm_read_byte(p1) < pgm_read_byte(p2))
return -1;
if (pgm_read_byte(p1) > pgm_read_byte(p2))
return 1;
if (pgm_read_byte(p1) == 0)
return 0;
if (pgm_read_byte(p1) >= 65 && pgm_read_byte(p1) <= 92) //p1 is upper case (p2 is always lowercase)
{
if ((pgm_read_byte(p1)+32) < pgm_read_byte(p2))
return -1;
if ((pgm_read_byte(p1)+32) > pgm_read_byte(p2))
return 1;
}
else if (pgm_read_byte(p1) == 0) {
return 0;
}
else { //p1 is lowercase
if (pgm_read_byte(p1) < pgm_read_byte(p2))
return -1;
if (pgm_read_byte(p1) > pgm_read_byte(p2))
return 1;
}
}
return 0;
}