Commit Graph

983 Commits

Author SHA1 Message Date
Markus Hitter bb24627242 dda.c: file attempt to use sign of dda->delta_um[] to set direction. 2014-10-18 21:04:07 +02:00
Markus Hitter c7b022fb3e dda.c: some whitespace cleaning. 2014-10-18 21:02:17 +02:00
Markus Hitter 6da02f3112 config_wrapper.h: protect against USB/serial misconfiguration. 2014-10-18 21:00:16 +02:00
Markus Hitter 9f618ee048 Testcases: add nothing.gcode.
This is for running stuff with run_in_simulavr.sh which needs no
G-code.
2014-10-18 20:59:41 +02:00
Markus Hitter 37e2b18f4c config.*.h: distribute changed TEMP_HYSTERESIS description to all templates. 2014-10-18 20:59:00 +02:00
Markus Hitter e0ee76b54e heater.c: add a hysteresis when using BANG_BANG.
Before, the heater would turn off and on at each tiny temperature
fluctuation. Or better: at every tiny analog voltage fluctuation.
2014-10-18 20:58:35 +02:00
Markus Hitter f26623d173 Move clock stuff from timer.c/.h to clock.c/.h.
I guess that's where it belongs.
2014-10-18 20:57:32 +02:00
Markus Hitter fc7365b320 preprocessor_math.h: fix errorneous comment. 2014-08-31 19:32:09 +02:00
Markus Hitter 95b3ea0b30 Canned G-code: distribute new config option to all templates. 2014-08-31 19:32:01 +02:00
Markus Hitter 5cc84a069a Canned G-code: setup right in config.h.
This works with Arduino IDE as well and should be easier to figure
for inexperienced users.
2014-08-31 19:31:39 +02:00
Markus Hitter 7f990a298c Canned G-code: don't miss first character. 2014-08-31 19:22:24 +02:00
Markus Hitter 1e97e51d2a Canned G-code: fix reading flash memory. 2014-08-31 19:20:50 +02:00
Michael Moon aed4bfdb5b Canned G-code: implement continuous replay of G-code stored on flash. 2014-08-31 19:19:21 +02:00
Erik Jonsson 0723b53c44 run-in-simulavr.sh: terminate simulation if stop recieved.
Note by Traumflug: this

  while read -r LINE; do
    some commands
  done << (some other command)

didn't work here (bash 4.3.11 on Ubuntu 14.04), so I had to swap
the sequence of these two commands for using a pipe. Anyways,
excellent idea, shortens some simulator runs drastically!
2014-08-31 19:12:43 +02:00
Erik Jonsson fa0e0d37e7 gcode_process.c: added stop message when M2 is recieved.
This shall help stopping a simulator when G-code is done.
2014-08-31 19:12:36 +02:00
Markus Hitter e4349083b4 Fix config.ramps-v1.3.h.
Finally had to look it up myself. RAMPS users are apparently all
incapable or too stupid to write such fixes into an issue report.

From IRC:

xxx: oh, motors move now, thanks for helping
yyy: please write the changes into a github issue
xxx: will do
...
xxx: have to run now

... and these are the last words the world reads about xxx :-)
Observed three times now.
2014-08-31 19:12:28 +02:00
Markus Hitter 642948acb2 gcode_process.c: review G28 comment. 2014-08-31 19:12:11 +02:00
Markus Hitter 5b3121abc5 arduino_xxx.h: add DIO names next to AIO names.
This is mostly for less confusion, because analog pins can
be used as digital ones, too. It also matches what other firmwares
do, so people can simply copy & paste pin definitions.

Definitions were taken from Sprinter's fastio.h (which was
initially crafted by copying Teacup's arduino*.h files :-) )
2014-08-31 19:11:58 +02:00
Markus Hitter 6c5809f0fa DDA: finally, don't bit-shift dda->c.
This was the goal: to not bit-shift when calling setTimer(). Binary
size another 40 bytes off, about 1.2 % better performance:

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20136 bytes          141%       66%        32%       16%
    RAM   :  2318 bytes          227%      114%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode statistics:
LED on occurences: 888.
LED on time minimum: 302 clock cycles.
LED on time maximum: 718 clock cycles.
LED on time average: 311.258 clock cycles.

smooth-curves.gcode statistics:
LED on occurences: 9124.
LED on time minimum: 307 clock cycles.
LED on time maximum: 708 clock cycles.
LED on time average: 357.417 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.
2014-08-31 19:11:49 +02:00
Markus Hitter e098a96bac DDA: don't bit-shift move_c.
Next babystep, tiny enhancement: 8 bytes less binary size.
2014-08-31 19:11:30 +02:00
Markus Hitter b9c38051cc DDA: don't bit-shift dda->c_min.
Another babystep. First results: binary 4 bytes smaller. Yikes!
Ha ha.
2014-08-31 19:11:19 +02:00
Markus Hitter 6880f05f7e DDA: don't bit-shift dda->end_c either.
Next babystep. All changes in ACCELERATION_REPRAP, which isn't
part of current test procedures, so let's cross fingers it was
done right.
2014-08-31 19:11:12 +02:00
Markus Hitter 2541eaf335 DDA: don't bit-shift c_limit, c_limit_calc either.
Admittedly it looks like advancing in babysteps, but really
catching every bit shifting instance isn't trivial, sometimes
these shifts are already embedded in other calculations.

Still no binary size or performance change.
2014-08-31 19:11:04 +02:00
Markus Hitter 4fa755daef dda.c: don't bit-shift c0.
While this shifting meant to increase accuracy, there's no actual
use of it, other than that this value gets shifted back and forth.
Let's start to get rid of it.

Performance stays exactly the same:

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20188 bytes          141%       66%        32%       16%
    RAM   :  2318 bytes          227%      114%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode statistics:
LED on occurences: 888.
LED on time minimum: 306 clock cycles.
LED on time maximum: 722 clock cycles.
LED on time average: 315.253 clock cycles.

smooth-curves.gcode statistics:
LED on occurences: 9124.
LED on time minimum: 311 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 361.416 clock cycles.

triangle-odd.gcode statistics:
LED on occurences: 1636.
LED on time minimum: 306 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 334.319 clock cycles.
2014-08-31 19:10:56 +02:00
Markus Hitter ec937adde2 run-in-simulavr.sh: move statistics to the end.
This is more convenient for obvious reasons, you no longer have
to search all the output for these few lines.
2014-08-31 19:10:48 +02:00
Markus Hitter 157a5a966b run-in-simulavr.sh: clean up tracein file after being done. 2014-08-31 19:10:39 +02:00
Markus Hitter 4f0a00c1a6 DDA: calculate acceleration for the actual fast axis.
This finally brings Z axis up to speed.

So far we always assumed the fastest axis to have the same steps/mm
as the X axis. In cases where this wasn't true, the movement
wouldn't do sufficient acceleration steps and, accordingly,
not reach the expected maximum speed. This was particularly visible
on a typical Mendel printer, where the Z axis would reach only a
6th of the commanded speed in some configurations.
2014-08-31 19:10:31 +02:00
Markus Hitter 5ee2aebbed DDA: remember number of the fast axis. 2014-08-31 19:10:23 +02:00
Markus Hitter 294f0eda26 DDA: have an acceleration constant for each axis individually.
For now, keep behaviour identical, like still use STEPS_PER_M_X.
This is about to change soon.
2014-08-31 19:10:14 +02:00
Markus Hitter 2ad7517e27 preprocessor_math.h, SQRT(): take a better initial guess.
Now results are apparently accurate across the whole uint32 range.
At least, this test passes with all numbers being exact:

  #include "preprocessor_math.h"
  #include <math.h>
  ... in main() ...
  sersendf_P(PSTR("0:  %lu  %lu\n"), (uint32_t)SQRT(0), (uint32_t)sqrt(0));
  sersendf_P(PSTR("1:  %lu  %lu\n"), (uint32_t)SQRT(1), (uint32_t)sqrt(1));
  sersendf_P(PSTR("2:  %lu  %lu\n"), (uint32_t)SQRT(2), (uint32_t)sqrt(2));
  sersendf_P(PSTR("3:  %lu  %lu\n"), (uint32_t)SQRT(3), (uint32_t)sqrt(3));
  sersendf_P(PSTR("4:  %lu  %lu\n"), (uint32_t)SQRT(4), (uint32_t)sqrt(4));
  sersendf_P(PSTR("5:  %lu  %lu\n"), (uint32_t)SQRT(5), (uint32_t)sqrt(5));
  sersendf_P(PSTR("6:  %lu  %lu\n"), (uint32_t)SQRT(6), (uint32_t)sqrt(6));
  sersendf_P(PSTR("7:  %lu  %lu\n"), (uint32_t)SQRT(7), (uint32_t)sqrt(7));
  sersendf_P(PSTR("8:  %lu  %lu\n"), (uint32_t)SQRT(8), (uint32_t)sqrt(8));
  sersendf_P(PSTR("9:  %lu  %lu\n"), (uint32_t)SQRT(9), (uint32_t)sqrt(9));
  sersendf_P(PSTR("10:  %lu  %lu\n"), (uint32_t)SQRT(10), (uint32_t)sqrt(10));
  sersendf_P(PSTR("20:  %lu  %lu\n"), (uint32_t)SQRT(20), (uint32_t)sqrt(20));
  sersendf_P(PSTR("30:  %lu  %lu\n"), (uint32_t)SQRT(30), (uint32_t)sqrt(30));
  sersendf_P(PSTR("40:  %lu  %lu\n"), (uint32_t)SQRT(40), (uint32_t)sqrt(40));
  sersendf_P(PSTR("50:  %lu  %lu\n"), (uint32_t)SQRT(50), (uint32_t)sqrt(50));
  sersendf_P(PSTR("60:  %lu  %lu\n"), (uint32_t)SQRT(60), (uint32_t)sqrt(60));
  sersendf_P(PSTR("70:  %lu  %lu\n"), (uint32_t)SQRT(70), (uint32_t)sqrt(70));
  sersendf_P(PSTR("80:  %lu  %lu\n"), (uint32_t)SQRT(80), (uint32_t)sqrt(80));
  sersendf_P(PSTR("90:  %lu  %lu\n"), (uint32_t)SQRT(90), (uint32_t)sqrt(90));
  sersendf_P(PSTR("100:  %lu  %lu\n"), (uint32_t)SQRT(100), (uint32_t)sqrt(100));
  sersendf_P(PSTR("200:  %lu  %lu\n"), (uint32_t)SQRT(200), (uint32_t)sqrt(200));
  sersendf_P(PSTR("300:  %lu  %lu\n"), (uint32_t)SQRT(300), (uint32_t)sqrt(300));
  sersendf_P(PSTR("400:  %lu  %lu\n"), (uint32_t)SQRT(400), (uint32_t)sqrt(400));
  sersendf_P(PSTR("500:  %lu  %lu\n"), (uint32_t)SQRT(500), (uint32_t)sqrt(500));
  sersendf_P(PSTR("600:  %lu  %lu\n"), (uint32_t)SQRT(600), (uint32_t)sqrt(600));
  sersendf_P(PSTR("700:  %lu  %lu\n"), (uint32_t)SQRT(700), (uint32_t)sqrt(700));
  sersendf_P(PSTR("800:  %lu  %lu\n"), (uint32_t)SQRT(800), (uint32_t)sqrt(800));
  sersendf_P(PSTR("900:  %lu  %lu\n"), (uint32_t)SQRT(900), (uint32_t)sqrt(900));
  sersendf_P(PSTR("1000:  %lu  %lu\n"), (uint32_t)SQRT(1000), (uint32_t)sqrt(1000));
  sersendf_P(PSTR("2000:  %lu  %lu\n"), (uint32_t)SQRT(2000), (uint32_t)sqrt(2000));
  sersendf_P(PSTR("3000:  %lu  %lu\n"), (uint32_t)SQRT(3000), (uint32_t)sqrt(3000));
  sersendf_P(PSTR("4000:  %lu  %lu\n"), (uint32_t)SQRT(4000), (uint32_t)sqrt(4000));
  sersendf_P(PSTR("5000:  %lu  %lu\n"), (uint32_t)SQRT(5000), (uint32_t)sqrt(5000));
  sersendf_P(PSTR("6000:  %lu  %lu\n"), (uint32_t)SQRT(6000), (uint32_t)sqrt(6000));
  sersendf_P(PSTR("7000:  %lu  %lu\n"), (uint32_t)SQRT(7000), (uint32_t)sqrt(7000));
  sersendf_P(PSTR("8000:  %lu  %lu\n"), (uint32_t)SQRT(8000), (uint32_t)sqrt(8000));
  sersendf_P(PSTR("9000:  %lu  %lu\n"), (uint32_t)SQRT(9000), (uint32_t)sqrt(9000));
  sersendf_P(PSTR("10000:  %lu  %lu\n"), (uint32_t)SQRT(10000), (uint32_t)sqrt(10000));
  sersendf_P(PSTR("20000:  %lu  %lu\n"), (uint32_t)SQRT(20000), (uint32_t)sqrt(20000));
  sersendf_P(PSTR("30000:  %lu  %lu\n"), (uint32_t)SQRT(30000), (uint32_t)sqrt(30000));
  sersendf_P(PSTR("40000:  %lu  %lu\n"), (uint32_t)SQRT(40000), (uint32_t)sqrt(40000));
  sersendf_P(PSTR("50000:  %lu  %lu\n"), (uint32_t)SQRT(50000), (uint32_t)sqrt(50000));
  sersendf_P(PSTR("60000:  %lu  %lu\n"), (uint32_t)SQRT(60000), (uint32_t)sqrt(60000));
  sersendf_P(PSTR("70000:  %lu  %lu\n"), (uint32_t)SQRT(70000), (uint32_t)sqrt(70000));
  sersendf_P(PSTR("80000:  %lu  %lu\n"), (uint32_t)SQRT(80000), (uint32_t)sqrt(80000));
  sersendf_P(PSTR("90000:  %lu  %lu\n"), (uint32_t)SQRT(90000), (uint32_t)sqrt(90000));
  sersendf_P(PSTR("100000:  %lu  %lu\n"), (uint32_t)SQRT(100000), (uint32_t)sqrt(100000));
  sersendf_P(PSTR("200000:  %lu  %lu\n"), (uint32_t)SQRT(200000), (uint32_t)sqrt(200000));
  sersendf_P(PSTR("300000:  %lu  %lu\n"), (uint32_t)SQRT(300000), (uint32_t)sqrt(300000));
  sersendf_P(PSTR("400000:  %lu  %lu\n"), (uint32_t)SQRT(400000), (uint32_t)sqrt(400000));
  sersendf_P(PSTR("500000:  %lu  %lu\n"), (uint32_t)SQRT(500000), (uint32_t)sqrt(500000));
  sersendf_P(PSTR("600000:  %lu  %lu\n"), (uint32_t)SQRT(600000), (uint32_t)sqrt(600000));
  sersendf_P(PSTR("700000:  %lu  %lu\n"), (uint32_t)SQRT(700000), (uint32_t)sqrt(700000));
  sersendf_P(PSTR("800000:  %lu  %lu\n"), (uint32_t)SQRT(800000), (uint32_t)sqrt(800000));
  sersendf_P(PSTR("900000:  %lu  %lu\n"), (uint32_t)SQRT(900000), (uint32_t)sqrt(900000));
  sersendf_P(PSTR("1000000:  %lu  %lu\n"), (uint32_t)SQRT(1000000), (uint32_t)sqrt(1000000));
  sersendf_P(PSTR("2000000:  %lu  %lu\n"), (uint32_t)SQRT(2000000), (uint32_t)sqrt(2000000));
  sersendf_P(PSTR("3000000:  %lu  %lu\n"), (uint32_t)SQRT(3000000), (uint32_t)sqrt(3000000));
  sersendf_P(PSTR("4000000:  %lu  %lu\n"), (uint32_t)SQRT(4000000), (uint32_t)sqrt(4000000));
  sersendf_P(PSTR("5000000:  %lu  %lu\n"), (uint32_t)SQRT(5000000), (uint32_t)sqrt(5000000));
  sersendf_P(PSTR("6000000:  %lu  %lu\n"), (uint32_t)SQRT(6000000), (uint32_t)sqrt(6000000));
  sersendf_P(PSTR("7000000:  %lu  %lu\n"), (uint32_t)SQRT(7000000), (uint32_t)sqrt(7000000));
  sersendf_P(PSTR("8000000:  %lu  %lu\n"), (uint32_t)SQRT(8000000), (uint32_t)sqrt(8000000));
  sersendf_P(PSTR("9000000:  %lu  %lu\n"), (uint32_t)SQRT(9000000), (uint32_t)sqrt(9000000));
  sersendf_P(PSTR("10000000:  %lu  %lu\n"), (uint32_t)SQRT(10000000), (uint32_t)sqrt(10000000));
  sersendf_P(PSTR("20000000:  %lu  %lu\n"), (uint32_t)SQRT(20000000), (uint32_t)sqrt(20000000));
  sersendf_P(PSTR("30000000:  %lu  %lu\n"), (uint32_t)SQRT(30000000), (uint32_t)sqrt(30000000));
  sersendf_P(PSTR("40000000:  %lu  %lu\n"), (uint32_t)SQRT(40000000), (uint32_t)sqrt(40000000));
  sersendf_P(PSTR("50000000:  %lu  %lu\n"), (uint32_t)SQRT(50000000), (uint32_t)sqrt(50000000));
  sersendf_P(PSTR("60000000:  %lu  %lu\n"), (uint32_t)SQRT(60000000), (uint32_t)sqrt(60000000));
  sersendf_P(PSTR("70000000:  %lu  %lu\n"), (uint32_t)SQRT(70000000), (uint32_t)sqrt(70000000));
  sersendf_P(PSTR("80000000:  %lu  %lu\n"), (uint32_t)SQRT(80000000), (uint32_t)sqrt(80000000));
  sersendf_P(PSTR("90000000:  %lu  %lu\n"), (uint32_t)SQRT(90000000), (uint32_t)sqrt(90000000));
  sersendf_P(PSTR("100000000:  %lu  %lu\n"), (uint32_t)SQRT(100000000), (uint32_t)sqrt(100000000));
  sersendf_P(PSTR("200000000:  %lu  %lu\n"), (uint32_t)SQRT(200000000), (uint32_t)sqrt(200000000));
  sersendf_P(PSTR("300000000:  %lu  %lu\n"), (uint32_t)SQRT(300000000), (uint32_t)sqrt(300000000));
  sersendf_P(PSTR("400000000:  %lu  %lu\n"), (uint32_t)SQRT(400000000), (uint32_t)sqrt(400000000));
  sersendf_P(PSTR("500000000:  %lu  %lu\n"), (uint32_t)SQRT(500000000), (uint32_t)sqrt(500000000));
  sersendf_P(PSTR("600000000:  %lu  %lu\n"), (uint32_t)SQRT(600000000), (uint32_t)sqrt(600000000));
  sersendf_P(PSTR("700000000:  %lu  %lu\n"), (uint32_t)SQRT(700000000), (uint32_t)sqrt(700000000));
  sersendf_P(PSTR("800000000:  %lu  %lu\n"), (uint32_t)SQRT(800000000), (uint32_t)sqrt(800000000));
  sersendf_P(PSTR("900000000:  %lu  %lu\n"), (uint32_t)SQRT(900000000), (uint32_t)sqrt(900000000));
  sersendf_P(PSTR("1000000000:  %lu  %lu\n"), (uint32_t)SQRT(1000000000), (uint32_t)sqrt(1000000000));
  sersendf_P(PSTR("2000000000:  %lu  %lu\n"), (uint32_t)SQRT(2000000000), (uint32_t)sqrt(2000000000));
  sersendf_P(PSTR("3000000000:  %lu  %lu\n"), (uint32_t)SQRT(3000000000), (uint32_t)sqrt(3000000000));
  sersendf_P(PSTR("4000000000:  %lu  %lu\n"), (uint32_t)SQRT(4000000000), (uint32_t)sqrt(4000000000));
2014-08-31 19:10:07 +02:00
Markus Hitter 6f83519a1d Add preprocessor math.
For now this is a square root function which should solve entirely
in the preprocessor. Test results described in the file.

Test code for runtime results, inserted right before the main loop
in mendel.c:

  for (uint32_t i = 0; i < 10000000; i++) {
    uint32_t mathlib = (uint32_t)(sqrt(i) + .5);
    uint32_t preprocessor = (uint32_t)(SQRT(i) + .5);

    if (mathlib != preprocessor) {
      sersendf_P(PSTR("%lu: %lu %lu\n"), i, mathlib, preprocessor);
      break;
    }

    if ((i & 0x00001fff) == 0)
      sersendf_P(PSTR("%lu\n"), i);
  }
  sersendf_P(PSTR("Square root check done.\n"));

Test code for compile time results:

  sersendf_P(PSTR("10000000: %lu\n"), (uint32_t)SQRT(10000000));
  sersendf_P(PSTR("10000000: %lu\n"), (uint32_t)sqrt(10000000));
  sersendf_P(PSTR("20000000: %lu\n"), (uint32_t)SQRT(20000000));
  sersendf_P(PSTR("20000000: %lu\n"), (uint32_t)sqrt(20000000));
  sersendf_P(PSTR("30000000: %lu\n"), (uint32_t)SQRT(30000000));
  sersendf_P(PSTR("30000000: %lu\n"), (uint32_t)sqrt(30000000));
  sersendf_P(PSTR("40000000: %lu\n"), (uint32_t)SQRT(40000000));
  sersendf_P(PSTR("40000000: %lu\n"), (uint32_t)sqrt(40000000));
  sersendf_P(PSTR("50000000: %lu\n"), (uint32_t)SQRT(50000000));
  sersendf_P(PSTR("50000000: %lu\n"), (uint32_t)sqrt(50000000));
  sersendf_P(PSTR("60000000: %lu\n"), (uint32_t)SQRT(60000000));
  sersendf_P(PSTR("60000000: %lu\n"), (uint32_t)sqrt(60000000));
  sersendf_P(PSTR("70000000: %lu\n"), (uint32_t)SQRT(70000000));
  sersendf_P(PSTR("70000000: %lu\n"), (uint32_t)sqrt(70000000));
  sersendf_P(PSTR("80000000: %lu\n"), (uint32_t)SQRT(80000000));
  sersendf_P(PSTR("80000000: %lu\n"), (uint32_t)sqrt(80000000));
  sersendf_P(PSTR("90000000: %lu\n"), (uint32_t)SQRT(90000000));
  sersendf_P(PSTR("90000000: %lu\n"), (uint32_t)sqrt(90000000));
2014-08-31 19:09:59 +02:00
Phil Hord 76bf5ef75a Datalog: show traced data as signed ints, not unsigned. 2014-08-31 19:09:37 +02:00
Phil Hord 24f5416bba DDA: Rename confusing variable name.
'all_time' sounds like forever to me, but this variable really
tracks the last time we hit one of "all the axes".  It sticks
out more now in looping, so rename it to make sense.
2014-08-31 19:09:24 +02:00
Phil Hord bc4cf20341 Trivial cleanups.
Fix some formatting and hide a couple of variables when they're
not being used.
2014-08-31 19:09:15 +02:00
Phil Hord f9f068596d DDA: Move axis calculations into loops, part 9 (last part).
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 9 is, finally use this set_direction() thing. As a dessert
topping, it reduces binary size by another 122 bytes.

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 19988 bytes          140%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%
2014-08-31 19:09:07 +02:00
Markus Hitter 96e9ae4dab dda.h: comment on these direction flags and other things. 2014-08-31 19:08:57 +02:00
Markus Hitter 41e76ca9fe dda.c: make update_current_position() even smaller.
Saves another 24 bytes.

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20110 bytes          141%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

Using muldiv() would be more accurate, but unfortunately, the
compiler bails out:

   static const axes_uint32_t PROGMEM steps_per_mm_P = {
                                                           ^
dda.c:889:1: error: unable to find a register to spill in class ‘POINTER_REGS’
 }
 ^
dda.c:889:1: error: this is the insn:
(insn 81 80 83 6 (set (reg:SI 77 [ D.3086 ])
        (mem:SI (post_inc:HI (reg:HI 2 r2 [orig:103 ivtmp.106 ] [103])) [3 MEM[base: _82, offset: 0B]+0 S4 A8])) dda.c:881 94 {*movsi}
     (expr_list:REG_INC (reg:HI 2 r2 [orig:103 ivtmp.106 ] [103])
        (nil)))
dda.c:889: confused by earlier errors, bailing out

Another one is, calculating this:

   (int32_t)get_direction(dda, i) *
   move_state.steps[i] * 1000 / pgm_read_dword(&steps_per_mm_P[i]);

produces nonsense values for negative returns from get_direction().
Apparently, the compiler doesn't want to divide negative values???
Odd. Anyways, sufficient parentheses solve the problem.
2014-08-31 19:08:49 +02:00
Phil Hord b552447789 DDA: Move axis calculations into loops, part 8.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 8 is, move remaining update_current_position() into a loop.

This makes the binary 134 bytes smaller. As it's not critical,
no performance test.

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20134 bytes          141%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%
2014-08-31 19:08:42 +02:00
Phil Hord 80b29b727b DDA: Move axis calculations into loops, part 7.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 7 is, turn update_current_position() in dda.c partially into
a loop. Surprise, surprise, this changes neither binary size nor
performance. Looking into the generated assembly, the loop is
indeed completely unrolled. Apparently that's smaller than a
real loop.

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20270 bytes          142%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 279945 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 722 clock cycles.
LED on time average: 315.253 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 3297806 clock cycles.
LED on time minimum: 311 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 361.443 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 546946 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 334.319 clock cycles.
2014-08-31 19:08:34 +02:00
David Forrest 32481e2799 debug.h: Align M111 debug bit codes with Repetier-Host.
No code changes, binary size and performance kept.
2014-08-31 19:08:26 +02:00
Markus Hitter cc9c9ff7b4 DDA: Revert move axis calculations into loops, part 6a-c.
Sad but true, this experiment didn't work out. Performance loss
due to looping in dda_step() is still at least 16% with the best
algorithm found.
2014-08-31 19:08:15 +02:00
Markus Hitter 1fc4a26ccd DDA: Move axis calculations into loops, part 6c.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 6c removes do_step(), but still tries to keep a loop. This
about the maximum of performance I (Traumflug) can think of.
Binary size is as good as with the former attempt, but performance
is actually pretty bad, 45% worse than without looping:

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 19876 bytes          139%       65%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 406041 clock cycles.
LED on time minimum: 448 clock cycles.
LED on time maximum: 864 clock cycles.
LED on time average: 457.253 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 4791132 clock cycles.
LED on time minimum: 453 clock cycles.
LED on time maximum: 867 clock cycles.
LED on time average: 525.113 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 800586 clock cycles.
LED on time minimum: 448 clock cycles.
LED on time maximum: 867 clock cycles.
LED on time average: 489.356 clock cycles.
2014-08-31 19:08:07 +02:00
Markus Hitter 808f5dcfca DDA: Move axis calculations into loops, part 6b.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 6b moves do_step() from the "tidiest" place into where it's
currently used, dda.c. Binary size goes down another 34 bytes, to
a total savings of 408 bytes and performance is much better, but
still 16% lower than without using loops:

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 19874 bytes          139%       65%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 320000 clock cycles.
LED on time minimum: 351 clock cycles.
LED on time maximum: 772 clock cycles.
LED on time average: 360.36 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 3875874 clock cycles.
LED on time minimum: 356 clock cycles.
LED on time maximum: 773 clock cycles.
LED on time average: 424.8 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 640357 clock cycles.
LED on time minimum: 351 clock cycles.
LED on time maximum: 773 clock cycles.
LED on time average: 391.416 clock cycles.
2014-08-31 19:07:59 +02:00
Phil Hord b83449d8c3 DDA: Move axis calculations into loops, part 6a.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 6a is putting stuff inside the step interrupt into a loop,
too. do_step() is put into the "tidiest" place. Binary size goes
down a remarkable 374 bytes, but stepping performance suffers by
almost 30%.

Traumflug's performance measurements:

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 19908 bytes          139%       65%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 354537 clock cycles.
LED on time minimum: 390 clock cycles.
LED on time maximum: 806 clock cycles.
LED on time average: 399.253 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 4268896 clock cycles.
LED on time minimum: 395 clock cycles.
LED on time maximum: 807 clock cycles.
LED on time average: 467.875 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 706846 clock cycles.
LED on time minimum: 390 clock cycles.
LED on time maximum: 807 clock cycles.
LED on time average: 432.057 clock cycles.
2014-08-31 19:07:51 +02:00
Markus Hitter ad82907b98 testcases: Add config.h.
There's nothing special about this config.h, it's just the one I
happened to use for first profiling investigations. To allow
everybody else to do the very same profiling runs, I add it here.

Doing profiling isn't too complicated:

  mv config.h config.h.backup
  ln -s testcases/config.h.Profiling config.h
  git checkout -b work
  git cherry-pick simulavr # add tweaks convenient for simulation runs
  make
  cd testcases
  ./run-in-simulavr.sh short-moves.gcode smooth-curves.gcode triangle-odd.gcode

After being done you can restore your config.h and delete this work branch.

Currently, performance is as following (with convenience commit applied):

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20270 bytes          142%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 279945 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 722 clock cycles.
LED on time average: 315.253 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 3297806 clock cycles.
LED on time minimum: 311 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 361.443 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 546946 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 334.319 clock cycles.
2014-08-31 19:07:39 +02:00
David Forrest 003697ee0f gcode_parse.c: Debug S with serwrite_int32. 2014-08-31 19:07:30 +02:00
David Forrest f046c013e3 sermesg.c: Add documentation tag for variable floating point. 2014-08-31 19:07:21 +02:00
Markus Hitter e7707ea275 config.*.h: extend DEBUG_LED_PIN comment to all config templates. 2014-08-31 19:07:13 +02:00
David Forrest f356f64bdb config.default.h: Add DEBUG_LED_PIN to the pinout section. 2014-08-31 19:07:01 +02:00
David Forrest b12157cb6f gcode_process.c: Add comment on units of P, I, and D parameters. 2014-08-31 19:06:52 +02:00