| |
|
|
The following lines describe the details of the algorithms used by the
software. In order to simplify the presentation, the following assumptions
are made:
Algorithm description:
Read A (Xa,Ya) starting point coordinates.
read the coordinates of the following (destination) point B (Xb,Yb).
Computation of the distance and the time TPS required to travel from
starting point to destination (speed is known).
Slope calculation m = (Yb-Ya) / (Xb-Xa)
= ref. slope
First Stage:
If m > 2 drive 1 Y step
If m >= 0.5 and m <= 2 drive 1
X step + 1 Y step
If m < 0.5 drive 1 X step
When the line is stored, one imagine the result
of the dispacement as a new starting point, then recalculate a new slope
value from this new point, up to the destination point B.
A each stage, we can count the number of X alone
or Y alone steps (N1) and the number of simultaneous X+Y steps. To define
the the time t to spend at each stage, we get the following relation
TPS = N1*t + (N2*t*1.414) ... from which t = TPS/(N1+N2*1.414).
Once destination B is reached, B become the new
starting point (B-> A) and the next point is read (next destination)...and
so on.
Gilles Muller has found a new algorithm, more powerfull:
the trajectory is similar but remains centered on the theoretical curve.
Preliminary operations are identical
If ref.slope = 1
drive (Xb-Xa) X + Y steps
Si ref; slope < 1
m = ((Xb-Xa) mod (Yb-Ya))
Do (Yb-Ya) times
{
(1/(pente ref) div 2) X steps
1 X+Y step
1/(ref. slope) -1 - (1/(ref.
slope) div 2) X steps
si (m >0)
{
drive 1 X step;
m= m-1
}
}
If ref. slope > 1
m = ((Xb-Xa) mod (Yb-Ya))
Do (Xb-Xa) times
{
(ref. slope div 2) Y steps
1 X+Y step
ref. slope -1 - (ref. slope
div 2) Y steps
si (m >0)
{
drive 1 X step;
m= m-1
}
}
With these 2 methods you get these types of trajectories:
|
| Starting point A(0,0)
Destination B(27,3)
ref. slope = 3/27 = 0.111
-> X displacement (with respect to this
new point B coordinates are now (26,3))
m = 3/26 = 0.115 -> X+Y displacement ( B(25,2))
m = 2/25 = 0.08 -> X displacement ( B(24,2))
et ainsi de suite...
m = 0 (That's not
a good example! there is no remainder....but it works also!)
Do 3 times
9 / 2 = 4.5 -> 4 X steps
1 X+Y step
9 - 1 - 4 = 4 X steps
... |
Remind that for a 48 steps/turn motor and a 6mm lead screw (1mm/trun),
1 step correspond to an absolute displacement value close to 2/100 mm (0.0208mm).
To be compared with wire kerf value (and error)....
|