Browse Source

Some fixes in planner

Erik van der Zalm 13 years ago
parent
commit
5fd41ae872
3 changed files with 24 additions and 23 deletions
  1. 13
    9
      Marlin/Configuration.h
  2. 3
    6
      Marlin/planner.cpp
  3. 8
    8
      Marlin/stepper.cpp

+ 13
- 9
Marlin/Configuration.h View File

115
 
115
 
116
   #ifdef PID_PID
116
   #ifdef PID_PID
117
     //PID according to Ziegler-Nichols method
117
     //PID according to Ziegler-Nichols method
118
-    #define  DEFAULT_Kp  (0.6*PID_CRITIAL_GAIN)
119
-    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
120
-    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
118
+//    #define  DEFAULT_Kp  (0.6*PID_CRITIAL_GAIN)
119
+//    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
120
+//    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
121
+
122
+    #define  DEFAULT_Kp  22.2
123
+    #define  DEFAULT_Ki (1.25*PID_dT)  
124
+    #define  DEFAULT_Kd (99/PID_dT)  
121
   #endif
125
   #endif
122
- 
126
+   
123
   #ifdef PID_PI
127
   #ifdef PID_PI
124
     //PI according to Ziegler-Nichols method
128
     //PI according to Ziegler-Nichols method
125
     #define  DEFAULT_Kp (PID_CRITIAL_GAIN/2.2) 
129
     #define  DEFAULT_Kp (PID_CRITIAL_GAIN/2.2) 
197
 
201
 
198
 #define AXIS_RELATIVE_MODES {false, false, false, false}
202
 #define AXIS_RELATIVE_MODES {false, false, false, false}
199
 
203
 
200
-#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
204
+#define MAX_STEP_FREQUENCY 40000L // Max step frequency for Ultimaker (5000 pps / half step)
201
 
205
 
202
 // default settings 
206
 // default settings 
203
 
207
 
204
-#define DEFAULT_AXIS_STEPS_PER_UNIT   {79.87220447,79.87220447,200*8/3,14}                    // default steps per unit for ultimaker 
208
+#define DEFAULT_AXIS_STEPS_PER_UNIT   {79.87220447,79.87220447,200*8/3,760*1.1}                    // default steps per unit for ultimaker 
205
 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} 
209
 //#define DEFAULT_AXIS_STEPS_PER_UNIT   {40, 40, 3333.92, 67} 
206
-#define DEFAULT_MAX_FEEDRATE          {500, 500, 10, 500000}    // (mm/min)    
210
+#define DEFAULT_MAX_FEEDRATE          {500, 500, 5, 200000}    // (mm/sec)    
207
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
211
 #define DEFAULT_MAX_ACCELERATION      {9000,9000,100,10000}    // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
208
 
212
 
209
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
213
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
210
 #define DEFAULT_RETRACT_ACCELERATION  7000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
214
 #define DEFAULT_RETRACT_ACCELERATION  7000   // X, Y, Z and E max acceleration in mm/s^2 for r retracts
211
 
215
 
212
-#define DEFAULT_MINIMUMFEEDRATE       0     // minimum feedrate
213
-#define DEFAULT_MINTRAVELFEEDRATE     0
216
+#define DEFAULT_MINIMUMFEEDRATE       0.0     // minimum feedrate
217
+#define DEFAULT_MINTRAVELFEEDRATE     0.0
214
 
218
 
215
 // minimum time in microseconds that a movement needs to take if the buffer is emptied.   Increase this number if you see blobs while printing high speed & high detail.  It will slowdown on the detailed stuff.
219
 // minimum time in microseconds that a movement needs to take if the buffer is emptied.   Increase this number if you see blobs while printing high speed & high detail.  It will slowdown on the detailed stuff.
216
 #define DEFAULT_MINSEGMENTTIME        20000   // Obsolete delete this
220
 #define DEFAULT_MINSEGMENTTIME        20000   // Obsolete delete this

+ 3
- 6
Marlin/planner.cpp View File

490
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
490
   delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
491
   delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
491
   delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
492
   block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
492
   block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
493
-                            square(delta_mm[Z_AXIS]));
493
+                            square(delta_mm[Z_AXIS]) + square(delta_mm[E_AXIS]));
494
   float inverse_millimeters = 1.0/block->millimeters;  // Inverse millimeters to remove multiple divides 
494
   float inverse_millimeters = 1.0/block->millimeters;  // Inverse millimeters to remove multiple divides 
495
   
495
   
496
   // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
496
   // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
502
   //  segment time im micro seconds
502
   //  segment time im micro seconds
503
   long segment_time = lround(1000000.0/inverse_second);
503
   long segment_time = lround(1000000.0/inverse_second);
504
  
504
  
505
- 
505
+
506
   if (block->steps_e == 0) {
506
   if (block->steps_e == 0) {
507
         if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
507
         if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
508
   }
508
   }
518
 #endif
518
 #endif
519
 
519
 
520
 /*
520
 /*
521
-
522
-  
523
   if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
521
   if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
524
     if (segment_time<minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
522
     if (segment_time<minsegmenttime)  { // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
525
         segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
523
         segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
531
   //  END OF SLOW DOWN SECTION    
529
   //  END OF SLOW DOWN SECTION    
532
 */
530
 */
533
 
531
 
532
+
534
  // Calculate speed in mm/sec for each axis
533
  // Calculate speed in mm/sec for each axis
535
   float current_speed[4];
534
   float current_speed[4];
536
   for(int i=0; i < 4; i++) {
535
   for(int i=0; i < 4; i++) {
545
   }
544
   }
546
 
545
 
547
 // Max segement time in us.
546
 // Max segement time in us.
548
-
549
 #ifdef XY_FREQUENCY_LIMIT
547
 #ifdef XY_FREQUENCY_LIMIT
550
 #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
548
 #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
551
 
549
 
575
   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, (float)min_xy_segment_time / (float)MAX_FREQ_TIME);
576
 #endif
574
 #endif
577
 
575
 
578
-
579
   // Correct the speed  
576
   // Correct the speed  
580
   if( speed_factor < 1.0) {
577
   if( speed_factor < 1.0) {
581
 //    Serial.print("speed factor : "); Serial.println(speed_factor);
578
 //    Serial.print("speed factor : "); Serial.println(speed_factor);

+ 8
- 8
Marlin/stepper.cpp View File

227
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
227
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
228
   
228
   
229
   if(step_rate > 20000) { // If steprate > 20kHz >> step 4 times
229
   if(step_rate > 20000) { // If steprate > 20kHz >> step 4 times
230
-    step_rate = step_rate >> 2;
230
+    step_rate = (step_rate >> 2)&0x3fff;
231
     step_loops = 4;
231
     step_loops = 4;
232
   }
232
   }
233
   else if(step_rate > 10000) { // If steprate > 10kHz >> step 2 times
233
   else if(step_rate > 10000) { // If steprate > 10kHz >> step 2 times
234
-    step_rate = step_rate >> 1;
234
+    step_rate = (step_rate >> 1)&0x7fff;
235
     step_loops = 2;
235
     step_loops = 2;
236
   }
236
   }
237
   else {
237
   else {
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;
256
+  if(timer < 100) timer = 100; //(20kHz this should never happen)
257
   return timer;
257
   return timer;
258
 }
258
 }
259
 
259
 
340
       #endif
340
       #endif
341
       #if X_MIN_PIN > -1
341
       #if X_MIN_PIN > -1
342
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
342
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
343
-              endstops_triggered(step_events_completed);
343
+ //             endstops_triggered(step_events_completed);
344
               step_events_completed = current_block->step_event_count;
344
               step_events_completed = current_block->step_event_count;
345
             }
345
             }
346
       #endif
346
       #endif
352
       #endif
352
       #endif
353
       #if X_MAX_PIN > -1
353
       #if X_MAX_PIN > -1
354
         if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_x >0)){
354
         if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_x >0)){
355
-          endstops_triggered(step_events_completed);
355
+ //         endstops_triggered(step_events_completed);
356
           step_events_completed = current_block->step_event_count;
356
           step_events_completed = current_block->step_event_count;
357
         }
357
         }
358
         #endif
358
         #endif
365
       #endif
365
       #endif
366
       #if Y_MIN_PIN > -1
366
       #if Y_MIN_PIN > -1
367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
-          endstops_triggered(step_events_completed);
368
+ //         endstops_triggered(step_events_completed);
369
           step_events_completed = current_block->step_event_count;
369
           step_events_completed = current_block->step_event_count;
370
         }
370
         }
371
       #endif
371
       #endif
377
       #endif
377
       #endif
378
       #if Y_MAX_PIN > -1
378
       #if Y_MAX_PIN > -1
379
       if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y >0)){
379
       if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y >0)){
380
-          endstops_triggered(step_events_completed);
380
+ //         endstops_triggered(step_events_completed);
381
           step_events_completed = current_block->step_event_count;
381
           step_events_completed = current_block->step_event_count;
382
         }
382
         }
383
       #endif
383
       #endif
402
       #endif
402
       #endif
403
       #if Z_MAX_PIN > -1
403
       #if Z_MAX_PIN > -1
404
         if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z >0)){
404
         if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z >0)){
405
-          endstops_triggered(step_events_completed);
405
+ //         endstops_triggered(step_events_completed);
406
           step_events_completed = current_block->step_event_count;
406
           step_events_completed = current_block->step_event_count;
407
         }
407
         }
408
       #endif
408
       #endif

Loading…
Cancel
Save