Commit Graph

933 Commits

Author SHA1 Message Date
David Forrest 5b5c44b523 dda_lookahead.c: Eliminate debug crossF variable compile warning.
Fix:
  dda_lookahead.c:327:17: warning: 'crossF' may be used
  uninitialized in this function [-Wmaybe-uninitialized]
       sersendf_P(PSTR("Initial crossing speed: %lu\n"), crossF);
                 ^
2014-08-31 19:06:43 +02:00
David Forrest 2496a95c6f dda_maths.h: Add comment on units of C0. 2014-08-31 19:06:34 +02:00
David Forrest f3666fc43f heater_sim.c: Note that the heater isn't implemented in the simulator. 2014-08-31 19:06:23 +02:00
Markus Hitter fdfd202e5d run-in-simulavr.sh: add statistics output for LED On Time.
As it's still a bit cumbersome to go through the whole .vcd file
to find the highest delay between On and Off, do this search
automatically and output an statistics. Can look like this:

  Statistics (assuming a 20 MHz clock):
  LED on occurences: 838.
  Sum of all LED on time: 262055 clock cycles.
  LED on time minimum: 306 clock cycles.
  LED on time maximum: 717 clock cycles.
  LED on time average: 312.715 clock cycles.

This should give an reasonable overview of wether and roughly
how much a particular code change makes your code slower or
faster. It should also show up showblockers, like occasionally
huge delays.

BTW., the above data was collected timing the step interrupt when
running short-moves.gcode with the current firmware.
2014-08-31 19:06:13 +02:00
Markus Hitter da08c35edd run-in-simulavr.sh: add support for timing measurements.
The idea is simple: if you want to time a portion of code
precisely, turn on the Debug LED (see config.h for
DEBUG_LED_PIN) at the start of sequence and turn it off when
done. Running this in SimulAVR, you have two flanges precise
to the clock cycle which exactly reflect the time taken to
run this code sequence. Ideally, you run this code n a loop
to get a number of samples, if it doesn't run in a loop anyways.

Time taken can then be measured in GTKWave. For convenience and
for a better overview, run-in-simulavr.sh also extracts all the
delays into it's own signal, so it can be viewed as an ongoing
number.
2014-08-31 19:06:05 +02:00
Markus Hitter 4389e670bd run-in-simulavr.sh: start signals undefined.
Also a few aesthetical corrections.
2014-08-31 19:05:56 +02:00
Markus Hitter 35c4949965 run-in-simulavr.sh: run SimulAVR a bit more verbose.
SimulAVR doesn't always work exactly the way it should, so looking
at the command line it's started with is a first debugging step.
2014-08-31 19:05:47 +02:00
Markus Hitter 6250dbb9e0 Configuration: move DEBUG_LED definition.
Eventual debugging LEDs aren't part of the CPU, but part of the
electronics. Accordingly, define it in config.*.h, not in
arduino_*.h (which would be better named something like
"atmega_*.h).
2014-08-31 19:05:38 +02:00
Markus Hitter 9a08675576 Rename all these new PROGMEM variables to end in _P.
Should be done for temptable in ThermistorTable.h, too, but this
would mess up an existing users' configuration.

This tries to put emphasis on the fact that you have to read
these values with pgm_read_*() instead of just using the variable.
Unfortunately, gcc compiler neither inserts PROGMEM reading
instructions automatically when reading data stored in flash,
nor does it complain or warn about the missing read instructions.

As such it's very easy to accidently handle data stored in flash
just like normal data. It'll compile and work ... you just read
arbitrary data (often, but not always zeros) instead of what you
intend.
2014-08-31 19:05:25 +02:00
Phil Hord 74808610c7 DDA: Move axis calculations into loops, part 5.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 5 is move ACCELERATION_TEMPORAL's step delay calculations
into loops. Not tested, binary size change unknown.
2014-08-31 19:05:09 +02:00
Phil Hord 8d729d499d DDA: Move axis calculations into loops, part 4.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 4 is move ACCELERATION_TEMPORAL's maximum feedrate limitation
into a loop. Not tested, binary size change unknown.
2014-08-31 19:05:00 +02:00
Phil Hord cd0155b5f4 DDA: Move axis calculations into loops, part 3.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 3 is moving fast axis detection into a loop.
Binary size 84 bytes smaller.
2014-08-31 19:04:52 +02:00
Phil Hord d3beb21225 DDA: Move axis calculations into loops, part 2.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 2 is moving maximum speed limit calculations into loops.
Binary size another 160 bytes smaller.
2014-08-31 19:04:42 +02:00
Phil Hord 427d6637c3 dda_maths.h: remove now obsolete um_to_steps_[xyze]. 2014-08-31 19:04:33 +02:00
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