Commit Graph

548 Commits

Author SHA1 Message Date
Jens Ch. Restemeier cea2a656a5 Fix assumption that debug led is on SCK pin
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-06-10 22:58:25 +10:00
Jens Ch. Restemeier b39a7b8d84 fixed documentation errors 2011-06-03 02:02:47 +10:00
Jens Ch. Restemeier 14afa84aca Added gcode documentation and extraction tool 2011-06-03 02:02:46 +10: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 f555887eb5 Testing and setting the delay to a minimum value needs to occur only
if delay is not zero, otherwise the timer is not turned off when it
should be. Move the test and setting back inside the block that is only
executed if delay > 0.
2011-05-15 16:48:25 +10: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 57b30b0ff1 Set a minimum delay instead of attempting to call the timer interrupt
service routine in the case that the requested timer interval is too
small.

Calling the interrupt service routine at this point is likely to
recursively clobber the stack.

Setting a lower bounds on the interrupt delay will limit the upper
speed of pulse generation, but it should not change the relative
pulse rates, and will not recurvisely clobber the stack.

Note that the lower limit of 17 has not been researched, it is
simply the value below which the old code attempted to call
the interrupt service routine directly.
2011-05-15 09:56:33 +10:00
Jim McGee 8241549276 Remove volatile from next_step_time as it can be easily managed using
memory barriers since it is only touched inside a single interrupt
handler or while interrupts are disabled in setTimer().

This saves about 90 bytes since it no longer needs to be reloaded multiple
times.
2011-05-15 09:56:33 +10:00
Jim McGee 8378aa04fc Address issues with interrupts and the shared variables used to
manage the movebuffer (mb_head, mb_tail, movebuffer).

The approach taken is to leave all of the variables non-volatile
and use memory barriers to control reads/writes. read/modify/write
operations that can be done outside of the interrupt context are
protected by disabling interrupts.

Also, manually cache the pointer to the movebuffer of interest
as the compiler does a poor job of reusing the pointer even in
places that it could.

There are still some groups of accesses to the movebuffer data that need
to be protected by disabling interrupts, but these are all related
to sending back debug data. The error will cause occassional mismatched
values to be sent back via the serial connection, but they do not
affect the actual operation of the code, so they will be addressed
in a separate checkin.

Conflicts:

	dda_queue.c
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 f22e691fee Convert the clock_flag variable into 3 separate varables.
This costs 2 bytes of ram, but saves 60 bytes of flash. Doing so
also eliminates the need to disable interrupts while clearing flags
in the ifclock macro.

Conflicts:

	clock.c
	timer.c
	timer.h
2011-05-15 09:56:32 +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
Jim McGee b6b5ced7be Add CLI_SEI_BUG_MEMORY_BARRIER() macro that inserts a memory barrier for older versions of avr-libc that do not include a memory barrier as part of the definition of SEI() and CLI(). 2011-05-15 09:56:32 +10:00
Jim McGee 4420652549 Add standalone memory barrier function to project. 2011-05-15 09:56:32 +10:00
Jim McGee 1059f27592 Clean up delay functions and rename them to be consistent with
what was used before the inline delay approach was attempted.
2011-05-15 09:56:32 +10:00
Jim McGee 757e1258e2 Shorten waiting delay while waiting for room to place a movebuffer on the queue. 2011-05-14 02:10:01 +02:00
Markus Hitter c095fa5de3 Leverage E_ABSOLUTE into config.h's, so people recognize it.
Oh, and let's hope it works already :-)
2011-05-13 13:24:52 +02:00
Sergey Batalov 03cebb5a82 TEMP_RESIDENCY now in units of 10ms rather than next_read_time
Signed-off-by: Michael Moon <triffid.hunter@gmail.com>
2011-05-10 14:10:56 +10:00
Michael Moon 7a57b69cc1 fix delay compilation. Takes some of madscifi's ideas yet still provides fallback functions for eg; homing which uses variable delays 2011-05-10 13:55:08 +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
Markus Hitter ea437e8e12 delay.h, contribution by macscifi: be C89 compatible again. 2011-05-08 23:20:39 +02:00
Ben Jackson f8d8b2a471 gcode_parse.c: Send newline as char rather than PSTR 2011-05-08 00:37:03 +10:00
Ben Jackson da2a9c3d56 func.sh: Fix a potential infinite loop in mendel_readsym_target 2011-05-08 00:36:55 +10:00
Ben Jackson 7198021f4a func.sh: Replace perl eval() with hex() where appropriate. 2011-05-08 00:36:43 +10:00
triffid a01981ac70 Merge pull request #6 from madscifi/universal-delay
Eliminate overflow in the delayMicrosecondsInterruptible function.
2011-05-07 06:56:57 -07:00
Jim McGee b00c53f69e The addition of delay.h to the dependencies of (PROGRAM).elf did not have the desired effect (to force a recompile of all if delay.h changed). Removed the dependency. 2011-05-04 22:33:41 -07:00
Jim McGee 86a34ad5a2 Eliminates overflow in the delayMicrosecondsInterruptible
function.

Inline delay functions and change base function to
use __builtin_avr_delay_cycles(). Generated delays
are at least as long as the requested delay and
compensate for the system clock (based on F_CPU).

Delay functions must be called with constant values.
A compile time error is issued if they are not.

Delay.c removed as it is no longer used.
2011-05-04 20:14:46 -07:00
Michael Moon 2822721a59 improve and simplify heater pin initialisation by moving to io_init[mendel.c] and using macro magic with DEFINE_HEATER 2011-05-05 00:02:06 +10:00
Michael Moon 3e32a8f634 allow M114 to report negative positions correctly 2011-05-01 17:17:56 +10:00
Michael Moon be81a13584 make sure timer is initialised properly
Reported-by: jv4779 <jv4779@gmail.com>
2011-04-30 11:00:11 +10:00
Michael Moon 143398705c add "functionsbysize" make target 2011-04-29 10:55:42 +10:00
Michael Moon e2cb6aef72 M109 just waits if no temperature provided 2011-04-29 10:15:49 +10:00
Kieran Levin 61ca4c114e fixed temperature reading problem where ReplicatorG would freeze because there is no newline before the temperature prints out... 2011-04-29 10:15:40 +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
Michael Moon e108ab2548 M114 returns millimeters instead of steps 2011-04-26 14:44:17 +10:00
Markus Hitter ee481864fa gcode_parse.c: get rid of the denominator variable in decfloat_to_int().
This allows for better optimisation and saves 100 bytes binary size
accordingly. For denominator = 1, the algorithm is also significantly
simpler.
2011-04-15 02:12:13 +02:00
Markus Hitter 6896aa5236 gcode_parse.c: join the upper and the lower formula in decfloat_to_int().
This also makes rounding more accurate with exponent > 0.
Saves another 40 bytes binary size.
2011-04-15 02:12:10 +02:00
Markus Hitter 8cf8a8a44a gcode_parse.c: get rid of rounding[].
This saves 8 bytes of flash and, more important, 16 bytes of RAM.
2011-04-15 02:12:07 +02:00
Markus Hitter f41dd9c098 gcode_parse.c: make all usages of decfloat_to_int()...
... to divide either by 1 or 1000. Accordingly, a flag
can be used instead of the actual value, shrinking code
size by 70 bytes.
2011-04-15 02:12:02 +02:00