Implement the conversion from print_time to the local mcu's clock
within the C code. This simplifies the python code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Everywhere the data in get_last_clock() is used can be done just as
easily with estimated_print_time().
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>
Instead of starting the print_time at zero, start it at the estimated
time of the main mcu's clock. This simplifies the code and it ensures
that print_time never goes backwards.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Return the same information from stepcompress_push() that is returned
from stepcompress_push_const() and stpcompress_push_delta().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Instead of assuming the maximum PWM value is 255, export a constant
from the firmware to the host with the maximum value.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When the log file does a rollover, start the top of the log with
critical system information (eg, software versions).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Always log the last synchronized clock during a shutdown event, and
use debug level for normal reports.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Advice users to issue a FIRMWARE_RESTART command on a printer shutdown
event, and remove support for CLEAR_SHUTDOWN. A full mcu reset is
preferable and it simplifies the interface.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Extend the FIRMWARE_RESTART command so that it can use the firmware
"reset" command instead of the "arduino" mechanism.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The delta code calculates a "virtual tower" along the line of
movement. Rework the variable names and comments to make it clear
that this is occurring.
It is not necessary to pass the start_pos variable to the C code as it
is simple to update the start_pos at the start of each movement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not necessary to have separate C delta kinematic functions for
constant acceleration and constant velocity as constant velocity can
be obtained by using a constant acceleration of zero.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the C delta kinematic code to take velocity and acceleration
directly in step distances and clock ticks. This simplifies the
mcu.py python code as it only needs to do unit and axis conversion.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not necessary to have separate C functions for constant
acceleration and constant velocity as constant velocity can be
obtained by using a constant acceleration of zero.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the C code to take velocity and acceleration directly in step
distances and clock ticks. This simplifies the mcu.py python code as
it only needs to do unit and axis conversion.
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>
Now that the kinematic classes call the mcu_stepper with millimeters
and seconds it is no longer necessary for them to directly access the
stepper's position in absolute steps. Rename
mcu_stepper.commanded_position to mcu_stepper._commanded_pos to make
clear it is not a variable intended to be externally accessed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework the parameters of step_delta_const() and step_delta_accel() so
that they take velocity and acceleration directly in millimeters and
seconds. This simplifies the delta.py kinematic code.
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>
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>