Commit Graph

47 Commits

Author SHA1 Message Date
Kevin O'Connor 32f61b01e9 trapq: Use C99 method for declaring struct members in trapq_append()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-07 11:32:53 -05:00
Kevin O'Connor f63f68bbbb chelper: Report an error if the C host code does not compile
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-07 11:32:20 -05:00
Kevin O'Connor 86121ff79e toolhead: Calculate and store axes_r in move class
Calculate the ratio of axis distance to total move distance (axis_d /
move_d) and store in a new member variable axes_r.  This avoids
needing to recalculate the value in other code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 076a66f791 trapq: Use separate 'move' entries for accel, cruise, and decel phases
Only track a single acceleration movement in a 'struct move' instance.
Break the classic trapezoid movement (accel, cruise, decel) into three
separate movements.  This simplifies the calculation logic.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 1acaaa98c2 trapq: Remove move_fill()
Now that all callers use the trapq system to queue moves, it is no
longer necessary to individually allocate and fill a 'struct move'.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 797dcfcb12 itersolve: Remove unused gen_steps()
Eliminate the old gen_steps() call now that all callers have been
converted to the newer trapq based generate_steps().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 9845d0d103 extruder: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 746b928c8b winch: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 4b5cbc18a4 polar: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 351b565728 delta: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor b792e0fdd1 corexy: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 7afac2b3af cartesian: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor f3ef9c1889 itersolve: Add support for generating steps from a trapq
Support associating a stepper_kinematics with a trapq.  Support
generating steps from a time range on the given trapq.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor d3afe4f1d8 trapq: Initial support for building a queue of trapezoidal velocity moves
Add support for building a list of moves in the trapq.c code.  Update
the toolhead code so that moves generated from the look-ahead code are
added to that list.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor c06f6943a6 list: Add additional list helper functions
Add list_is_first, list_is_last, list_last_entry, and list_prev_entry
helper functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor fdbdb3c707 trapq: Add new trapq.c file with code for trapezoidal velocity handling
Move the "struct move" code from itersolve.c to new file trapq.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 374eb98765 polar: Implement bed angle wrapping adjustments in chelper code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 92993c062b itersolve: Rename calc_position to calc_position_cb
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor 9945cc0f46 itersolve: Fix possible infinite loop in itersolve_gen_steps()
If the kinematic position calculation function had an error in it (if
it produces sudden position changes) then it could lead to an infinite
loop in itersolve_gen_steps().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-11-06 15:51:51 -05:00
Kevin O'Connor c3fe3d0d2c stepcompress: Remove no longer needed stepcompress_set_homing()
Now that homing is implemented via "drip moves", it is no longer
necessary for the stepcompress code to have special homing logic.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-07-10 10:43:20 -04:00
Kevin O'Connor e5f74a64ed polar: Add initial support for multiple bed rotations
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-06-28 10:00:40 -04:00
Kevin O'Connor adc4af2fc4 serialqueue: Wrap code to 80 columns
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-27 14:20:15 -05:00
Kevin O'Connor e4d52a19b8 stepcompress: Wrap code to 80 columns
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-27 14:20:15 -05:00
Kevin O'Connor af882ee0fe chelper: Wrap code to 80 columns
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2019-02-27 13:20:57 -05:00
Kevin O'Connor 5dc74f3152 winch: Add experimental support for cable winch kinematics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-24 11:38:59 -05:00
Kevin O'Connor ec9cb3a1b3 polar: Experimental support for polar kinematics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-12-24 11:38:59 -05:00
lf e7498fa241 chelper: Add a quick __main__ to compile c helper (#782)
Signed-off-by: Lucas Fink <software@lfcode.ca>
2018-10-16 12:21:18 -04:00
Kevin O'Connor 5632cf6d77 serialqueue: Increase receive message debug queue to 100 messages
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-02 12:16:13 -04:00
Kevin O'Connor cb29143939 itersolve: Support calculating a stepper position from a cartesian coordinate
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-18 11:51:28 -04:00
Kevin O'Connor e1833e020a chelper: Use CLOCK_MONOTONIC_RAW
Switch the host code from the CLOCK_MONOTONIC clock to the Linux
specific CLOCK_MONOTONIC_RAW clock.  It's common for ntp to slew the
CLOCK_MONOTONIC clock to account for drift, and that can break the
host's ability to make accurate predictions of the micro-controller
clock.  This could lead to "move queue empty" errors.  The
CLOCK_MONOTONIC_RAW clock is not slewed and thus should not have this
problem.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-09 12:25:19 -04:00
Kevin O'Connor 890298d34d itersolve: Support setting the stepper position via a cartesian coordinate
Add support for an itersolve_set_position() function that sets a
stepper position from a cartesian coordinate.  This eliminates the
need for both the python and C code to be able to translate from a
cartesian coordinate to a stepper position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-22 14:09:01 -04:00
Kevin O'Connor 926829e737 itersolve: Move tracking of commanded position to itersolve code
Track the commanded position in just the itersolve.c code instead of
in mcu.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 8f747e2720 kin_cartesian: Remove stepcompress_push_const()
All the kinematic code now uses the iterative solver to generate
steps.  Remove the old stepcompress_push_const() mechanism.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor bbe53cf8e5 extruder: Convert to using iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor fc4a9e7564 corexy: Convert corexy to use the iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor ca0d0135dc delta: Convert delta kinematics to use iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 2511471b0d itersolve: Add kinematic iterative solver code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor ba3428822d stepcompress: Allow stepcompress_alloc() to be called early
Don't require an mcu connection to allocate the stepcompress object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 9a2eb4bedd chelper: Move cartesian and delta kinematics code to their own C files
Move the cartesian and delta specific code to new files
kin_cartesian.c and kin_delta.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 8a830ff0ce chelper: Compile with gcc -fwhole-program option
Use the -fwhole-program option when compiling the host C code.  This
makes it easier to support inlining across C files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Kevin O'Connor 189ebb4c7d chelper: Add compiler.h header
Add the compiler.h header file to the chelper code - this adds a
number of useful gcc definitions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-06-20 09:26:10 -04:00
Michael Barbour a748cf39eb stepcompress: Fix comment typo.
Signed-off-by: Michael Barbour <barbour.michael.0@gmail.com>
2018-06-04 09:41:55 -04:00
Kevin O'Connor d798fae20b serialqueue: Limit message transmission to available receive buffer size
If the mcu is using a traditional serial port, then only send a new
message block if there is space available in the mcu receive buffer.
This should make it significantly less likely that high load on the
mcu will result in retransmits.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-28 11:12:30 -04:00
Kevin O'Connor 75f8709947 command: Wait to send ack until after processing commands
Send the ack after processing commands - this gives the host code more
information on serial buffer utilization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-28 10:43:40 -04:00
Kevin O'Connor 99b233df3f serialqueue: Fix batching of BACKGROUND_PRIORITY_CLOCK messages
In order to properly delay BACKGROUND_PRIORITY_CLOCK messages, they
must be 5ms beyond the minimum defined by MIN_REQTIME_DELTA.  So, add
both MIN_REQTIME_DELTA and MIN_BACKGROUND_DELTA to the timing of these
messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-05 20:59:33 -04:00
cruwaller 7fd14848ca chelper: Fix hub-ctrl compilation
Signed-off-by: Petri Honkala <cruwaller@gmail.com>
2018-05-05 11:23:18 -04:00
Kevin O'Connor 15248706ae chelper: Move the host C code to a new klippy/chelper/ directory
Move the C code out of the main klippy/ directory and into its own
directory.  This reduces the clutter in the main klippy directory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-04-30 11:44:53 -04:00