Commit Graph

891 Commits

Author SHA1 Message Date
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
Markus Hitter 42ad12fba3 DDA: store distance of each movement.
This is required to calculate speeds of individual axes. So far only
in dda_find_crossing_speed(), but soon also in dda_join_moves().
2014-03-04 19:54:41 +01:00
Markus Hitter 1b5682c01a dda.c: describe all lookahead cases in a comment. 2014-03-04 19:54:34 +01:00
Markus Hitter d10c0f3041 dda.c: clear /all/ lookahead variables when starting.
Catched it! :-)

This was causing occasional step losses when a movement with
zero crossF followed a pair with high crossF.
2014-03-04 19:54:23 +01:00
Markus Hitter 9715b7702d dda_lookahead.c: remember movement distance to avoid recalculation. 2014-03-04 19:52:54 +01:00
Markus Hitter da5339d163 DDA: use the already calculated distance for crossing speed calculation. 2014-03-04 19:52:42 +01:00
Markus Hitter 3ac26f0cab DDA: move dda_find_crossing_speed() to dda.c.
This is a preparation towards going through the existing movement
queue backwards with dda_join_moves() to allow higher feedrates
for lots of short movements.
2014-03-04 19:52:29 +01:00
Phil Hord 88b6101e9a DDA: reduce code duplication and simplify.
There are three locations in the code that repeat a pattern of
"If z=0 then use 2d-approx(dx,dy), else if x==0 && y==0 then use dz,
else use 3d-approx".

Teach approx_distance_3 to detect these conditions for us and apply
the same logic.  Replace the three call locations with a simple call
to approx_distance_3.

Binary size for the LOOKAHEAD case drops by almost 400 bytes:

  old:  FLASH : 21242 bytes          149%       70%        34%       17%
  new:  FLASH : 20844 bytes          146%       68%        33%       17%

The size for non-LOOKAHEAD drops by 40 bytes:

  old:  FLASH : 16592 bytes          116%       55%        27%       13%
  new:  FLASH : 16552 bytes          116%       54%        27%       13%

We can actually do a little better if we consider the zero-ness of all
three axes, but this does make the code a little bit bigger. Another
change will consider that option. This change simply tries to mimic
the existing functionality.
2014-03-04 19:51:56 +01:00
Markus Hitter ed9f56a9d8 look-ahead: move jerk definitions into config.h templates. 2014-03-04 19:29:28 +01:00
Markus Hitter b2063e1182 look-ahead: change crossing speed calculation algorithm.
The new one solely looks at speed differences of individual axes.
This means individual jerks for each axis (good!) and relative
simple maths (also good!).

For details and maths, see comments in the code and
https://github.com/Traumflug/Teacup_Firmware/issues/45 .
2014-03-04 19:29:20 +01:00
Markus Hitter 1b5b40e61d dda_lookahead.c: move crossing speed calculation into a dedicated function.
This is mostly a preparation for reverse walks through the movement queue,
where crossing speed calculation is done only once, while actually used
speeds can be raised successively with repeated walks.
2014-03-04 19:28:48 +01:00
David Forrest 8ddc633531 sersend.c: Make %d, %ld, %sd print signed values. 2014-02-19 13:02:14 +01:00
Markus Hitter 1eaf711923 dda.c: review debug messages a bit. 2013-12-06 19:24:58 +01:00
Phil Hord 199d6d2bb4 Show velocity from simulator trace file
Add a tool (tools/velocity_plot.sh) to read in a simulator trace
file, calculate the velocity of the X and Y axes, and show a plot
of these velocities against time along with the X and Y positions.
2013-12-06 19:24:58 +01:00
Markus Hitter d94e3c7258 Testcases: add save file for GTKWave.
The nice thing about these save files is, they provide a display
for the data, so you simply load a .vcd, additionally read a
save file and you're ready to investigate your movement data.
2013-12-06 19:24:58 +01:00
Markus Hitter 06d496e8ca run-in-simulavr.sh: also output position in micrometers. 2013-12-06 19:24:58 +01:00
Markus Hitter f1873b4360 run-in-simulavr.sh: also record position.
So far only in steps.
2013-12-06 19:24:58 +01:00
Markus Hitter 3ad9ad5594 run-in-simulavr.sh: fix bitfield conversion.
No major thing, even numbers had the last bit set.
2013-12-06 19:24:58 +01:00
Markus Hitter c25547da15 Add a testcase for moves shorter than the acceleration ramps. 2013-12-06 19:24:58 +01:00
Markus Hitter f92b59365e Testcases review:
- comment on why the case exists,

- add an M2 at the end to later allow automatic simulation stop,

- move comments to the end to avoid filling the serial buffer with
  stuff unrelated to movements,

- make sure there's a line ending at the end of the file and

- use Windows line endings (they're more difficult to handle).
2013-12-06 19:24:58 +01:00
Markus Hitter 46526ecdda Add testcase for nullmoves.
Moves which have no movement intention, e.g. pure feedrate changes,
and moves too small to cause a single step, are a bit tricky to
handle with lookahead. Essentially, they should be joined with the
next movement, without queueing them up.
2013-12-06 19:24:58 +01:00
Markus Hitter c594af3e19 dda.c: don't set timer twice when going from one move to the next.
This is a bug which existed, well, basically forever. Nobody noticed
until precision timings could be recorded with SimulAVR.
2013-12-06 19:24:58 +01:00
Markus Hitter 68cc213a70 dda_maths.c: pick a nugget from @phord's distance calculation rework. 2013-12-06 19:24:58 +01:00
Markus Hitter 8a476e2fba Makefile: get rid of the config.h check.
This doesn't work well for developers, because config.h.default is
rewritten all the time when switching branches.
2013-12-06 19:24:58 +01:00
Markus Hitter f37a65ca36 dda_queue.c: run every queued thing through dda_create().
This allows dda_create() to track things queued but not being a movement.
Important for lookahead.
2013-12-06 19:24:58 +01:00
Phil Hord ddd8988727 dda_create(): store prev_dda locally.
This obviously requires less place on the stack and accordingly a
few CPU cycles less, but more importantly, it lets decide
dda_start() whether a previous movement is to be taken into account
or not.

To make this decision more reliable, add a flag for movements done.
Else it could happen we'd try to join with a movement done long
before.
2013-12-06 19:24:58 +01:00
Markus Hitter ec9e84a068 gcode_parse.c: assume G1 only for stuff which might actually move.
Previously, even comments were run through dda_create(), quite a waste
of time.
2013-12-06 19:24:58 +01:00
Phil Hord 96495fb9bb simulator: Make time-scale=0 a cmdline option
Teach the simulator to run with no delays when time-scale=0.

Let the user specify the time-scale on the command line.
2013-12-06 19:24:58 +01:00
Phil Hord c7b43782ce datalog: add a tip showing gnuplot usage
Add a comment to the datalog output showing how it can be viewed with
gnuplot.  It would be trivial to add this as a .plot script, but it's
even easier in the datalog output.
2013-12-06 19:24:58 +01:00