Commit Graph

157 Commits

Author SHA1 Message Date
Kevin O'Connor 6138d18f4b toolhead: Also call reset_print_time() on force_shutdown()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:29 -05:00
Kevin O'Connor d028f42e99 mcu: Don't call steppersync_flush if steppersync not created
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:29 -05:00
Kevin O'Connor 860fc3e91d gcode: Add support for M115 command
Support querying the firmware type and version.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:29 -05:00
Kevin O'Connor 2e03d84755 gcode: Add support for M400 command
Add ability to fully stall the input until all moves are complete.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:28 -05:00
Kevin O'Connor f2b406fc5e toolhead: Don't call into kinematic class on extrude only moves
Add a is_kinematic_move flag to the Move class and clear it on extrude
only moves.  Don't call the kinematic check_move() or move() methods
for extrude only moves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:28 -05:00
Kevin O'Connor f46bc0ef04 stepper: Change default max_error from 50us to 25us
Change the default compression error window (max_error) from 50us to
25us - it's common for stepper motor drivers to have 30us for their
"pwm fixed off time" and it would be good for the steps to be
scheduled within that time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-28 22:38:27 -05:00
Kevin O'Connor 800d53db6a stepcompress: Rework addfactor integer overflow check
Revert 4a16053c and avoid integer overflows in the addfactor
calculation by exiting the loop early if count > 0x200.  This provides
stronger protection against overflows.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-26 12:47:17 -05:00
Kevin O'Connor a9444d3399 mcu: Log the MCU configuration during connect phase
Log the constants reported by the MCU and log the number of move items
allocated after configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-24 12:33:56 -05:00
Kevin O'Connor 4a16053c00 stepcompress: Fix integer overflow leading to infinite loop
Commit a217c0f3 changed the way the "addfactor" was calculated.
Unfortunately, it was possible for the updated method to cause an
integer overflow and have a negative addfactor.  Fix this by
explicitly casting the addfactor calculation to uint32_t.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-24 12:02:37 -05:00
Kevin O'Connor d0c61f0f76 klippy: Log the contents of the config file at startup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-24 10:18:41 -05:00
Kevin O'Connor 451ffd567d klippy: Log the host software git version at startup
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-24 10:17:48 -05:00
Kevin O'Connor f3a49604f1 stepcompress: Increase check on max count to 10000000
Some motors have very small step distances and they can generate over
a million steps during a homing operation.  Increase the maximum count
to ten million to avoid triggering the internal sanity check.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-23 23:13:35 -05:00
Kevin O'Connor 872b08601a mcu: Obtain the maximum adc value from the firmware
Don't assume the hardware ADC has 10bit resultion - instead have the
firmware define a constant and read that constant in the host.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-23 17:06:10 -05:00
Kevin O'Connor fe95ea221b build: Define DECL_CONSTANT mechanism for defining exported constants
Add a DECL_CONSTANT macro to allow the firmware to define constants
that are to be exported to the host during the "identify" phase.  This
replaces the existing hardcoded mechanism of scanning the Kconfig
header file for certain constants.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-23 17:06:10 -05:00
Kevin O'Connor 219796ef4e gcode: Add a "STATUS" command
Add a status command that will report the current printer status.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-21 11:35:00 -05:00
Kevin O'Connor 4f087c331c klippy: Update config error message - use "RESTART" when ready to continue
It is possible to restart the host software with a RESTART command
after manually resetting the micro-controller.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-21 11:16:06 -05:00
Kevin O'Connor 1d841eeb87 stepcompress: Prefer greater interval if all else equal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-19 11:20:39 -05:00
Kevin O'Connor 19d1f83d97 stepcompress: Move check for add=0 sequences out of loop
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-19 11:20:38 -05:00
Kevin O'Connor 6efadf44d0 stepcompress: Favor higher add values when bisecting
Instead of splitting the available "add range" in half, try for add
values closer to the higher end of the range.  This heuristic seems to
result in better choices.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-19 11:20:38 -05:00
Kevin O'Connor e4c4a4628b stepcompress: Use inclusive range on min/maxadd
Change the min/maxadd variables to use an inclusive range instead of
exclusive.  This better matches min/maxinterval.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-19 11:20:38 -05:00
Kevin O'Connor a217c0f394 stepcompress: Be consistent with "point" vs "nextpoint"
Make it clear which variables refer to the best verified point found
so far, and which variables deal with the next (not yet verified)
point.

Also, remove checked_count as bestcount serves the same purpose.

Also, allow minmax_point to be inlined.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-19 11:20:38 -05:00
Kevin O'Connor 1dbd11446c stepcompress: Don't warn on multi-step interval=0 sequences
It is possible to get a valid multi-step sequence with an interval of
zero if the add is non-zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-14 11:03:16 -05:00
Kevin O'Connor 74fa8a3907 serialhdl: Clear "hupcl" bit from serial port
The arduino style serial port interfaces can reset the MCU when the
serial port is opened.  Clearing the HUPCL flag makes this less
likely.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 19:07:03 -05:00
Kevin O'Connor b099851a8b gcode: Increase initial speed
If a speed is never specified then default to 25mm/s (up from 1 mm/s).
If a user accidentally issues a move without setting the speed, the
default speed shouldn't be so slow that it takes minutes to finish the
move.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:28:09 -05:00
Kevin O'Connor f25ead109c gcode: Handle M112 emergency stop command
Also try to support the command if it is sent out of order.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor edd7dfe1c8 gcode: Rework toolhead stalling to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor 89f5452ddb gcode: Rework homing to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor a6de1db94d gcode: Rework endstop query to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-09 17:09:51 -05:00
Kevin O'Connor ed9d7e4fae gcode: Convert wait for temp to use greenlets
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-08 18:15:11 -05:00
Kevin O'Connor e169f70bfb gcode: Convert busy handler from timer to greenlet
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-08 18:15:11 -05:00
Kevin O'Connor 35428f2e04 cartesian: Make it clear which methods of CartKinematics are internal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-08 18:14:46 -05:00
Kevin O'Connor 0718a1bd1f delta: Make it clear which methods of DeltaKinematics are internal
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-08 18:13:34 -05:00
Kevin O'Connor 83f7d702e7 stepcompress: Encourage add=0 in compress_bisect_add()
Only use a non-zero 'add' if it actually extends the number of steps
the command covers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-06 19:01:00 -05:00
Kevin O'Connor 4565a73e91 stepcompress: Optimize push_delta_const() for common XY or Z only moves
Most moves are on the XY plane - avoid a few multiplications in the
inner loop in this case.  When there is a Z move, it is almost always
entirely a Z move - avoid the sqrt() call in the inner loop in this
case.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-05 14:40:29 -05:00
Kevin O'Connor 9c932ad514 delta: Rework delta math to avoid using inv_movexy_r
Taking the inverse of the XY move distance can lead to extremely large
values when the XY distance is very small.  This can lead to
saturation of the double precision variables and incorrect results.

Rework the delta kinematic math to avoid using this inverse.  Pass the
closestxy_d value directly to the C functions so that the C code can
calculate its intermediate constants.

After this change the move_z special case is no longer necessary as
the regular delta functions now work with movexy_r=0 and movez_r=1.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-05 14:36:02 -05:00
Kevin O'Connor 5458f3cbd2 delta: Make sure homing distance is large enough to hit the endstop
The head may be far away from an axis at the start of a home, and that
axis must then traverse more than just the distance from zero height
to the endstop position.  Add in additional distance to account for
this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-05 14:06:38 -05:00
Kevin O'Connor d2abbd8f5d extruder: Fix retract
Commit 7554c7f6 broke retract moves.  Fix by making sure extrude_r is
always a positive number.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 18:17:54 -05:00
Kevin O'Connor 00b40b720f klippy: stats() method must check that mcu and toolhead classes exist
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 18:17:54 -05:00
Kevin O'Connor 71b4923208 delta: Support limiting the maximum velocity of z moves
On a delta printer, z moves require the mcu to support the greatest
number of steps per second.  However, z moves are rare, so it makes
sense to limit the velocity of z moves separately from the velocity of
normal xy moves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 18:17:54 -05:00
Kevin O'Connor c49d3fdb17 toolhead: Specify maximum acceleration and velocity in toolhead class
Change the config file so the maximum accel and velocity are specified
in the "printer" section instead of the individual "stepper" sections.
The underlying code limits the velocity and accel of the toolhead
relative to the print object, so it makes sense to configure the
system that was as well.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 18:17:54 -05:00
Kevin O'Connor 9a31c068c4 klippy: Fix typo causing missing stats on 'exit_eof' case
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 10:55:04 -05:00
Kevin O'Connor d2ecc9d80c gcode: Add support for CLEAR_SHUTDOWN command
Add ability to clear the MCU shutdown flag from the console.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-12-01 00:21:20 -05:00
Kevin O'Connor fbd7cc243b klippy: Add ability to restart the host software
Add a "restart" gcode command that will cause the host "klippy"
software to reload its config and restart.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 23:53:03 -05:00
Kevin O'Connor a6055ce069 gcode: Support parsing of "extended" gcode commands
Support human readable commands (eg, "help").  Add a "help" command to
list these extended commands.

Also, add support for declaring command aliases, command help, and
command availability next to the handlers themselves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 23:00:29 -05:00
Kevin O'Connor 35719e665c delta: Fix delta kinematics startup
Commit 1e1364c3 moved the storage of the stepper position to the
mcu_stepper class.  The initializing of that position needs to be
pushed back until after the mcu_stepper class is instantiated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:24:03 -05:00
Kevin O'Connor bc80ed4e88 mcu: Detect if the communication channel to the firmware is lost
Detect a comms loss and report it to the user.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:20:09 -05:00
Kevin O'Connor 5ebe8ce025 gcode: Don't dump the message log directly from set_printer_ready()
The set_printer_ready() method can be called from a background thread.
Have the main Printer class call a new dump_debug() method in the main
thread on a shutdown event.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:20:09 -05:00
Kevin O'Connor 17dcb42752 klippy: Validate that options in the config file exist
Check that all options specified in the config file are valid.  This
catches possible typos and spelling errors in variable names that have
a default.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:20:09 -05:00
Kevin O'Connor 2f97b2d7c2 klippy: Add ConfigWrapper.getchoice method
Add helper function that ensures a config option is one of several
choices.  This helps ensure that a proper error is raised if an
invalid choice is made.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:19:44 -05:00
Kevin O'Connor 57244de37d klippy: Throw an exception if any required config parameter is missing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-11-30 21:19:44 -05:00