Commit Graph

194 Commits

Author SHA1 Message Date
Markus Hitter e28afeca7d DDA, dda_start(): use mb_tail_dda directly.
Just avoiding to pass mb_tail_dda as parameter didn't work out,
so how about using it directly? This is what this commit does.

Result: binary size another 32 bytes bigger, slowest step another
16 clock cycles slower. No dice.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19306 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 414 clock cycles.
  LED on time average: 249.436 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 457 clock cycles.
  LED on time average: 272.256 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 414 clock cycles.
  LED on time average: 262.595 clock cycles.
2016-12-06 19:44:25 +01:00
Markus Hitter 480cc40618 DDA, dda_start(): don't pass mb_tail_dda as parameter.
Instead, read the global variable directly.

The idea is that reading the global variable directly removes
the effort to build up a parameter stack, making things faster.

Actually, binary size increases by 4 bytes and the slowest step
takes 3 clock cycles longer. D'oh.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19274 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 398 clock cycles.
  LED on time average: 249.111 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 441 clock cycles.
  LED on time average: 272.222 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 398 clock cycles.
  LED on time average: 262.576 clock cycles.
2016-12-06 19:44:23 +01:00
Markus Hitter d5eb8cd916 DDA: avoid looking up the movebuffer array.
As we have mb_tail_dda now, that's no longer necessary. Using
something like movebuffer[mb_tail] is more expensive than
dereferencing mb_tail_dda directly.

This is the first time we see a stepping performance improvement
since introducing mb_tail_dda. 13 clock cycles faster on the
slowest step, which is 9 cycles faster than before that
introduction.

Binary size also a nice 94 bytes down.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19270 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 249.051 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 438 clock cycles.
  LED on time average: 272.216 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 262.572 clock cycles.
2016-12-06 15:33:26 +01:00
Markus Hitter eec0e00f85 dda_queue.c/.h: eliminate queue_current_movement().
Again no stepping performance improvement, but another 34 bytes
off the binary size:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19364 bytes      136%       64%       31%       16%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
2016-12-06 15:08:50 +01:00
Markus Hitter fc70e00ca2 DDA: don't queue up heater waits.
Not queuing up waits for the heaters in the movement queue removes
some code in performance critical paths. What a luck we just
implemented an alternative M116 functionality with the previous
commit :-)

Performance of the slowest step is decreased a nice 29 clock
cycles and binary size decreased by a whoppy 472 bytes. That's
still 210 bytes less than before implementing the alternative
heater wait.

Best of all, average step time is down some 21 clock cycles, too,
so we increased general stepping performance by no less than 5%.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19436 bytes      136%       64%       31%       16%
     Data:   2177 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 259 clock cycles.
  LED on time maximum: 429 clock cycles.
  LED on time average: 263.491 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 251 clock cycles.
  LED on time maximum: 472 clock cycles.
  LED on time average: 286.259 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 251 clock cycles.
  LED on time maximum: 429 clock cycles.
  LED on time average: 276.616 clock cycles.
2016-12-05 21:36:03 +01:00
Markus Hitter 974c4b7de8 dda.c: simplify copy of startpoint.
This reduces binary size by 26 bytes without drawback.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19526 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
2016-11-27 22:16:58 +01:00
Markus Hitter 6d95620f32 DDA: don't queue up nullmoves.
Nullmoves are movements which don't actually move a stepper. For
example because it's a velocity change only or the movement is
shorter than a single motor step.

Not queueing them up removes the necessity to check for them,
which reduces code in critical areas. It also removes the
necessity to run dda_start() twice to get past a nullmove.

Best of this is, it also makes lookahead perform better. Before,
a nullmove just changing speed interrupted the lookahead chain,
now it no longer does. See straight-speeds.gcode and
...-Fsep.gcode, which produced different timings before, now
results are identical.

Also update the function description for dda_create().

Performance increase is impressive: another 75 clock cycles off
the slowest step, only 36 bytes binary size increase:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19652 bytes      138%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 280 clock cycles.
  LED on time maximum: 458 clock cycles.
  LED on time average: 284.653 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 501 clock cycles.
  LED on time average: 307.275 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 458 clock cycles.
  LED on time average: 297.625 clock cycles.

Performance of straight-speeds{-Fsep}.gcode before:

  straight-speeds.gcode statistics:
  LED on occurences: 32000.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 586 clock cycles.
  LED on time average: 298.75 clock cycles.

  straight-speeds-Fsep.gcode statistics:
  LED on occurences: 32000.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 672 clock cycles.
  LED on time average: 298.79 clock cycles.

Now:

  straight-speeds.gcode statistics:
  LED on occurences: 32000.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 501 clock cycles.
  LED on time average: 298.703 clock cycles.

  straight-speeds-Fsep.gcode statistics:
  LED on occurences: 32000.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 501 clock cycles.
  LED on time average: 298.703 clock cycles.

There we save even 171 clock cycles :-)
2016-11-27 22:16:56 +01:00
Markus Hitter 3ba52e5906 Revert "DDA: use bitmask to track active axes [...]"
While this was an improvement of 9 clocks on AVRs, it had more
than the opposite effect on ARMs: 25 clocks slower on the slowest
step. Apparently ARMs aren't as efficient in reading and writing
single bits.

  https://github.com/Traumflug/Teacup_Firmware/issues/189#issuecomment-262837660

Performance on AVR is back to what we had before:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19610 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 280 clock cycles.
  LED on time maximum: 549 clock cycles.
  LED on time average: 286.273 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 580 clock cycles.
  LED on time average: 307.439 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 539 clock cycles.
  LED on time average: 297.732 clock cycles.
2016-11-25 20:58:25 +01:00
Phil Hord 00a28cd502 DDA: use bitmask to track active axes for faster dda_step().
In dda_step instead of checking our 32-bit-wide delta[n] value,
just check a single bit in an 8-bit field.  Should be a tad faster.
It does make the code larger, but also about 10% faster, I think.

Performance:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19696 bytes      138%       65%       32%       16%
     Data:   2191 bytes      214%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 263 clock cycles.
  LED on time maximum: 532 clock cycles.
  LED on time average: 269.273 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 255 clock cycles.
  LED on time maximum: 571 clock cycles.
  LED on time average: 297.792 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 255 clock cycles.
  LED on time maximum: 522 clock cycles.
  LED on time average: 283.861 clock cycles.
2016-11-24 11:31:46 +01:00
Markus Hitter 1326db002f DDA, dda_step(): test for individual axes again.
This time we don't test for remaining steps, but wether the axis
moves at all. A much cheaper test, because this variable has to
be loaded into registers anyways.

Performance is now even better than without this test. Slowest
step down from 604 to 580 clock cycles.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19610 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 280 clock cycles.
  LED on time maximum: 549 clock cycles.
  LED on time average: 286.273 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 580 clock cycles.
  LED on time average: 307.439 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 539 clock cycles.
  LED on time average: 297.732 clock cycles.
2016-11-23 12:47:46 +01:00
Markus Hitter 437cb08e42 dda.c: use muldiv in update_current_position().
Apparently gcc doesn't manage to sort nested calculations. Putting
all the muldiv()s into one line gives this error:

  dda.c: In function ‘update_current_position’:
  dda.c:969:1: error: unable to find a register to spill in class ‘POINTER_REGS’
   }
   ^
  dda.c:969:1: error: this is the insn:
  (insn 81 80 259 4 (set (reg:SI 82 [ D.3267 ])
          (mem:SI (post_inc:HI (reg:HI 2 r2 [orig:121 ivtmp.106 ] [121])) [4 MEM[base: _97, offset: 0B]+0 S4 A8])) dda.c:952 95 {*movsi}
       (expr_list:REG_INC (reg:HI 2 r2 [orig:121 ivtmp.106 ] [121])
          (nil)))
  dda.c:969: confused by earlier errors, bailing out

This problem was solved by doing the calculation step by step,
using intermediate variables. Glad I could help you, gcc :-)

Moving performance unchanged, M114 accuracy should have improved,
binary size 18 bytes bigger:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19582 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
2016-11-22 19:28:12 +01:00
Markus Hitter 20a0808887 DDA: don't count individual axis steps.
Using the Bresenham algorithm it's safe to assume that if the axis
with the most steps is done, all other axes are done, too.

This way we save a lot of variable loading in dda_step(). We also
save this very expensive comparison of all axis counters against
zero. Minor drawback: update_current_position() is now even slower.

About performance. The slowest step decreased from 719 to 604
clocks, which is quite an improvement. Average step time increased
for single axis movements by 16 clocks and decreased for multi-
axis movements. At the bottom line this should improve real-world
performance quite a bit, because a printer movement speed isn't
limited by average timings, but by the time needed for the slowest
step.

Along the way, binary size dropped by nice 244 bytes, RAM usage by
also nice 16 bytes.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19564 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 326 clock cycles.
  LED on time maximum: 595 clock cycles.
  LED on time average: 333.62 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 318 clock cycles.
  LED on time maximum: 604 clock cycles.
  LED on time average: 333.311 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 318 clock cycles.
  LED on time maximum: 585 clock cycles.
  LED on time average: 335.233 clock cycles.
2016-11-22 19:13:41 +01:00
wurstnase cd66feb8d1 dda.c: let's save 3 divisions. 2016-11-14 21:49:44 +01:00
wurstnase 2b1f3371c7 DDA: get rid of fast_spm.
We need the fastest axis instead of its steps.

Eleminates also an overflow when ACCELERATION > 596.

We save 118 bytes program and 2 bytes data.

Reviewer Traumflug's note: I see 100 bytes program and 32 bytes
RAM saving on ATmegas here. 16 and 32 on the LPC 1114. Either way:
great stuff!
2016-11-14 21:36:00 +01:00
Wurstnase 39cababb07 dda.c: don't apply feedrate multiplier when searching endstops.
With M220 we can increase the step rate while printing. But when
using this feature it could cause unexpected behaviour while
homing.
2016-11-08 21:21:34 +01:00
Phil Hord 5f6371c53d M220: add support for feedrate override percentage.
Similar to M221 which sets a variable flow rate percentage, add
support for M220 which sets a percentage modifier for the
feedrate, F.

It seems a little disturbing that the flow rate modifies the next
G1 command and does not touch the buffered commands, but this
seems like the only reasonable thing to do since the M221 setting
could be embedded in the source gcode for some use cases.  Perhaps
an "immediate" setting using P1 could be considered later if
needed.
2016-07-09 14:18:06 +02:00
Phil Hord 6679dd6562 dda_create(): treat 'target' as const and input only.
`target` is an input to dda_create, but we don't modify it.  We
copy it into dda->endpoint and modify that instead, if needed.
Make `target` const so this treatment is explicit.

Rely on dda->endpoint to hold our "target" data so any decisions
we make leading up to using it will be correctly reflected in our
math.
2016-07-09 14:17:51 +02:00
Phil Hord 51321910bc M221: use 256 for 100% flow internally for faster math
The flow rate is given as a percentage which is kept as
100 = 100% internally. But this means we must divide by 100 for
every movement which can be expensive.  Convert the value to
256 = 100% so the compiler can optimize the division to a
byte-shift.

Also, avoid the math altogether in the normal case where the
flow rate is already 100% and no change is required.

Note: This also requires an increase in the size of e_multiplier
to 16 bits so values >= 100% can be stored.  Previously flow
rates only up to 255% (2.5x) were supported which may have
surprised some users.  Now the flow rate can be as high as
10000% (100x), at least internally.
2016-07-09 11:42:16 +02:00
wurstnase 9b010e65ee Introduce M221 aka flow-control.
Now it is possible to control the extruders flow.

  M221 S100 = 100% of the extruders steps
  M221 S90  = 90% of the extruders steps

M221 is also used in other firmwares for this. Also a lot of
hosts, like Octoprint and Pronterface using this M-Code for
this behaviour.
2016-07-09 11:42:16 +02:00
Markus Hitter 6cce9d173a DDA: extruders aren't subject to kinematics.
As such, move extruder handling out of dda_kinematics.c into
dda.c.
2016-07-09 11:42:16 +02:00
wurstnase 705e4563db DDA: X is not critical anymore.
It's prepared here:

  https://github.com/Traumflug/Teacup_Firmware/commit/294f0eda26

And gone here:

  https://github.com/Traumflug/Teacup_Firmware/commit/4f0a00c1a

Anyhow, we have a calculation with X in dda_lookahead.c

Traumflugs review note: true, at least until we get distinct
acceleration on each axis.
2016-07-02 22:07:27 +02:00
Phil Hord 803ff6e8b3 fix ACCELERATION_REPRAP build (moved/extra vars)
REPRAP style acceleration broke quite a while ago, but no one noticed.
Maybe it's not being used, and therefore also not tested. But it should
at least compile while it remains an option.

The compiler complains that dda->n is not defined and that current_id is
never used.  The first bug goes back to f0b9daeea0 in late 2013.

In the interest of supporting exploratory accelerations, fix this to
build when ACCELERATION_REPRAP is chosen.
2016-06-22 19:28:38 -04:00
Phil Hord b317ba086c corexy: Fix new_dda_startpoint for corexy
Add a function axes_um_to_steps to convert from um to steps on all axes
respecting current kinematics setting.

Extend code_stepper_axescode_axes_to_stepper_axes to convert all axes,
including E-axis for consistency.

It seems like axes_um_to_steps could be simplified to something like
"apply_kinematics_axes()" which would just do the transformation math
in-place on some axes[] to move from 'Cartesian' to 'target-kinematics'.
Then the original um_to_steps and delta_um code could remain untouched
since 2014.  But I'm not sure how this will work with scara or delta
configurations. I'm fairly certain they only work from absolute positions
anyway.

Fixes #216.
2016-05-31 15:19:50 -04:00
Phil Hord 90d519af5f dda_clock(): guard against *dda changes in interrupts
dda_clock() might be interrupted by dda_step(), and dda_step might
use or modify variables also being used in dda_clock().  It is
possible for dda to be modified when a new dda becomes live during
our dda_clock().  Check the dda->id to ensure it has not changed on
us before we actually write new calculated values into the dda.

Note by Traumflug: copied some of the explanation in the commit
message directly into the code.
2016-05-21 15:46:10 +02:00
Phil Hord 1eefb28a19 dda_clock(): modify dda->n only in atomic code
dda_clock() might be interrupted by dda_step(), and dda_step might
use or modify variables also being used in dda_clock. In particular
dda->c is modified in both functions but it is done atomically in
dda_clock() to prevent dda_step() from interrupting during the
write.  But dda->n is also modified in both places and it is not
protected in dda_clock().

Move updates to dda->n to the atomic section along with dda->c.

Note by Traumflug: good catch! It even makes the binary 14 bytes
smaller, so likely faster.
2016-05-21 15:45:49 +02:00
Markus Hitter e633222cd3 Make message/text sending aware of the sending destination.
Point of this change is to allow using these functions for
writing to the display, too, without duplicating all the code.

To reduce confusion, functions were renamed (they're no longer
'serial', after all:

  serwrite_xxx() -> write_xxx()
  sersendf_P()   -> sendf_P()

To avoid changing all the existing code, a couple of macros
with the old names are provided. They might even be handy as
convenience macros.

Nicely, this addition costs no additional RAM. Not surprising, it
costs quite some binary size, 278 bytes. Sizes now:

Program:  24058 bytes      168%       79%       38%       19%
   Data:   1525 bytes      149%       75%       38%       19%
 EEPROM:     32 bytes        4%        2%        2%        1%

Regarding USB Serial: code was adjusted without testing on
hardware.
2016-04-26 15:23:15 +02:00
Markus Hitter 82374b8e24 Rename Z_LATE_ENABLE to Z_AUTODISABLE and refine description.
Also turn it on by default for the Mendel printer.

Also add the forgotten Mendel90 printer.
2016-03-27 20:23:05 +02:00
Wurstnase 57afef9fdd Add Z late enable.
Until this commit, the Z axis is disabled after each move and
only enabled when the Z axis will move. Now you can enable this
as a feature. Some printer axes are too heavy or have a high
pitch which are not self locking. In that case simply do nothing.
It's now off by default.
2016-03-27 20:14:04 +02:00
Markus Hitter 5d8e866501 Move interrupt busy detection from dda_clock() to clock tick ISR.
The reason is, interrupts can't be re-entered on ARM, so we need
a different mechanism.
2015-08-12 14:26:37 +02:00
Markus Hitter 7be5212f06 ARM: introduce sei() and cli().
No test, because it's tricky to test, but it compiles and the
firmware still works as before.
2015-08-12 14:26:36 +02:00
Phil Hord 22b640697b Replace SIMULATOR with __AVR__ in several places.
Previously some features were excluded based on whether SIMULATOR
was defined. But in fact these should have been included when __AVR__
was defined. These used to be the same thing, but now with ARM coming
into the picture, they are not. Fix the situation so AVR includes are
truly only used when __AVR__ is defined.

The _crc16_update function appears to be specific to AVR; I've kept the
alternate implementation limited to AVR in that case in crc.c. I think
this is the right thing to do, but I am not sure. Maybe ARM has some
equivalent function in their libraries.
2015-07-29 21:05:38 +02:00
Yiannis Mandravellos fb249214f0 dda.c: fix overflow for large steps/meter values.
The trick is to use doubles earlier. As these calculations are
optimised out anyways, binary size and performance is kept.

Verified to have an identical outcome on a few common steps/mm and
acceleration cases.
2015-06-06 12:04:52 +02:00
Markus Hitter 9dd7426f9d DDA: on short schedules, repeat step routine immediately ...
... instead of trying to fire an interrupt as quickly as possible.
This affects ACCELERATION_TEMPORAL only. It almost doubles the
achievable step rate. Measured maximum step rate (X axis only,
100 mm moves) is 40'000 steps/s on a 16 MHz electronics, so
approx. 50'000 steps/s on a 20 MHz controller, which is even
a bit faster than the ACCELERATION_RAMPING algorithm.

Tests with temporary test code were run and judging by these
tests, clock interrupts are now very reliable up to the point
where processing speed is simply exhaused.

Performance with ACCELERATION_RAMPING: this costs 10 bytes
binary size and exactly 2 clock cycles per step interrupt or
0.6% performance even. We could avoid this with a lot
of #ifdefs, but considering ACCELERATION_TEMPORAL will one
day be the default acceleration, skip these #ifdefs, also
for better code readability.

$ cd testcases
$ ./run-in-simulavr.sh short-moves.gcode smooth-curves.gcode triangle-odd.gcode
    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH  : 20528 bytes         144%        67%        33%      16%
    RAM    :  2188 bytes         214%       107%        54%      27%
    EEPROM :    32 bytes           4%         2%         2%       1%

short-moves.gcode statistics:
LED on occurences: 838.
LED on time minimum: 304 clock cycles.
LED on time maximum: 715 clock cycles.
LED on time average: 310.717 clock cycles.

smooth-curves.gcode statistics:
LED on occurences: 8585.
LED on time minimum: 309 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 360.051 clock cycles.

triangle-odd.gcode statistics:
LED on occurences: 1636.
LED on time minimum: 304 clock cycles.
LED on time maximum: 710 clock cycles.
LED on time average: 332.32 clock cycles.
2015-04-21 02:51:32 +02:00
Markus Hitter 7dda91ab56 dda.c: put code for ACCELERATION_TEMPORAL in dda_step() together.
Performance for ACCELERATION_RAMPING unchanged:

$ cd testcases
$ ./run-in-simulavr.sh short-moves.gcode smooth-curves.gcode triangle-odd.gcode
[...]
    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH  : 20518 bytes         144%        67%        33%      16%
    RAM    :  2188 bytes         214%       107%        54%      27%
    EEPROM :    32 bytes           4%         2%         2%       1%

short-moves.gcode statistics:
LED on occurences: 838.
LED on time minimum: 302 clock cycles.
LED on time maximum: 713 clock cycles.
LED on time average: 308.72 clock cycles.

smooth-curves.gcode statistics:
LED on occurences: 8585.
LED on time minimum: 307 clock cycles.
LED on time maximum: 710 clock cycles.
LED on time average: 358.051 clock cycles.

triangle-odd.gcode statistics:
LED on occurences: 1636.
LED on time minimum: 302 clock cycles.
LED on time maximum: 708 clock cycles.
LED on time average: 330.322 clock cycles.
2015-04-21 02:51:32 +02:00
Markus Hitter 8b88334b06 Rename setTimer() to timer_set() for more consistency.
Pure cosmetical change.

Performance check:

$ cd testcases
$ ./run-in-simulavr.sh short-moves.gcode smooth-curves.gcode triangle-odd.gcode
[...]
    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH  : 20518 bytes         144%        67%        33%      16%
    RAM    :  2188 bytes         214%       107%        54%      27%
    EEPROM :    32 bytes           4%         2%         2%       1%

short-moves.gcode statistics:
LED on occurences: 838.
LED on time minimum: 302 clock cycles.
LED on time maximum: 713 clock cycles.
LED on time average: 308.72 clock cycles.

smooth-curves.gcode statistics:
LED on occurences: 8585.
LED on time minimum: 307 clock cycles.
LED on time maximum: 710 clock cycles.
LED on time average: 358.051 clock cycles.

triangle-odd.gcode statistics:
LED on occurences: 1636.
LED on time minimum: 302 clock cycles.
LED on time maximum: 708 clock cycles.
LED on time average: 330.322 clock cycles.
2015-04-21 02:51:32 +02:00
Markus Hitter a6be2f9584 dda.c: add forgotten variable declaration.
Forgotten in commit 74808610c7,
"DDA: Move axis calculations into loops, part 5.".

This and the previous commit makes ACCELERATION_TEMPORAL building
(and working!) again.
2015-04-21 02:51:31 +02:00
Markus Hitter a303f1ba3e dda.c: complete the rename from all_step to last_step.
Next time, please at least try to compile the code section in
question when explicitely changing the section. In this case,
with ACCELERATION_TEMPORAL enabled. It didn't build.

Was broken with commit 95926a3f113809bde8ff0c84b94c55c73e398f67,
"DDA: Rename confusing variable name.".
2015-04-21 02:51:31 +02:00
Markus Hitter 1cd21251d2 Get rid of STEP_INTERRUPT_INTERRUPTIBLE.
It was certainly a good idea, but also always a suspect of
malfunctions and as such, almost never used. Newer code
organisation moves most of the code behind it to dda_clock()
anyways, so it also became mostly obsolete.

Rest In Peace, STEP_INTERRUPT_INTERRUPTIBLE, you were matter
of quite a number of interesting discussions and investigations.

Changes for Configtool by jbernardis <jeff.bernardis@gmail.com>
2015-04-21 02:11:01 +02:00
Markus Hitter 4c34674b6e dda.c/.h: reduce debounce counting variable.
As we can always only move towards one end of an axis, one common
variable to count debouncing is sufficient.

Binary size 12 bytes smaller (and faster).
2015-01-09 13:11:06 +01:00
Markus Hitter f577431aac home.c, dda.c: consider endstops on both axis ends when homing.
Previously, when backing off of X_MIN, X_MAX was also checked,
which of course was already open, so it signals endstop release
even while X_MIN is still closed. The issue exposed only when
endstops on both ends of an axis were defined, a more rare situation.

Essentially the fix simply makes a distinct endstop check case
for each side of each axis.

This even makes binary size 40 bytes smaller for the standard case.
2015-01-09 13:11:01 +01:00
Markus Hitter cca2994dd8 dda.c: fix debug statement position.
It's always a good idea to read a structure _after_ filling it :-)
2014-12-27 14:47:58 +01:00
Markus Hitter 9fe9c919a4 dda.c: add some TODOs about duplicate and redundant code. 2014-12-26 19:41:38 +01:00
Markus Hitter ab25efbe81 dda.c: abs32() is obsolete now.
It's obsolete, because it's used for signed ints, only.
2014-12-26 19:41:37 +01:00
Markus Hitter 30dd1f4535 CoreXY: separate out bot axes distance calculations.
This also introduces dda_kinematics.c/.h and a KINEMATICS definition,
which allows to do different distance calculations depending on the
bot kinematics in use. So far only KINEMATICS_STRAIGHT, which matches
what we had before, but other kinematics types are present in
comments already.
2014-12-26 19:41:37 +01:00
Markus Hitter 7d2dbaa481 CoreXY, dda.c: use signed delta_steps to simplify dda->delta_um[] calc.
Saves another 8 bytes binary size.
2014-12-26 19:41:37 +01:00
Markus Hitter cca464260b CoreXY, dda.c: use our now signed delta_steps to set direction.
This nicely makes the binary 36 bytes smaller.
2014-12-26 19:41:37 +01:00
Markus Hitter 12f01a783a CoreXY, dda.c: calculate delta steps separately.
This will allow us to use it's sign to set direction.

No binary size increase, optimizer can handle this.
2014-12-26 19:41:37 +01:00
Markus Hitter 41bf99c1aa CoreXY, dda.c: separate bot axes from extruder axes. 2014-12-26 19:41:37 +01:00
Markus Hitter a36b96357e CoreXY, dda.c: start by making steps an array.
Goal is to calculate steps in a separate function to allow different
methods of steps calculation, which is neccessary for supporting
different kinematics types. Accordingly we have to calculate steps
for all axes before setting directions and such stuff.
2014-12-26 19:41:37 +01:00
Markus Hitter c7b022fb3e dda.c: some whitespace cleaning. 2014-10-18 21:02:17 +02:00