potential race fixes
authorJim Morris <morris@wolfman.com>
Mon, 8 Dec 2014 05:29:49 +0000 (21:29 -0800)
committerJim Morris <morris@wolfman.com>
Mon, 8 Dec 2014 05:29:49 +0000 (21:29 -0800)
src/libs/StepperMotor.cpp

index 1200117..4c64d3c 100644 (file)
@@ -62,6 +62,9 @@ void StepperMotor::init()
 // This is in highest priority interrupt so cannot be pre-empted
 void StepperMotor::step()
 {
+    // ignore if we are still processing the end of a block
+    if(this->is_move_finished) return;
+
     // output to pins 37t
     this->step_pin.set( 1 );
 
@@ -135,7 +138,9 @@ StepperMotor* StepperMotor::move( bool direction, unsigned int steps, float init
         // if an axis stops too soon then we can get a huge number of ticks here which causes problems, so if the number of ticks is too great we ignore them
         // example of when this happens is when one axis is going very slow an the min 20steps/sec kicks in, the axis will reach its target much sooner leaving a long gap
         // until the end of the block.
-        if(ts > 15) ts= 0;
+        // TODO we may need to set this based on the current step rate, trouble is we don't know what that is yet
+        if(ts > 5) ts= 5; // limit to 50us catch up around 1-2 steps
+        else if(ts > 15) ts= 0; // no way to know what the delay was
         this->fx_counter= ts*fx_increment;
     }else{
         this->fx_counter = 0; // set to zero as there was no step last block