Undo babystepping in Z before G28 / G80, if applied already.

Update babystepsTodo atomically (disable / enable interrupts).
Disable debugging outputs on the serial line from the X/Y calibration code.
OctoPrint fix - fixes a hangup after G28: Link the G28->G80 G codes
by calling the G80 code directly without pushing it into the command buffer.
SD card driver patch to support the Toshiba FlashAir SD/WiFi card.
This commit is contained in:
bubnikv 2016-07-18 17:28:54 +02:00
parent 3c21438392
commit 2e6e4542c9
5 changed files with 78 additions and 31 deletions

View file

@ -235,7 +235,8 @@ byte b[2];
int value;
};
int babystepLoad[3];
// Number of baby steps applied
int babystepLoadZ = 0;
float homing_feedrate[] = HOMING_FEEDRATE;
// Currently only the extruder axis may be switched to a relative mode.
@ -738,7 +739,7 @@ void enquecommand(const char *cmd, bool from_progmem)
cmdqueue_dump_to_serial();
#endif /* CMDBUFFER_DEBUG */
} else {
SERIAL_ECHO_START;
SERIAL_ERROR_START;
SERIAL_ECHORPGM(MSG_Enqueing);
if (from_progmem)
SERIAL_PROTOCOLRPGM(cmd);
@ -770,7 +771,7 @@ void enquecommand_front(const char *cmd, bool from_progmem)
cmdqueue_dump_to_serial();
#endif /* CMDBUFFER_DEBUG */
} else {
SERIAL_ECHO_START;
SERIAL_ERROR_START;
SERIAL_ECHOPGM("Enqueing to the front: \"");
if (from_progmem)
SERIAL_PROTOCOLRPGM(cmd);
@ -1907,6 +1908,11 @@ void process_commands()
// Wait for the motors to stop and update the current position with the absolute values.
world2machine_revert_to_uncorrected();
// Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be
// consumed during the first movements following this statement.
babystepsTodoZsubtract(babystepLoadZ);
babystepLoadZ = 0;
saved_feedrate = feedrate;
saved_feedmultiply = feedmultiply;
feedmultiply = 100;
@ -2114,11 +2120,12 @@ void process_commands()
previous_millis_cmd = millis();
endstops_hit_on_purpose();
#ifndef MESH_BED_LEVELING
// If MESH_BED_LEVELING is not active, then it is the original Prusa i3.
// Offer the user to load the baby step value, which has been adjusted at the previous print session.
if(card.sdprinting) {
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoad[2]);
if(babystepLoad[2] != 0){
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoadZ);
if(babystepLoadZ != 0)
lcd_adjust_z();
}
}
#endif
@ -2139,7 +2146,8 @@ void process_commands()
st_synchronize();
// Push the commands to the front of the message queue in the reverse order!
// There shall be always enough space reserved for these commands.
enquecommand_front_P((PSTR("G80")));
// enquecommand_front_P((PSTR("G80")));
goto case_G80;
}
#endif
@ -2334,6 +2342,7 @@ void process_commands()
*
*/
case 80:
case_G80:
{
if (!IS_SD_PRINTING)
{
@ -2354,9 +2363,14 @@ void process_commands()
}
mbl.reset();
// Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be
// consumed during the first movements following this statement.
babystepsTodoZsubtract(babystepLoadZ);
babystepLoadZ = 0;
// Cycle through all points and probe them
// First move up.
// First move up. During this first movement, the babystepping will be reverted.
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
// The move to the first calibration point.
@ -2450,8 +2464,9 @@ void process_commands()
{
if(eeprom_read_byte((unsigned char*)EEPROM_BABYSTEP_Z_SET) == 0x01)
{
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoad[2]);
babystepsTodo[Z_AXIS] = babystepLoad[2];
// End of G80: Apply the baby stepping value.
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoadZ);
babystepsTodoZadd(babystepLoadZ);
}
}
}
@ -2497,7 +2512,7 @@ void process_commands()
break;
/**
* G83: Babystep in Z and store to EEPROM
* G83: Prusa3D specific: Babystep in Z and store to EEPROM
*/
case 83:
{
@ -2505,15 +2520,16 @@ void process_commands()
int BabyPosition = code_seen('P') ? code_value() : 0;
if (babystepz != 0) {
//FIXME Vojtech: What shall be the index of the axis Z: 3 or 4?
// Is the axis indexed starting with zero or one?
if (BabyPosition > 4) {
SERIAL_PROTOCOLLNPGM("Index out of bounds");
}else{
// Save it to the eeprom
babystepLoad[2] = babystepz;
EEPROM_save_B(EEPROM_BABYSTEP_Z0+(BabyPosition*2),&babystepLoad[2]);
// adjist the Z
babystepsTodo[Z_AXIS] = babystepLoad[2];
babystepLoadZ = babystepz;
EEPROM_save_B(EEPROM_BABYSTEP_Z0+(BabyPosition*2),&babystepLoadZ);
// adjust the Z
babystepsTodoZadd(babystepLoadZ);
}
}
@ -2521,27 +2537,30 @@ void process_commands()
}
break;
/**
* G84: UNDO Babystep Z (move Z axis back)
* G84: Prusa3D specific: UNDO Babystep Z (move Z axis back)
*/
case 84:
babystepsTodo[Z_AXIS] = -babystepLoad[2];
babystepsTodoZsubtract(babystepLoadZ);
// babystepLoadZ = 0;
break;
/**
* G85: Pick best babystep
* G85: Prusa3D specific: Pick best babystep
*/
case 85:
lcd_pick_babystep();
break;
/**
* G86: Disable babystep correction after home
* G86: Prusa3D specific: Disable babystep correction after home.
* This G-code will be performed at the start of a calibration script.
*/
case 86:
eeprom_write_byte((unsigned char*)EEPROM_BABYSTEP_Z_SET, 0xFF);
break;
/**
* G87: Enable babystep correction after home
* G87: Prusa3D specific: Enable babystep correction after home
* This G-code will be performed at the end of a calibration script.
*/
case 87:
eeprom_write_byte((unsigned char*)EEPROM_BABYSTEP_Z_SET, 0x01);

View file

@ -500,10 +500,14 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
spiRec();
#endif
chipSelectHigh();
// Toshiba FlashAir Patch. Purge pending status byte.
spiSend(0XFF);
return true;
fail:
chipSelectHigh();
// Toshiba FlashAir Patch. Purge pending status byte.
spiSend(0XFF);
return false;
}
//------------------------------------------------------------------------------

View file

@ -580,7 +580,7 @@ static inline bool vec_undef(const float v[2])
void world2machine_initialize()
{
SERIAL_ECHOLNPGM("world2machine_initialize()");
// SERIAL_ECHOLNPGM("world2machine_initialize()");
float cntr[2] = {
eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER+0)),
eeprom_read_float((float*)(EEPROM_BED_CALIBRATION_CENTER+4))
@ -596,7 +596,7 @@ void world2machine_initialize()
bool reset = false;
if (vec_undef(cntr) || vec_undef(vec_x) || vec_undef(vec_y)) {
SERIAL_ECHOLNPGM("Undefined bed correction matrix.");
// SERIAL_ECHOLNPGM("Undefined bed correction matrix.");
reset = true;
}
else {
@ -632,6 +632,7 @@ void world2machine_initialize()
world2machine_reset();
} else {
world2machine_update(vec_x, vec_y, cntr);
/*
SERIAL_ECHOPGM("world2machine_initialize() loaded: ");
MYSERIAL.print(world2machine_rotation_and_skew[0][0], 5);
SERIAL_ECHOPGM(", ");
@ -645,6 +646,7 @@ void world2machine_initialize()
SERIAL_ECHOPGM(", ");
MYSERIAL.print(world2machine_shift[1], 5);
SERIAL_ECHOLNPGM("");
*/
}
}
@ -695,7 +697,7 @@ static inline void update_current_position_z()
// At the current position, find the Z stop.
inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter)
{
SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 1");
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 1");
bool endstops_enabled = enable_endstops(true);
bool endstop_z_enabled = enable_z_endstop(false);
float z = 0.f;
@ -720,9 +722,9 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter)
update_current_position_z();
if (! endstop_z_hit_on_purpose())
goto error;
SERIAL_ECHOPGM("Bed find_bed_induction_sensor_point_z low, height: ");
MYSERIAL.print(current_position[Z_AXIS], 5);
SERIAL_ECHOLNPGM("");
// SERIAL_ECHOPGM("Bed find_bed_induction_sensor_point_z low, height: ");
// MYSERIAL.print(current_position[Z_AXIS], 5);
// SERIAL_ECHOLNPGM("");
z += current_position[Z_AXIS];
}
current_position[Z_AXIS] = z;
@ -731,11 +733,11 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter)
enable_endstops(endstops_enabled);
enable_z_endstop(endstop_z_enabled);
SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
return true;
error:
SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 4");
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 4");
enable_endstops(endstops_enabled);
enable_z_endstop(endstop_z_enabled);
return false;

View file

@ -73,7 +73,25 @@ extern float current_temperature_bed;
#ifdef BABYSTEPPING
extern volatile int babystepsTodo[3];
#endif
inline void babystepsTodoZadd(int n)
{
if (n != 0) {
CRITICAL_SECTION_START
babystepsTodo[Z_AXIS] += n;
CRITICAL_SECTION_END
}
}
inline void babystepsTodoZsubtract(int n)
{
if (n != 0) {
CRITICAL_SECTION_START
babystepsTodo[Z_AXIS] -= n;
CRITICAL_SECTION_END
}
}
//high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease.
//deg=degreeCelsius

View file

@ -1093,7 +1093,9 @@ static void lcd_move_z() {
static void _lcd_babystep(int axis, const char *msg) {
if (encoderPosition != 0)
{
CRITICAL_SECTION_START
babystepsTodo[axis] += (int)encoderPosition;
CRITICAL_SECTION_END
babystepMem[axis] += (int)encoderPosition;
babystepMemMM[axis] = babystepMem[axis]/axis_steps_per_unit[Z_AXIS];
delay(50);
@ -1188,7 +1190,9 @@ void lcd_adjust_z() {
EEPROM_read_B(EEPROM_BABYSTEP_X, &babystepMem[0]);
EEPROM_read_B(EEPROM_BABYSTEP_Y, &babystepMem[1]);
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepMem[2]);
CRITICAL_SECTION_START
babystepsTodo[Z_AXIS] = babystepMem[2];
CRITICAL_SECTION_END
} else {
babystepMem[0] = 0;
babystepMem[1] = 0;