Commit Graph

223 Commits

Author SHA1 Message Date
Ben Gamari 677ebfcccd dda: Fix signed-ness mismatch in handling of dda->e_delta 2012-08-04 22:07:43 +02:00
Markus Hitter 674014cc70 dda.c: remove two, now obsolete warnings. 2012-08-04 22:07:34 +02:00
Markus Hitter 81f85b018d Move utility functions from dda.c to dda_math.c.
Simple cleanup, no functional change.
2012-08-04 22:07:24 +02:00
Markus Hitter 0068ed1e26 Use the new muldiv() to replace um_to_steps..().
This gets rid of overflows at micrometer to step conversion as
much as possible within 31 bits. It also opens the door to get
STEPS_PER_M configurable at runtime.

This also costs 290 bytes, unfortunately.
2012-08-04 22:01:16 +02:00
Markus Hitter 3d1ebf1186 Review power supply timeout.
- Move the variable from dda.c to pinio.c.

- Reset the timeout on each power on, to guarantee a minimum PSU on time.
2012-07-16 20:13:12 +02:00
Markus Hitter ac22a57329 dda.c: enable update_current_position() for the new E relative handling. 2012-05-11 13:50:49 +02:00
Markus Hitter 9dda3349be Revert the new relative handling for X, Y and Z.
These were commits 9dbfa7217e0de8b140846ab480d6b4a7fc9b6791 and
2b596cb05e621ed822071486f812eb334328267a.

There are several reasons why this new approach didn't work out well:

- The machine coordinate system is lost on relative movements.
  OK, we could keep tracking it, but this would mean even more
  code, so even more chances for bugs.

- With the lost coordinate system, no software endstops are possible.

- Neither of X, Y, Z will ever overflow.

- If a movement planner would appear one day, he'd have to handle
  relative movements as well. Even more code duplication.
2012-05-11 13:50:47 +02:00
Markus Hitter e5cc5ab066 dda.c: Fix a number of minor things, detected by Phord.
These were mistakes introduced with the last commit.
Thanks, Phord!
2012-05-11 13:50:35 +02:00
Markus Hitter 5f9ae5b087 Implement M82/M83 and handle relative movements entirely different.
Instead of converting them to absolute first, then back to
relative and having all the fuzz with working on the queue's
start vs. working at the queue's end, mark a movement as relative
and use this directly.
2012-05-11 13:50:33 +02:00
Markus Hitter 25b72b4ea3 dda.c: remove the hack to set a minimum delay.
This in no longer needed, as the timer handles very short delays
now properly.
2012-03-04 19:03:31 +01:00
Markus Hitter 07fcff1661 dda.c: initialize dda.c properly. 2012-03-04 19:03:20 +01:00
Markus Hitter 1996cb4167 dda.c: axis_to_step = ' ' is no longer needed.
The need for this was a result of failing code in timer.c, which
was fixed in recent commits.
2012-03-04 19:03:07 +01:00
Markus Hitter 962209dceb Teach ACCELERATION_TEMPORAL to respect maximum feedrates. 2012-03-04 19:02:57 +01:00
Markus Hitter e8db35ec76 dda.c: get rid of a unused variable warning. 2012-03-04 19:02:48 +01:00
Markus Hitter fd91ee7e8b dda.c: re-introduce ACCELERATION_TEMPORAL.
The implementation is slightly different this time, as it's not
using these famous bresenham algorithms. The intention is to
allow axis-independent movements, as it's required for
EMC-quality look-ahead.
2012-03-04 19:02:17 +01:00
Markus Hitter 53490bb318 Get rid of defered enabling of the step interrupt again.
This makes the code cleaner and the reduction of code
probably easily compensates for keeping global interrupts
enabled for a bit longer. Talked to macscifi about this.

Saves about 300 bytes of binary size.
2011-11-21 09:54:38 +01:00
Markus Hitter fcd11a6f24 dda.c: get rid of did_step.
We want to stop stepping as there are no steps left, not one step later.

Accordingly, we get rid of a small pause between two movements and
also have to decelerate one step earlier.
2011-11-21 09:54:35 +01:00
Markus Hitter 1ee4668e21 dda.c: also reset startpoint_steps.E on relative extruder movements.
Thanks to bgamari for identifying this bug.
2011-11-17 13:49:08 +01:00
Markus Hitter 64b1a23cd3 dda.c: fix a typo in update_current_position(). 2011-11-17 13:48:48 +01:00
Markus Hitter 4e5f51f01e Store distances in the TARGET strucure in micrometers for all axes.
This extends the previous commit from X to Y, Z and E.
2011-11-17 13:48:36 +01:00
Markus Hitter c96ea0c773 Store distances in the TARGET structure always in micrometers.
This is a intrusive patch and for now, it's done for the X axis only.
To make comparison with the former approach easier ...

The advantages of this change:

- Converting from mm to steps in gcode_parse.c and back in dda.c
  wastes cycles and accuracy.

- In dda.c, UM_PER_STEP simply goes away, so distance calculations
  work now with STEPS_PER_MM > 500 just fine. 1/16 microstepping
  on threaded rods (Z axis) becomes possible.

- Distance calculations (feedrate, acceleration, ...) become much
  simpler.

- A wide range of STEPS_PER_M can now be handled at reasonable
  (4 decimal digit) accuracy with a simple macro. Formerly,
  we were limited to 500 steps/mm, now we can do 4'096 steps/mm
  and could easily raise this another digit.

Disadvantages:

- STEPS_PER_MM is gone in config.h, using STEPS_PER_M is required,
  because the preprocessor refuses to compare numbers with decimal
  points in them.

- The DDA has to store the position in steps anyways to avoid
  rounding errors.
2011-11-17 13:48:26 +01:00
Markus Hitter 2f8a257a0d dda.c: make update_position() work with an empty queue. 2011-10-23 19:52:00 +02:00
Markus Hitter 7a458486ed dda.c: reset ramping after an endstop stop.
As the new homing code ramps up, but not down, we have to reset
move_state.c before starting the next move.
2011-10-23 19:51:55 +02:00
Markus Hitter 2f04a9e58c Update current_position only as needed.
This saves almost 200 bytes and 100 runs of
update_current_position() per second.
2011-10-23 19:51:54 +02:00
Markus Hitter df693c0113 config.h/dda.c: make endstop debouncing steps configurable. 2011-10-23 19:51:46 +02:00
Ben Gamari 45124316e3 Rework endstop homing.
The DDA is now used for motion control.

Note from Traumflug: thanks a lot for this excellent patch, Ben.
2011-10-23 19:51:40 +02:00
Markus Hitter b45969e57a Introduce stepper_enable() and stepper_disable().
This allows to heat up with disables steppers, even if all steppers
share a common enable pin.
2011-10-05 14:13:21 +02:00
Markus Hitter 47d8dedf24 dda.c: move dda->*_steps and dda->*_counter into move_state as well.
Now we're easily back into business with an 8-line buffer queue
on an '168.
2011-05-16 22:09:12 +02:00
Markus Hitter ed77abba31 Move dda->step_no into move_state as well. 2011-05-16 22:09:10 +02:00
Markus Hitter bebb619054 dda.c, RAMPING: 16 bits for move_state.n are sufficient. 2011-05-16 00:16:00 +02:00
Markus Hitter 826f534fff dda.c: remove a few obsolete comments. 2011-05-15 23:48:58 +02:00
Markus Hitter 2421b788b9 Move dda->c out of DDA into move_state as well.
This also required to get rid of the usage of this variable
when waiting for temperature in dda_queue.*. Hope I got this
later part right.
2011-05-15 20:34:38 +02:00
Markus Hitter 51be23177a dda: move dda->n out into a new state variable
This required to also introduce dda_init() and re-adjust the
number of accelerating steps a bit.

Goal of this is to make look-ahead possible by just reducing
the number of deceleration steps and acceleration steps of
the next move. dda->c and dda->n no longer go down to their
initial values, then.

Also, quite a number of variables in the dda struct are used only when
the dda is live, so there is no need to store that for each
movement of the queue.
2011-05-15 20:34:35 +02:00
Markus Hitter 2f7619ae26 ACCELERATION_RAMPING: remove the old ramping algorithm.
The new algorithm takes up 80 bytes more binary size
and 12 bytes more RAM, but offers opportunities to
compensate for that.
2011-05-15 13:10:40 +02:00
Markus Hitter 20093404e9 ACCELERATION_RAMPING: use the precalculated number of ramping steps.
This is an intermediate step where both, the old and the new
ramping calculation methods are used and compared. The commit
is done for the case the new method needs debugging in other setups.
2011-05-15 13:10:38 +02:00
Markus Hitter ec47633794 ACCELERATION_RAMPING: precalculate number of acceleration steps.
These numbers aren't used, yet, but they can be compared with the
numbers calculated by the traditional method.
2011-05-15 13:10:36 +02:00
Markus Hitter 26fb18d178 Define acceleration in mm/s^2 instead of some unspecified value.
This units thing nicely covers the fact we need the ACCELERATION
to precalculate ramping steps later.
2011-05-15 13:10:32 +02:00
Jim McGee 408718d2bb Limit effect on dda->c when computing reprap style acceleration.
This fix is really a hack to protect from overflow/underflows
in the acceleration code due to the limited precision of the
fixed point calculations. It does, however, protect the code
from accidently turning off the step timer or setting the
timer interval value outside of the range defined by the current
interval and the ultimate endpoint interval.

This is a cleanup replacement for the code posted on the reprap forum:
http://forums.reprap.org/read.php?147,33082,83467#msg-83467
2011-05-15 09:56:33 +10:00
Jim McGee 5dc0c80f0b Defer enabling of timer1_compa interrupt the end of the interrupt handler.
Specifically, disable interrupts just before returning and then enable
the timer interrupt if appropriate. This means that the timer interrupt
cannot actually fire until after the RETI, so the function cannot be
entered recursively.
2011-05-15 09:56:33 +10:00
Jim McGee 85a9f63dfb Pretest DEBUG_X constants for non-zero and && the test with all existing
& tests of the debug_flags. Currently the compiler is able to eliminate
the block and the & operation when the constant is zero, but since
the debug_flags variable is a volatile the compiler does not eliminate
the load of the variable. By pretesting and shortcutting the load is
eliminated. Saves a small number of bytes when the debug build is
disabled and costs nothing when it is enabled.
2011-05-15 09:56:33 +10:00
Jim McGee 1e198e16ea Fix handling of the steptimeout variable.
Steptimeout is used both inside and outside
of interrupts, and as such it needs special attention.
Specifically, the increment outside of the interrupt
context needs to occur when interrupts are disabled,
or a clear of the variable can be missed.

The variable was also made volatile. This is not strictly necessary
given the current code, but it is the more conservative approach
to dealing with the variable (and costs nothing in the current code).
2011-05-15 09:56:32 +10:00
Michael Moon 1b1aea7f41 try to prevent queue locking due to non-atomic accesses and interrupt mismanagement 2011-05-10 12:43:27 +10:00
Michael Moon 74e03b7df1 allow G92 to work again after 0389289 2011-04-26 18:19:00 +10:00
Michael Moon 03892894ed remove ACCELERATION_TEMPORAL, update current_position from main loop instead of step interrupt 2011-04-26 14:45:32 +10:00
Markus Amsler 4b7f8fba48 Fix absolute E positioning.
Now also works with M101/M103
2011-04-12 01:36:57 +02:00
Michael Moon 0dc7d77885 Massive Doxygen documentation addition
'make doc' then point your browser at doc/html/

Needs plenty of cleanup and polishing, but the main bulk is here

even documents your configuration! ;)
2011-03-22 01:34:36 +11:00
Markus Hitter 12516be978 dda.c: get rid of duplicate power_on() & friends. 2011-03-02 00:59:48 +01:00
Markus Amsler d85f821872 Disable z stepper after each move.
All z-axis I'm aware off hold their positions with powered down stepper.
2011-02-27 22:15:15 +01:00
Markus Amsler d2c0a84da7 Arduino ide doesn't like definitions in for loops. 2011-02-27 22:11:13 +01:00
Stephan Walter 8acb072e0b Actually set extruder enable pin if defined 2011-02-27 00:55:14 +11:00
Michael Moon 4aefda6f17 added integer square root algorithm for future use 2011-02-24 18:49:28 +11:00
John Gilmore fe034d5e35 graycode stepper operation, distilled to one line in dda.c
Which includes a seperate file (graycode.c) with the defines and additional variable declaration.
I went with the "graycode" spelling, as there's about ten times as many hits for that as for "greycode" on google. I've read that both spellings are acceptable, but whatever.

Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-02-06 16:42:08 +11:00
Michael Moon 096d7dfdf3 Merge release-candidate-triffid branch 2011-01-07 23:09:13 +11:00
Stephan Walter 3028b297f3 Add simulation code: use "make sim" 2010-10-21 11:05:55 +11:00
Michael Moon dd8a5cd377 UM_PER_STEP stayed floating a bit too long 2010-10-20 17:39:57 +11:00
Michael Moon 18565b776f attempt to fix precision underflow in UM_PER_STEP macros 2010-10-20 17:23:18 +11:00
Markus Hitter 468b212077 Move micrometer conversion from config.h(.dist) to
dda.c, where it's used.
2010-10-07 21:34:38 +02:00
Markus Hitter 4bddf3452f Move stepper macros from config.h(.dist) to dda.c, as they're not
meant to be configured by the user.
2010-10-07 21:34:29 +02:00
Markus Hitter 95939ecc22 Don't disable the stepper timer interrupt while stepping.
After lots of try and error the conclusion was, disabling this
interrupt makes the timer vulnerable to be messed up by
characters incoming over the serial line. So, now the
interrupt is enabled as a move starts and not disabled before
the move, and all subsequent moves are done.
2010-10-04 16:05:01 +02:00
Markus Hitter 94e0cce89b Don't set the timer on nullmoves, as dda->c isn't initialized, then. 2010-09-30 21:20:22 +02:00
Markus Hitter f6f2b7f44f Enhance ACCELERATION_RAMPING on short moves.
Problem was: For short moves, you have to ramp down before
reaching target speed. The point of return was set to half
of the number of total steps.

Now, what happens is there's an uneven number of steps? In
integer math, 3 / 2 = 1, so the move would ramp one step up,
one step down and ... well, one step even further down, resulting
in a really sloooow step. Slow, like a full second or so.

Adding one to the first half, the movement ramps two steps up,
one down and would do another step at minimum speed, if it wasn't
already at target position. This is about as accurate as we
can get it without introducing more code at interrupt time.
2010-09-25 18:11:45 +02:00
Markus Hitter 696baea16a Implement better machine speed limits checking. Do it for
each axis individually, as the combined speed of two or more
axes can be higher than the limit of a single one.

While this is tested to work well for all three acceleration
types, I'm not enthusiastic about the code, as it adds almost
500 bytes. Perhaps an efficient-coding-geek can help :-)
2010-09-24 16:08:11 +02:00
Michael Moon c1dbd869f5 minor fixes: comments, indenting, etc 2010-09-18 08:08:31 +10:00
Michael Moon 6ce5895819 Merge branch 'master' of github.com:triffid/FiveD_on_Arduino 2010-09-16 17:15:30 +10:00
Markus Hitter bd1e357c35 dda.c: remove ABSDELTA() and delta32() implementations as they're unused. 2010-09-14 19:45:23 +02:00
Michael Moon 004bc1b789 code cleaning
(cherry picked from commit c3333278beaca0d81023b7ee752530466b37f316)
2010-09-13 20:40:23 +10:00
Markus Hitter 2178ff4ac1 Implement acceleration ramping. Enjoy always smooth rides! 2010-09-10 02:09:04 +02:00
Markus Hitter 639f5237be Make acceleration, RepRap-style, disable-able. This is also
in preparation for introducing acceleration ramping.
2010-09-08 22:35:27 +02:00
Markus Hitter 548b79f3d6 dda.c: replaced can_step() with a more simple solution. This
saves a whopping 270 bytes in interrupt context.
2010-09-08 19:14:04 +02:00
Markus Hitter 0572687cb2 dda_create(): clear _all_ flags before proceeding. 2010-09-08 15:57:32 +02:00
Michael Moon 883c488107 fixed some mess from moving stuff around 2010-08-10 14:59:41 +10:00
Michael Moon 0b51c1d0ab Merge branch 'mendel-triffid'
Conflicts:
	dda.c
	gcode.c
	machine.h
	temp.c
2010-08-10 14:55:06 +10:00
Michael Moon 595b66a341 setting up new branch 2 2010-08-10 14:26:24 +10:00