Commit Graph

167 Commits

Author SHA1 Message Date
Kevin O'Connor 770b92863f mcu: Add a set_commanded_position() method to MCU_stepper
Add the ability to directly set the "commanded" stepper position.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-10-10 14:30:09 -04:00
Kevin O'Connor ef6068dc42 mcu: Log MCU information before configuring
Log the details of the MCU prior to attempting to configure the MCU.
This way, the log contains the MCU information even if a configuration
error occurs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-03 18:34:10 -04:00
Kevin O'Connor 30013a1fb8 mcu: Rename add_config_object() to register_config_callback()
Change the name of the config registration method and pass an explicit
reference to the callback to the new method.  This makes the
relationship between mcu registration and build_config() more clear in
the calling code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-09-03 11:48:22 -04:00
Kevin O'Connor ad480bd470 mcu: Avoid adding the same stepper multiple times to an endstop
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-08-26 23:06:32 -04:00
Kevin O'Connor 13ccb1a46f mcu: Minor whitespace changes
Wrap lines at 80 columns.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-26 10:54:31 -04:00
Kevin O'Connor 273a98d39a pins: Explicitly pass can_invert and can_pullup to lookup_pin()
Don't pass pin_type to lookup_pin() - instead, if a pin can be
inverted or can have a pullup, then the caller must explicitly specify
that when calling lookup_pin().  This simplifies the code for the
cases where it is not valid to invert or pullup.

Explicitly pass the pin_type to setup_pin() and have ppins.setup_pin()
apply default pullup and invert flags.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-26 09:44:45 -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 a31c31aed4 mcu: Enhance itersolve stepper kinematics allocation
Allocate the stepper_kinematics directly in mcu.py - that way the
kinematic classes don't have to interact with the chelper code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-13 11:37:36 -04:00
Kevin O'Connor 7d897d84d7 klippy: No need to pass printer reference to add_printer_objects()
The config reference already stores a reference to the printer object.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 22:26:32 -04:00
Kevin O'Connor 5cdba1fda8 mcu: Send mcu config and init immediately after building it
Don't issue a get_config command after building the config as the
built config may contain time sensitive initialization commands.
Instead, send the config and init commands immediately after invoking
the build_config() callbacks.  This avoids some rare "timer too close"
errors during configuration.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 12:54:12 -04:00
Kevin O'Connor 211e34e62b mcu: Add leading underscore to handle_shutdown() and handle_mcu_stats()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-12 12:19:04 -04:00
Kevin O'Connor 0dbfa915de adccmds: Add support for min/max temperature check filtering
Extend the ADC out of range check so that it is possible to sample
multiple times before going into a shutdown state.  This reduces the
chance that measurement noise will cause an error.  In an actual over
temperature (or under temperature event) it is expected that the
sensor will consistently report the problem, so extra checks for an
additional second or two should not substantially increase risk.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-07-02 13:56:34 -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 eb73b5d0b0 stepper_buzz: Convert to 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 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
cruwaller 26378c2564 mcu: config_reset_cmd typo fixed
Signed-off-by: Petri Honkala <cruwaller@gmail.com>
2018-06-01 09:49:55 -04:00
Kevin O'Connor ff9543eee2 clocksync: Simplify is_active() check
In some rare circumstances it was possible for the host software to
become so busy that it does not transmit a get_clock request for
several seconds.  (In particular, this could occur with some complex
calls to coordinate_descent.)  If that happened, it was possible for
the code to incorrectly report a "Timeout with MCU" error.  Rework the
is_active() check to prevent that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-31 18:20:30 -04:00
Kevin O'Connor 879c45db19 mcu: Do not automatically restart MCU with new config if it is shutdown
Normally, the MCU is restarted on a config change.  However, that
should not be done automatically if the MCU is in a shutdown state.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-29 10:57:29 -04:00
Kevin O'Connor ee4f37fe0c stepper: Add STEPPER_BUZZ command
Add a new command that can help diagnose stepper motor connectivity.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-24 09:49:17 -04:00
Kevin O'Connor 3025638b9b z_tilt: Add support for Z_TILT_ADJUST
Add new module to support independent adjustments to multiple Z
steppers to account for bed tilt.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-05-22 22:23:44 -04:00
Kevin O'Connor 4eeb43b191 pins: Remove module level get_printer_pins() and setup_pin() functions
Most callers did a lookup of the pins module via
printer.lookup_object("pins").  Use that as the standard method and
remove these less frequently used methods.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-04-04 12:26:39 -04:00
Kevin O'Connor bb8926d67a klippy: Automatically clear rollover_info on each restart
Automatically clear the information printed at the start of each log
file rollover on a klippy internal restart.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-04-03 13:18:52 -04:00
Kevin O'Connor b139a8561f serialhdl: Add a wrapper around the results of lookup_command()
Add a lookup_command() method to the SerialReader class that provides
a wrapper that stores the serial and commandqueue references.  This
makes it easier to run the send() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-02-27 21:06:16 -05:00
Dave Bacon 5abea041b4 mcu: Fix PWM static start value setup
config_setup uses ._start_value instead of ._static_value which isn't defined.

Signed-off-by: Dave Bacon <drb.github@mrbacon.com>
2018-02-10 13:00:22 -05:00
Kevin O'Connor 0a5b07f9da klippy: Allow any stats producer to determine when stats are needed
Instead of using the toolhead class to determine if stats should be
reported, allow every printer object with a stats() callback to
determine if stats are needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-02-05 13:52:05 -05:00
Kevin O'Connor 21df21b7af fan: Clarify hardware_pwm and allow cycle_time to be set on software pwm
Specify hardware pwm cycle times using the same method as software pwm
(in seconds, not clock ticks).  Allow the fan code to be configured
with an explicit cycle time even when using software pwm.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-29 13:08:15 -05:00
Kevin O'Connor 077a56c2ca mcu: Default the restart method to 'command' on non-serial ports
If the mcu supports command restarts and it does not appear to use a
real serial port, then default the restart method to 'command'.  This
is a better default on boards with native USB support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-29 10:25:25 -05:00
Kevin O'Connor e38c7df064 probe: Support activate/deactivate scripts on each probe
Allow a set of g-code scripts to be run on each probe invocation.
This may be useful for probes that need to be setup before they are
useful (eg, with servo actuated probes).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor ce9db609ad probe: Initial support for Z-Probe hardware
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor d3665699f1 klippy: Support generic printer_state() and stats() callbacks
Instead of hardcoding which objects are called on state transitions,
allow any "printer object" to be invoked if it has a printer_state()
method.  Convert connect, ready, shutdown, and disconnect callbacks to
this mechanism.

Similarly, allow all printer objects to provide a stats() callback.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor 81013ba5c8 klippy: Add access methods and avoid peeking into the printer classes
Add get_reactor(), lookup_object(), lookup_module_objects(), and
set_rollover_info() to the main Printer class so that callers do not
need to peek into the class' members.  Similarly, add get_printer()
and get_name() methods to the ConfigWrapper class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-28 12:19:26 -05:00
Kevin O'Connor 3833669c3a pins: Check if the same pin is referenced via different aliases
Change the update_command() call to use a new PinResolver class.  In
that new class, verify that the same pin isn't referenced in two
different parts of the config using different aliases for the pin.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-10 19:26:06 -05:00
Kevin O'Connor ed80b92b59 mcu: Setup static values via setup_start_value() call
Add an "is_static" setting to setup_start_value() and remove the
setup_static() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-08 21:21:30 -05:00
Kevin O'Connor ed9dee4602 mcu: Only report an MCU timeout once
Don't flood the log with timeout messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2018-01-08 10:55:37 -05:00
Kevin O'Connor d778ae1846 build: Add gcc and binutils version to mcu data dictionary
Store the gcc and binutils versions used in the compilation of the
firmware in the firmware data dictionary.  Forward that information to
the log so it is available during debugging.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-21 20:32:10 -05:00
Kevin O'Connor 68d03e4a3e mcu: Allow both shutdown and startup values to be set for output pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-18 20:45:00 -05:00
Kevin O'Connor e0c947e188 mcu: Store MCU_stepper commanded_pos as a float
It's valid to consider the stepper at a position that is not on a step
interval - only the "mcu position" needs to be an integer.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-07 18:14:50 -05:00
Kevin O'Connor 1d6af72de5 mcu: Remove unneeded MCU_digital_out.get_last_setting() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor 2a8dd5c51f mcu: Reset the stepper step clock on init - not after each motor on
Reset the last step clock during the init phase and after each home -
this simplifies the runtime code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor c78f66b8e8 mcu: Be sure all moves are completed before raising a home timeout
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:54 -05:00
Kevin O'Connor b340fdcc4a homing: Make sure to clean up homing state even if homing fails
Make sure to always call MCU_endstop.home_wait() if
MCU_endstop.home_start() is invoked.  Rename
MCU_stepper.note_homing_triggered() to note_homing_end() and make sure
it is always called if MCU_stepper.note_homing_start() is invoked.

With these changes, MCU_endstop.home_finalize() is no longer needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 19:13:53 -05:00
Kevin O'Connor 7785d3a87d homing: Pass list of endstops (not steppers) to the homing code
The homing code wants the list of endstops to enable during a homing
operation - it's confusing to pass the steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:49:14 -05:00
Kevin O'Connor 31db4cc772 mcu: Make sure steppers added to an endstop are on the same mcu
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:35:51 -05:00
Kevin O'Connor 7932de11a7 mcu: Make sure all endstop objects are disabled on a reconnect
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-12-06 18:35:51 -05:00
Kevin O'Connor 38643f52c9 stepper: Add get_endstops() / set_position wrappers
Add wrappers around mcu_endstop and mcu_stepper so that the kinematic
classes do not need to directly access these low-level classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-11-18 17:36:45 -05:00
Kevin O'Connor 07a69df62f mcu: Fix command restart
Fix omission in commit f8750b14 that broke restarts via Klipper
command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 21:43:33 -04:00
Kevin O'Connor f8750b142f klippy: Rework shutdown handling
If an MCU signals a shutdown from the background thread, notify the
main thread and handle the shutdown there.  Dispatch shutdown handling
from the main Printer() class instead of from the Toolhead class.
This simplifies the shutdown logic.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-10-12 16:28:53 -04:00