Use a base of 256 instead of 65536 when calculating the sum of the
square of the clock differences in the stats. This makes the
calculation more accurate. Export the new base via DECL_CONSTANT for
the host to access. Use DIV_ROUND_UP() when adjusting for the base to
ensure no lost ticks. Do the division after multiplication in the
common case where the time between stats_task() invocations is less
than 64K ticks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of requiring the user enter velocity and accel parameters for
extrude only moves, calculate sane defaults from the printer's maximum
velocity and accel.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's possible for a printer with very fine resolution to require a
large number of steps for a homing operation. Instead of storing all
of those steps in memory, periodically flush the queue should more
than 64K steps be present. This keeps a reasonable limit on the
amount of ram needed to store steps.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The serialqueue_flush_ready() code was used to flush queue_step
commands during a homing operation. It's no longer necessary now that
moves during a homing operation use the normal message priority
system.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The endstop homing system requires all queue_step commands be in the
MCU's 'move queue' before endstop checking starts. Use the normal
message priority system to request that stepper queue_step commands
are received prior to the start of the end_stop_home command. This
simplifies the code and removes the need for special serial queue
flushing.
This also fixes a bug in homing operations that take longer than 2^31
clock ticks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>