We have multiplies followed by divides all over the place and
most of them are difficult to handle regarding overflows. This
new algorithm handles this fine in all cases, as long as all
three operators and the overall result fits into 32 bits.
The previous code was actually misbehaving and sent this string:
TYPE:Mendel EXTRUDER_COUNT:%d TEMP_SENSOR_COUNT:%d HEATER_COUNT:%d
(part of a string in gcode_process.c) instead of "0x". Ouch! Memory
landscape messed up?
This means:
- Max endstops are gone.
- Min endstops are now PB0 / PB1 / PB2.
- Order of the steppers is inverted (X Y Z E instead of E Z Y X).
- All pins on port A one to the left (pin number - 1).
These were commits 9dbfa7217e0de8b140846ab480d6b4a7fc9b6791 and
2b596cb05e621ed822071486f812eb334328267a.
There are several reasons why this new approach didn't work out well:
- The machine coordinate system is lost on relative movements.
OK, we could keep tracking it, but this would mean even more
code, so even more chances for bugs.
- With the lost coordinate system, no software endstops are possible.
- Neither of X, Y, Z will ever overflow.
- If a movement planner would appear one day, he'd have to handle
relative movements as well. Even more code duplication.
Instead of converting them to absolute first, then back to
relative and having all the fuzz with working on the queue's
start vs. working at the queue's end, mark a movement as relative
and use this directly.
Now we don't have tables for default or gen7 electronics, but
two default tables for a single vs. two different thermistors.
This seems to be more logical.
This isn't the magic patch which suddenly allows us to run at
arbitrary high step rates, but can deal with short bursts of
very short delays only. Typical for a 45 deg move when using
ACCELERATION_TEMPORAL.
The implementation simply extends the impossible small delay.
To keep overall timing promises regardless, the extra is stored
and compensated for when a longer delay request comes in.
Wrapped all this in #ifdef ACCELERATION_TEMPORAL, as this adds
about 300 bytes of binary size, so it likely slows down the
setTimer() code a bit and non-temporal algorithms are expected to
never request an unreasonable short delay.
The implementation is slightly different this time, as it's not
using these famous bresenham algorithms. The intention is to
allow axis-independent movements, as it's required for
EMC-quality look-ahead.
This makes the code cleaner and the reduction of code
probably easily compensates for keeping global interrupts
enabled for a bit longer. Talked to macscifi about this.
Saves about 300 bytes of binary size.