Commit Graph

480 Commits

Author SHA1 Message Date
Kevin O'Connor ca6245e974 docs: Update Code Overview document with code flow for a typical move
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-10 22:10:49 -04:00
Kevin O'Connor 1cdddeec30 stepcompress: Add comment on common suffixes and units
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 20:22:32 -04:00
Kevin O'Connor 657c908f88 stepcompress: Modify check_expand() into check_push()
Add the new item at the same time as checking if there is space in the
queue.

Also, update the default optimization level of c_helper.so to O2 to
improve the compiled code layout.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 19:05:04 -04:00
Kevin O'Connor d7a0e22d59 stepcompress: Remove step_dist from stepcompress_push_delta()
Pass the step direction explicitly to the low-level delta kinematic C
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 15:08:42 -04:00
Kevin O'Connor 33b809714f delta: Do reverse direction checking in C code
Calculate where a tower must reverse direction during a move in the C
code instead of the delta.py kinematic code.  This simplifies the
python code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 15:05:41 -04:00
Kevin O'Connor b915a2ad7d delta: Make it clear that a "virtual tower" is created
The delta code calculates a "virtual tower" along the line of
movement.  Rework the variable names and comments to make it clear
that this is occurring.

It is not necessary to pass the start_pos variable to the C code as it
is simple to update the start_pos at the start of each movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 15:05:41 -04:00
Kevin O'Connor 85ed5cef7f stepcompress: Merge stepcompress_delta_const and stepcompress_delta_accel
It's not necessary to have separate C delta kinematic functions for
constant acceleration and constant velocity as constant velocity can
be obtained by using a constant acceleration of zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 14:47:00 -04:00
Kevin O'Connor df42b0d1ac stepcompress: Pass delta velocity and acceleration directly to C code
Update the C delta kinematic code to take velocity and acceleration
directly in step distances and clock ticks.  This simplifies the
mcu.py python code as it only needs to do unit and axis conversion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 14:43:48 -04:00
Kevin O'Connor 98add22891 stepcompress: Merge stepcompress_push_accel() and stepcompress_push_const()
It's not necessary to have separate C functions for constant
acceleration and constant velocity as constant velocity can be
obtained by using a constant acceleration of zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 14:43:25 -04:00
Kevin O'Connor 1d81bf5596 stepcompress: Pass constant velocity and acceleration directly to C code
Update the C code to take velocity and acceleration directly in step
distances and clock ticks.  This simplifies the mcu.py python code as
it only needs to do unit and axis conversion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:57:24 -04:00
Kevin O'Connor e4153a536f mcu: Change mcu_stepper.set_position() to take a location in millimeters
Update the set_position() method to convert from millimeters to
absolute step position.

Also, update PrinterStepper.get_homed_offset() and
mcu_stepper.get_commanded_position() to return millimeters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:44:17 -04:00
Kevin O'Connor 79f31238b0 mcu: Don't export the commanded_position variable from mcu_stepper
Now that the kinematic classes call the mcu_stepper with millimeters
and seconds it is no longer necessary for them to directly access the
stepper's position in absolute steps.  Rename
mcu_stepper.commanded_position to mcu_stepper._commanded_pos to make
clear it is not a variable intended to be externally accessed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:44:17 -04:00
Kevin O'Connor 8c712d959d mcu: Pass delta velocity and acceleration directly to mcu_stepper
Rework the parameters of step_delta_const() and step_delta_accel() so
that they take velocity and acceleration directly in millimeters and
seconds.  This simplifies the delta.py kinematic code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:44:04 -04:00
Kevin O'Connor c4b1a79db2 mcu: Pass constant velocity and acceleration directly to mcu_stepper
Rename step_sqrt/step_factor to step_accel/step_const and have them
directly take the velocity and acceleration in millimeters and
seconds.  This simplifies the kinematic classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:43:56 -04:00
Kevin O'Connor 47f12f107d stepcompress: Move stepcompress_push_* functions to their own section
This is only code movement; no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-07 13:26:39 -04:00
Kevin O'Connor bfad970e4d mcu: Rename self.ffi_lib to self._ffi_lib
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-04 10:13:02 -04:00
Kevin O'Connor 49bdc6fbd1 corexy: Initial corexy kinematic implementation
Add initial support for corexy kinematics.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-03 17:27:14 -04:00
Kevin O'Connor 57f279677f endstop: Support halting more than one stepper on trigger
Extend the endstop code so that more than one stepper can be halted
during endstop homing.  Some kinematic setups (eg, corexy) require an
endstop to support this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-03 17:27:10 -04:00
Kevin O'Connor fff73c7735 avr: Invert diff in timer checks
Minor optimization on avr.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-03 10:39:49 -04:00
Kevin O'Connor e44678ceba avr: Implement reset command
Support restarting the mcu using the watchdog feature of AVR chips via
a new reset command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-02 23:19:29 -04:00
Kevin O'Connor 85c0e9c574 sam3x8e: Implement reset command
Support restarting the mcu via a new reset command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-02 23:19:25 -04:00
Kevin O'Connor 0c3ec7f9a5 avr: Do not use --relax linker option
The relax option corrupts the compilation on at least some versions of
gcc/binutils (eg, on fedora's avr-gcc 6.2.0 / binutils 2.27) due to
corruption of switch tables that use jump offsets.  This issue is also
the root cause that resulted in commit d67f962a.  Since the --relax
option provides minimal size / performance improvements it can simply
be dropped.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-02 23:19:19 -04:00
Kevin O'Connor 74e15b2eb5 checkstack: Be more flexible in finding the timer irq function
If __vector_13 doesn't exist then try __vector_17.  If neither exists
then handle that gracefully.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-02 23:19:02 -04:00
Kevin O'Connor 565861f680 reactor: Support pause() command even when the reactor is not running
If the reactor isn't running then implement pause using the system
sleep command.  This simplifies the users of pause().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-04-01 12:26:24 -04:00
Kevin O'Connor 7c991399ac timer: Remove dup timer_shutdown code
Commmit a1c61563 renamed timer_shutdown() to timer_reset() but
neglected to delete timer_shutdown().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-31 19:20:45 -04:00
Kevin O'Connor 384c853a39 docs: Update benchmark results in Features document
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-31 17:50:36 -04:00
Kevin O'Connor c0380d0280 stepper: Disable homing_endstop_accuracy errors on debug runs
If klippy is started in file output debugging, disable the
homing_endstop_accuracy error check.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-31 14:38:09 -04:00
Kevin O'Connor a1c61563a0 avr: Fix bug causing timer_read_time() to not be in sync with scheduler
Commit 16e3dbb1 changed the avr implementation of timer_read_time().
Unfortunately, it raised the possibility for timer_read_time() to be
out of sync with the scheduler's understanding of the current time.
In particular, it was common for the timer irq to overflow the 16bit
hardware counter once at startup, and this would lead to
timer_read_time() always returning a time ~4ms ahead of the scheduler
on 16Mhz chips.  This resulted in "Move queue empty" errors.

To resolve this issue, only increment timer_high from timer_periodic()
and make sure the timer irqs start immediately after timer_init().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-31 14:36:57 -04:00
Kevin O'Connor aa0f1aaeb2 toolhead: Increase the motor_off_time default to 10 minutes
Increase the default motor_off_time from 1 minute to 10 minutes.  The
small value is a common source of confusion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 14:09:17 -04:00
Kevin O'Connor 03ddd64b93 config: Decrease example max_z_velocity to 25mm/s
Change the example files for cartesian printers to have a 25mm/s
maximum Z velocity.  It's common to use lead screws for the Z axis on
cartesians and it is unlikely one would want to drive them at 250mm/s.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 14:05:05 -04:00
Kevin O'Connor 7fc9ba7d3a mcu: Log the mcu clock each time print_time is synchronized
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 12:51:10 -04:00
Kevin O'Connor 63b6bab5c3 sam3x8e: Align the TC0_Handler timer irq handler
The code alignment of the TC0_Handler function seems to noticeably
impact performance benchmarks.  Set the function alignment to 16 bytes
to improve testing consistency.  An alignment of 16 doesn't
necessarily improve performance, but it seems to improve testing
consistency on code changes unrelated to timer dispatch.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 12:04:08 -04:00
Kevin O'Connor eb4eeb6f73 timer_irq: Integrate timer_try_set_next() into timer_dispatch_many()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 11:25:23 -04:00
Kevin O'Connor 6988507998 timer_irq: Rename generic/timer.c to generic/timer_irq.c
Rename the file to make it clear that the code is helper functions for
boards with irq based timers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 11:24:44 -04:00
Kevin O'Connor 65be6d5146 avr: Integrate timer_try_set_next() into the irq handler
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 11:24:44 -04:00
Kevin O'Connor 6d05dd07f5 sched: Move timer dispatch loop to board code
Rename sched_timer_kick() to sched_timer_dispatch() and move its loop
into its callers in the board code.  This eliminates the need to
export timer_try_set_next() from the board code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 11:24:42 -04:00
Kevin O'Connor 7436ec093a sched: Rename reschedule_timer() to insert_timer() and use in sched_add_timer()
Use the same code in both rescheduling of a timer and adding a new
timer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 10:57:35 -04:00
Kevin O'Connor 2b735daae5 timer: Make sure to reset the timer repeat checks on a shutdown
Reset the timer repeat checks on shutdown, otherwise it is possible to
get into an infinite shutdown loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 10:57:35 -04:00
Kevin O'Connor f8b0c884b0 stepper: Improve performance of scheduled unsteps
On faster MCUs where a delay is needed between step and unstep use a
"busy loop" in the scheduler instead of trying to schedule to the
unstep time.  This reduces the chance of jitter in the scheduler
accumulating.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 10:57:35 -04:00
Kevin O'Connor 18f4d343f5 avr: Remove F_CPU compile time definition
Directly use the Kconfig defined CONFIG_CLOCK_FREQ in the code and
avoid defining F_CPU.  Also, remove the unnecessary O2 option - that
is already the default from the main makefile.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-30 10:56:17 -04:00
Kevin O'Connor 31e78c90e2 avr: Minor optimization for timer_read_time() / timer_periodic()
Tell the compiler that the TOV1 bit is rarely set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-27 13:37:20 -04:00
Kevin O'Connor 3238256b79 docs: Update benchmark results in Features document
Some additional tweeks to the scheduler has resulted in minor
improvements to the stepper benchmarks.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 23:31:33 -04:00
Kevin O'Connor 59b71d5d05 sched: Be explicit with loading of the waketime variable
Explicilty load the timer waketime variable into local variables in
sched_timer_kick().  Change the optimization level from Os to O2.
This helps gcc to avoid unnecessary reloads from memory in the common
stepper_event() case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 22:45:58 -04:00
Kevin O'Connor 4dfa6c6ee4 avr: Introduce optimized timer_is_before()
Provide hand-coded assembler for timer_is_before() on AVR as that code
is used frequently in the time-critical timer dispatch loop and gcc
doesn't do a good job at compiling that comparison code.  Remove the
no longer needed waketime+1 hack from reschedule_timer().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 22:45:58 -04:00
Kevin O'Connor 60e488eb17 timer: Allow board code to define its own timer_is_before implementation
Move sched_is_before() from sched.c to timer_is_before() in the board
specific timer code.  This allows the board code to provide its own
definition.

Also, remove the sched_from_us() and sched_read_time() wrapper
functions and change the callers to directly invoke timer_from_us() /
timer_read_time().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 22:45:58 -04:00
Kevin O'Connor 14340ac4df timer: Organize timer_try_set_next() with priority for repeat timers
Organize the code flow to optimize for repeat timers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 22:01:07 -04:00
Kevin O'Connor efbfc2b1ab avrsim: Catch simulation errors
Request that simulavr throw an exception on a fatal emulation error
instead of exiting the process.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 22:01:07 -04:00
Kevin O'Connor d4f09bc20d checkstack: Updates for newer binutils
Newer versions of binutils report the variable name on memory
accesses.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 21:55:24 -04:00
Kevin O'Connor d67f962a38 command: Simplify sendf() switch
Commit f28eb902 reworked the switch to fix int16 encoding.  However,
at least one version of avr gcc doesn't like that switch layout (it
uses a jump table).  Reorg the switch to avoid that issue.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-26 21:55:24 -04:00
Kevin O'Connor 6de85d02ae serialqueue: Message receive_time must be taken after read()
The est_clock calculation code requires timestamps on status messages
to never be prior to the reception of the message.  The eventtime of
handle_message() is taken before the read() and there is a small
possibility that it could be inaccurate enough to corrupt the
est_clock calculation.  Take a new timestamp when storing receive_time
to prevent this.  This fix prevents some firmware "Move queue empty"
shutdowns.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-03-24 19:16:33 -04:00