Browse Source

Fixed some small planner bugs

Erik van der Zalm 13 years ago
parent
commit
805d37f77b
4 changed files with 24 additions and 18 deletions
  1. 3
    2
      Marlin/Configuration.h
  2. 10
    5
      Marlin/planner.cpp
  3. 10
    10
      Marlin/planner.h
  4. 1
    1
      Marlin/stepper.cpp

+ 3
- 2
Marlin/Configuration.h View File

@@ -11,7 +11,8 @@
11 11
 
12 12
 // Frequency limit
13 13
 // See nophead's blog for more info
14
-#define XY_FREQUENCY_LIMIT  15
14
+// Not working OK
15
+//#define XY_FREQUENCY_LIMIT  15
15 16
 
16 17
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
17 18
 // of the buffer and all stops. This should not be much greater than zero and should only be changed
@@ -201,7 +202,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
201 202
 
202 203
 #define AXIS_RELATIVE_MODES {false, false, false, false}
203 204
 
204
-#define MAX_STEP_FREQUENCY 40000L // Max step frequency for Ultimaker (5000 pps / half step)
205
+#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
205 206
 
206 207
 // default settings 
207 208
 

+ 10
- 5
Marlin/planner.cpp View File

@@ -72,7 +72,7 @@
72 72
 unsigned long minsegmenttime;
73 73
 float max_feedrate[4]; // set the max speeds
74 74
 float axis_steps_per_unit[4];
75
-long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
75
+unsigned long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
76 76
 float minimumfeedrate;
77 77
 float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
78 78
 float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
@@ -153,8 +153,8 @@ inline float intersection_distance(float initial_rate, float final_rate, float a
153 153
 // Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
154 154
 
155 155
 void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) {
156
-  long initial_rate = ceil(block->nominal_rate*entry_factor); // (step/min)
157
-  long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min)
156
+  unsigned long initial_rate = ceil(block->nominal_rate*entry_factor); // (step/min)
157
+  unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min)
158 158
 
159 159
   // Limit minimal step rate (Otherwise the timer will overflow.)
160 160
   if(initial_rate <120) {initial_rate=120; }
@@ -570,7 +570,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
570 570
   long max_x_segment_time = max(x_segment_time[0], max(x_segment_time[1], x_segment_time[2]));
571 571
   long max_y_segment_time = max(y_segment_time[0], max(y_segment_time[1], y_segment_time[2]));
572 572
   long min_xy_segment_time =min(max_x_segment_time, max_y_segment_time);
573
-  if(min_xy_segment_time < MAX_FREQ_TIME) speed_factor = min(speed_factor, (float)min_xy_segment_time / (float)MAX_FREQ_TIME);
573
+  if(min_xy_segment_time < MAX_FREQ_TIME) speed_factor = min(speed_factor, speed_factor * (float)min_xy_segment_time / (float)MAX_FREQ_TIME);
574 574
 #endif
575 575
 
576 576
   // Correct the speed  
@@ -579,7 +579,12 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
579 579
     for(int i=0; i < 4; i++) {
580 580
     if(abs(current_speed[i]) > max_feedrate[i])
581 581
       speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
582
-//      Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
582
+ /*     
583
+      if(speed_factor < 0.1) {
584
+        Serial.print("speed factor : "); Serial.println(speed_factor);
585
+        Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
586
+      }
587
+ */
583 588
   }
584 589
     for(unsigned char i=0; i < 4; i++) {
585 590
       current_speed[i] *= speed_factor;

+ 10
- 10
Marlin/planner.h View File

@@ -32,9 +32,9 @@ typedef struct {
32 32
   // Fields used by the bresenham algorithm for tracing the line
33 33
   long steps_x, steps_y, steps_z, steps_e;  // Step count along each axis
34 34
   long step_event_count;                    // The number of step events required to complete this block
35
-  volatile long accelerate_until;           // The index of the step event on which to stop acceleration
36
-  volatile long decelerate_after;           // The index of the step event on which to start decelerating
37
-  volatile long acceleration_rate;          // The acceleration rate used for acceleration calculation
35
+  long accelerate_until;                    // The index of the step event on which to stop acceleration
36
+  long decelerate_after;                    // The index of the step event on which to start decelerating
37
+  long acceleration_rate;                   // The acceleration rate used for acceleration calculation
38 38
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
39 39
   #ifdef ADVANCE
40 40
 //    long advance_rate;
@@ -50,14 +50,14 @@ typedef struct {
50 50
   float max_entry_speed;                             // Maximum allowable junction entry speed in mm/min
51 51
   float millimeters;                                 // The total travel of this block in mm
52 52
   float acceleration;                                // acceleration mm/sec^2
53
-  unsigned char recalculate_flag;                          // Planner flag to recalculate trapezoids on entry junction
54
-  unsigned char nominal_length_flag;                       // Planner flag for nominal speed always reached
53
+  unsigned char recalculate_flag;                    // Planner flag to recalculate trapezoids on entry junction
54
+  unsigned char nominal_length_flag;                 // Planner flag for nominal speed always reached
55 55
 
56 56
   // Settings for the trapezoid generator
57
-  long nominal_rate;                                 // The nominal step rate for this block in step_events/sec 
58
-  volatile long initial_rate;                        // The jerk-adjusted step rate at start of block  
59
-  volatile long final_rate;                          // The minimal rate at exit
60
-  long acceleration_st;                              // acceleration steps/sec^2
57
+  unsigned long nominal_rate;                        // The nominal step rate for this block in step_events/sec 
58
+  unsigned long initial_rate;                        // The jerk-adjusted step rate at start of block  
59
+  unsigned long final_rate;                          // The minimal rate at exit
60
+  unsigned long acceleration_st;                     // acceleration steps/sec^2
61 61
   volatile char busy;
62 62
 } block_t;
63 63
 
@@ -84,7 +84,7 @@ void check_axes_activity();
84 84
 extern unsigned long minsegmenttime;
85 85
 extern float max_feedrate[4]; // set the max speeds
86 86
 extern float axis_steps_per_unit[4];
87
-extern long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
87
+extern unsigned long max_acceleration_units_per_sq_second[4]; // Use M201 to override by software
88 88
 extern float minimumfeedrate;
89 89
 extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
90 90
 extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX

+ 1
- 1
Marlin/stepper.cpp View File

@@ -253,7 +253,7 @@ inline unsigned short calc_timer(unsigned short step_rate) {
253 253
     timer = (unsigned short)pgm_read_word_near(table_address);
254 254
     timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
255 255
   }
256
-  if(timer < 100) timer = 100; //(20kHz this should never happen)
256
+  if(timer < 100) { timer = 100; Serial.print("Steprate to high : "); Serial.println(step_rate); }//(20kHz this should never happen)
257 257
   return timer;
258 258
 }
259 259
 

Loading…
Cancel
Save