|
@@ -51,9 +51,6 @@
|
51
|
51
|
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
|
52
|
52
|
*/
|
53
|
53
|
|
54
|
|
-
|
55
|
|
-
|
56
|
|
-
|
57
|
54
|
#include "Marlin.h"
|
58
|
55
|
#include "planner.h"
|
59
|
56
|
#include "stepper.h"
|
|
@@ -377,20 +374,26 @@ void plan_init() {
|
377
|
374
|
void getHighESpeed()
|
378
|
375
|
{
|
379
|
376
|
static float oldt=0;
|
380
|
|
- if(!autotemp_enabled)
|
|
377
|
+ if(!autotemp_enabled){
|
381
|
378
|
return;
|
382
|
|
- if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
|
|
379
|
+ }
|
|
380
|
+ if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
|
383
|
381
|
return; //do nothing
|
|
382
|
+ }
|
384
|
383
|
|
385
|
|
- float high=0;
|
|
384
|
+ float high=0.0;
|
386
|
385
|
uint8_t block_index = block_buffer_tail;
|
387
|
386
|
|
388
|
387
|
while(block_index != block_buffer_head) {
|
389
|
|
- float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
|
390
|
|
- //se; units steps/sec;
|
391
|
|
- if(se>high)
|
392
|
|
- {
|
393
|
|
- high=se;
|
|
388
|
+ if((block_buffer[block_index].steps_x != 0) ||
|
|
389
|
+ (block_buffer[block_index].steps_y != 0) ||
|
|
390
|
+ (block_buffer[block_index].steps_z != 0)) {
|
|
391
|
+ float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
|
|
392
|
+ //se; mm/sec;
|
|
393
|
+ if(se>high)
|
|
394
|
+ {
|
|
395
|
+ high=se;
|
|
396
|
+ }
|
394
|
397
|
}
|
395
|
398
|
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
396
|
399
|
}
|
|
@@ -407,10 +410,6 @@ void getHighESpeed()
|
407
|
410
|
}
|
408
|
411
|
oldt=t;
|
409
|
412
|
setTargetHotend0(t);
|
410
|
|
-// SERIAL_ECHO_START;
|
411
|
|
-// SERIAL_ECHOPAIR("highe",high);
|
412
|
|
-// SERIAL_ECHOPAIR(" t",t);
|
413
|
|
-// SERIAL_ECHOLN("");
|
414
|
413
|
}
|
415
|
414
|
#endif
|
416
|
415
|
|
|
@@ -456,6 +455,9 @@ void check_axes_activity() {
|
456
|
455
|
analogWrite(FAN_PIN,tail_fan_speed);
|
457
|
456
|
}
|
458
|
457
|
#endif
|
|
458
|
+ #ifdef AUTOTEMP
|
|
459
|
+ getHighESpeed();
|
|
460
|
+ #endif
|
459
|
461
|
}
|
460
|
462
|
|
461
|
463
|
|
|
@@ -517,7 +519,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
517
|
519
|
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
|
518
|
520
|
|
519
|
521
|
// Bail if this is a zero-length block
|
520
|
|
- if (block->step_event_count <=dropsegments) { return; };
|
|
522
|
+ if (block->step_event_count <= dropsegments) { return; };
|
521
|
523
|
|
522
|
524
|
block->fan_speed = FanSpeed;
|
523
|
525
|
|
|
@@ -540,7 +542,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
540
|
542
|
// Enable all
|
541
|
543
|
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
|
542
|
544
|
|
543
|
|
-
|
544
|
545
|
if (block->steps_e == 0) {
|
545
|
546
|
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
546
|
547
|
}
|
|
@@ -548,12 +549,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
548
|
549
|
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
|
549
|
550
|
}
|
550
|
551
|
|
551
|
|
- // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
552
|
|
- int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
553
|
|
- #ifdef SLOWDOWN
|
554
|
|
- if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
555
|
|
- #endif
|
556
|
|
-
|
557
|
552
|
float delta_mm[4];
|
558
|
553
|
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
|
559
|
554
|
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
|
|
@@ -569,34 +564,33 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
569
|
564
|
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
|
570
|
565
|
float inverse_second = feed_rate * inverse_millimeters;
|
571
|
566
|
|
572
|
|
- block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
573
|
|
- block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
574
|
|
-
|
|
567
|
+ int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
|
568
|
+
|
|
569
|
+ // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
|
570
|
+ #ifdef OLD_SLOWDOWN
|
|
571
|
+ if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
|
572
|
+ #endif
|
575
|
573
|
|
576
|
|
-/*
|
|
574
|
+ #ifdef SLOWDOWN
|
577
|
575
|
// segment time im micro seconds
|
578
|
|
- long segment_time = lround(1000000.0/inverse_second);
|
579
|
|
- if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
|
580
|
|
- if (segment_time<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
581
|
|
- segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
|
|
576
|
+ unsigned long segment_time = lround(1000000.0/inverse_second);
|
|
577
|
+ if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
|
|
578
|
+ if (segment_time < minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
|
579
|
+ inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
|
582
|
580
|
}
|
583
|
581
|
}
|
584
|
|
- else {
|
585
|
|
- if (segment_time<minsegmenttime) segment_time=minsegmenttime;
|
586
|
|
- }
|
|
582
|
+ #endif
|
587
|
583
|
// END OF SLOW DOWN SECTION
|
588
|
|
-*/
|
589
|
584
|
|
|
585
|
+
|
|
586
|
+ block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
|
587
|
+ block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
590
|
588
|
|
591
|
|
- // Calculate speed in mm/sec for each axis
|
|
589
|
+ // Calculate and limit speed in mm/sec for each axis
|
592
|
590
|
float current_speed[4];
|
593
|
|
- for(int i=0; i < 4; i++) {
|
594
|
|
- current_speed[i] = delta_mm[i] * inverse_second;
|
595
|
|
- }
|
596
|
|
-
|
597
|
|
- // Limit speed per axis
|
598
|
591
|
float speed_factor = 1.0; //factor <=1 do decrease speed
|
599
|
592
|
for(int i=0; i < 4; i++) {
|
|
593
|
+ current_speed[i] = delta_mm[i] * inverse_second;
|
600
|
594
|
if(abs(current_speed[i]) > max_feedrate[i])
|
601
|
595
|
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
|
602
|
596
|
}
|
|
@@ -633,17 +627,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
633
|
627
|
|
634
|
628
|
// Correct the speed
|
635
|
629
|
if( speed_factor < 1.0) {
|
636
|
|
-// Serial.print("speed factor : "); Serial.println(speed_factor);
|
637
|
|
- for(int i=0; i < 4; i++) {
|
638
|
|
- if(abs(current_speed[i]) > max_feedrate[i])
|
639
|
|
- speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
|
640
|
|
- /*
|
641
|
|
- if(speed_factor < 0.1) {
|
642
|
|
- Serial.print("speed factor : "); Serial.println(speed_factor);
|
643
|
|
- Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
|
644
|
|
- }
|
645
|
|
- */
|
646
|
|
- }
|
647
|
630
|
for(unsigned char i=0; i < 4; i++) {
|
648
|
631
|
current_speed[i] *= speed_factor;
|
649
|
632
|
}
|
|
@@ -784,9 +767,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
784
|
767
|
*/
|
785
|
768
|
#endif // ADVANCE
|
786
|
769
|
|
787
|
|
-
|
788
|
|
-
|
789
|
|
-
|
790
|
770
|
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
|
791
|
771
|
MINIMUM_PLANNER_SPEED/block->nominal_speed);
|
792
|
772
|
|
|
@@ -797,9 +777,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
797
|
777
|
memcpy(position, target, sizeof(target)); // position[] = target[]
|
798
|
778
|
|
799
|
779
|
planner_recalculate();
|
800
|
|
- #ifdef AUTOTEMP
|
801
|
|
- getHighESpeed();
|
802
|
|
- #endif
|
|
780
|
+
|
803
|
781
|
st_wake_up();
|
804
|
782
|
}
|
805
|
783
|
|