Keep ticking fx_counter regardless, this allows all axis to compensate for late block...
authorJim Morris <morris@wolfman.com>
Tue, 2 Dec 2014 06:22:11 +0000 (22:22 -0800)
committerJim Morris <morris@wolfman.com>
Tue, 2 Dec 2014 06:22:11 +0000 (22:22 -0800)
added an active flag to steppermotor so it can know when to ignore step or not

src/libs/StepTicker.cpp
src/libs/StepperMotor.cpp
src/libs/StepperMotor.h

index 93292d4..795f241 100644 (file)
@@ -187,9 +187,8 @@ void StepTicker::TIMER0_IRQHandler (void){
 
     // Step pins NOTE takes 1.2us when nothing to step, 1.8-2us for one motor stepped and 2.6us when two motors stepped, 3.167us when three motors stepped
     for (uint32_t motor = 0; motor < num_motors; motor++){
-        if (this->active_motor[motor]){
-            this->motor[motor]->tick();
-        }
+        // always send tick to all motors
+        this->motor[motor]->tick();
     }
 
     // We may have set a pin on in this tick, now we start the timer to set it off
index 21a2ec6..61b9c7f 100644 (file)
@@ -45,6 +45,7 @@ void StepperMotor::init()
     this->stepped = 0;
     this->steps_to_move = 0;
     this->is_move_finished = false;
+    this->active= false;
 
     steps_per_mm         = 1.0F;
     max_rate             = 50.0F;
@@ -62,7 +63,7 @@ void StepperMotor::init()
 void StepperMotor::step()
 {
     // we can't do anything until the next move has been processed, but we will be able to offset the time by shortening the next step
-    if(this->is_move_finished || !this->moving) return;
+    if(!this->active) return;
 
     // output to pins 37t
     this->step_pin.set( 1 );
@@ -115,9 +116,11 @@ void StepperMotor::update_exit_tick()
     if( !this->moving || this->paused || this->steps_to_move == 0 ) {
         // No more ticks will be recieved and no more events from StepTicker
         THEKERNEL->step_ticker->remove_motor_from_active_list(this);
+        this->active= false;
     } else {
         // we will now get ticks and StepTIcker will send us events
         THEKERNEL->step_ticker->add_motor_to_active_list(this);
+        this->active= true;
     }
 }
 
index 0a1e67e..1429781 100644 (file)
@@ -95,6 +95,7 @@ class StepperMotor {
             bool direction:1;
             volatile bool is_move_finished:1; // Whether the move just finished
             bool paused:1;
+            bool active:1; // whether in the stepticker active motors list or not
             volatile bool moving:1;
         };