From 789ba02d43a2b940a032d0e4f87a0b92c920a940 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 14:13:53 +0200 Subject: [PATCH 01/16] fixed typo in comment --- Marlin/Marlin.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 1f2908766..0164a761a 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1246,7 +1246,7 @@ void process_commands() } break; - case 302: // finish all moves + case 302: // allow cold extrudes { allow_cold_extrudes(true); } From 060b38de5c72dd0a98e222f8d7f5e000f7cc6fdf Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 14:15:46 +0200 Subject: [PATCH 02/16] delete obsolete and wrong code "i" runs from 0 to 4 but "add_homeing" array size is 3 only. On the other hand the calculated value gets overwritten by either one of the if choice. --- Marlin/Marlin.pde | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 0164a761a..2facb9429 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -687,7 +687,6 @@ void process_commands() st_synchronize(); for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) { - current_position[i] = code_value()+add_homeing[i]; if(i == E_AXIS) { current_position[i] = code_value(); plan_set_e_position(current_position[E_AXIS]); From bd1ad7c76a8d6eb770c5a982817f4ce206f95770 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 14:22:43 +0200 Subject: [PATCH 03/16] explicit includes to make it compile with AVRStudio/Eclipse --- Marlin/ultralcd.pde | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index c6cd15bb0..a10fbb342 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -1,6 +1,9 @@ #include "ultralcd.h" #ifdef ULTRA_LCD #include "Marlin.h" +#include "language.h" +#include "temperature.h" +#include "EEPROMwrite.h" #include //=========================================================================== //=============================imported variables============================ @@ -13,6 +16,7 @@ extern volatile int extrudemultiply; extern long position[4]; #ifdef SDSUPPORT +#include "cardreader.h" extern CardReader card; #endif From 032df0b2c6dde69303f60ee05681e046b1a4aab3 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 14:28:17 +0200 Subject: [PATCH 04/16] Moved LCD initialization out of constructor Since the class "MainMenu" was used within a static variable the initialization of the object (constructor call) was done before Arduino library startup. It always caused a crash when using AVRStudio with JTAG debugger (caused from calling the LCD initialization / the lot of I/O work / the stack used during this calls). By moving the LCD_INIT out of the constructor and using an explicit call inside of Arduino setup() implementation immediately fixed all problems and the JTAG debugger runs fine. --- Marlin/Marlin.pde | 2 ++ Marlin/ultralcd.h | 3 ++- Marlin/ultralcd.pde | 7 +++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 2facb9429..c9cff67de 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -300,6 +300,8 @@ void setup() st_init(); // Initialize stepper; wd_init(); setup_photpin(); + + LCD_INIT; } diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 253149cbb..39d262222 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -134,11 +134,12 @@ char *ftostr3(const float &x); - + #define LCD_INIT lcd_init(); #define LCD_MESSAGE(x) lcd_status(x); #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x)); #define LCD_STATUS lcd_status() #else //no lcd + #define LCD_INIT #define LCD_STATUS #define LCD_MESSAGE(x) #define LCD_MESSAGEPGM(x) diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index a10fbb342..912402294 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -99,6 +99,9 @@ FORCE_INLINE void clear() void lcd_init() { //beep(); + #ifdef ULTIPANEL + buttons_init(); + #endif byte Degree[8] = { @@ -306,10 +309,6 @@ MainMenu::MainMenu() displayStartingRow=0; activeline=0; force_lcd_update=true; - #ifdef ULTIPANEL - buttons_init(); - #endif - lcd_init(); linechanging=false; tune=false; } From 3682d9bd5b34bdc6560d97278d6d7eff3243bddc Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 15:43:23 +0200 Subject: [PATCH 05/16] magic PROGMEM defines to avoid hundreds of wrong GCC warnings --- Marlin/Marlin.h | 7 +++++++ Marlin/thermistortables.h | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 5bb728c6f..5982302da 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -20,6 +20,13 @@ #include #include +//do some magic defines in order to prevent hundreds of wrong warnings in gcc +//more info here: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=646359 +typedef short prog_short PROGMEM; +#undef PROGMEM +#define PROGMEM __attribute__(( section(".progmem.data") )) +#undef PSTR +#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) #include "fastio.h" #include "Configuration.h" diff --git a/Marlin/thermistortables.h b/Marlin/thermistortables.h index 3071a6b5b..0ac03d510 100644 --- a/Marlin/thermistortables.h +++ b/Marlin/thermistortables.h @@ -7,7 +7,7 @@ #if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor -const short temptable_1[][2] PROGMEM = { +const prog_short temptable_1[][2] = { { 23*OVERSAMPLENR , 300 }, { 25*OVERSAMPLENR , 295 }, { 27*OVERSAMPLENR , 290 }, @@ -72,7 +72,7 @@ const short temptable_1[][2] PROGMEM = { }; #endif #if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor -const short temptable_2[][2] PROGMEM = { +const prog_short temptable_2[][2] = { {1*OVERSAMPLENR, 848}, {54*OVERSAMPLENR, 275}, {107*OVERSAMPLENR, 228}, @@ -98,7 +98,7 @@ const short temptable_2[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts -const short temptable_3[][2] PROGMEM = { +const prog_short temptable_3[][2] = { {1*OVERSAMPLENR,864}, {21*OVERSAMPLENR,300}, {25*OVERSAMPLENR,290}, @@ -131,7 +131,7 @@ const short temptable_3[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor -const short temptable_4[][2] PROGMEM = { +const prog_short temptable_4[][2] = { {1*OVERSAMPLENR, 430}, {54*OVERSAMPLENR, 137}, {107*OVERSAMPLENR, 107}, @@ -156,7 +156,7 @@ const short temptable_4[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2) -const short temptable_5[][2] PROGMEM = { +const prog_short temptable_5[][2] = { {1*OVERSAMPLENR, 713}, {18*OVERSAMPLENR, 316}, {35*OVERSAMPLENR, 266}, @@ -222,7 +222,7 @@ const short temptable_5[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor -const short temptable_6[][2] PROGMEM = { +const prog_short temptable_6[][2] = { {28*OVERSAMPLENR, 250}, {31*OVERSAMPLENR, 245}, {35*OVERSAMPLENR, 240}, @@ -263,7 +263,7 @@ const short temptable_6[][2] PROGMEM = { #endif #if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01 -const short temptable_7[][2] PROGMEM = { +const prog_short temptable_7[][2] = { {46*OVERSAMPLENR, 270}, {50*OVERSAMPLENR, 265}, {54*OVERSAMPLENR, 260}, From d188ae4c9d32ab87a31ac67e2bc587b7ed6c4d08 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Thu, 3 May 2012 15:48:44 +0200 Subject: [PATCH 06/16] added missing declaration of buttons_init() This is required when moving the buttons_init() function to the lcd_init() function --- Marlin/ultralcd.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 39d262222..ab5675d59 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -7,6 +7,7 @@ void lcd_init(); void lcd_status(const char* message); void beep(); + void buttons_init(); void buttons_check(); #define LCD_UPDATE_INTERVAL 100 From 108011085b9790cefec46928dec3e02e11277092 Mon Sep 17 00:00:00 2001 From: Bernhard Kubicek Date: Fri, 4 May 2012 08:37:49 +0300 Subject: [PATCH 07/16] futher docu of M500 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b61129b36..0448bdbe9 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,8 @@ Advance: EEPROM: -* M500 - stores paramters in EEPROM +* M500 - stores paramters in EEPROM. This parameters are stored: axis_steps_per_unit, max_feedrate, max_acceleration ,acceleration,retract_acceleration, + minimumfeedrate,mintravelfeedrate,minsegmenttime, jerk velocities, PID * M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). * M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. * M503 - print the current settings (from memory not from eeprom) From b657a18449356fb002199d17fbfc59fb21e8da0e Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Fri, 4 May 2012 12:24:07 +0200 Subject: [PATCH 08/16] Revert "magic PROGMEM defines to avoid hundreds of wrong GCC warnings" This reverts commit 3682d9bd5b34bdc6560d97278d6d7eff3243bddc. --- Marlin/Marlin.h | 7 ------- Marlin/thermistortables.h | 14 +++++++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 5982302da..5bb728c6f 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -20,13 +20,6 @@ #include #include -//do some magic defines in order to prevent hundreds of wrong warnings in gcc -//more info here: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=646359 -typedef short prog_short PROGMEM; -#undef PROGMEM -#define PROGMEM __attribute__(( section(".progmem.data") )) -#undef PSTR -#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) #include "fastio.h" #include "Configuration.h" diff --git a/Marlin/thermistortables.h b/Marlin/thermistortables.h index 0ac03d510..3071a6b5b 100644 --- a/Marlin/thermistortables.h +++ b/Marlin/thermistortables.h @@ -7,7 +7,7 @@ #if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor -const prog_short temptable_1[][2] = { +const short temptable_1[][2] PROGMEM = { { 23*OVERSAMPLENR , 300 }, { 25*OVERSAMPLENR , 295 }, { 27*OVERSAMPLENR , 290 }, @@ -72,7 +72,7 @@ const prog_short temptable_1[][2] = { }; #endif #if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor -const prog_short temptable_2[][2] = { +const short temptable_2[][2] PROGMEM = { {1*OVERSAMPLENR, 848}, {54*OVERSAMPLENR, 275}, {107*OVERSAMPLENR, 228}, @@ -98,7 +98,7 @@ const prog_short temptable_2[][2] = { #endif #if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts -const prog_short temptable_3[][2] = { +const short temptable_3[][2] PROGMEM = { {1*OVERSAMPLENR,864}, {21*OVERSAMPLENR,300}, {25*OVERSAMPLENR,290}, @@ -131,7 +131,7 @@ const prog_short temptable_3[][2] = { #endif #if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor -const prog_short temptable_4[][2] = { +const short temptable_4[][2] PROGMEM = { {1*OVERSAMPLENR, 430}, {54*OVERSAMPLENR, 137}, {107*OVERSAMPLENR, 107}, @@ -156,7 +156,7 @@ const prog_short temptable_4[][2] = { #endif #if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2) -const prog_short temptable_5[][2] = { +const short temptable_5[][2] PROGMEM = { {1*OVERSAMPLENR, 713}, {18*OVERSAMPLENR, 316}, {35*OVERSAMPLENR, 266}, @@ -222,7 +222,7 @@ const prog_short temptable_5[][2] = { #endif #if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor -const prog_short temptable_6[][2] = { +const short temptable_6[][2] PROGMEM = { {28*OVERSAMPLENR, 250}, {31*OVERSAMPLENR, 245}, {35*OVERSAMPLENR, 240}, @@ -263,7 +263,7 @@ const prog_short temptable_6[][2] = { #endif #if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01 -const prog_short temptable_7[][2] = { +const short temptable_7[][2] PROGMEM = { {46*OVERSAMPLENR, 270}, {50*OVERSAMPLENR, 265}, {54*OVERSAMPLENR, 260}, From 451f9cc6d1696f187a7630940760aa27b1266308 Mon Sep 17 00:00:00 2001 From: Bernhard Kubicek Date: Wed, 9 May 2012 08:05:13 +0300 Subject: [PATCH 09/16] Residual in the comments: there are no more mm/minutes but only mm/sec in the planner buffer. --- Marlin/planner.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/planner.h b/Marlin/planner.h index 873441bb0..fc0d83c2b 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -45,10 +45,10 @@ typedef struct { #endif // Fields used by the motion planner to manage acceleration -// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis - float nominal_speed; // The nominal speed for this block in mm/min - float entry_speed; // Entry speed at previous-current junction in mm/min - float max_entry_speed; // Maximum allowable junction entry speed in mm/min +// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis + float nominal_speed; // The nominal speed for this block in mm/sec + float entry_speed; // Entry speed at previous-current junction in mm/sec + float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float millimeters; // The total travel of this block in mm float acceleration; // acceleration mm/sec^2 unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction From 602c8ee02bcd6993cb60e8758aa5928253b577dd Mon Sep 17 00:00:00 2001 From: Guan Yang Date: Fri, 27 Apr 2012 11:28:10 -0400 Subject: [PATCH 10/16] Melzi support --- Marlin/Configuration.h | 1 + Marlin/pins.h | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f15876770..6c5b97432 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -26,6 +26,7 @@ // Gen6 = 5 // Gen6 deluxe = 51 // Sanguinololu 1.2 and above = 62 +// Melzi = 63 // Ultimaker = 7 // Teensylu = 8 // Gen3+ =9 diff --git a/Marlin/pins.h b/Marlin/pins.h index 0d6b6022e..95a036968 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -554,7 +554,10 @@ * Sanguinololu pin assignment * ****************************************************************************************/ -#if MOTHERBOARD == 62 +#if MOTHERBOARD == 63 +#define MELZI +#endif +#if MOTHERBOARD == 62 || MOTHERBOARD == 63 #undef MOTHERBOARD #define MOTHERBOARD 6 #define SANGUINOLOLU_V_1_2 @@ -589,6 +592,11 @@ #define FAN_PIN -1 +#ifdef MELZI +#define LED_PIN 28 +#define FAN_PIN 4 +#endif + #define PS_ON_PIN -1 #define KILL_PIN -1 @@ -621,6 +629,10 @@ #define SDPOWER -1 #define SDSS 31 +#ifdef MELZI +#define SDSS 24 +#endif + #endif From 1efe9ab49719b9d501f6cb339f824a9d86b8685f Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Fri, 11 May 2012 15:19:09 +0200 Subject: [PATCH 11/16] changed encoder pos from int to long to fix problems setting x/y/z/e stepps_per_mm using the lcd menu --- Marlin/ultralcd.h | 6 ++-- Marlin/ultralcd.pde | 80 ++++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index ab5675d59..b01368bc1 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -70,7 +70,7 @@ void showAxisMove(); void showSD(); bool force_lcd_update; - int lastencoderpos; + long lastencoderpos; int8_t lineoffset; int8_t lastlineoffset; @@ -79,11 +79,11 @@ bool tune; private: - FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos) + FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos) { if(linechanging) return; // an item is changint its value, do not switch lines hence lastlineoffset=lineoffset; - int curencoderpos=encoderpos; + long curencoderpos=encoderpos; force_lcd_update=false; if( (abs(curencoderpos-lastencoderpos)9999) encoderpos=9999; - lcd.setCursor(13,line);lcd.print(itostr4(encoderpos)); + if(encoderpos>999999) encoderpos=999999; + lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0)); } }break; @@ -1296,7 +1296,7 @@ void MainMenu::showControlTemp() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)Kp; + encoderpos=(long)Kp; } else { @@ -1331,7 +1331,7 @@ void MainMenu::showControlTemp() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(Ki*10/PID_dT); + encoderpos=(long)(Ki*10/PID_dT); } else { @@ -1367,7 +1367,7 @@ void MainMenu::showControlTemp() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(Kd/5./PID_dT); + encoderpos=(long)(Kd/5./PID_dT); } else { @@ -1403,7 +1403,7 @@ void MainMenu::showControlTemp() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)Kc; + encoderpos=(long)Kc; } else { @@ -1476,7 +1476,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)acceleration/100; + encoderpos=(long)acceleration/100; } else { @@ -1510,7 +1510,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)max_xy_jerk; + encoderpos=(long)max_xy_jerk; } else { @@ -1553,7 +1553,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)max_feedrate[i-ItemCM_vmaxx]; + encoderpos=(long)max_feedrate[i-ItemCM_vmaxx]; } else { @@ -1589,7 +1589,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(minimumfeedrate); + encoderpos=(long)(minimumfeedrate); } else { @@ -1624,7 +1624,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)mintravelfeedrate; + encoderpos=(long)mintravelfeedrate; } else { @@ -1667,7 +1667,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100; + encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100; } else { @@ -1701,7 +1701,7 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)retract_acceleration/100; + encoderpos=(long)retract_acceleration/100; } else { @@ -1725,7 +1725,7 @@ void MainMenu::showControlMotion() if(force_lcd_update) { lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS); - lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0])); + lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS])); } if((activeline!=line) ) @@ -1736,13 +1736,13 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(axis_steps_per_unit[0]*100.0); + encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0); } else { - float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]); + float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]); position[X_AXIS]=lround(position[X_AXIS]*factor); - //current_position[3]*=factor; + //current_position[X_AXIS]*=factor; axis_steps_per_unit[X_AXIS]= encoderpos/100.0; encoderpos=activeline*lcdslow; } @@ -1752,7 +1752,7 @@ void MainMenu::showControlMotion() if(linechanging) { if(encoderpos<5) encoderpos=5; - if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800 + if(encoderpos>999999) encoderpos=99999; lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); } @@ -1762,7 +1762,7 @@ void MainMenu::showControlMotion() if(force_lcd_update) { lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS); - lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1])); + lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS])); } if((activeline!=line) ) @@ -1773,13 +1773,13 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(axis_steps_per_unit[1]*100.0); + encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0); } else { - float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]); + float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]); position[Y_AXIS]=lround(position[Y_AXIS]*factor); - //current_position[3]*=factor; + //current_position[Y_AXIS]*=factor; axis_steps_per_unit[Y_AXIS]= encoderpos/100.0; encoderpos=activeline*lcdslow; @@ -1790,7 +1790,7 @@ void MainMenu::showControlMotion() if(linechanging) { if(encoderpos<5) encoderpos=5; - if(encoderpos>9999) encoderpos=9999; + if(encoderpos>999999) encoderpos=999999; lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); } @@ -1800,7 +1800,7 @@ void MainMenu::showControlMotion() if(force_lcd_update) { lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS); - lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2])); + lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS])); } if((activeline!=line) ) @@ -1811,13 +1811,13 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(axis_steps_per_unit[2]*100.0); + encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0); } else { - float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]); + float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]); position[Z_AXIS]=lround(position[Z_AXIS]*factor); - //current_position[3]*=factor; + //current_position[Z_AXIS]*=factor; axis_steps_per_unit[Z_AXIS]= encoderpos/100.0; encoderpos=activeline*lcdslow; @@ -1828,7 +1828,7 @@ void MainMenu::showControlMotion() if(linechanging) { if(encoderpos<5) encoderpos=5; - if(encoderpos>9999) encoderpos=9999; + if(encoderpos>999999) encoderpos=999999; lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); } @@ -1839,7 +1839,7 @@ void MainMenu::showControlMotion() if(force_lcd_update) { lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS); - lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3])); + lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS])); } if((activeline!=line) ) @@ -1850,13 +1850,13 @@ void MainMenu::showControlMotion() linechanging=!linechanging; if(linechanging) { - encoderpos=(int)(axis_steps_per_unit[3]*100.0); + encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0); } else { - float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]); + float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]); position[E_AXIS]=lround(position[E_AXIS]*factor); - //current_position[3]*=factor; + //current_position[E_AXIS]*=factor; axis_steps_per_unit[E_AXIS]= encoderpos/100.0; encoderpos=activeline*lcdslow; @@ -1867,7 +1867,7 @@ void MainMenu::showControlMotion() if(linechanging) { if(encoderpos<5) encoderpos=5; - if(encoderpos>9999) encoderpos=9999; + if(encoderpos>999999) encoderpos=999999; lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); } @@ -2381,4 +2381,4 @@ char *ftostr52(const float &x) #endif //ULTRA_LCD - + From e48f5aa6a7a55389979e1a4192b9e9462979e186 Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Fri, 11 May 2012 15:22:06 +0200 Subject: [PATCH 12/16] fixed typo --- Marlin/ultralcd.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index d57d16094..060b7208d 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -1752,7 +1752,7 @@ void MainMenu::showControlMotion() if(linechanging) { if(encoderpos<5) encoderpos=5; - if(encoderpos>999999) encoderpos=99999; + if(encoderpos>999999) encoderpos=999999; lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0)); } From 159ae90874d6a4c9afa2906d09ef2ee279f1bc9e Mon Sep 17 00:00:00 2001 From: MaikStohn Date: Fri, 11 May 2012 15:23:10 +0200 Subject: [PATCH 13/16] bug fix for scrolling of main menu when using SMALL_DISPLAY (2 lines only) --- Marlin/ultralcd.pde | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index 060b7208d..69364acb0 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -2108,9 +2108,10 @@ void MainMenu::showMainMenu() } } clearIfNecessary(); - for(int8_t line=0;line Date: Wed, 16 May 2012 18:17:34 +0200 Subject: [PATCH 14/16] Fixes #153 for bad call to abs() --- Marlin/planner.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index cfb503deb..27633109e 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -555,7 +555,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]; delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0; if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) { - block->millimeters = abs(delta_mm[E_AXIS]); + block->millimeters = fabs(delta_mm[E_AXIS]); } else { block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); } @@ -591,8 +591,8 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa float speed_factor = 1.0; //factor <=1 do decrease speed for(int i=0; i < 4; i++) { current_speed[i] = delta_mm[i] * inverse_second; - if(abs(current_speed[i]) > max_feedrate[i]) - speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i])); + if(fabs(current_speed[i]) > max_feedrate[i]) + speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i])); } // Max segement time in us. @@ -696,25 +696,25 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa #endif // Start with a safe speed float vmax_junction = max_xy_jerk/2; - if(abs(current_speed[Z_AXIS]) > max_z_jerk/2) + if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) vmax_junction = max_z_jerk/2; vmax_junction = min(vmax_junction, block->nominal_speed); - if(abs(current_speed[E_AXIS]) > max_e_jerk/2) + if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) vmax_junction = min(vmax_junction, max_e_jerk/2); if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) { float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2)); - if((abs(previous_speed[X_AXIS]) > 0.0001) || (abs(previous_speed[Y_AXIS]) > 0.0001)) { + if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) { vmax_junction = block->nominal_speed; } if (jerk > max_xy_jerk) { vmax_junction *= (max_xy_jerk/jerk); } - if(abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { - vmax_junction *= (max_z_jerk/abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS])); + if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) { + vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS])); } - if(abs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { - vmax_junction *= (max_e_jerk/abs(current_speed[E_AXIS] - previous_speed[E_AXIS])); + if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) { + vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS])); } } block->max_entry_speed = vmax_junction; From ba96059203ba8655061dd6a9dc88e5ebb727d2fa Mon Sep 17 00:00:00 2001 From: Erik van der Zalm Date: Wed, 16 May 2012 19:21:44 +0200 Subject: [PATCH 15/16] add additional dropsegments test --- Marlin/planner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 27633109e..ac9ff19e8 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -554,7 +554,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]; delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]; delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0; - if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) { + if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) { block->millimeters = fabs(delta_mm[E_AXIS]); } else { block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); From e31bef31ad4ce8f97b892ccccec4947c8fc372d4 Mon Sep 17 00:00:00 2001 From: Erik van der Zalm Date: Wed, 16 May 2012 19:32:23 +0200 Subject: [PATCH 16/16] Limit PID autotune PWM to PID_MAX --- Marlin/temperature.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index e21bd2598..395061cc2 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -134,8 +134,8 @@ void PID_autotune(float temp) long t_high; long t_low; - long bias=127; - long d = 127; + long bias=PID_MAX/2; + long d = PID_MAX/2; float Ku, Tu; float Kp, Ki, Kd; float max, min; @@ -144,7 +144,7 @@ void PID_autotune(float temp) disable_heater(); // switch off all heaters. - soft_pwm[0] = 255>>1; + soft_pwm[0] = PID_MAX/2; for(;;) { @@ -172,8 +172,8 @@ void PID_autotune(float temp) t_low=t2 - t1; if(cycles > 0) { bias += (d*(t_high - t_low))/(t_low + t_high); - bias = constrain(bias, 20 ,235); - if(bias > 127) d = 254 - bias; + bias = constrain(bias, 20 ,PID_MAX-20); + if(bias > PID_MAX/2) d = PID_MAX - 1 - bias; else d = bias; SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);