Commit Graph

876 Commits

Author SHA1 Message Date
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
Phil Hord 46bbc09118 Turn dead-code removal back on when not simulavr 2013-12-06 19:24:58 +01:00
Markus Hitter fd5fe676f4 run-in-simulator.sh: express velocities in mm/min, too.
Uh, this bloats the resulting VCD file by 50% ... ;-)
2013-12-06 19:24:58 +01:00
Markus Hitter 5c0808732c run-in-simulator.sh: run (only) selected files. 2013-12-06 19:24:58 +01:00
Markus Hitter e559b59b54 run-in-simulator.sh: use stdin/stdout for the data file, too. 2013-12-06 19:24:58 +01:00
Markus Hitter 005a935adc run-in-simulavr.sh: also rewrite VCD file to add speed values.
This is quite handy, as you can see accurate speed ramps in
GTKWave now.
2013-12-06 19:24:58 +01:00
Markus Hitter 6e4bdc43ca Add a draft of a script running testcases in SimulAVR.
This script also asks SimulAVR to generate pin traces of the X
and Y axis and even processes this data into a data file with
time, position and current speed of each axis.

Missing:

- Acceleration calculation.

- LOTS of polish.
2013-12-06 19:24:58 +01:00
Markus Hitter b2e22c6d3b Add another testcase, add lookahead-warmup.
Lookahead-warmup = two lines of G-code which take just long enough
to allow the intended movements to be added with look-ahead.
2013-12-06 19:24:58 +01:00
Markus Hitter 71ae941a09 Add simulation info for SimulAVR.
This shouldn't change the running binary at all, so it shouldn't
harm. However, it allows to run Teacup inside SimulAVR and accessing
Teacups' serial line through the console/terminal.

For detailed instructions, see http://reprap.org/wiki/SimulAVR .
2013-12-06 19:24:58 +01:00
Phil Hord ab65ba6c95 Rename delta -> delta_um to avoid collision. 2013-12-06 19:24:58 +01:00
Phil Hord 3f07a47c06 pinio.h: Fix bug in macro definition
Including a semicolon in a macro function causes problems
when the "function" is called inside an if statement.  Fix
four cases in pinio.h where this error exists but currently
is not harming the code.
2013-12-06 19:24:58 +01:00
Johannes Schriewer (Dunkelstern) 1fb9f8ccd5 Missing member variable for lookahead in DDA struct. 2013-12-06 19:24:58 +01:00
Markus Hitter c8b0da53c1 timer.c: we never managed to recover from an emergency stop ...
... other than by pressing the reset button. Accordingly, save
these 2 clock cycles at step interrupt time.
2013-12-06 19:24:58 +01:00
Phil Hord cfa4857550 simulator: cmdline switches for output options
Teach simulator several command line options to control console output
of info messages, gcode traces, data_recorder output, etc.

Also move gcode output to sim_gcode instead of sending directly to
datarecorder.
2013-12-06 19:24:58 +01:00
Phil Hord 8874397b45 Make data logging optional (internal)
If the recorder is initialized with a filename, write trace data
to that file.  But if it is not initialized, don't complain and
don't write the data anywhere.
2013-12-06 19:24:58 +01:00
Phil Hord 36747e5703 Teach simulator to process gcode files directly
The simulator runs as a device simulator complete with serial port
so it can communicate with printer software like pronterface. But
often we just want to stream it a file of gcode commands and get
some output.  Teach the simulator to take a regular file as input
and process it as a file of gcode commands if it is not a device.
2013-12-06 19:24:58 +01:00