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
 
11
 
12
 // Frequency limit
12
 // Frequency limit
13
 // See nophead's blog for more info
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
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
17
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
17
 // of the buffer and all stops. This should not be much greater than zero and should only be changed
18
 // of the buffer and all stops. This should not be much greater than zero and should only be changed
201
 
202
 
202
 #define AXIS_RELATIVE_MODES {false, false, false, false}
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
 // default settings 
207
 // default settings 
207
 
208
 

+ 10
- 5
Marlin/planner.cpp View File

72
 unsigned long minsegmenttime;
72
 unsigned long minsegmenttime;
73
 float max_feedrate[4]; // set the max speeds
73
 float max_feedrate[4]; // set the max speeds
74
 float axis_steps_per_unit[4];
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
 float minimumfeedrate;
76
 float minimumfeedrate;
77
 float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
77
 float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
78
 float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
78
 float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
153
 // Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
153
 // Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
154
 
154
 
155
 void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) {
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
   // Limit minimal step rate (Otherwise the timer will overflow.)
159
   // Limit minimal step rate (Otherwise the timer will overflow.)
160
   if(initial_rate <120) {initial_rate=120; }
160
   if(initial_rate <120) {initial_rate=120; }
570
   long max_x_segment_time = max(x_segment_time[0], max(x_segment_time[1], x_segment_time[2]));
570
   long max_x_segment_time = max(x_segment_time[0], max(x_segment_time[1], x_segment_time[2]));
571
   long max_y_segment_time = max(y_segment_time[0], max(y_segment_time[1], y_segment_time[2]));
571
   long max_y_segment_time = max(y_segment_time[0], max(y_segment_time[1], y_segment_time[2]));
572
   long min_xy_segment_time =min(max_x_segment_time, max_y_segment_time);
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
 #endif
574
 #endif
575
 
575
 
576
   // Correct the speed  
576
   // Correct the speed  
579
     for(int i=0; i < 4; i++) {
579
     for(int i=0; i < 4; i++) {
580
     if(abs(current_speed[i]) > max_feedrate[i])
580
     if(abs(current_speed[i]) > max_feedrate[i])
581
       speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
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
     for(unsigned char i=0; i < 4; i++) {
589
     for(unsigned char i=0; i < 4; i++) {
585
       current_speed[i] *= speed_factor;
590
       current_speed[i] *= speed_factor;

+ 10
- 10
Marlin/planner.h View File

32
   // Fields used by the bresenham algorithm for tracing the line
32
   // Fields used by the bresenham algorithm for tracing the line
33
   long steps_x, steps_y, steps_z, steps_e;  // Step count along each axis
33
   long steps_x, steps_y, steps_z, steps_e;  // Step count along each axis
34
   long step_event_count;                    // The number of step events required to complete this block
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
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
38
   unsigned char direction_bits;             // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
39
   #ifdef ADVANCE
39
   #ifdef ADVANCE
40
 //    long advance_rate;
40
 //    long advance_rate;
50
   float max_entry_speed;                             // Maximum allowable junction entry speed in mm/min
50
   float max_entry_speed;                             // Maximum allowable junction entry speed in mm/min
51
   float millimeters;                                 // The total travel of this block in mm
51
   float millimeters;                                 // The total travel of this block in mm
52
   float acceleration;                                // acceleration mm/sec^2
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
   // Settings for the trapezoid generator
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
   volatile char busy;
61
   volatile char busy;
62
 } block_t;
62
 } block_t;
63
 
63
 
84
 extern unsigned long minsegmenttime;
84
 extern unsigned long minsegmenttime;
85
 extern float max_feedrate[4]; // set the max speeds
85
 extern float max_feedrate[4]; // set the max speeds
86
 extern float axis_steps_per_unit[4];
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
 extern float minimumfeedrate;
88
 extern float minimumfeedrate;
89
 extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
89
 extern float acceleration;         // Normal acceleration mm/s^2  THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
90
 extern float retract_acceleration; //  mm/s^2   filament pull-pack and push-forward  while standing still in the other axis M204 TXXXX
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
     timer = (unsigned short)pgm_read_word_near(table_address);
253
     timer = (unsigned short)pgm_read_word_near(table_address);
254
     timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
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
   return timer;
257
   return timer;
258
 }
258
 }
259
 
259
 

Loading…
Cancel
Save