Skip to content

Commit

Permalink
Fix to DDA acceleration calculation
Browse files Browse the repository at this point in the history
Fixed problem with DDA acceleration calculation identified by rayhicks
  • Loading branch information
dc42 committed Feb 18, 2014
1 parent acbd556 commit 1450276
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Licence: GPL
#define CONFIGURATION_H

#define NAME "RepRapFirmware"
#define VERSION "0.57m-dc42"
#define DATE "2014-02-08"
#define VERSION "0.57n-dc42"
#define DATE "2014-02-18"
#define LAST_AUTHOR "dc42"

// Other firmware that we might switch to be compatible with.
Expand Down
37 changes: 17 additions & 20 deletions Move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,6 @@ void Move::DoLookAhead()
LookAhead* n1;
LookAhead* n2;

float u, v;

// If there are a reasonable number of moves in there (LOOK_AHEAD), or if we are
// doing single moves with no other move immediately following on, run up and down
// the moves using the DDA Init() function to reduce the start or the end speed
Expand All @@ -454,8 +452,8 @@ void Move::DoLookAhead()
{
if(n1->Processed() & vCosineSet)
{
u = n0->V();
v = n1->V();
float u = n0->V();
float v = n1->V();
if(lookAheadDDA->Init(n1, u, v) & change)
{
n0->SetV(u);
Expand All @@ -476,8 +474,8 @@ void Move::DoLookAhead()
{
if(n1->Processed() & vCosineSet)
{
u = n0->V();
v = n1->V();
float u = n0->V();
float v = n1->V();
if(lookAheadDDA->Init(n1, u, v) & change)
{
n0->SetV(u);
Expand All @@ -489,7 +487,7 @@ void Move::DoLookAhead()
n2 = n1;
n1 = n0;
n0 = n0->Previous();
}while(n0 != lookAheadRingGetPointer);
} while(n0 != lookAheadRingGetPointer);
n0->SetProcessed(complete);
}

Expand Down Expand Up @@ -833,27 +831,26 @@ MovementProfile DDA::AccelerationCalculation(float& u, float& v, MovementProfile
if(dCross < 0.0 || dCross > distance)
{
// With the acceleration available, it is not possible
// to satisfy u and v within the distance; reduce u and v
// proportionately to get ones that work and flag the fact.
// to satisfy u and v within the distance; reduce the greater of u and v
// to get ones that work and flag the fact.
// The result is two velocities that can just be accelerated
// or decelerated between over the distance to get
// from one to the other.

result = change;

float k = v/u;
u = 2.0*acceleration*distance/(k*k - 1);
if(u >= 0.0)
float temp = 2.0 * acceleration * distance;
if (v > u)
{
u = sqrt(u);
v = k*u;
} else
// Accelerating, reduce v
v = sqrt((u * u) + temp);
dCross = distance;
}
else
{
v = sqrt(-u);
u = v/k;
// Decelerating, reduce u
u = sqrt((v * v) + temp);
dCross = 0.0;
}

dCross = 0.5*(0.5*(v*v - u*u)/acceleration + distance);
}

// The DDA steps at which acceleration stops and deceleration starts
Expand Down

0 comments on commit 1450276

Please sign in to comment.