Commit Graph

76 Commits

Author SHA1 Message Date
Markus Hitter 13ec2d7521 Move endstop handling into a time-based procedure.
Before, endstops were checked on every step, wasting precious time.
Checking them 500 times a second should be more than sufficient.

Additionally, an endstop stop now properly decelerates the movement.
This is one important step towards handling accidental endstop hits
gracefully, as it avoids step losses in such situations.
2013-10-27 20:01:10 +01:00
Markus Hitter 1aca61c277 Make lookahead basically working.
This means, modify existing code to let the lookahead algorithms
do their work. It also means to remove some unused code in
dda_lookahead.c and reordering some code to make it work with
LOOKAHEAD undefined.
2013-07-11 22:02:13 +02:00
Markus Hitter 5d6de1761b Enable internal pullups for endstops on demand, only.
The binary size impact is moderate, like 18 bytes plus
4 bytes per endstop defined.

The story is a follows:

The endstop logic can be used to use a touch probe with PCB
milling. Connect the (conductive) PCB surface to GND, the
spindle/mill bit to the signal line, turn the internal pullups
on and there you go.

However, doing so with pullups always enabled and while milling
under (conductive) water showed polished mill and drill bits to
become matte after a few hours of usage. Obviously, this small
0.5 mA current from the pullup resistors going through the
rotating mill bit is sufficient to get some spark erosion going.
That's bad, as spark erosion happening also means tools become
dull faster than neccessary.

With this patch, pullups are turned on while being used, only,
so this sparc erosion should go away.
2012-12-03 19:48:13 +01:00
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