Raise an error during config parsing if the position_endstop is not
between the position_min and position_max. This avoids a confusing
error message during homing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
It's common for multiple steppers to use the same stepper enable
line. Detect this and only create a single digital_out oid on the
micro-controller.
Also, prohibit any other pin from being used multiple times in the
config file.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Always set the pin_params['type'] field on a pin lookup. Rename
parse_pin_desc() to lookup_pin() to make the change more clear.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 002dc0df added rounding to the homing speed, but it did not
work if the configured homing speed was less than the printer's
maximum velocity. Move the speed rounding from stepper.py to
homing.py and make sure the rounded speed is less than the maximum
speed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new config option 'homing_endstop_align_zero' to enable the
alignment of the endstop to a stepper full step. It's possible one
may wish to specify a homing_endstop_phase while not aligning the
endstop.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
Allow multiple steppers to be defined for a single cartesian axis.
This adds support for dual-z setups.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Pass the sample_ticks and sample_count parameters directly in the
end_stop_home command instead. This simplifies the code.
Also, simplify calculation of next wakeup time in
end_stop_oversample_event().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the stepper phases are known then it is possible to arrange for the
0.0 position to occur at a full step. On cartesian style printer,
this makes it possible for the Z levels to occur at full steps (which
may help reduce "Z ribbing").
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some printers can show occasional noise on the endstop pin. Support
sampling the endstop pin multiple times to attempt to filter out this
noise.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The logging module can build strings directly from printf syntax - no
need to build the string first.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the print_time is always synchronized with the mcu_time,
there is no longer a need to track mcu_time as a separate quantity.
Eliminate references to mcu_time from the code and pass print_time
directly in its place.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure to initialize mcu_enable to None so that it is initialized
if no 'enable_pin' config value is provided.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
Don't modify dictionaries while iterating them and be careful to use
// when doing an integer divide.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the set_position() method to convert from millimeters to
absolute step position.
Also, update PrinterStepper.get_homed_offset() and
mcu_stepper.get_commanded_position() to return millimeters.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename step_sqrt/step_factor to step_accel/step_const and have them
directly take the velocity and acceleration in millimeters and
seconds. This simplifies the kinematic classes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Extend the endstop code so that more than one stepper can be halted
during endstop homing. Some kinematic setups (eg, corexy) require an
endstop to support this.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The previous calculation was only valid if the stepper is always
commanded to a position that is an exact multiple of the
step_distance. The safety check was programmed with a value too large
for other commanded positions, which could result in "No next step"
errors. Fix by changing the calculation to use the worst case
scenario.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the mcu objects can be created prior to connecting to the
mcu, it is no longer necessary to separate the init and build_config
phases in the high-level code. Move the mcu objection creation from
the build_config phase to the init phase and eliminate the
build_config phase.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Create a separate callback for setting the min_stop_interval.
Also, move the setting of the stepper max_error from the stepper
configs to the mcu config and rename it to max_stepper_error.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>