Browse Source

Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

Daid 13 years ago
parent
commit
7244aa7eb7
9 changed files with 96 additions and 74 deletions
  1. 1
    0
      Marlin/Configuration.h
  2. 3
    2
      Marlin/Marlin.pde
  3. 13
    1
      Marlin/pins.h
  4. 11
    11
      Marlin/planner.cpp
  5. 4
    4
      Marlin/planner.h
  6. 5
    5
      Marlin/temperature.cpp
  7. 6
    4
      Marlin/ultralcd.h
  8. 51
    46
      Marlin/ultralcd.pde
  9. 2
    1
      README.md

+ 1
- 0
Marlin/Configuration.h View File

26
 // Gen6 = 5
26
 // Gen6 = 5
27
 // Gen6 deluxe = 51
27
 // Gen6 deluxe = 51
28
 // Sanguinololu 1.2 and above = 62
28
 // Sanguinololu 1.2 and above = 62
29
+// Melzi = 63
29
 // Ultimaker = 7
30
 // Ultimaker = 7
30
 // Teensylu = 8
31
 // Teensylu = 8
31
 // Gen3+ =9
32
 // Gen3+ =9

+ 3
- 2
Marlin/Marlin.pde View File

300
   st_init();    // Initialize stepper;
300
   st_init();    // Initialize stepper;
301
   wd_init();
301
   wd_init();
302
   setup_photpin();
302
   setup_photpin();
303
+  
304
+  LCD_INIT;
303
 }
305
 }
304
 
306
 
305
 
307
 
687
         st_synchronize();
689
         st_synchronize();
688
       for(int8_t i=0; i < NUM_AXIS; i++) {
690
       for(int8_t i=0; i < NUM_AXIS; i++) {
689
         if(code_seen(axis_codes[i])) { 
691
         if(code_seen(axis_codes[i])) { 
690
-           current_position[i] = code_value()+add_homeing[i];  
691
            if(i == E_AXIS) {
692
            if(i == E_AXIS) {
692
              current_position[i] = code_value();  
693
              current_position[i] = code_value();  
693
              plan_set_e_position(current_position[E_AXIS]);
694
              plan_set_e_position(current_position[E_AXIS]);
1246
      }
1247
      }
1247
     break;
1248
     break;
1248
       
1249
       
1249
-    case 302: // finish all moves
1250
+    case 302: // allow cold extrudes
1250
     {
1251
     {
1251
       allow_cold_extrudes(true);
1252
       allow_cold_extrudes(true);
1252
     }
1253
     }

+ 13
- 1
Marlin/pins.h View File

554
 * Sanguinololu pin assignment
554
 * Sanguinololu pin assignment
555
 *
555
 *
556
 ****************************************************************************************/
556
 ****************************************************************************************/
557
-#if MOTHERBOARD == 62
557
+#if MOTHERBOARD == 63
558
+#define MELZI
559
+#endif
560
+#if MOTHERBOARD == 62 || MOTHERBOARD == 63
558
 #undef MOTHERBOARD
561
 #undef MOTHERBOARD
559
 #define MOTHERBOARD 6
562
 #define MOTHERBOARD 6
560
 #define SANGUINOLOLU_V_1_2 
563
 #define SANGUINOLOLU_V_1_2 
589
 
592
 
590
 #define FAN_PIN            -1 
593
 #define FAN_PIN            -1 
591
 
594
 
595
+#ifdef MELZI
596
+#define LED_PIN            28
597
+#define FAN_PIN            4
598
+#endif
599
+
592
 #define PS_ON_PIN          -1
600
 #define PS_ON_PIN          -1
593
 #define KILL_PIN           -1
601
 #define KILL_PIN           -1
594
 
602
 
621
 #define SDPOWER            -1
629
 #define SDPOWER            -1
622
 #define SDSS               31
630
 #define SDSS               31
623
 
631
 
632
+#ifdef MELZI
633
+#define SDSS               24
634
+#endif
635
+
624
 #endif
636
 #endif
625
 
637
 
626
 
638
 

+ 11
- 11
Marlin/planner.cpp View File

556
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
556
   delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
557
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
557
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
558
   delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
558
   delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS])*extrudemultiply/100.0;
559
-  if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) {
560
-    block->millimeters = abs(delta_mm[E_AXIS]);
559
+  if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
560
+    block->millimeters = fabs(delta_mm[E_AXIS]);
561
   } else {
561
   } else {
562
     block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
562
     block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
563
   }
563
   }
593
   float speed_factor = 1.0; //factor <=1 do decrease speed
593
   float speed_factor = 1.0; //factor <=1 do decrease speed
594
   for(int i=0; i < 4; i++) {
594
   for(int i=0; i < 4; i++) {
595
     current_speed[i] = delta_mm[i] * inverse_second;
595
     current_speed[i] = delta_mm[i] * inverse_second;
596
-    if(abs(current_speed[i]) > max_feedrate[i])
597
-      speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
596
+    if(fabs(current_speed[i]) > max_feedrate[i])
597
+      speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
598
   }
598
   }
599
 
599
 
600
 // Max segement time in us.
600
 // Max segement time in us.
698
 #endif
698
 #endif
699
   // Start with a safe speed
699
   // Start with a safe speed
700
   float vmax_junction = max_xy_jerk/2;  
700
   float vmax_junction = max_xy_jerk/2;  
701
-  if(abs(current_speed[Z_AXIS]) > max_z_jerk/2) 
701
+  if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2) 
702
     vmax_junction = max_z_jerk/2;
702
     vmax_junction = max_z_jerk/2;
703
   vmax_junction = min(vmax_junction, block->nominal_speed);
703
   vmax_junction = min(vmax_junction, block->nominal_speed);
704
-  if(abs(current_speed[E_AXIS]) > max_e_jerk/2) 
704
+  if(fabs(current_speed[E_AXIS]) > max_e_jerk/2) 
705
     vmax_junction = min(vmax_junction, max_e_jerk/2);
705
     vmax_junction = min(vmax_junction, max_e_jerk/2);
706
     
706
     
707
   if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
707
   if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
708
     float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
708
     float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
709
-    if((abs(previous_speed[X_AXIS]) > 0.0001) || (abs(previous_speed[Y_AXIS]) > 0.0001)) {
709
+    if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
710
       vmax_junction = block->nominal_speed;
710
       vmax_junction = block->nominal_speed;
711
     }
711
     }
712
     if (jerk > max_xy_jerk) {
712
     if (jerk > max_xy_jerk) {
713
       vmax_junction *= (max_xy_jerk/jerk);
713
       vmax_junction *= (max_xy_jerk/jerk);
714
     } 
714
     } 
715
-    if(abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
716
-      vmax_junction *= (max_z_jerk/abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
715
+    if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
716
+      vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
717
     } 
717
     } 
718
-    if(abs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
719
-      vmax_junction *= (max_e_jerk/abs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
718
+    if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
719
+      vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
720
     } 
720
     } 
721
   }
721
   }
722
   block->max_entry_speed = vmax_junction;
722
   block->max_entry_speed = vmax_junction;

+ 4
- 4
Marlin/planner.h View File

45
   #endif
45
   #endif
46
 
46
 
47
   // Fields used by the motion planner to manage acceleration
47
   // Fields used by the motion planner to manage acceleration
48
-//  float speed_x, speed_y, speed_z, speed_e;        // Nominal mm/minute for each axis
49
-  float nominal_speed;                               // The nominal speed for this block in mm/min  
50
-  float entry_speed;                                 // Entry speed at previous-current junction in mm/min
51
-  float max_entry_speed;                             // Maximum allowable junction entry speed in mm/min
48
+//  float speed_x, speed_y, speed_z, speed_e;        // Nominal mm/sec for each axis
49
+  float nominal_speed;                               // The nominal speed for this block in mm/sec 
50
+  float entry_speed;                                 // Entry speed at previous-current junction in mm/sec
51
+  float max_entry_speed;                             // Maximum allowable junction entry speed in mm/sec
52
   float millimeters;                                 // The total travel of this block in mm
52
   float millimeters;                                 // The total travel of this block in mm
53
   float acceleration;                                // acceleration mm/sec^2
53
   float acceleration;                                // acceleration mm/sec^2
54
   unsigned char recalculate_flag;                    // Planner flag to recalculate trapezoids on entry junction
54
   unsigned char recalculate_flag;                    // Planner flag to recalculate trapezoids on entry junction

+ 5
- 5
Marlin/temperature.cpp View File

134
   long t_high;
134
   long t_high;
135
   long t_low;
135
   long t_low;
136
 
136
 
137
-  long bias=127;
138
-  long d = 127;
137
+  long bias=PID_MAX/2;
138
+  long d = PID_MAX/2;
139
   float Ku, Tu;
139
   float Ku, Tu;
140
   float Kp, Ki, Kd;
140
   float Kp, Ki, Kd;
141
   float max, min;
141
   float max, min;
144
   
144
   
145
   disable_heater(); // switch off all heaters.
145
   disable_heater(); // switch off all heaters.
146
   
146
   
147
-  soft_pwm[0] = 255>>1;
147
+  soft_pwm[0] = PID_MAX/2;
148
     
148
     
149
   for(;;) {
149
   for(;;) {
150
 
150
 
172
           t_low=t2 - t1;
172
           t_low=t2 - t1;
173
           if(cycles > 0) {
173
           if(cycles > 0) {
174
             bias += (d*(t_high - t_low))/(t_low + t_high);
174
             bias += (d*(t_high - t_low))/(t_low + t_high);
175
-            bias = constrain(bias, 20 ,235);
176
-            if(bias > 127) d = 254 - bias;
175
+            bias = constrain(bias, 20 ,PID_MAX-20);
176
+            if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
177
             else d = bias;
177
             else d = bias;
178
 
178
 
179
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
179
             SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);

+ 6
- 4
Marlin/ultralcd.h View File

7
   void lcd_init();
7
   void lcd_init();
8
   void lcd_status(const char* message);
8
   void lcd_status(const char* message);
9
   void beep();
9
   void beep();
10
+  void buttons_init();
10
   void buttons_check();
11
   void buttons_check();
11
 
12
 
12
   #define LCD_UPDATE_INTERVAL 100
13
   #define LCD_UPDATE_INTERVAL 100
69
     void showAxisMove();
70
     void showAxisMove();
70
     void showSD();
71
     void showSD();
71
     bool force_lcd_update;
72
     bool force_lcd_update;
72
-    int lastencoderpos;
73
+    long lastencoderpos;
73
     int8_t lineoffset;
74
     int8_t lineoffset;
74
     int8_t lastlineoffset;
75
     int8_t lastlineoffset;
75
     
76
     
78
     bool tune;
79
     bool tune;
79
     
80
     
80
   private:
81
   private:
81
-    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
82
+    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
82
     {
83
     {
83
       if(linechanging) return; // an item is changint its value, do not switch lines hence
84
       if(linechanging) return; // an item is changint its value, do not switch lines hence
84
       lastlineoffset=lineoffset; 
85
       lastlineoffset=lineoffset; 
85
-      int curencoderpos=encoderpos;  
86
+      long curencoderpos=encoderpos;  
86
       force_lcd_update=false;
87
       force_lcd_update=false;
87
       if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
88
       if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
88
       { 
89
       { 
134
   char *ftostr3(const float &x);
135
   char *ftostr3(const float &x);
135
 
136
 
136
 
137
 
137
-
138
+  #define LCD_INIT lcd_init();
138
   #define LCD_MESSAGE(x) lcd_status(x);
139
   #define LCD_MESSAGE(x) lcd_status(x);
139
   #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
140
   #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
140
   #define LCD_STATUS lcd_status()
141
   #define LCD_STATUS lcd_status()
141
 #else //no lcd
142
 #else //no lcd
143
+  #define LCD_INIT
142
   #define LCD_STATUS
144
   #define LCD_STATUS
143
   #define LCD_MESSAGE(x)
145
   #define LCD_MESSAGE(x)
144
   #define LCD_MESSAGEPGM(x)
146
   #define LCD_MESSAGEPGM(x)

+ 51
- 46
Marlin/ultralcd.pde View File

3
 #include "ultralcd.h"
3
 #include "ultralcd.h"
4
 #ifdef ULTRA_LCD
4
 #ifdef ULTRA_LCD
5
 #include "Marlin.h"
5
 #include "Marlin.h"
6
+#include "language.h"
7
+#include "temperature.h"
8
+#include "EEPROMwrite.h"
6
 #include <LiquidCrystal.h>
9
 #include <LiquidCrystal.h>
7
 //===========================================================================
10
 //===========================================================================
8
 //=============================imported variables============================
11
 //=============================imported variables============================
15
 
18
 
16
 extern long position[4];   
19
 extern long position[4];   
17
 #ifdef SDSUPPORT
20
 #ifdef SDSUPPORT
21
+#include "cardreader.h"
18
 extern CardReader card;
22
 extern CardReader card;
19
 #endif
23
 #endif
20
 
24
 
22
 //=============================public variables============================
26
 //=============================public variables============================
23
 //===========================================================================
27
 //===========================================================================
24
 volatile char buttons=0;  //the last checked buttons in a bit array.
28
 volatile char buttons=0;  //the last checked buttons in a bit array.
25
-int encoderpos=0;
29
+long encoderpos=0;
26
 short lastenc=0;
30
 short lastenc=0;
27
 
31
 
28
 
32
 
97
 void lcd_init()
101
 void lcd_init()
98
 {
102
 {
99
   //beep();
103
   //beep();
104
+  #ifdef ULTIPANEL
105
+    buttons_init();
106
+  #endif
100
   
107
   
101
   byte Degree[8] =
108
   byte Degree[8] =
102
   {
109
   {
304
   displayStartingRow=0;
311
   displayStartingRow=0;
305
   activeline=0;
312
   activeline=0;
306
   force_lcd_update=true;
313
   force_lcd_update=true;
307
-  #ifdef ULTIPANEL
308
-    buttons_init();
309
-  #endif
310
-  lcd_init();
311
   linechanging=false;
314
   linechanging=false;
312
   tune=false;
315
   tune=false;
313
 }
316
 }
884
       if(force_lcd_update)
887
       if(force_lcd_update)
885
         {
888
         {
886
           lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
889
           lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
887
-          lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
890
+          lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
888
         }
891
         }
889
         
892
         
890
         if((activeline!=line) )
893
         if((activeline!=line) )
895
           linechanging=!linechanging;
898
           linechanging=!linechanging;
896
           if(linechanging)
899
           if(linechanging)
897
           {
900
           {
898
-              encoderpos=(int)axis_steps_per_unit[3];
901
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
899
           }
902
           }
900
           else
903
           else
901
           {
904
           {
902
-            float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
905
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
903
             position[E_AXIS]=lround(position[E_AXIS]*factor);
906
             position[E_AXIS]=lround(position[E_AXIS]*factor);
904
-            //current_position[3]*=factor;
905
-            axis_steps_per_unit[E_AXIS]= encoderpos;
907
+            //current_position[E_AXIS]*=factor;
908
+            axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
906
             encoderpos=activeline*lcdslow;
909
             encoderpos=activeline*lcdslow;
907
               
910
               
908
           }
911
           }
912
         if(linechanging)
915
         if(linechanging)
913
         {
916
         {
914
           if(encoderpos<5) encoderpos=5;
917
           if(encoderpos<5) encoderpos=5;
915
-          if(encoderpos>9999) encoderpos=9999;
916
-          lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
918
+          if(encoderpos>999999) encoderpos=999999;
919
+          lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
917
         }
920
         }
918
         
921
         
919
       }break; 
922
       }break; 
1296
           linechanging=!linechanging;
1299
           linechanging=!linechanging;
1297
           if(linechanging)
1300
           if(linechanging)
1298
           {
1301
           {
1299
-              encoderpos=(int)Kp;
1302
+              encoderpos=(long)Kp;
1300
           }
1303
           }
1301
           else
1304
           else
1302
           {
1305
           {
1331
           linechanging=!linechanging;
1334
           linechanging=!linechanging;
1332
           if(linechanging)
1335
           if(linechanging)
1333
           {
1336
           {
1334
-              encoderpos=(int)(Ki*10/PID_dT);
1337
+              encoderpos=(long)(Ki*10/PID_dT);
1335
           }
1338
           }
1336
           else
1339
           else
1337
           {
1340
           {
1367
           linechanging=!linechanging;
1370
           linechanging=!linechanging;
1368
           if(linechanging)
1371
           if(linechanging)
1369
           {
1372
           {
1370
-              encoderpos=(int)(Kd/5./PID_dT);
1373
+              encoderpos=(long)(Kd/5./PID_dT);
1371
           }
1374
           }
1372
           else
1375
           else
1373
           {
1376
           {
1403
           linechanging=!linechanging;
1406
           linechanging=!linechanging;
1404
           if(linechanging)
1407
           if(linechanging)
1405
           {
1408
           {
1406
-              encoderpos=(int)Kc;
1409
+              encoderpos=(long)Kc;
1407
           }
1410
           }
1408
           else
1411
           else
1409
           {
1412
           {
1476
           linechanging=!linechanging;
1479
           linechanging=!linechanging;
1477
           if(linechanging)
1480
           if(linechanging)
1478
           {
1481
           {
1479
-              encoderpos=(int)acceleration/100;
1482
+              encoderpos=(long)acceleration/100;
1480
           }
1483
           }
1481
           else
1484
           else
1482
           {
1485
           {
1510
           linechanging=!linechanging;
1513
           linechanging=!linechanging;
1511
           if(linechanging)
1514
           if(linechanging)
1512
           {
1515
           {
1513
-              encoderpos=(int)max_xy_jerk;
1516
+              encoderpos=(long)max_xy_jerk;
1514
           }
1517
           }
1515
           else
1518
           else
1516
           {
1519
           {
1553
           linechanging=!linechanging;
1556
           linechanging=!linechanging;
1554
           if(linechanging)
1557
           if(linechanging)
1555
           {
1558
           {
1556
-              encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
1559
+              encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
1557
           }
1560
           }
1558
           else
1561
           else
1559
           {
1562
           {
1589
           linechanging=!linechanging;
1592
           linechanging=!linechanging;
1590
           if(linechanging)
1593
           if(linechanging)
1591
           {
1594
           {
1592
-              encoderpos=(int)(minimumfeedrate);
1595
+              encoderpos=(long)(minimumfeedrate);
1593
           }
1596
           }
1594
           else
1597
           else
1595
           {
1598
           {
1624
           linechanging=!linechanging;
1627
           linechanging=!linechanging;
1625
           if(linechanging)
1628
           if(linechanging)
1626
           {
1629
           {
1627
-              encoderpos=(int)mintravelfeedrate;
1630
+              encoderpos=(long)mintravelfeedrate;
1628
           }
1631
           }
1629
           else
1632
           else
1630
           {
1633
           {
1667
           linechanging=!linechanging;
1670
           linechanging=!linechanging;
1668
           if(linechanging)
1671
           if(linechanging)
1669
           {
1672
           {
1670
-              encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1673
+              encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1671
           }
1674
           }
1672
           else
1675
           else
1673
           {
1676
           {
1701
           linechanging=!linechanging;
1704
           linechanging=!linechanging;
1702
           if(linechanging)
1705
           if(linechanging)
1703
           {
1706
           {
1704
-              encoderpos=(int)retract_acceleration/100;
1707
+              encoderpos=(long)retract_acceleration/100;
1705
           }
1708
           }
1706
           else
1709
           else
1707
           {
1710
           {
1725
       if(force_lcd_update)
1728
       if(force_lcd_update)
1726
         {
1729
         {
1727
           lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1730
           lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1728
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0]));
1731
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
1729
         }
1732
         }
1730
         
1733
         
1731
         if((activeline!=line) )
1734
         if((activeline!=line) )
1736
           linechanging=!linechanging;
1739
           linechanging=!linechanging;
1737
           if(linechanging)
1740
           if(linechanging)
1738
           {
1741
           {
1739
-              encoderpos=(int)(axis_steps_per_unit[0]*100.0);
1742
+              encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
1740
           }
1743
           }
1741
           else
1744
           else
1742
           {
1745
           {
1743
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]);
1746
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
1744
             position[X_AXIS]=lround(position[X_AXIS]*factor);
1747
             position[X_AXIS]=lround(position[X_AXIS]*factor);
1745
-            //current_position[3]*=factor;
1748
+            //current_position[X_AXIS]*=factor;
1746
             axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
1749
             axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
1747
             encoderpos=activeline*lcdslow;
1750
             encoderpos=activeline*lcdslow;
1748
           }
1751
           }
1752
         if(linechanging)
1755
         if(linechanging)
1753
         {
1756
         {
1754
           if(encoderpos<5) encoderpos=5;
1757
           if(encoderpos<5) encoderpos=5;
1755
-          if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800
1758
+          if(encoderpos>999999) encoderpos=999999;
1756
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1759
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1757
         }
1760
         }
1758
         
1761
         
1762
       if(force_lcd_update)
1765
       if(force_lcd_update)
1763
         {
1766
         {
1764
           lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1767
           lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1765
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1]));
1768
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
1766
         }
1769
         }
1767
         
1770
         
1768
         if((activeline!=line) )
1771
         if((activeline!=line) )
1773
           linechanging=!linechanging;
1776
           linechanging=!linechanging;
1774
           if(linechanging)
1777
           if(linechanging)
1775
           {
1778
           {
1776
-              encoderpos=(int)(axis_steps_per_unit[1]*100.0);
1779
+              encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
1777
           }
1780
           }
1778
           else
1781
           else
1779
           {
1782
           {
1780
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]);
1783
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
1781
             position[Y_AXIS]=lround(position[Y_AXIS]*factor);
1784
             position[Y_AXIS]=lround(position[Y_AXIS]*factor);
1782
-            //current_position[3]*=factor;
1785
+            //current_position[Y_AXIS]*=factor;
1783
             axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
1786
             axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
1784
             encoderpos=activeline*lcdslow;
1787
             encoderpos=activeline*lcdslow;
1785
               
1788
               
1790
         if(linechanging)
1793
         if(linechanging)
1791
         {
1794
         {
1792
           if(encoderpos<5) encoderpos=5;
1795
           if(encoderpos<5) encoderpos=5;
1793
-          if(encoderpos>9999) encoderpos=9999;
1796
+          if(encoderpos>999999) encoderpos=999999;
1794
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1797
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1795
         }
1798
         }
1796
         
1799
         
1800
       if(force_lcd_update)
1803
       if(force_lcd_update)
1801
         {
1804
         {
1802
           lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1805
           lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1803
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2]));
1806
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS]));
1804
         }
1807
         }
1805
         
1808
         
1806
         if((activeline!=line) )
1809
         if((activeline!=line) )
1811
           linechanging=!linechanging;
1814
           linechanging=!linechanging;
1812
           if(linechanging)
1815
           if(linechanging)
1813
           {
1816
           {
1814
-              encoderpos=(int)(axis_steps_per_unit[2]*100.0);
1817
+              encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
1815
           }
1818
           }
1816
           else
1819
           else
1817
           {
1820
           {
1818
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]);
1821
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
1819
             position[Z_AXIS]=lround(position[Z_AXIS]*factor);
1822
             position[Z_AXIS]=lround(position[Z_AXIS]*factor);
1820
-            //current_position[3]*=factor;
1823
+            //current_position[Z_AXIS]*=factor;
1821
             axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
1824
             axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
1822
             encoderpos=activeline*lcdslow;
1825
             encoderpos=activeline*lcdslow;
1823
               
1826
               
1828
         if(linechanging)
1831
         if(linechanging)
1829
         {
1832
         {
1830
           if(encoderpos<5) encoderpos=5;
1833
           if(encoderpos<5) encoderpos=5;
1831
-          if(encoderpos>9999) encoderpos=9999;
1834
+          if(encoderpos>999999) encoderpos=999999;
1832
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1835
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1833
         }
1836
         }
1834
         
1837
         
1839
       if(force_lcd_update)
1842
       if(force_lcd_update)
1840
         {
1843
         {
1841
           lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1844
           lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1842
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3]));
1845
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
1843
         }
1846
         }
1844
         
1847
         
1845
         if((activeline!=line) )
1848
         if((activeline!=line) )
1850
           linechanging=!linechanging;
1853
           linechanging=!linechanging;
1851
           if(linechanging)
1854
           if(linechanging)
1852
           {
1855
           {
1853
-              encoderpos=(int)(axis_steps_per_unit[3]*100.0);
1856
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
1854
           }
1857
           }
1855
           else
1858
           else
1856
           {
1859
           {
1857
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]);
1860
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
1858
             position[E_AXIS]=lround(position[E_AXIS]*factor);
1861
             position[E_AXIS]=lround(position[E_AXIS]*factor);
1859
-            //current_position[3]*=factor;
1862
+            //current_position[E_AXIS]*=factor;
1860
             axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
1863
             axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
1861
             encoderpos=activeline*lcdslow;
1864
             encoderpos=activeline*lcdslow;
1862
               
1865
               
1867
         if(linechanging)
1870
         if(linechanging)
1868
         {
1871
         {
1869
           if(encoderpos<5) encoderpos=5;
1872
           if(encoderpos<5) encoderpos=5;
1870
-          if(encoderpos>9999) encoderpos=9999;
1873
+          if(encoderpos>999999) encoderpos=999999;
1871
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1874
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1872
         }
1875
         }
1873
         
1876
         
2108
     }
2111
     }
2109
   } 
2112
   } 
2110
   clearIfNecessary();
2113
   clearIfNecessary();
2111
-  for(int8_t line=0;line<LCD_HEIGHT;line++)
2114
+  uint8_t line=0;
2115
+  for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
2112
   {
2116
   {
2113
-    switch(line)
2117
+    switch(i)
2114
     { 
2118
     { 
2115
       case ItemM_watch:
2119
       case ItemM_watch:
2116
         MENUITEM(  lcdprintPGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2120
         MENUITEM(  lcdprintPGM(MSG_WATCH)  ,  BLOCK;status=Main_Status;beepshort(); ) ;
2164
         SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
2168
         SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
2165
       break;
2169
       break;
2166
     }
2170
     }
2171
+    line++;
2167
   }
2172
   }
2168
   updateActiveLines(3,encoderpos);
2173
   updateActiveLines(3,encoderpos);
2169
 }
2174
 }
2381
 
2386
 
2382
 #endif //ULTRA_LCD
2387
 #endif //ULTRA_LCD
2383
 
2388
 
2384
-
2389
+

+ 2
- 1
README.md View File

161
 
161
 
162
 EEPROM:
162
 EEPROM:
163
 
163
 
164
-*   M500 - stores paramters in EEPROM
164
+*   M500 - stores paramters in EEPROM. This parameters are stored:  axis_steps_per_unit,  max_feedrate, max_acceleration  ,acceleration,retract_acceleration,
165
+  minimumfeedrate,mintravelfeedrate,minsegmenttime,  jerk velocities, PID
165
 *   M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
166
 *   M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).  
166
 *   M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
167
 *   M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
167
 *   M503 - print the current settings (from memory not from eeprom)
168
 *   M503 - print the current settings (from memory not from eeprom)

Loading…
Cancel
Save