Browse Source

Added 20MHz support.

Erik van der Zalm 12 years ago
parent
commit
910f4e77a2
4 changed files with 84 additions and 11 deletions
  1. 4
    4
      Marlin/Configuration.h
  2. 2
    5
      Marlin/create_speed_lookuptable.py
  3. 76
    0
      Marlin/speed_lookuptable.h
  4. 2
    2
      Marlin/stepper.cpp

+ 4
- 4
Marlin/Configuration.h View File

@@ -82,13 +82,13 @@
82 82
   //#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
83 83
   #define PID_INTEGRAL_DRIVE_MAX 255  //limit for the integral term
84 84
   #define K1 0.95 //smoothing factor withing the PID
85
-  #define PID_dT 0.128 //sampling period of the PID
85
+  #define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the
86 86
 
87 87
 // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
88 88
 // Ultimaker
89 89
     #define  DEFAULT_Kp  22.2
90
-    #define  DEFAULT_Ki (1.25*PID_dT)  
91
-    #define  DEFAULT_Kd (99/PID_dT)  
90
+    #define  DEFAULT_Ki (1.08*PID_dT)  
91
+    #define  DEFAULT_Kd (114/PID_dT)  
92 92
 
93 93
 // Makergear
94 94
 //    #define  DEFAULT_Kp 7.0
@@ -194,7 +194,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
194 194
 
195 195
 #define ULTIPANEL
196 196
 #ifdef ULTIPANEL
197
-  #define NEWPANEL  //enable this if you have a click-encoder panel
197
+//  #define NEWPANEL  //enable this if you have a click-encoder panel
198 198
   #define SDSUPPORT
199 199
   #define ULTRA_LCD
200 200
   #define LCD_WIDTH 20

+ 2
- 5
Marlin/create_speed_lookuptable.py View File

@@ -22,11 +22,8 @@ print
22 22
 print '#include "Marlin.h"'
23 23
 print
24 24
 
25
-# Based on timer calculations of 'RepRap cartesian firmware' by Zack
26
-# Smith and Philip Tiefenbacher.
27
-
28 25
 print "const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {"
29
-a = [ timer_freq / ((i*256)+32) for i in range(256) ]
26
+a = [ timer_freq / ((i*256)+(args.cpu_freq*2)) for i in range(256) ]
30 27
 b = [ a[i] - a[i+1] for i in range(255) ]
31 28
 b.append(b[-1])
32 29
 for i in range(32):
@@ -38,7 +35,7 @@ print "};"
38 35
 print
39 36
 
40 37
 print "const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {"
41
-a = [ timer_freq / ((i*8)+32) for i in range(256) ]
38
+a = [ timer_freq / ((i*8)+(args.cpu_freq*2)) for i in range(256) ]
42 39
 b = [ a[i] - a[i+1] for i in range(255) ]
43 40
 b.append(b[-1])
44 41
 for i in range(32):

+ 76
- 0
Marlin/speed_lookuptable.h View File

@@ -3,6 +3,8 @@
3 3
 
4 4
 #include "Marlin.h"
5 5
 
6
+#if F_CPU == 16000000
7
+
6 8
 const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
7 9
 { 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135}, 
8 10
 { 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32}, 
@@ -73,4 +75,78 @@ const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
73 75
 { 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
74 76
 };
75 77
 
78
+#else
79
+
80
+const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {
81
+   {62500, 54055}, {8445, 3917}, {4528, 1434}, {3094, 745}, {2349, 456}, {1893, 307}, {1586, 222}, {1364, 167},
82
+   {1197, 131}, {1066, 105}, {961, 86}, {875, 72}, {803, 61}, {742, 53}, {689, 45}, {644, 40},
83
+   {604, 35}, {569, 32}, {537, 28}, {509, 25}, {484, 23}, {461, 21}, {440, 19}, {421, 17},
84
+   {404, 16}, {388, 15}, {373, 14}, {359, 13}, {346, 12}, {334, 11}, {323, 10}, {313, 10},
85
+   {303, 9}, {294, 9}, {285, 8}, {277, 7}, {270, 8}, {262, 7}, {255, 6}, {249, 6},
86
+   {243, 6}, {237, 6}, {231, 5}, {226, 5}, {221, 5}, {216, 5}, {211, 4}, {207, 5},
87
+   {202, 4}, {198, 4}, {194, 4}, {190, 3}, {187, 4}, {183, 3}, {180, 3}, {177, 4},
88
+   {173, 3}, {170, 3}, {167, 2}, {165, 3}, {162, 3}, {159, 2}, {157, 3}, {154, 2},
89
+   {152, 3}, {149, 2}, {147, 2}, {145, 2}, {143, 2}, {141, 2}, {139, 2}, {137, 2},
90
+   {135, 2}, {133, 2}, {131, 2}, {129, 1}, {128, 2}, {126, 2}, {124, 1}, {123, 2},
91
+   {121, 1}, {120, 2}, {118, 1}, {117, 1}, {116, 2}, {114, 1}, {113, 1}, {112, 2},
92
+   {110, 1}, {109, 1}, {108, 1}, {107, 2}, {105, 1}, {104, 1}, {103, 1}, {102, 1},
93
+   {101, 1}, {100, 1}, {99, 1}, {98, 1}, {97, 1}, {96, 1}, {95, 1}, {94, 1},
94
+   {93, 1}, {92, 1}, {91, 0}, {91, 1}, {90, 1}, {89, 1}, {88, 1}, {87, 0},
95
+   {87, 1}, {86, 1}, {85, 1}, {84, 0}, {84, 1}, {83, 1}, {82, 1}, {81, 0},
96
+   {81, 1}, {80, 1}, {79, 0}, {79, 1}, {78, 0}, {78, 1}, {77, 1}, {76, 0},
97
+   {76, 1}, {75, 0}, {75, 1}, {74, 1}, {73, 0}, {73, 1}, {72, 0}, {72, 1},
98
+   {71, 0}, {71, 1}, {70, 0}, {70, 1}, {69, 0}, {69, 1}, {68, 0}, {68, 1},
99
+   {67, 0}, {67, 1}, {66, 0}, {66, 1}, {65, 0}, {65, 0}, {65, 1}, {64, 0},
100
+   {64, 1}, {63, 0}, {63, 1}, {62, 0}, {62, 0}, {62, 1}, {61, 0}, {61, 1},
101
+   {60, 0}, {60, 0}, {60, 1}, {59, 0}, {59, 0}, {59, 1}, {58, 0}, {58, 0},
102
+   {58, 1}, {57, 0}, {57, 0}, {57, 1}, {56, 0}, {56, 0}, {56, 1}, {55, 0},
103
+   {55, 0}, {55, 1}, {54, 0}, {54, 0}, {54, 1}, {53, 0}, {53, 0}, {53, 0},
104
+   {53, 1}, {52, 0}, {52, 0}, {52, 1}, {51, 0}, {51, 0}, {51, 0}, {51, 1},
105
+   {50, 0}, {50, 0}, {50, 0}, {50, 1}, {49, 0}, {49, 0}, {49, 0}, {49, 1},
106
+   {48, 0}, {48, 0}, {48, 0}, {48, 1}, {47, 0}, {47, 0}, {47, 0}, {47, 1},
107
+   {46, 0}, {46, 0}, {46, 0}, {46, 0}, {46, 1}, {45, 0}, {45, 0}, {45, 0},
108
+   {45, 1}, {44, 0}, {44, 0}, {44, 0}, {44, 0}, {44, 1}, {43, 0}, {43, 0},
109
+   {43, 0}, {43, 0}, {43, 1}, {42, 0}, {42, 0}, {42, 0}, {42, 0}, {42, 0},
110
+   {42, 1}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 0}, {41, 1}, {40, 0},
111
+   {40, 0}, {40, 0}, {40, 0}, {40, 1}, {39, 0}, {39, 0}, {39, 0}, {39, 0},
112
+   {39, 0}, {39, 0}, {39, 1}, {38, 0}, {38, 0}, {38, 0}, {38, 0}, {38, 0},
113
+};
114
+
115
+const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {
116
+   {62500, 10417}, {52083, 7441}, {44642, 5580}, {39062, 4340}, {34722, 3472}, {31250, 2841}, {28409, 2368}, {26041, 2003},
117
+   {24038, 1717}, {22321, 1488}, {20833, 1302}, {19531, 1149}, {18382, 1021}, {17361, 914}, {16447, 822}, {15625, 745},
118
+   {14880, 676}, {14204, 618}, {13586, 566}, {13020, 520}, {12500, 481}, {12019, 445}, {11574, 414}, {11160, 385},
119
+   {10775, 359}, {10416, 336}, {10080, 315}, {9765, 296}, {9469, 278}, {9191, 263}, {8928, 248}, {8680, 235},
120
+   {8445, 222}, {8223, 211}, {8012, 200}, {7812, 191}, {7621, 181}, {7440, 173}, {7267, 165}, {7102, 158},
121
+   {6944, 151}, {6793, 145}, {6648, 138}, {6510, 133}, {6377, 127}, {6250, 123}, {6127, 118}, {6009, 113},
122
+   {5896, 109}, {5787, 106}, {5681, 101}, {5580, 98}, {5482, 95}, {5387, 91}, {5296, 88}, {5208, 86},
123
+   {5122, 82}, {5040, 80}, {4960, 78}, {4882, 75}, {4807, 73}, {4734, 70}, {4664, 69}, {4595, 67},
124
+   {4528, 64}, {4464, 63}, {4401, 61}, {4340, 60}, {4280, 58}, {4222, 56}, {4166, 55}, {4111, 53},
125
+   {4058, 52}, {4006, 51}, {3955, 49}, {3906, 48}, {3858, 48}, {3810, 45}, {3765, 45}, {3720, 44},
126
+   {3676, 43}, {3633, 42}, {3591, 40}, {3551, 40}, {3511, 39}, {3472, 38}, {3434, 38}, {3396, 36},
127
+   {3360, 36}, {3324, 35}, {3289, 34}, {3255, 34}, {3221, 33}, {3188, 32}, {3156, 31}, {3125, 31},
128
+   {3094, 31}, {3063, 30}, {3033, 29}, {3004, 28}, {2976, 28}, {2948, 28}, {2920, 27}, {2893, 27},
129
+   {2866, 26}, {2840, 25}, {2815, 25}, {2790, 25}, {2765, 24}, {2741, 24}, {2717, 24}, {2693, 23},
130
+   {2670, 22}, {2648, 22}, {2626, 22}, {2604, 22}, {2582, 21}, {2561, 21}, {2540, 20}, {2520, 20},
131
+   {2500, 20}, {2480, 20}, {2460, 19}, {2441, 19}, {2422, 19}, {2403, 18}, {2385, 18}, {2367, 18},
132
+   {2349, 17}, {2332, 18}, {2314, 17}, {2297, 16}, {2281, 17}, {2264, 16}, {2248, 16}, {2232, 16},
133
+   {2216, 16}, {2200, 15}, {2185, 15}, {2170, 15}, {2155, 15}, {2140, 15}, {2125, 14}, {2111, 14},
134
+   {2097, 14}, {2083, 14}, {2069, 14}, {2055, 13}, {2042, 13}, {2029, 13}, {2016, 13}, {2003, 13},
135
+   {1990, 13}, {1977, 12}, {1965, 12}, {1953, 13}, {1940, 11}, {1929, 12}, {1917, 12}, {1905, 12},
136
+   {1893, 11}, {1882, 11}, {1871, 11}, {1860, 11}, {1849, 11}, {1838, 11}, {1827, 11}, {1816, 10},
137
+   {1806, 11}, {1795, 10}, {1785, 10}, {1775, 10}, {1765, 10}, {1755, 10}, {1745, 9}, {1736, 10},
138
+   {1726, 9}, {1717, 10}, {1707, 9}, {1698, 9}, {1689, 9}, {1680, 9}, {1671, 9}, {1662, 9},
139
+   {1653, 9}, {1644, 8}, {1636, 9}, {1627, 8}, {1619, 9}, {1610, 8}, {1602, 8}, {1594, 8},
140
+   {1586, 8}, {1578, 8}, {1570, 8}, {1562, 8}, {1554, 7}, {1547, 8}, {1539, 8}, {1531, 7},
141
+   {1524, 8}, {1516, 7}, {1509, 7}, {1502, 7}, {1495, 7}, {1488, 7}, {1481, 7}, {1474, 7},
142
+   {1467, 7}, {1460, 7}, {1453, 7}, {1446, 6}, {1440, 7}, {1433, 7}, {1426, 6}, {1420, 6},
143
+   {1414, 7}, {1407, 6}, {1401, 6}, {1395, 7}, {1388, 6}, {1382, 6}, {1376, 6}, {1370, 6},
144
+   {1364, 6}, {1358, 6}, {1352, 6}, {1346, 5}, {1341, 6}, {1335, 6}, {1329, 5}, {1324, 6},
145
+   {1318, 5}, {1313, 6}, {1307, 5}, {1302, 6}, {1296, 5}, {1291, 5}, {1286, 6}, {1280, 5},
146
+   {1275, 5}, {1270, 5}, {1265, 5}, {1260, 5}, {1255, 5}, {1250, 5}, {1245, 5}, {1240, 5},
147
+   {1235, 5}, {1230, 5}, {1225, 5}, {1220, 5}, {1215, 4}, {1211, 5}, {1206, 5}, {1201, 5},
148
+};
149
+
150
+#endif
151
+
76 152
 #endif

+ 2
- 2
Marlin/stepper.cpp View File

@@ -236,8 +236,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
236 236
     step_loops = 1;
237 237
   } 
238 238
   
239
-  if(step_rate < 32) step_rate = 32;
240
-  step_rate -= 32; // Correct for minimal speed
239
+  if(step_rate < (F_CPU/500000)) step_rate = (F_CPU/500000);
240
+  step_rate -= (F_CPU/500000); // Correct for minimal speed
241 241
   if(step_rate >= (8*256)){ // higher step rate 
242 242
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
243 243
     unsigned char tmp_step_rate = (step_rate & 0x00ff);

Loading…
Cancel
Save