Commit Graph

931 Commits (9e3b300b2e5bbbd5c9b8cb90110b10ee9539abff)

Author SHA1 Message Date
D.R.racer b4d4807971 Add globa Panic() function
The intent is to halt the firmware while retaining the reporting capabilities and blinking LEDs
2021-08-31 14:19:40 +02:00
D.R.racer dc3d8941f7 Fix formatting 2021-08-31 06:59:29 +02:00
3d-gussner 1c565ddc02 Update documentation 2021-08-31 06:59:29 +02:00
3d-gussner 59db864329 Clean up code findaADC.. 2021-08-31 06:59:29 +02:00
3d-gussner 763e33f79a Fix unit test: unload_filament 2021-08-31 06:59:29 +02:00
3d-gussner d5e473f9c9 Fix unit test: tool_change 2021-08-31 06:59:29 +02:00
3d-gussner 12cf25511a Fix unit test: load_filament 2021-08-31 06:59:29 +02:00
3d-gussner 3d121c1ca9 Fix unit test: unload_to_finda 2021-08-31 06:59:29 +02:00
3d-gussner 382a2c8dc0 Fix unit test: feed_to_finda 2021-08-31 06:59:29 +02:00
3d-gussner a7a55b4039 Fix unit test: cut_fillament 2021-08-31 06:59:29 +02:00
3d-gussner 003b2f6899 Change FINDA from ADC to digital
Fix rebase issues
2021-08-31 06:59:29 +02:00
D.R.racer 06c46b20a6 Turn off green LED after load/unload finished successfully
MMU-65
2021-08-30 17:34:46 +02:00
Yuri D'Elia e9e43f744d Correct pulley steps by experimentation
Test performed by moving 500mm of filament back&forth 5 times across 5
pulleys of a MMU2 unit.

The error with this factor is centered around +/- 1.5mm depending on the
pulley and tension on the idler.
2021-08-30 12:49:54 +02:00
Yuri D'Elia f77e426af1 Use the MK2 values for the Pulley 2021-08-30 12:49:54 +02:00
Yuri D'Elia a7d8953519 Fix stepsPerUnit for the Pulley
Also use the correct value multiplied by the current ustep resolution to
make the conversion obvious.
2021-08-30 12:49:54 +02:00
Yuri D'Elia bc36ea4566 PulseGen: fix speed types in functions
Type was incorrectly changed in the last commit while debugging
2021-08-30 12:49:34 +02:00
Yuri D'Elia 04631677cc Motion/PulseGen: implement move chaining and end-speed control
Allow to chain moves by adding one extra parameter to the PlanMove[to]
functions: ending speed.

A move will always be accelerated from the last speed towards end ending
speed. The following:

  PlanMove(100._mm, 50._mm_s, 50._mm_s);
  PlanMove(200._mm, 100._mm_s);

Will first move the axis 100mm, accelerating towards 50mm/s, then
accelerate again to 100mm/s. The move will for then decelerate towards a
full stop after reaching 300mm in total.

Acceleration can be changed for each segment, so that a custom
acceleration curve can be created:

  SetAcceleration(10._mm_s2);
  PlanMove(100._mm, 50._mm_s, 50._mm_s);
  SetAcceleration(100._mm_s2);
  PlanMove(100._mm, 50._mm_s, 50._mm_s);

The ending speed might not always be reached, depending on the current
acceleration settings. The new function "Rate()" will return the ending
feedrate of the last move, if necessary.

AbortPlannedMoves accepts a new "halt" parameter to control how moves
will be chanined when interrupting the current move. By default
(halt=true) the move is completely interrupted.

When halt=false is requested, a subsequent move will be chained starting
at the currently aborted velocity. This allows to chain moves in reponse
to events, for example to accelerate the pulley without stopping as soon
as the FINDA is triggered, it's sufficient to interrupt the current move
followed by a new one:

  PlanMove(maximum_loading_lenght, slow_feedrate);
  ... wait for PINDA trigger ...
  AbortPlannedMoves(true);
  PlanMove(bowden_lenght, fast_feedrate);

will seamlessy continue loading and transition to the fast feedrate.

Jerk control has been simplified. It now handles only the maximal
velocity change of the last segment, which doesn't require reverse
planning.
2021-08-30 12:49:34 +02:00
Yuri D'Elia d55e01bb58 Motion/PulseGen: allow to abort a move for chaining
Add a new parameter "halt" (default to true) to control the stopping
behavior:

- halt=true: no subsequent moves will be planned, motions stops abruptly
- half=false: a new move will be chained after the current one
2021-08-30 12:49:34 +02:00
Yuri D'Elia d18143dff2 PulseGen: store/return the last segment speed 2021-08-30 12:49:34 +02:00
Yuri D'Elia 60c83b0af2 Allow to set axis acceleration with AxisUnit and physical units 2021-08-30 12:49:34 +02:00
Yuri D'Elia 563c8192cd Update motor currents
Use the same values from the original FW as suggested by @leptun
2021-08-30 07:12:24 +02:00
Yuri D'Elia bcf818b8fd Silence motion::Isr() unused variable warning
Move motion.Step() directly inside the __AVR__ code, silencing an unused
variable warning.

Calling motion.Step() without getting or setting the timer is not useful
anyway.
2021-08-30 07:11:29 +02:00
Yuri D'Elia fe621eb280 test_motion_ramp: improve robustness when checking multiple axes
When checking multiple axes together, also reconstruct the step rate, so
that subsequent checks do not fail randomly.
2021-08-30 07:10:54 +02:00
Yuri D'Elia e4af0717f6 test_ramp_gen: cosmetic fixes 2021-08-30 07:10:54 +02:00
Yuri D'Elia bb9e2a075b temp_motion_ramp: test single and multiple axes moving
stepTimerQuantum introduces discretization error, which makes the
acceleration curves noisy.

In rampgen generate ramps for a single moving axis in addition
of two axes moving together.

Then, in test_ramp_gen, test a single axis moving accurately, while
allow for some discretization error when two (or more) axes are running.
2021-08-30 07:10:54 +02:00
Yuri D'Elia 734612238e test_motion_ramp: do not skip tests
Remove a debugging left-over causing just the first ramp to be checked
2021-08-30 07:10:54 +02:00
Yuri D'Elia 9c3b31756e Optimize timer multiplexing and increase stepTimerQuantum
Avoid calling PulseGen::Step() on idle axes by checking for a non-zero
queue size (which is more efficient to compute).

Increase stepTimerQuantum to 128us to ensure acceleration can be
computed in realtime for 3 axes at the same time.

Fix the logic of the static assertion, which was flipped: we need to
create slices larger than the maximal step frequency in order to ensure
no axis is starved while moving.
2021-08-30 07:10:54 +02:00
Yuri D'Elia d23ed53f3c Also fix min/max outside of AVR by using the standard std::min/max 2021-08-30 07:07:19 +02:00
Yuri D'Elia b55c13dec2 Use operators for min/max
Turns out AVR doesn't have __builtin_min/max
2021-08-30 07:07:19 +02:00
Yuri D'Elia 1f2662518b Fix gpio::TogglePin on AVR
TogglePin was incorrectly using the PINx pin for toggling, causing the
current pins (in addition to the requested ones) to be toggled, causing
stepping havoc.
2021-08-30 07:06:28 +02:00
D.R.racer a58450acb6 Extract feedrates of Idler and Selector into config.h 2021-08-27 15:31:20 +02:00
Yuri D'Elia c7f3fae266 Implement an initial Motion ISR for AVR
This is a tentative/crude implementation of an Init and ISR for the MMU
in order to check the motion API.

We remove the "extern void Isr", declaring it "static inline" instead.
We need to inline the ISR here in order to avoid the function call.

Include the missing speed_table data in the executable. This bumps the
code size to ~60% of the flash.

Implemement motion::Init to setup the ISR and timers, and replace the
call in main from tmc::Init to motion::Init. Motion will init each
driver every time the axis is enabled, so there should be no need for
a global module initialization (we need SPI, but this is initialized
earlier on by it's own module anyway).

The timer is currently setup without any HAL or proper TIMER1 wrapper.
This is to be improved later.

The real MMU unit seems to slow down quite a bit during acceleration.
At this point we need to inline some methods in PulseGen to avoid
overhead, however this breaks the stubs.
2021-08-27 10:13:23 +02:00
Yuri D'Elia 1b0a67826a Improve motion::unit tests to handle fractional scaling
Pulley doesn't result in an exact step count due to the fractional
count.result in an exact step count due to the fractional count.

Use Selector instead to test values exacly.

Still check Pulley and Idler, but allowing for a +/-1 step of rounding
error.
2021-08-25 09:16:56 +02:00
Yuri D'Elia 288e74283d Introduce config::MRes and fix (real) axis units
The parameter config::AxisConfig::uSteps was supposed to be
microstepping resolution, but it's instead being used as the driver's
MRES directly.

To avoid a runtime conversion, rename the field to mRes and define a new
enum listing all the possible (and valid) microstepping resolutions.

This simplifies the code and makes clear the stepsPerUnit scale.

Assign correct stepsPerUnit to all axes as a result, including working
limits.
2021-08-25 09:16:56 +02:00
Yuri D'Elia f7f0df4afa Move hal/avr/tmc2130 into hal/ directly
There are no dependencies on AVR in TMC2130, so move into the main tree
2021-08-25 07:57:19 +02:00
Yuri D'Elia 6a9f2a2df9 Motion: test the middle driver's Enabled status too 2021-08-25 07:57:19 +02:00
Yuri D'Elia 0548c17078 Motion: test low-level enable changes via GPIO stub
This fixes the driver's enable/disable incorrectly setting the direction
bit instead.
2021-08-25 07:57:19 +02:00
Yuri D'Elia 8e24d1e084 Motion: Use an SPI stub in order to test TMC2130 2021-08-25 07:57:19 +02:00
Yuri D'Elia 9a93ebecfc Motion: add tests for the axis autoenable
Add Motion::Enabled() to get the current axis enablement status.
2021-08-25 07:57:19 +02:00
Yuri D'Elia 448edfd84b Add -fno-rtti to ensure no RTTI is generated
As for the MK3, we should never depend on RTTI in the FW
2021-08-24 16:16:34 +02:00
Alex Voinea fc2fce1230 Even more shr16 documentation 2021-08-23 08:18:47 +02:00
Alex Voinea 55ac3d5c32 Update documentation 2021-08-23 08:18:47 +02:00
Alex Voinea 36e63e678c Fix tests 2021-08-23 08:18:47 +02:00
Alex Voinea 2144a3f440 Swap led direction 2021-08-23 08:18:47 +02:00
Alex Voinea 8766642a21 Turn off all LEDs after Init 2021-08-23 08:18:47 +02:00
Yuri D'Elia a6780d2224 Correct motor pins 2021-08-23 08:16:15 +02:00
Yuri D'Elia 3fd11d17cb Make cmake show verbose errors on failure 2021-08-12 17:50:39 +02:00
Yuri D'Elia 0d1441b721 Skip motion::test_motion_ramp test if pandas is not installed 2021-08-12 17:50:07 +02:00
Yuri D'Elia c3509e6296 Remove pandas from bootstrap.py and as docker dependency
We'll not depend on pandas for normal builds, skipping
test_motion_ramp.py if not installed.
2021-08-12 17:50:07 +02:00
Yuri D'Elia 5f643126ba Add pandas as a required dependency for testing 2021-08-12 17:50:07 +02:00