Commit Graph

359 Commits

Author SHA1 Message Date
Kevin O'Connor 7d17002b33 fan: Allow heater_fan to work with heater_bed
Fix order of init error preventing heater_fan from being used with
heater_bed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-07 11:19:27 -04:00
Kevin O'Connor 477b3941a6 console: Add support for SUPPRESS command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-07 11:19:27 -04:00
Kevin O'Connor 36dd7e7609 console: Add support for a FLOOD command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-07 11:19:27 -04:00
Kevin O'Connor 167a65d826 util: Fix reporting of git version of klippy code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-07 11:19:27 -04:00
Kevin O'Connor c9cd8cea66 mcu: Limit value range of PWM and digital outputs prior to transmission
Make sure schedule_digital_out and schedule_pwm_out commands always go
out with a value that is in range for the particular command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-06 12:04:05 -04:00
Kevin O'Connor dfdcbece53 mcu: Improve error descriptions in Common_MCU_errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-06 12:03:49 -04:00
Kevin O'Connor 5b62f15c6d extruder: Provide more details on extruder errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-05 22:12:15 -04:00
Kevin O'Connor 09e32d1b84 mcu: Provide some further help on common MCU shutdown errors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-05 22:12:15 -04:00
Kevin O'Connor ff56c0fb74 extruder: Fix typo in init
Commit 7a81bfc4 broke extrude only moves due to a typo in the commit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-05 22:12:15 -04:00
Kevin O'Connor 36de6118c1 mcu: Limit ADC min/max range to a 16bit integer
Make sure the ADC range sent to the MCU can be encoded into a 16bit
integer.  Otherwise, if the provided min_temp/max_temp was outside the
range of possible values it could result in a spurious mcu shutdown.
In particular, the AD595 could not properly encode a min_temp of zero.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-05 18:22:21 -04:00
Kevin O'Connor 7083a33ecd pru: Support config_reset command to manually reset mcu
Add support for resetting the MCU via a software only mechanism.  This
is useful on the PRU.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-03 23:16:38 -04:00
Kevin O'Connor 8d0ef49e8f toolhead: Permit look-ahead between Z moves
Extend the look-ahead mechanism to work between moves that contain Z
movement.  This improves Klipper's handling of g-code produced in
"vase mode".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-03 15:46:48 -04:00
Kevin O'Connor 7a81bfc4a4 toolhead: Eliminate set_max_jerk() from kinematic classes
Allow the kinematic classes to query the max velocity, max accel, and
max halt velocity from the toolhead class instead of having the
toolhead class call into the kinematic classes with those values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-03 15:45:04 -04:00
Kevin O'Connor 0d13834293 gcode: Fix error that could cause commands to be processed out of order
Commit d0932009 changed the way command handling was performed, and
commit 95950949 fixed a defect in that commit.  Unfortunately, the fix
was incomplete.

If multiple commands were sent to Klippy without waiting for an "ok"
response from Klippy, then it was possible for those additional
commands to be queued and processed after subsequent commands.  This
would result in commands being processed out of order.

Fix this by only reregistering the input fd in the greenlet that
performs the unregistration of the fd.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-02 12:05:51 -04:00
Kevin O'Connor ac53806e04 gcode: Add an ECHO command for debugging purposes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-09-02 12:05:51 -04:00
Kevin O'Connor 026b9c336c stepcompress: Minor performance tweaks for rpi
Invert the if conditional in queue_append() and change the order of
reads in minmax_point() - gcc on the rpi seems to do generate better
code this way.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-31 10:17:01 -04:00
Kevin O'Connor 588ecbe868 stepcompress: Use addition instead of multiplication on queue add
Replace multiplication with addition where possible.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-31 02:15:32 -04:00
Kevin O'Connor e05c635489 stepcompreses: Change the step queue to use 32bit integers
The RaspberryPi processor implements 'double to int32' conversions
much faster than 'double to int64' conversions.  Rework the code so
that steps stored in the queue are always a small offset from the last
sent step time.  (In the unlikely event that a step is far from the
last step time, then the queue is flushed to maintain this invariant.)

This simplifies the step compression code as well - it no longer needs
to check for integer overflows.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-31 00:27:43 -04:00
Kevin O'Connor f5cc355044 stepcompress: Refactor queue insertion to use a cursor
Create an insertion "cursor" for adding items to the step compression
queue.  This makes the calling code simpler and it makes it easier to
update the queue memory management in the future.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-31 00:15:03 -04:00
Kevin O'Connor 78f4c25a14 homing: Add a small delay before each homing operation
The homing operation can be cpu intensive for the host software.  Add
a small (250ms) delay before homing so that the host has additional
time to process the command before it is due on the mcu.  This is
intended to work around some reports of "timer too close" errors
during Z homing on RPi2 hosts and printers with high precision Z
positioning.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 18:02:36 -04:00
Kevin O'Connor 002dc0dfaf stepper: Adjust homing_speed so that it's an even number of ticks per step
Adjust the configured homing speed so that it always results in a
speed that is an even number of mcu ticks per step.  This ensures that
the code can always get good step compression during homing, which is
important as the entire homing operation must be able to fit within
the mcu's move queue.  This fixes some "move queue empty" mcu shutdown
errors that could occur when the Z step distance was an unusual size.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 18:00:17 -04:00
Kevin O'Connor 68d6788413 mcu: Add get_mcu() call to the mcu oid objects
Allow external code to obtain the mcu object that controls a pin setup
with setup_pin().  Also, don't bother defining print_to_mcu_time() and
system_to_mcu_time() on each pin object as they can be obtained via
the new get_mcu() method.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 17:59:27 -04:00
Kevin O'Connor c7c551369f mcu: Fix bug causing corexy to not work (introduced in 9d75c3b0)
Commit 9d75c3b0 changed the order of allocation for mcu oid integer
ids.  However, the stepper oids must always be allocated before
endstop oids so that corexy can register multiple steppers on a single
endstop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 17:59:15 -04:00
Kevin O'Connor 0c2919b534 klippy: Move restart logic into Printer() class
Move the restart logic out of main() and into Printer.run().  This
simplifies the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:21 -04:00
Kevin O'Connor d8c75fc608 klippy: Rename internal functions so that they are prefaced with "_"
Preface the internal functions to make it more clear which functions
are interfaces to external code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:21 -04:00
Kevin O'Connor a42cb4fecf toolhead: Avoid directly accessing the printer.mcu field
Lookup the mcu object from the printer objects and store it locally in
the toolhead class.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:21 -04:00
Kevin O'Connor 68ba3d5106 mcu: Drop support for TICKS() expansion in mcu config commands
It's no longer necessary to use the TICKS() hack as the config
commands are now all generated after the mcu speed is known.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:21 -04:00
Kevin O'Connor 931811ab59 chipmisc: Add support for configuring ad5206 digipots
Support an "ad5206" config section so that one can configure the
digipots found on Reprap "RAMBo" boards.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:21 -04:00
Kevin O'Connor 9d75c3b0ca chipmisc: Add support for statically configured output pins
Allow digital and PWM output pins to be setup via new config
sections.  This makes it easier to setup pin configurations.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-26 18:27:20 -04:00
Kevin O'Connor 6ab8567d51 mcu: Track stepqueues separately from steppers
The MCU() class needs to track the stepqueues so that it can
initialize the steppersync object.  Track the stepqueues directly
instead of via the list of steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-25 20:45:54 -04:00
Kevin O'Connor c727ed3592 mcu: Track oids separately from objects requiring a build_config() callback
Track the oid count separately from the configurable object count -
this way it is possible to have internal objects that don't require an
oid in the mcu.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-25 20:44:51 -04:00
Kevin O'Connor c72ca983ba mcu: Eliminate "init callback" phase during connect
It's not necessary to register and execute "init callbacks" when
configuring the mcu.  Instead, have each mcu object produce its init
messages in the build_config() callback.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-25 20:41:09 -04:00
Kevin O'Connor ec7990796a pins: Support registering arbitrary chips that supply configurable pins
Allow multiple chips to provide pin mappings (not just the main mcu
chip).  Move the pin parsing from the mcu.py code to pins.py and
support mapping from pin descriptions to their corresponding chips and
parameters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-25 20:38:55 -04:00
Kevin O'Connor 268834e4ae klippy: Store printer startup parameters in new "start_args" dictionary
Store pertinent information from the software startup in a dictionary
that the various printer components can access instead of in
individual variables in the Printer() class.  This makes it easier to
add future command-line options.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-25 19:27:05 -04:00
Kevin O'Connor b80c488d36 heater: Another minor cleanup to Steinhart-Hart math
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-20 12:42:50 -04:00
Kevin O'Connor f25cb33367 heater: Minor cleanup to Steinhart-Hart math
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-18 13:28:04 -04:00
Kevin O'Connor 4b5f3bec4b heater: Add support for a generic "NTC 100K beta 3950" thermistor
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-17 15:12:51 -04:00
Kevin O'Connor 1f4c6443ef heater: Calibrate thermistor directly from temperature and resistance
Store the underlying temperature and resistance values instead of the
Steinhart-Hart coefficents obtained from them.  This makes it easier
to add new thermistors.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-17 13:26:51 -04:00
Kevin O'Connor 4b5109c1b9 serialqueue: Make sure fds are in non-blocking mode
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-14 21:08:28 -04:00
Kevin O'Connor 085817d332 serialhdl: Sometimes we get an IOError when serial port not found
Catch IOError when opening the serial port.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-14 21:07:26 -04:00
Kevin O'Connor 5e6acf7dbc console: Add support for a STATS command
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-08 00:27:28 -04:00
Kevin O'Connor 58811b5c44 console: Add LIST command that shows available commands and variables
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-08 00:27:28 -04:00
Kevin O'Connor 86a762b2b7 console: Add a HELP command
Show available features at startup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-08 00:27:28 -04:00
Kevin O'Connor 981c53682f stepper: Use a sane default for homing_positive_dir
Use the endstop position to determine a sane default for
homing_positive_dir.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-24 14:31:46 -04:00
Kevin O'Connor 143b7cccf4 stepper: Separate out homing code to its own PrinterHomingStepper class
Keep the homing code separate from the main stepper class.  This makes
it easier to verify the correct config parameters are provided.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-24 13:54:46 -04:00
Kevin O'Connor 959a20888c serialhdl: Dump serial stats in dump_debug()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-24 11:43:54 -04:00
Kevin O'Connor 7bf0ec2fe7 gcode: Don't wait for moves to finish if both debug input and output
Don't wait for moves to finish if the output is going to a debug file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-23 21:32:26 -04:00
Kevin O'Connor c6231a16e3 serialqueue: Improve limit on number of in-flight bytes
Instead of limiting the amount of non-acked messages to 50ms, limit
the amount to one round-trip-time.  This should make it less likely
that the mcu will be overloaded and it should make retransmits faster.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-23 20:47:08 -04:00
Kevin O'Connor a619aacfc6 serialqueue: Further retransmit timing fixes
The first message always has a sync byte with it, so its size should
be one larger.  Also, the idle_time should always be the minimum time
that the message could be received, so it should always be reset to
eventtime on a retransmit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-23 19:32:42 -04:00
Kevin O'Connor d469db84ee serialqueue: Allow a second nak after a retransmit
If a nak message causes a retransmission then also accept a second nak
message as long as it is for a sequence greater than the first nak.
This should allow faster retransmits when there are multiple
transmission errors in a small time period.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-07-21 23:49:44 -04:00