Commit Graph

118 Commits

Author SHA1 Message Date
Kevin O'Connor afada5e79e trapq: Prune interrupted moves from history on trapq_set_position()
It is possible for a homing move to not fully complete.  Fixup the
trapq history to make processing of the history easier for callers.
Similarly, do not add artificial "null" moves to the trapq history.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 12:22:07 -04:00
Kevin O'Connor b17ec3d2e9 stepcompress: Pass clock to stepcompress_set_last_position()
Using sc->last_step_clock for the last position marker does not work
properly, because the stepper.py code calls stepcompress_reset() prior
to calling stepcompress_set_last_position().  Fix by passing an
explicit clock to stepcompress_set_last_position().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-06 11:19:36 -04:00
Kevin O'Connor 7013a7b15f stepcompress: Support extracting stepcompress history
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor fbfa31a3c3 stepcompress: Rename 'struct history_move' to 'struct history_steps'
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor 07f0ecb4d0 trapq: Store toolhead.set_position() updates in trapq history
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor 45c232b2c7 trapq: Keep history of recent trapq moves
Store trapq moves in a separate "history" list after each move is
nominally expired.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Kevin O'Connor e2f483aea3 trapq: Rename trapq_free_moves() to trapq_finalize_moves()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-07-29 16:35:30 -04:00
Tircown 4d559633e3
kinematics: Add dual_carriage to hybrid-corexyz (#4296)
- Add dual_carriage abilities for hybrid-corexy and hybrid-corexz
- Introduce the module idex_mode
- Fix add_stepper to the correct rail in hybrid-corexy

Signed-off-by: Fabrice GALLET <tircown@gmail.com>
2021-06-27 18:37:05 -04:00
Kevin O'Connor 1506043477 stepcompress: Add missing functions to stepcompress.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-11 23:12:16 -04:00
Kevin O'Connor e1f7748e1a trdispatch: Support fast responses to trsync_state messages
Add C code that can process trsync_state messages and dispatch
responses with low-latency.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor b6d8cf27d2 serialqueue: Add serialqueue_send_one() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor c53e8c7d4a serialqueue: Add "fast reader" support
Add ability to run C code directly from the low-level socket reading
thread.  This enables host based low-latency handlers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 620f77ddb7 msgblock: Add clock estimation helper functions
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor f938caa0d2 msgblock: Add msgblock_decode()
Add function that can parse a simple VLQ encoded message to an array
of integers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 1865080a07 msgblock: Move message manipulation code from serialqueue.c to new msgblock.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor 2559a2dd5a pollreactor: Move C pollreactor code from serialqueue.c to its own file
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-06-09 18:58:35 -04:00
Kevin O'Connor dce9971aa9 stepcompress: Improve numerical stability of step+dir+step filter
Apply the step+dir+step filter even if, for some reason, a negative
time is found.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-04-11 12:19:57 -04:00
Kevin O'Connor 81428265bd stepcompress: Add support for tracking history of queue_step commands
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 15:19:43 -05:00
Kevin O'Connor 8b4ad34e22 serialqueue: Support sending messages over a CAN bus
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-13 11:29:41 -05:00
Lasse Dalegaard f8b0ea53dc serialqueue: correctly report EOF errors
If `klippy` loses connection to a device, the next `read()` from the
device file descriptor will result in a zero-byte result, i.e. an `EOF`.
Right now this gives a confusing error message, so this simply handles
the special case of `EOF` and outputs a better log message.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
2021-03-01 13:46:59 -05:00
Kevin O'Connor 70a1b752c9 chelper: Move logging_callback() to global scope
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-03-01 13:30:02 -05:00
Kevin O'Connor 81da5379d4 buildcommands: Extend number of available mcu messages from 96 to 128
Some internal code treats the message ids as encoded "variable length
quantities", while other internal code assumes the message id is
always one byte long.  Continue using this scheme, but convert the VLQ
users to use the name "msgtag" while the 1-byte users use "msgid".
Increase the number of available msgids from 96 to 127 - the higher
values get encoded as negative "msgtags".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-18 15:21:32 -05:00
Kevin O'Connor c5968a0830 serialqueue: Batch multiple message blocks in a single write()
Some communication protocols are more efficient if fewer write() calls
are invoked.  If multiple message blocks can be sent at the same time
then batch them into a single write() call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-12 13:59:57 -05:00
Kevin O'Connor 730ef9d347 serialqueue: Improve timing of sleep durations
If any callback is invoked from the pollreactor then obtain a new
eventtime before calculating a sleep duration.  This improves the
timing of events.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-12 13:57:51 -05:00
Kevin O'Connor 1049282eec chelper: Fix check for failed code build
Commit 73b78af6 inadvertently removed the check for a successful gcc
compilation.  Add the check back in.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-07 20:48:21 -05:00
Kevin O'Connor 6a3f4c7ae6 serialqueue: Improve checking of out-of-order messages
Consider any message block that acks a message never sent as an
out-of-order block and discard it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-02-01 19:16:23 -05:00
Kevin O'Connor ccc8fe2fc5 itersolve: Convert iterative solver to use "secant method"
The previous code calculates each step time via an "exponential
search" followed by a "false position with Illinois algorithm" search.
Replace with a "secant method" with "bounds check" search.  This
simplifies the code, improves the performance, and does a better job
of finding steps near a direction change.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-11-02 12:07:23 -05:00
Kevin O'Connor aaf3dc6ac3 serialqueue: Fix registration of serial fd in debug mode
When in debug output mode, make sure to register the fd correctly.
Otherwise, the poll() call will use the 0 fd which could cause random
results.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-30 14:02:12 -04:00
Kevin O'Connor 1b6b7fc58c kin_extruder: Fix numerical stability when using pressure advance
Avoid using the absolute E position when calculating pressure advance
as that position can grow arbitrarily large, which can result in
"numerical stability" problems.  That instability could eventually
lead to internal errors during step compression.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-10-23 22:59:20 -04:00
Kevin O'Connor 04f9f1b44e chelper: Add missing serialqueue_set_receive_window() def to serialqueue.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:15:33 -04:00
Kevin O'Connor 04b822c3aa chelper: Use standard C type definition for pyhelper_logging_callback
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:15:21 -04:00
Kevin O'Connor 73b78af6b2 chelper: Rework check for building C code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-26 20:15:10 -04:00
Kevin O'Connor a92d995727 chelper: Set compiler flags to never use "x387" floating point math
The default on X86 32bit machines is to use 80bit floating point math
(as found in the ancient "387 coprocessor").  This can cause numerical
stability problems.  Set the compiler flags to make sure the newer SSE
math is always used on X86.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-09-15 17:12:53 -04:00
Kevin O'Connor a7defdcad0 kin_shaper: Fix check for optimized X or Y only calculations
The optimized version is only available if it's the only axis used.
This fixes input_shaper on corexz.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-30 12:32:11 -04:00
Kevin O'Connor 08ddf25cf3 kin_shaper: Add an init_shaper() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-30 12:32:11 -04:00
Kevin O'Connor d28e148ddc kin_shaper: Group shaper setup code together
No code changes - just code movement.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-30 12:32:11 -04:00
Kevin O'Connor 0e21188cb2 kin_shaper: Allocate space for maximum number of shaper pulses in advance
Combine the shaper pulses and count of those pulses into a `struct
shaper_pulses`.  Allocate space for the maximum number of pulses in
`struct input_shaper`.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-30 11:30:39 -04:00
Kevin O'Connor ea5e76746a itersolve: Use stricter completion check in itersolve_find_step()
Use a more strict check for determining if the iterative solver has
correctly found a step - the guess must be within 1 picometer of the
target or correct to within 1 nanosecond.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-08 11:59:19 -04:00
Kevin O'Connor 513582afc4 itersolve: Enhance "false position" method with "illinois algorithm"
This prevents some cases where the iterative solver fails to converge
in a reasonable time, causing "no next step" errors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-08-08 10:58:20 -04:00
Voron 9213646c63
corexz: Add CoreXZ kinematics (#3129)
Add a CoreXZ kinematics

Signed-off-by: Maks Zolin <mzolin@vorondesign.com>
2020-07-30 12:42:23 -04:00
Dmitry Butyugin 5dc0c8aac0 input_shaper: Fixed C module compilation on older gnu90 compilers
For example, Raspbian GNU/Linux 8 (jessie) uses an old GCC version 4.9.2
which uses -std=gnu90 by default.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2020-07-07 17:50:51 -04:00
Dmitry Butyugin 4bdc11a8b3
input_shaper: Initial support of input shaping (#3032)
Input shaping can help to reduce printer vibrations due to resonances
and eliminate or reduce ghosting in prints.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2020-07-05 20:54:38 -04:00
Kevin O'Connor 9a92b346fd itersolve: Use more explicit list traversal in itersolve_generate_steps()
Avoid using doubles as flags when generating steps during "lead up to
stepper activity".  Instead, explicitly track how many inactive move
entries are skipped and only generate steps for those entries.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-04 14:00:53 -04:00
Kevin O'Connor 7843c23b8c itersolve: Fix numeric stability of flush range times
Don't assume the times passed to itersolve_gen_steps_range() are
contained within the move.  It's possible the checks in
itersolve_generate_steps() may round to different values when
converting the times to a relative move time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-04 10:24:46 -04:00
Kevin O'Connor acd165cbea stepcompress: Implement a step+dir+step filter
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events.  In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode.  Detect these events and remove them from the
generated step times.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-13 21:53:48 -04:00
Kevin O'Connor d86bf0b927 stepcompress: Move code around in stepcompress.c
Just code movement - no code changes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-13 21:53:48 -04:00
Kevin O'Connor e872290c47 Revert "itersolve: Implement a step+dir+step filter"
This reverts commit c9cb462f90.

The step flushing for this commit was not complete.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-05 18:37:02 -05:00
Kevin O'Connor c9cb462f90 itersolve: Implement a step+dir+step filter
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events.  In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode.  Detect these events and remove them from the
generated step times.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 19:43:47 -05:00
Kevin O'Connor 8f8c1e2c58 itersolve: Reset bounds search on a direction change
If the stepper changes direction then the average velocity since the
last step pulse isn't a good indicator of the next step pulse.
Instead, reset the bounds checking to use a low starting guess.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 19:43:47 -05:00
Kevin O'Connor 271e412ae6 itersolve: Simplify main itersolve_gen_steps_range() loop
Reorder the loop to try and make the code flow a little simpler.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-03-04 19:43:47 -05:00