Преглед изворни кода

changed encoder pos from int to long to fix problems setting x/y/z/e stepps_per_mm using the lcd menu

MaikStohn пре 13 година
родитељ
комит
1efe9ab497
2 измењених фајлова са 43 додато и 43 уклоњено
  1. 3
    3
      Marlin/ultralcd.h
  2. 40
    40
      Marlin/ultralcd.pde

+ 3
- 3
Marlin/ultralcd.h Прегледај датотеку

@@ -70,7 +70,7 @@
70 70
     void showAxisMove();
71 71
     void showSD();
72 72
     bool force_lcd_update;
73
-    int lastencoderpos;
73
+    long lastencoderpos;
74 74
     int8_t lineoffset;
75 75
     int8_t lastlineoffset;
76 76
     
@@ -79,11 +79,11 @@
79 79
     bool tune;
80 80
     
81 81
   private:
82
-    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
82
+    FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
83 83
     {
84 84
       if(linechanging) return; // an item is changint its value, do not switch lines hence
85 85
       lastlineoffset=lineoffset; 
86
-      int curencoderpos=encoderpos;  
86
+      long curencoderpos=encoderpos;  
87 87
       force_lcd_update=false;
88 88
       if(  (abs(curencoderpos-lastencoderpos)<lcdslow) ) 
89 89
       { 

+ 40
- 40
Marlin/ultralcd.pde Прегледај датотеку

@@ -24,7 +24,7 @@ extern CardReader card;
24 24
 //=============================public variables============================
25 25
 //===========================================================================
26 26
 volatile char buttons=0;  //the last checked buttons in a bit array.
27
-int encoderpos=0;
27
+long encoderpos=0;
28 28
 short lastenc=0;
29 29
 
30 30
 
@@ -884,7 +884,7 @@ void MainMenu::showTune()
884 884
       if(force_lcd_update)
885 885
         {
886 886
           lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
887
-          lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
887
+          lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
888 888
         }
889 889
         
890 890
         if((activeline!=line) )
@@ -895,14 +895,14 @@ void MainMenu::showTune()
895 895
           linechanging=!linechanging;
896 896
           if(linechanging)
897 897
           {
898
-              encoderpos=(int)axis_steps_per_unit[3];
898
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
899 899
           }
900 900
           else
901 901
           {
902
-            float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
902
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
903 903
             position[E_AXIS]=lround(position[E_AXIS]*factor);
904
-            //current_position[3]*=factor;
905
-            axis_steps_per_unit[E_AXIS]= encoderpos;
904
+            //current_position[E_AXIS]*=factor;
905
+            axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
906 906
             encoderpos=activeline*lcdslow;
907 907
               
908 908
           }
@@ -912,8 +912,8 @@ void MainMenu::showTune()
912 912
         if(linechanging)
913 913
         {
914 914
           if(encoderpos<5) encoderpos=5;
915
-          if(encoderpos>9999) encoderpos=9999;
916
-          lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
915
+          if(encoderpos>999999) encoderpos=999999;
916
+          lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
917 917
         }
918 918
         
919 919
       }break; 
@@ -1296,7 +1296,7 @@ void MainMenu::showControlTemp()
1296 1296
           linechanging=!linechanging;
1297 1297
           if(linechanging)
1298 1298
           {
1299
-              encoderpos=(int)Kp;
1299
+              encoderpos=(long)Kp;
1300 1300
           }
1301 1301
           else
1302 1302
           {
@@ -1331,7 +1331,7 @@ void MainMenu::showControlTemp()
1331 1331
           linechanging=!linechanging;
1332 1332
           if(linechanging)
1333 1333
           {
1334
-              encoderpos=(int)(Ki*10/PID_dT);
1334
+              encoderpos=(long)(Ki*10/PID_dT);
1335 1335
           }
1336 1336
           else
1337 1337
           {
@@ -1367,7 +1367,7 @@ void MainMenu::showControlTemp()
1367 1367
           linechanging=!linechanging;
1368 1368
           if(linechanging)
1369 1369
           {
1370
-              encoderpos=(int)(Kd/5./PID_dT);
1370
+              encoderpos=(long)(Kd/5./PID_dT);
1371 1371
           }
1372 1372
           else
1373 1373
           {
@@ -1403,7 +1403,7 @@ void MainMenu::showControlTemp()
1403 1403
           linechanging=!linechanging;
1404 1404
           if(linechanging)
1405 1405
           {
1406
-              encoderpos=(int)Kc;
1406
+              encoderpos=(long)Kc;
1407 1407
           }
1408 1408
           else
1409 1409
           {
@@ -1476,7 +1476,7 @@ void MainMenu::showControlMotion()
1476 1476
           linechanging=!linechanging;
1477 1477
           if(linechanging)
1478 1478
           {
1479
-              encoderpos=(int)acceleration/100;
1479
+              encoderpos=(long)acceleration/100;
1480 1480
           }
1481 1481
           else
1482 1482
           {
@@ -1510,7 +1510,7 @@ void MainMenu::showControlMotion()
1510 1510
           linechanging=!linechanging;
1511 1511
           if(linechanging)
1512 1512
           {
1513
-              encoderpos=(int)max_xy_jerk;
1513
+              encoderpos=(long)max_xy_jerk;
1514 1514
           }
1515 1515
           else
1516 1516
           {
@@ -1553,7 +1553,7 @@ void MainMenu::showControlMotion()
1553 1553
           linechanging=!linechanging;
1554 1554
           if(linechanging)
1555 1555
           {
1556
-              encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
1556
+              encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
1557 1557
           }
1558 1558
           else
1559 1559
           {
@@ -1589,7 +1589,7 @@ void MainMenu::showControlMotion()
1589 1589
           linechanging=!linechanging;
1590 1590
           if(linechanging)
1591 1591
           {
1592
-              encoderpos=(int)(minimumfeedrate);
1592
+              encoderpos=(long)(minimumfeedrate);
1593 1593
           }
1594 1594
           else
1595 1595
           {
@@ -1624,7 +1624,7 @@ void MainMenu::showControlMotion()
1624 1624
           linechanging=!linechanging;
1625 1625
           if(linechanging)
1626 1626
           {
1627
-              encoderpos=(int)mintravelfeedrate;
1627
+              encoderpos=(long)mintravelfeedrate;
1628 1628
           }
1629 1629
           else
1630 1630
           {
@@ -1667,7 +1667,7 @@ void MainMenu::showControlMotion()
1667 1667
           linechanging=!linechanging;
1668 1668
           if(linechanging)
1669 1669
           {
1670
-              encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1670
+              encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
1671 1671
           }
1672 1672
           else
1673 1673
           {
@@ -1701,7 +1701,7 @@ void MainMenu::showControlMotion()
1701 1701
           linechanging=!linechanging;
1702 1702
           if(linechanging)
1703 1703
           {
1704
-              encoderpos=(int)retract_acceleration/100;
1704
+              encoderpos=(long)retract_acceleration/100;
1705 1705
           }
1706 1706
           else
1707 1707
           {
@@ -1725,7 +1725,7 @@ void MainMenu::showControlMotion()
1725 1725
       if(force_lcd_update)
1726 1726
         {
1727 1727
           lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
1728
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0]));
1728
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
1729 1729
         }
1730 1730
         
1731 1731
         if((activeline!=line) )
@@ -1736,13 +1736,13 @@ void MainMenu::showControlMotion()
1736 1736
           linechanging=!linechanging;
1737 1737
           if(linechanging)
1738 1738
           {
1739
-              encoderpos=(int)(axis_steps_per_unit[0]*100.0);
1739
+              encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
1740 1740
           }
1741 1741
           else
1742 1742
           {
1743
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]);
1743
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
1744 1744
             position[X_AXIS]=lround(position[X_AXIS]*factor);
1745
-            //current_position[3]*=factor;
1745
+            //current_position[X_AXIS]*=factor;
1746 1746
             axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
1747 1747
             encoderpos=activeline*lcdslow;
1748 1748
           }
@@ -1752,7 +1752,7 @@ void MainMenu::showControlMotion()
1752 1752
         if(linechanging)
1753 1753
         {
1754 1754
           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
1755
+          if(encoderpos>999999) encoderpos=99999;
1756 1756
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1757 1757
         }
1758 1758
         
@@ -1762,7 +1762,7 @@ void MainMenu::showControlMotion()
1762 1762
       if(force_lcd_update)
1763 1763
         {
1764 1764
           lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
1765
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1]));
1765
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
1766 1766
         }
1767 1767
         
1768 1768
         if((activeline!=line) )
@@ -1773,13 +1773,13 @@ void MainMenu::showControlMotion()
1773 1773
           linechanging=!linechanging;
1774 1774
           if(linechanging)
1775 1775
           {
1776
-              encoderpos=(int)(axis_steps_per_unit[1]*100.0);
1776
+              encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
1777 1777
           }
1778 1778
           else
1779 1779
           {
1780
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]);
1780
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
1781 1781
             position[Y_AXIS]=lround(position[Y_AXIS]*factor);
1782
-            //current_position[3]*=factor;
1782
+            //current_position[Y_AXIS]*=factor;
1783 1783
             axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
1784 1784
             encoderpos=activeline*lcdslow;
1785 1785
               
@@ -1790,7 +1790,7 @@ void MainMenu::showControlMotion()
1790 1790
         if(linechanging)
1791 1791
         {
1792 1792
           if(encoderpos<5) encoderpos=5;
1793
-          if(encoderpos>9999) encoderpos=9999;
1793
+          if(encoderpos>999999) encoderpos=999999;
1794 1794
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1795 1795
         }
1796 1796
         
@@ -1800,7 +1800,7 @@ void MainMenu::showControlMotion()
1800 1800
       if(force_lcd_update)
1801 1801
         {
1802 1802
           lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
1803
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2]));
1803
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS]));
1804 1804
         }
1805 1805
         
1806 1806
         if((activeline!=line) )
@@ -1811,13 +1811,13 @@ void MainMenu::showControlMotion()
1811 1811
           linechanging=!linechanging;
1812 1812
           if(linechanging)
1813 1813
           {
1814
-              encoderpos=(int)(axis_steps_per_unit[2]*100.0);
1814
+              encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
1815 1815
           }
1816 1816
           else
1817 1817
           {
1818
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]);
1818
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
1819 1819
             position[Z_AXIS]=lround(position[Z_AXIS]*factor);
1820
-            //current_position[3]*=factor;
1820
+            //current_position[Z_AXIS]*=factor;
1821 1821
             axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
1822 1822
             encoderpos=activeline*lcdslow;
1823 1823
               
@@ -1828,7 +1828,7 @@ void MainMenu::showControlMotion()
1828 1828
         if(linechanging)
1829 1829
         {
1830 1830
           if(encoderpos<5) encoderpos=5;
1831
-          if(encoderpos>9999) encoderpos=9999;
1831
+          if(encoderpos>999999) encoderpos=999999;
1832 1832
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1833 1833
         }
1834 1834
         
@@ -1839,7 +1839,7 @@ void MainMenu::showControlMotion()
1839 1839
       if(force_lcd_update)
1840 1840
         {
1841 1841
           lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
1842
-          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3]));
1842
+          lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
1843 1843
         }
1844 1844
         
1845 1845
         if((activeline!=line) )
@@ -1850,13 +1850,13 @@ void MainMenu::showControlMotion()
1850 1850
           linechanging=!linechanging;
1851 1851
           if(linechanging)
1852 1852
           {
1853
-              encoderpos=(int)(axis_steps_per_unit[3]*100.0);
1853
+              encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
1854 1854
           }
1855 1855
           else
1856 1856
           {
1857
-            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]);
1857
+            float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
1858 1858
             position[E_AXIS]=lround(position[E_AXIS]*factor);
1859
-            //current_position[3]*=factor;
1859
+            //current_position[E_AXIS]*=factor;
1860 1860
             axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
1861 1861
             encoderpos=activeline*lcdslow;
1862 1862
               
@@ -1867,7 +1867,7 @@ void MainMenu::showControlMotion()
1867 1867
         if(linechanging)
1868 1868
         {
1869 1869
           if(encoderpos<5) encoderpos=5;
1870
-          if(encoderpos>9999) encoderpos=9999;
1870
+          if(encoderpos>999999) encoderpos=999999;
1871 1871
           lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
1872 1872
         }
1873 1873
         
@@ -2381,4 +2381,4 @@ char *ftostr52(const float &x)
2381 2381
 
2382 2382
 #endif //ULTRA_LCD
2383 2383
 
2384
-
2384
+

Loading…
Откажи
Сачувај