Don't report a CRC mismatch if a shutdown or other failure occurs
during config - instead report the appropriate details.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Not all hardware has PWM support and there is no compelling reason to
use hardware PWM for fans. Change the default to use software PWM.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Store a full 64bit uptime in the mcu and query it at the start of each
connection. This ensures the host's 64bit clock is always in synch
with the mcu's clock.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change the mcu PWM value from an integer (0-255) to a float (0. - 1.).
Add support for limiting the maximum power (as measured over a
sufficiently long duration) to a particular heater.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of defaulting the pressure advance lookahead time to be the
same as the pressure_advance variable, allow it to be configured.
Default the new config setting (pressure_advance_lookahead_time) to
10ms.
Also, make the setting more accurate if a future move is accelerating
in the middle of the lookahead window.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Simplify the mechanism for limiting stepper speed (introduced in
commit bdfdf7ef) - split the extreme end of the build envelope into
two zones and use the same speeds for all moves that traverse any part
of one of those zones.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit c24b7a7e reworked the way lookahead was done and it introduced
a bug when a full acceleration move is immiedietly followed by a full
deceleration move. In that situation, depending on when the lookahead
queue was flushed, it was possible to call move.move() without calling
move.set_junction(). This resulted in a "Move instance has no
attribute 'accel_t'" internal error.
Simplify and fix the logic for checking full accel moves followed by
full decel moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There's no reason for the user to specify position_max - it can be
inferred on deltas from the endstop positions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some XY moves at the extreme end of the build envelope could cause
excessive axis stepper movement. Check for any moves that could
possibly result in a stepper movement of more than 3 times the XY
movement and cap the move's acceleration and speed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate and store the maximum xy2 value for the given z level each
time the head moves to a new z level. This simplifies the boundary
check for common XY moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Report in the log the host CPU type and count. This helps distinguish
between different rpi versions when debugging the log from a problem
report.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the user requests a restart and the machine appears to be otherwise
functioning normally, then attempt to stop the heaters and fans prior
to restarting the host. This prevents the firmware from going into a
shutdown state when the heater is on and the host restarts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change the lookahead queue so that it attempts to buffer at least
buffer_time_high amount of moves when first starting a print. This
helps ensure the buffer is normally always full.
If the buffer falls below buffer_time_low then it is either due to the
end of a print or because octoprint/klippy is unable to keep up.
Change the code so that in this case the lookahead queue will attempt
to gather buffer_time_high amount of moves before restarting movement.
Update the default buffer_time_low to 1 second and buffer_time_high to
2 seconds. With the above changes a smaller buffer_time_high and a
larger buffer_time_low are more practical.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use a minimum time window as a heuristic for determining when to try
to lazily flush the lookahead buffer. In the common case this will
result in more moves processed for each flush and thus reduce the
overall cost of the lookahead processing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Do a better job of calculating the maximum halt velocity for the
stepper motors. The maximum cornering velocity is related to both the
maximum acceleration and the junction_deviation, so both should be in
the formula. Tests show that "math.sqrt(8. * self.junction_deviation
* self.max_accel)" very closely fits the maximum on cartesian robots.
This fixes potential "no next step" shutdowns that could occur on
some print moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The normal system clock can have sudden jumps if the system clock is
changed. Use the system monotonic clock to avoid these sudden changes
in time.
It appears the Raspbian OS (which is used by OctoPi) is setup to
update the system clock upon network connectivity. This could cause
sudden system clock changes which could lead to Klippy processing
errors. Using the monotonic clock eliminates these issues.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the lookahead code to track both normal toolhead acceleration
as well as a pseudo acceleration to the point of deceleration. This
reduces the top speed of small zig-zag moves and it reduces printer
vibration during these moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It is not necessary to track the do_calc_junction flag as it can just
as easily be determined at the top of the calc_junction() method.
This simplifies the code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When calculating the extruder lookahead, determine how far to
lookahead by the amount of elapsed time each move takes. This makes
the extruder lookahead code more flexible as it is no longer limited
to the next immediate cornering moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of calculating min/max_corner_v in the toolhead class,
calculate it in the extruder class. This keeps the extruder specific
code together.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When testing via a gcode input file, it's easier to debug problems if
the program exits upon the first exception.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure max_corner_v2 is fully calculated before proactively
flushing moves from the lookahead queue. Without this, some moves
would do unnecessary pressure advance during cornering.
Also, handle the min/max_corner_v2 calculations correctly in the rare
case where a move that does only acceleration is immediately followed
by a move that does only deceleration.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The junction speeds are tracked in velocity squared - introduce the
common suffix "_v2" to track that instead of using a prefix of
"junction_".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Continue to resend the pwm value even if the last value was zero -
this extends the debugging info.
Also, add the target temperature to the pwm debugging.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Fix a bug causing timers to be delayed when pause() is called from a
fd event. The eventtime needs to be reloaded when an old greenlet is
reactivated.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Check for msgproto.error and warn the user about version firmware
version mismatch. Raise msgproto.error when extracting firmware
constants.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>