Merge pull request #82 from PavelSindler/MK2

pause print statistics fixed, pinda temperature compensation extrapolation, pinda preheat coordinates changed, button timeout to status, redefinition removed
This commit is contained in:
PavelSindler 2017-04-25 13:44:42 +02:00 committed by GitHub
commit 67a2e9f8b4
8 changed files with 45 additions and 36 deletions

View file

@ -5,7 +5,7 @@
#include "Configuration_prusa.h"
// Firmware version
#define FW_version "3.0.10-9"
#define FW_version "3.0.10-10"
#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
#define FW_PRUSA3D_MAGIC_LEN 10

View file

@ -317,6 +317,7 @@ extern float HotendTempBckp;
extern int fanSpeedBckp;
extern float pause_lastpos[4];
extern unsigned long pause_time;
extern unsigned long start_pause_print;
extern bool mesh_bed_leveling_flag;

View file

@ -263,6 +263,7 @@ float HotendTempBckp = 0;
int fanSpeedBckp = 0;
float pause_lastpos[4];
unsigned long pause_time = 0;
unsigned long start_pause_print = millis();
bool mesh_bed_leveling_flag = false;
@ -2791,6 +2792,17 @@ void process_commands()
}
break;
case 75:
{
for (int i = 40; i <= 110; i++) {
MYSERIAL.print(i);
MYSERIAL.print(" ");
MYSERIAL.println(temp_comp_interpolation(i));// / axis_steps_per_unit[Z_AXIS]);
}
}
break;
case 76: //PINDA probe temperature calibration
{
setTargetBed(PINDA_MIN_T);
@ -2812,7 +2824,7 @@ void process_commands()
custom_message = MSG_TEMP_CALIBRATION;
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = 0;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
st_synchronize();
@ -2845,7 +2857,7 @@ void process_commands()
setTargetBed(t_c);
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = 0;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
st_synchronize();
while (degBed() < t_c) delay_keep_alive(1000);
@ -2926,7 +2938,7 @@ void process_commands()
*
*/
case 80:
case 80:
case_G80:
{
mesh_bed_leveling_flag = true;
@ -6315,11 +6327,11 @@ void temp_compensation_start() {
current_position[X_AXIS] = PINDA_PREHEAT_X;
current_position[Y_AXIS] = PINDA_PREHEAT_Y;
current_position[Z_AXIS] = 0;
current_position[Z_AXIS] = PINDA_PREHEAT_Z;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder);
st_synchronize();
while (fabs(degBed() - target_temperature_bed) > 3) delay_keep_alive(1000);
while (fabs(degBed() - target_temperature_bed) > 1) delay_keep_alive(1000);
for(int i = 0; i < PINDA_HEAT_T; i++) delay_keep_alive(1000);
@ -6334,12 +6346,11 @@ void temp_compensation_apply() {
float z_shift_mm;
if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) {
if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 50 && target_temperature_bed <= 100) {
if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) {
i_add = (target_temperature_bed - 60) / 10;
EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift);
z_shift_mm = z_shift / axis_steps_per_unit[Z_AXIS];
}
else {
}else {
//interpolation
z_shift_mm = temp_comp_interpolation(target_temperature_bed) / axis_steps_per_unit[Z_AXIS];
}
@ -6351,7 +6362,7 @@ void temp_compensation_apply() {
plan_set_z_position(current_position[Z_AXIS]);
}
else {
//message that we have no temp compensation data ?
//we have no temp compensation data
}
}
@ -6360,23 +6371,21 @@ float temp_comp_interpolation(float inp_temperature) {
//cubic spline interpolation
int n, i, j, k;
float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], p, m[10][10] = { 0 }, temp;
float h[10], a, b, c, d, sum, s[10] = { 0 }, x[10], F[10], f[10], m[10][10] = { 0 }, temp;
int shift[10];
int temp_C[10];
p = inp_temperature;
n = 6; //number of measured points
shift[0] = 0;
for (i = 0; i < n; i++) {
//scanf_s("%f%f", &x[i], &f[i]);
if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM
temp_C[i] = 50 + i * 10; //temperature in C
x[i] = (float)temp_C[i];
f[i] = (float)shift[i];
}
if (inp_temperature < x[0]) return 0;
for (i = n - 1; i>0; i--) {
@ -6407,12 +6416,12 @@ float temp_comp_interpolation(float inp_temperature) {
}
for (i = 0; i<n - 1; i++)
if (x[i] <= p&&p <= x[i + 1]) {
if ((x[i] <= inp_temperature && inp_temperature <= x[i + 1]) || (i == n-2 && inp_temperature > x[i + 1])) {
a = (s[i + 1] - s[i]) / (6 * h[i]);
b = s[i] / 2;
c = (f[i + 1] - f[i]) / h[i] - (2 * h[i] * s[i] + s[i + 1] * h[i]) / 6;
d = f[i];
sum = a*pow((p - x[i]), 3) + b*pow((p - x[i]), 2) + c*(p - x[i]) + d;
sum = a*pow((inp_temperature - x[i]), 3) + b*pow((inp_temperature - x[i]), 2) + c*(inp_temperature - x[i]) + d;
}
return sum;
@ -6427,8 +6436,8 @@ void long_pause() //long pause print
saved_feedmultiply = feedmultiply;
HotendTempBckp = degTargetHotend(active_extruder);
fanSpeedBckp = fanSpeed;
pause_time += (millis() - starttime);
start_pause_print = millis();
//save position
pause_lastpos[X_AXIS] = current_position[X_AXIS];

View file

@ -277,7 +277,7 @@
#define MSG_CALIBRATE_PINDA "Zkalibrovat"
#define MSG_CALIBRATION_PINDA_MENU "Teplotni kalibrace"
#define MSG_PINDA_NOT_CALIBRATED "Tiskarna nebyla teplotne zkalibrovana"
#define MSG_PINDA_PREHEAT "Predehrivani"
#define MSG_PINDA_PREHEAT "Predehrivani "
#define MSG_TEMP_CALIBRATION "Tepl. kal. "
#define MSG_TEMP_CALIBRATION_DONE "Teplotni kalibrace dokoncena. Pokracujte stiskem tlacitka."
#define MSG_TEMP_CALIBRATION_ON "Tepl. kal. [ON]"

View file

@ -278,7 +278,7 @@
#define(length=17, lines=1) MSG_CALIBRATE_PINDA "Calibrate"
#define(length=17, lines=1) MSG_CALIBRATION_PINDA_MENU "Temp. calibration"
#define(length=20, lines=4) MSG_PINDA_NOT_CALIBRATED "Temperature calibration has not been run yet"
#define(length=20, lines=1) MSG_PINDA_PREHEAT "Preheating"
#define(length=20, lines=1) MSG_PINDA_PREHEAT "Preheating "
#define(length=20, lines=1) MSG_TEMP_CALIBRATION "Temp. cal. "
#define(length=20, lines=4) MSG_TEMP_CALIBRATION_DONE "Temperature calibration is finished. Click to continue."
#define(length=20, lines=1) MSG_TEMP_CALIBRATION_ON "Temp. cal. [ON]"

View file

@ -114,10 +114,6 @@ long long_press_timer = millis();
long button_blanking_time = millis();
bool button_pressed = false;
bool long_press_active = false;
long long_press_timer = millis();
bool button_pressed = false;
bool menuExiting = false;
#ifdef FILAMENT_LCD_DISPLAY
@ -544,11 +540,12 @@ void lcd_commands()
lcdDrawUpdate = 3;
lcd_commands_step = 4;
}
if (lcd_commands_step == 1 && !blocks_queued()) { //recover feedmultiply, current
if (lcd_commands_step == 1 && !blocks_queued()) { //recover feedmultiply
sprintf_P(cmd1, PSTR("M220 S%d"), saved_feedmultiply);
enquecommand(cmd1);
isPrintPaused = false;
pause_time += (millis() - start_pause_print); //accumulate time when print is paused for correct statistics calculation
card.startFileprint();
lcd_commands_step = 0;
lcd_commands_type = 0;
@ -584,7 +581,7 @@ void lcd_commands()
strcat(cmd1, " Y");
strcat(cmd1, ftostr32(pause_lastpos[Y_AXIS]));
enquecommand(cmd1);
lcd_setstatuspgm(MSG_RESUMING_PRINT);
lcd_commands_step = 3;
}
@ -2440,7 +2437,6 @@ void lcd_pinda_calibration_menu()
START_MENU();
MENU_ITEM(back, MSG_MENU_CALIBRATION, lcd_calibration_menu);
MENU_ITEM(submenu, MSG_CALIBRATE_PINDA, lcd_calibrate_pinda);
//MENU_ITEM(back, MSG_SETTINGS, lcd_settings_menu);
if (temp_cal_active == false) {
MENU_ITEM(function, MSG_TEMP_CALIBRATION_OFF, lcd_temp_calibration_set);
}
@ -4655,7 +4651,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
}
/*if (LCD_CLICKED)*/ lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
if (LCD_CLICKED) lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
#endif//ULTIPANEL
#ifdef DOGLCD // Changes due to different driver architecture of the DOGM display
@ -4792,6 +4788,7 @@ void lcd_buttons_update()
#if BTN_ENC > 0
if (lcd_update_enabled == true) { //if we are in non-modal mode, long press can be used and short press triggers with button release
if (READ(BTN_ENC) == 0) { //button is pressed
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
if (millis() > button_blanking_time) {
button_blanking_time = millis() + BUTTON_BLANKING_TIME;
if (button_pressed == false && long_press_active == false) {

View file

@ -370,8 +370,9 @@ THERMISTORS SETTINGS
#define Z_BABYSTEP_MIN -3999
#define Z_BABYSTEP_MAX 0
#define PINDA_PREHEAT_X 75
#define PINDA_PREHEAT_Y 75
#define PINDA_PREHEAT_X 70
#define PINDA_PREHEAT_Y -3
#define PINDA_PREHEAT_Z 1
#define PINDA_HEAT_T 120 //time in s
#define PINDA_MIN_T 50
@ -385,10 +386,10 @@ THERMISTORS SETTINGS
#define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release
#define PAUSE_RETRACT 2
#define PAUSE_RETRACT 1
#define DEFAULT_PID_TEMP 210
#define DEFAULT_RETRACTION 1 //used for PINDA temp compensation
#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration
#endif //__CONFIGURATION_PRUSA_H

View file

@ -373,8 +373,9 @@ THERMISTORS SETTINGS
#define Z_BABYSTEP_MIN -3999
#define Z_BABYSTEP_MAX 0
#define PINDA_PREHEAT_X 75
#define PINDA_PREHEAT_Y 75
#define PINDA_PREHEAT_X 70
#define PINDA_PREHEAT_Y -3
#define PINDA_PREHEAT_Z 1
#define PINDA_HEAT_T 120 //time in s
#define PINDA_MIN_T 50
@ -388,10 +389,10 @@ THERMISTORS SETTINGS
#define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release
#define PAUSE_RETRACT 2
#define PAUSE_RETRACT 1
#define DEFAULT_PID_TEMP 210
#define DEFAULT_RETRACTION 1 //used for PINDA temp compensation
#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration
#endif //__CONFIGURATION_PRUSA_H