Browse Source

Fixed lookup table bug.

Erik van der Zalm 12 years ago
parent
commit
0024a26ccf
1 changed files with 13 additions and 13 deletions
  1. 13
    13
      Marlin/Marlin.pde

+ 13
- 13
Marlin/Marlin.pde View File

@@ -33,7 +33,7 @@
33 33
 #include "Marlin.h"
34 34
 #include "speed_lookuptable.h"
35 35
 
36
-char version_string[] = "0.9.1";
36
+char version_string[] = "0.9.2";
37 37
 
38 38
 #ifdef SDSUPPORT
39 39
 #include "SdFat.h"
@@ -1163,8 +1163,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_speed, float exit
1163 1163
 #endif // ADVANCE
1164 1164
 
1165 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 1169
   // Calculate the acceleration steps
1170 1170
   long acceleration = block->acceleration;
@@ -1213,10 +1213,9 @@ inline float max_allowable_speed(float acceleration, float target_velocity, floa
1213 1213
 // velocities of the respective blocks.
1214 1214
 inline float junction_jerk(block_t *before, block_t *after) {
1215 1215
   return(sqrt(
1216
-  pow((before->speed_x-after->speed_x), 2)+
1216
+    pow((before->speed_x-after->speed_x), 2)+
1217 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 1221
 // Return the safe speed which is max_jerk/2, e.g. the 
@@ -1494,7 +1493,7 @@ void plan_buffer_line(float x, float y, float z, float e, float feed_rate) {
1494 1493
 
1495 1494
   block->nominal_speed = block->millimeters * multiplier;
1496 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 1497
   block->entry_speed = safe_speed(block);
1499 1498
 
1500 1499
   // Compute the acceleration rate for the trapezoid generator. 
@@ -1603,7 +1602,7 @@ asm volatile ( \
1603 1602
 "d" (charIn1), \
1604 1603
 "d" (intIn2) \
1605 1604
 : \
1606
-"r26" , "r27" \
1605
+"r26" \
1607 1606
 )
1608 1607
 
1609 1608
 // intRes = longIn1 * longIn2 >> 24
@@ -1670,7 +1669,7 @@ static short old_advance = 0;
1670 1669
 static short e_steps;
1671 1670
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
1672 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 1673
 static unsigned short acc_step_rate; // needed for deccelaration start point
1675 1674
 
1676 1675
 
@@ -1700,7 +1699,7 @@ inline unsigned short calc_timer(unsigned short step_rate) {
1700 1699
   unsigned short timer;
1701 1700
   if(step_rate < 32) step_rate = 32;
1702 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 1703
     unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate>>8)][0];
1705 1704
     unsigned char tmp_step_rate = (step_rate & 0x00ff);
1706 1705
     unsigned short gain = (unsigned short)pgm_read_word_near(table_address+2);
@@ -1725,6 +1724,7 @@ inline void trapezoid_generator_reset() {
1725 1724
   acceleration_rate = current_block->acceleration_rate;
1726 1725
   initial_rate = current_block->initial_rate;
1727 1726
   final_rate = current_block->final_rate;
1727
+  nominal_rate = current_block->nominal_rate;
1728 1728
   advance = current_block->initial_advance;
1729 1729
   final_advance = current_block->final_advance;
1730 1730
   deceleration_time = 0;
@@ -1864,8 +1864,8 @@ ISR(TIMER1_COMPA_vect)
1864 1864
       acc_step_rate += initial_rate;
1865 1865
       
1866 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 1870
       // step_rate to timer interval
1871 1871
       timer = calc_timer(acc_step_rate);
@@ -1873,7 +1873,7 @@ ISR(TIMER1_COMPA_vect)
1873 1873
       acceleration_time += timer;
1874 1874
       OCR1A = timer;
1875 1875
     } 
1876
-    else if (step_events_completed > decelerate_after) {   
1876
+    else if (step_events_completed >= decelerate_after) {   
1877 1877
       MultiU24X24toH16(step_rate, deceleration_time, acceleration_rate);
1878 1878
       
1879 1879
       if(step_rate > acc_step_rate) { // Check step_rate stays positive

Loading…
Cancel
Save