Commit Graph

919 Commits

Author SHA1 Message Date
Phil Hord cec3c5f52e DDA: Move axis calculations into loops, part 1.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Traumflug notes:

Split this once huge commit into smaller ones for ease of
reviewing and bisecting (in case something went wrong).

Part 1 is to put dda_create() distance calculations into loops.
This reduces binary size by another whopping 756 bytes.
2014-08-31 19:04:25 +02:00
Markus Hitter 1c19158bbc DDA: use new generic um_to_steps_* in dda_new_startpoint().
This was contributed by Phil Hord as part of another commit.

It saves 168 bytes, to it more than outweights the overhead of
introducing a generic implementation already.
2014-08-31 19:04:17 +02:00
Phil Hord 62bdbd86d6 DDA: convert um_to_steps_* to generic implementation.
A generic implementation here will allow callers to pass the
target axis in as a parameter so the callers can also be made more
generic.

Traumflug notes:

Split out application of the new implementation in dda.c into its
own commit.

This actually costs 128 bytes, but as we can access axes from within
a loop now, I expect to get more savings elsewhere.

Interestingly, binary size is raised by another 18 bytes if

  um_to_steps(int32_t, enum axis_e)

is changed to

  um_to_steps(enum axis_e, int32_t)

even on the 8-bit ATmega. While putting the axis number to the
front might be a bit more logical (think of additional parameters,
the axis number position would move), NXP application note
AN10963 states on page 10ff, 16-bit data should be 16-bit aligned
and 32-bit data should be 32-bit aligned for best performance.
Well, so let's do it this way.
2014-08-31 19:04:08 +02:00
Markus Hitter 84cbf2a42a home.c: no need to turn off Z axis here.
This is done in dda.c already, see dda.c, line 678.
2014-08-31 19:03:57 +02:00
Markus Hitter 94fa733ee8 home.c: don't move to zero after homing to max endstop.
This can be counterproductive if the actual zero point is
outside the available build room. For example, if an additional
bed probing is going to happen. It also costs quite some
time on the Z axis. If you actually  want this behaviour,
send a simple G0 XYZ after homing.
2014-08-31 19:03:45 +02:00
Phil Hord e2f793c2b3 DDA: Convert more axis variables to arrays.
Many places in the code use individual variables for int/uint values
for X, Y, Z, and E.  A tip from a comment suggests making these into
arrays for scalability in the future. Replace the discrete variables
with arrays so the code can be simplified in the future.
2014-08-31 19:03:31 +02:00
Phil Hord d3f49b3e95 DDA: Convert TARGET axis vars to array.
In preparation for more efficient and scalable code using axis-loops
for common operations, add two new array-types for signed and unsigned
32-bit values per axis. Make the TARGET type use this array instead of
its current X, Y, Z, and E variables.

Traumflug notes:

- Did the usual conversion to spaces for changed lines.

- Added X = 0 to the enum. Just for peace of mind.

- Excellent patch!

Initially I wanted to make the new array an anonymous union with the
old variables to allow accessing values both ways. This way it would
have been possible to do the transition in smaller pieces. But as
the patch worked so flawlessly and binary size is precisely the
same, I abandoned this idea. Maybe it's a good idea in other areas.
2014-08-31 19:03:17 +02:00
Markus Hitter e76bfa0d05 gcode_process.c: more preprocessor conditions for homing movements.
Well, optimizer isn't _that_ smart. It apparently removes
empty functions in the same compilation unit ( = source code file),
but not ones across units.

This saves 10 bytes binary size per endstop not used, so 30 bytes
in a standard configuration. All without any drawbacks.
2014-07-11 01:38:34 +02:00
Markus Hitter d53407bdc3 home.c: remove some redundant preprocessor stuff.
Binary size is exactly the same, to the optimizer apparently
manages to drop empty functions.
2014-07-11 01:38:25 +02:00
Markus Hitter dc84e4dfe0 home.c: adaptive homing feedrates for all axes. 2014-07-11 01:38:18 +02:00
Markus Hitter a7adc66ae5 config.*.h: distribute adaptive homing feedrate to all templates. 2014-07-11 01:38:08 +02:00
Markus Hitter b275bfcc32 Implement adaptive homing feedrates.
For now for X min only, but it works excellently already.
Tested quite a few combinations and raising acceleration
or endstop clearance raises homing feedrate just as expected.

Quite a chunk of the code is for testing the given configuration,
only. A thing which would ideally be done for every macro
used in each code file.
2014-07-11 01:37:57 +02:00
Markus Hitter 7611872baa Get rid of E_STARTSTOP_STEPS.
This meant to be a firmware-provided retract feature but was
never really supported by G-code generators. Without their support
(by issueing M101/M103), it's pretty hard to detect extrusion
pauses, so this feature simply has no future.

As this was on by default, it saves over 200 bytes binary size
in a default configuration.
2014-07-11 01:37:48 +02:00
David Forrest c35d1c1caf heater.c, config.default.h: Make PID_CONDITIONAL_INTEGRATION non-optional.
See
https://github.com/Traumflug/Teacup_Firmware/issues/74#issuecomment-38999466
2014-07-11 01:37:35 +02:00
David Forrest 23679855a0 heater.c: Enable more anti-windup with PID_CONDITIONAL_INTEGRATION. 2014-07-11 01:37:24 +02:00
David Forrest 707c4f35de heater.c: Limit PID I term with conditional integration. 2014-07-11 01:37:16 +02:00
Markus Hitter 4ccca52367 Give users a hint in case they obviously forgot to read instructions. 2014-07-09 21:38:12 +02:00
David Forrest c74b5175fc Makefile-AVR: Update MCU_TARGET=at90usb1286 conditional. 2014-06-13 21:04:13 +02:00
Markus Hitter 3e02de3cde gcode_parse.h: raise S word size.
Some M-codes apparently need this. Perhaps it could be avoided,
but it costs just 8 bytes binary size and 2 bytes RAM, so not
really a reason to make a headache.
2014-05-29 21:49:29 +02:00
Markus Hitter f51e52e7fa dda.c: endstop stop more reliably. 2014-05-29 21:49:20 +02:00
David Forrest 6c6b4b3b3f config.teensypp.h: Update to match testbed hardware. 2014-05-29 21:49:03 +02:00
David Forrest 2bf98feaaa mendel.c: Enable DEBUG_LED_PIN output if defined. 2014-05-29 21:48:46 +02:00
David Forrest 9d5d2a5492 heater.c: Update link to 'PID without a PhD' Tim Wescott 2000 Embedded article. 2014-05-29 21:48:29 +02:00
David Forrest dd72f9c1d6 dda.c: Update links to 'Generate stepper-motor speed profiles in real time' David Austin 2004 Embedded article. 2014-05-29 21:48:11 +02:00
Phil Hord d2b1df6a93 simulator: Turn off printf format warnings
PC-based target emits warnings about printf formats, but there's nothing
to be done about them, really.  Turn them off for polite builds.
2014-05-29 21:47:52 +02:00
David Forrest 034d8445fd heater.c: Add comments about units of PID variables and constants. 2014-05-29 21:47:42 +02:00
David Forrest e771d2340e config.teensypp.h: Modify pins to be more like Teensylu and Printrboard. 2014-05-29 21:47:21 +02:00
Markus Hitter 6dbc7a7797 temp.c: fix typo. 2014-04-13 11:24:47 +02:00
Markus Hitter da8ccf7535 temp_achieved(): check only sensors/heaters turned on.
Problem spotted, described in a helpful manner and over-fixed
by @zungmann. This fix picks up his basic idea and implements it
with already existing state properties.
2014-03-04 19:58:19 +01:00
Markus Hitter 95a44e8777 DDA: clear flags of a queue entry earlier.
Formerly, once a wait for temp was given, this flag would stick
forever on this queue entry.

Spotted by Zungmann, thanks a lot!

http://forums.reprap.org/read.php?147,33082,280439#msg-280439
2014-03-04 19:58:06 +01:00
Markus Hitter 793a04b991 Align section attributes usage: always before the variable name. 2014-03-04 19:57:56 +01:00
Phil Hord c7150445af Zungmann's fixes to compile simulator on Mac OS X, part 2.
Here: .bss section syntax is different.
2014-03-04 19:57:48 +01:00
Phil Hord 5cd6cf50d8 Zungmann's fixes to compile simulator on Mac OS X, part 1.
Compiling for Mac OS X needs some customizations noticed by zungmann
in the reprap forum:

http://forums.reprap.org/read.php?147,33082,279050#msg-279050
2014-03-04 19:57:41 +01:00
Phil Hord 3fcd6b3c59 deriv.awk: Calculate derivative of every column
Instead of just two columns (x and y) in the trace file, treat
every column as a function and calculate the first derivative
of it without regard for its supposed "meaning".  In addition
to getting more data from this, it also allows us to calculate
the 2nd derivative easily by running the script again on the
resulting data.

Also convert time in column 1 from microseconds to seconds.
2014-03-04 19:57:28 +01:00
Phil Hord ed7f3ad559 simulator: Respect XYZE_INVERT_DIR settings
Simulator assumes a basic set of config pins.  Most it ignores
and redefines.  But the INVERT_DIR pins it did not, and these
could be useful to simulate.  So teach Simulator to respect them.
2014-03-04 19:57:19 +01:00
Phil Hord 96b7b8e6c9 Update URLs for new github location 2014-03-04 19:57:08 +01:00
Phil Hord e4cfffee42 DRY: Reduce duplication in platform Makefiles
Move builds for non-avr target (simulator) into a $(BUILD_FLAVOR)
build subdir (build/sim) to isolate it more completely and
cleanly from the AVR builds.  This allows AVR and SIM to use common
build rules again.

Move newly bits out of Makefile-{SIM,AVR} and into Makefile-common.
2014-03-04 19:56:46 +01:00
Phil Hord 917d879d03 DRY: Reduce duplication in Makefile-AVR
Refactor the "sizes" code into a parametric make function and
reformat it for readability.
2014-03-04 19:56:39 +01:00
Phil Hord 11d7227d2c make Makefile-{SIM,AVR,common} more generic
Allow stock makefile variables to be overridden by 'make' caller
so the user's 'Makefile' can be authoritative.

See Makefile-example for usage.
2014-03-04 19:56:30 +01:00
Phil Hord 21e5343552 Add config.h wrapper to simplify test automation
Test code which wants to customize config.h can do so without
touching config.h itself by wrapping config.h in a macro variable
which is passed in to the compiler.  It defaults to "config.h" if
no override is provided.

This change would break makefile dependency checking since the selection
of a different header file on the command line is not noticed by make
as a build-trigger.  To solve this, we add a layer to the BUILDDIR path
so build products are now specific to the USER_CONFIG choice if it is
not "config.h".
2014-03-04 19:56:23 +01:00
Markus Hitter 08179ccbbe Remove __attribute__((hot)).
There's no apparent documentation for this on the AVR variant of GCC.
Likely it means to optimize "more aggressively". Uhm, is gcc
intentionally wasting cycles otherwise? Likely not.

Also, the compilation result is exactly the same size with or
without this attribute.
2014-03-04 19:56:13 +01:00
Markus Hitter 6fae5a8b7c DDA: make macro ACCELERATE_RAMP_LEN_SPM() a function.
This macro is pretty expensive (700 bytes, well, stuff is now
calculated at runtime), so there's no chance to use it in multiple
places and we likely also need this in dda_lookahead.c to achieve
full 4 axis compatibility there.
2014-03-04 19:56:01 +01:00
Markus Hitter 9739382da9 dda.c: remember steps per m of the fast axis for rampup calculation.
For now this is for the initial rampup calculation, only, notably
for moving the Z axis (which else gets far to few rampup steps on
a typical mendel-like printer).

The used macro was verified with this test code (in mendel.c):

[...]
int main (void) {
  init();

  uint32_t speed, spm;
  char string[128];
  for (spm = 2000; spm < 4099000; spm <<= 1) {
    for (speed = 11; speed < 65536; speed *= 8) {
      sersendf_P(PSTR("spm = %lu  speed %lu ==> macro %lu  "),
                 spm, speed, ACCELERATE_RAMP_LEN_SPM(speed, spm));
      delay_ms(10);
      sprintf(string, "double %f\n",
              (double)speed * (double)speed / ((double)7200000 * (double)ACCELERATION / (double)spm));
      serial_writestr((uint8_t *)string);
      delay_ms(10);
    }
  }
[...]

Note: to link the test code, this linker flag is required to add
      the full printf library (which does print doubles):

  LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
2014-03-04 19:55:53 +01:00
Markus Hitter 3da2363ac5 DDA: remember the fast axis micrometers and save their reconstruction.
No surprise, this saves a whopping 600 bytes.
2014-03-04 19:55:45 +01:00
Roland Brochard 297aa28dfd Lookahead: refactored code to compute everything in dda steps. 2014-03-04 19:55:36 +01:00
Markus Hitter 20686eb52c dda.c: remove the hack for too high rampup steps for lookahead.
Keeping the hack causes the previous move to decelerate, which isn't
intended when movements are joined with lookahead.

Removing only the hack breaks endstop handling on those axes which
set a huuuge number of acceleration steps for the lack of a proper
calculation algorithm. We have this algorithm now, so we can stop
using this kludge.

Solves part 1 of issue #68.
2014-03-04 19:55:28 +01:00
Markus Hitter 2f1142d461 dda.c: base rampup_steps calculation on the fast axis, too. 2014-03-04 19:55:20 +01:00
Markus Hitter 730c1836ad dda_lookahead.c: base ramping calculations on the fast axis.
Previously, ramps were calculated with the combined speed,
which can differ from the speed of the fast axis by factor 2.

This solves part 2 of issue #68.
2014-03-04 19:55:12 +01:00
Markus Hitter 41ca1b7570 dda.c: actually reduce endpoint.F for overly fast movement attempts.
This fix was long overdue and is now unavoidable, as the hack with
limiting maximum speed to c_min in dda_clock() conflicts with
lookahead.
2014-03-04 19:55:03 +01:00
Markus Hitter 46548dba47 DDA: make a huge comment compact and move it to where it belongs.
Also clarify the acceleration formula.
2014-03-04 19:54:53 +01:00