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,11 +115,15 @@
115 115
 
116 116
   #ifdef PID_PID
117 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 125
   #endif
122
- 
126
+   
123 127
   #ifdef PID_PI
124 128
     //PI according to Ziegler-Nichols method
125 129
     #define  DEFAULT_Kp (PID_CRITIAL_GAIN/2.2) 
@@ -197,20 +201,20 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
197 201
 
198 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 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 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 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 213
 #define DEFAULT_ACCELERATION          3000    // X, Y, Z and E max acceleration in mm/s^2 for printing moves 
210 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 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 220
 #define DEFAULT_MINSEGMENTTIME        20000   // Obsolete delete this

+ 3
- 6
Marlin/planner.cpp View File

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

+ 8
- 8
Marlin/stepper.cpp View File

@@ -227,11 +227,11 @@ inline unsigned short calc_timer(unsigned short step_rate) {
227 227
   if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
228 228
   
229 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 231
     step_loops = 4;
232 232
   }
233 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 235
     step_loops = 2;
236 236
   }
237 237
   else {
@@ -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;
256
+  if(timer < 100) timer = 100; //(20kHz this should never happen)
257 257
   return timer;
258 258
 }
259 259
 
@@ -340,7 +340,7 @@ ISR(TIMER1_COMPA_vect)
340 340
       #endif
341 341
       #if X_MIN_PIN > -1
342 342
             if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
343
-              endstops_triggered(step_events_completed);
343
+ //             endstops_triggered(step_events_completed);
344 344
               step_events_completed = current_block->step_event_count;
345 345
             }
346 346
       #endif
@@ -352,7 +352,7 @@ ISR(TIMER1_COMPA_vect)
352 352
       #endif
353 353
       #if X_MAX_PIN > -1
354 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 356
           step_events_completed = current_block->step_event_count;
357 357
         }
358 358
         #endif
@@ -365,7 +365,7 @@ ISR(TIMER1_COMPA_vect)
365 365
       #endif
366 366
       #if Y_MIN_PIN > -1
367 367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
-          endstops_triggered(step_events_completed);
368
+ //         endstops_triggered(step_events_completed);
369 369
           step_events_completed = current_block->step_event_count;
370 370
         }
371 371
       #endif
@@ -377,7 +377,7 @@ ISR(TIMER1_COMPA_vect)
377 377
       #endif
378 378
       #if Y_MAX_PIN > -1
379 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 381
           step_events_completed = current_block->step_event_count;
382 382
         }
383 383
       #endif
@@ -402,7 +402,7 @@ ISR(TIMER1_COMPA_vect)
402 402
       #endif
403 403
       #if Z_MAX_PIN > -1
404 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 406
           step_events_completed = current_block->step_event_count;
407 407
         }
408 408
       #endif

Loading…
Cancel
Save