瀏覽代碼

Fixed lookup table bug.

Erik van der Zalm 13 年之前
父節點
當前提交
0024a26ccf
共有 1 個檔案被更改,包括 13 行新增13 行删除
  1. 13
    13
      Marlin/Marlin.pde

+ 13
- 13
Marlin/Marlin.pde 查看文件

33
 #include "Marlin.h"
33
 #include "Marlin.h"
34
 #include "speed_lookuptable.h"
34
 #include "speed_lookuptable.h"
35
 
35
 
36
-char version_string[] = "0.9.1";
36
+char version_string[] = "0.9.2";
37
 
37
 
38
 #ifdef SDSUPPORT
38
 #ifdef SDSUPPORT
39
 #include "SdFat.h"
39
 #include "SdFat.h"
1163
 #endif // ADVANCE
1163
 #endif // ADVANCE
1164
 
1164
 
1165
   // Limit minimal step rate (Otherwise the timer will overflow.)
1165
   // Limit minimal step rate (Otherwise the timer will overflow.)
1166
-  if(initial_rate <32) initial_rate=32;
1167
-  if(final_rate < 32) final_rate=32;
1166
+  if(initial_rate <120) initial_rate=120;
1167
+  if(final_rate < 120) final_rate=120;
1168
   
1168
   
1169
   // Calculate the acceleration steps
1169
   // Calculate the acceleration steps
1170
   long acceleration = block->acceleration;
1170
   long acceleration = block->acceleration;
1213
 // velocities of the respective blocks.
1213
 // velocities of the respective blocks.
1214
 inline float junction_jerk(block_t *before, block_t *after) {
1214
 inline float junction_jerk(block_t *before, block_t *after) {
1215
   return(sqrt(
1215
   return(sqrt(
1216
-  pow((before->speed_x-after->speed_x), 2)+
1216
+    pow((before->speed_x-after->speed_x), 2)+
1217
     pow((before->speed_y-after->speed_y), 2)+
1217
     pow((before->speed_y-after->speed_y), 2)+
1218
-    pow((before->speed_z-after->speed_z)*axis_steps_per_unit[Z_AXIS]/axis_steps_per_unit[X_AXIS], 2))
1219
-    );
1218
+    pow((before->speed_z-after->speed_z)*axis_steps_per_unit[Z_AXIS]/axis_steps_per_unit[X_AXIS], 2)));
1220
 }
1219
 }
1221
 
1220
 
1222
 // Return the safe speed which is max_jerk/2, e.g. the 
1221
 // Return the safe speed which is max_jerk/2, e.g. the 
1494
 
1493
 
1495
   block->nominal_speed = block->millimeters * multiplier;
1494
   block->nominal_speed = block->millimeters * multiplier;
1496
   block->nominal_rate = ceil(block->step_event_count * multiplier / 60);  
1495
   block->nominal_rate = ceil(block->step_event_count * multiplier / 60);  
1497
-  if(block->nominal_rate < 32) block->nominal_rate = 32;
1496
+  if(block->nominal_rate < 120) block->nominal_rate = 120;
1498
   block->entry_speed = safe_speed(block);
1497
   block->entry_speed = safe_speed(block);
1499
 
1498
 
1500
   // Compute the acceleration rate for the trapezoid generator. 
1499
   // Compute the acceleration rate for the trapezoid generator. 
1603
 "d" (charIn1), \
1602
 "d" (charIn1), \
1604
 "d" (intIn2) \
1603
 "d" (intIn2) \
1605
 : \
1604
 : \
1606
-"r26" , "r27" \
1605
+"r26" \
1607
 )
1606
 )
1608
 
1607
 
1609
 // intRes = longIn1 * longIn2 >> 24
1608
 // intRes = longIn1 * longIn2 >> 24
1670
 static short e_steps;
1669
 static short e_steps;
1671
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
1670
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
1672
 static long acceleration_time, deceleration_time;
1671
 static long acceleration_time, deceleration_time;
1673
-static long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate;
1672
+static long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
1674
 static unsigned short acc_step_rate; // needed for deccelaration start point
1673
 static unsigned short acc_step_rate; // needed for deccelaration start point
1675
 
1674
 
1676
 
1675
 
1700
   unsigned short timer;
1699
   unsigned short timer;
1701
   if(step_rate < 32) step_rate = 32;
1700
   if(step_rate < 32) step_rate = 32;
1702
   step_rate -= 32; // Correct for minimal speed
1701
   step_rate -= 32; // Correct for minimal speed
1703
-  if(step_rate > (8*256)){ // higher step rate 
1702
+  if(step_rate >= (8*256)){ // higher step rate 
1704
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
1703
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
1705
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
1704
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
1706
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
1705
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
1725
   acceleration_rate = current_block->acceleration_rate;
1724
   acceleration_rate = current_block->acceleration_rate;
1726
   initial_rate = current_block->initial_rate;
1725
   initial_rate = current_block->initial_rate;
1727
   final_rate = current_block->final_rate;
1726
   final_rate = current_block->final_rate;
1727
+  nominal_rate = current_block->nominal_rate;
1728
   advance = current_block->initial_advance;
1728
   advance = current_block->initial_advance;
1729
   final_advance = current_block->final_advance;
1729
   final_advance = current_block->final_advance;
1730
   deceleration_time = 0;
1730
   deceleration_time = 0;
1864
       acc_step_rate += initial_rate;
1864
       acc_step_rate += initial_rate;
1865
       
1865
       
1866
       // upper limit
1866
       // upper limit
1867
-      if(acc_step_rate > current_block->nominal_rate)
1868
-        acc_step_rate = current_block->nominal_rate;
1867
+      if(acc_step_rate > nominal_rate)
1868
+        acc_step_rate = nominal_rate;
1869
 
1869
 
1870
       // step_rate to timer interval
1870
       // step_rate to timer interval
1871
       timer = calc_timer(acc_step_rate);
1871
       timer = calc_timer(acc_step_rate);
1873
       acceleration_time += timer;
1873
       acceleration_time += timer;
1874
       OCR1A = timer;
1874
       OCR1A = timer;
1875
     } 
1875
     } 
1876
-    else if (step_events_completed > decelerate_after) {   
1876
+    else if (step_events_completed >= decelerate_after) {   
1877
       MultiU24X24toH16(step_rate, deceleration_time, acceleration_rate);
1877
       MultiU24X24toH16(step_rate, deceleration_time, acceleration_rate);
1878
       
1878
       
1879
       if(step_rate > acc_step_rate) { // Check step_rate stays positive
1879
       if(step_rate > acc_step_rate) { // Check step_rate stays positive

Loading…
取消
儲存