Commit Graph

297 Commits (main)

Author SHA1 Message Date
D.R.racer b685ec4aff Fix waiting for homing of Selector after UnloadFilament 2022-02-17 08:21:15 +01:00
D.R.racer c95c6677b1 Add more unit tests for homing + fix the homing
It is a carpet-bombing-commit again, but solving the problem correctly required such an approach.
2022-02-17 08:21:15 +01:00
D.R.racer bcba966a0e Fix repeated re-homing + add more unit tests for that scenario 2022-02-17 08:21:15 +01:00
D.R.racer f25f88b164 Extract buttonADCMaxValue into config
to be used later
2022-02-17 08:21:15 +01:00
D.R.racer 18891dbeaf Add ClearButtons into unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 7fbd3c9c7e Fix homing error recovery + add homing unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 4d9d310f00 Fix unit tests 2022-02-17 08:21:15 +01:00
D.R.racer f9addb0d7a WIP: homing on both ends of axes
The principle has been implemented, but the TMC is not providing
the right data for some reason - homing doesn't work at all right now.

Also, after solving the physical homing, unit tests must be updated.
2022-02-17 08:21:15 +01:00
D.R.racer 0c9d59ba5a Fix processing of Home commands + unit tests 2022-02-17 08:21:15 +01:00
D.R.racer c5e5f57100 Rename mp (modules::pulley) namespace to mpu
clashed with the already used `modules::protocol` (mp)
2022-02-17 08:21:15 +01:00
D.R.racer b36e6b99a1 Add Pulley as a Movable module
This PR brings the following improvements:
- unifies the error handling of TMC and Homing/Stallguard errors on all motorized modules (Idler, Selector, Pulley)
- now we distinguish between Homing and TMC errors + we have a separate handling of these two kinds into CommandBase unified for all motorized modules
- adds unit tests to verify the function
- fixes SetFINDAStateAndDebounce (didn't obey the press parameter before)
2022-02-17 08:21:15 +01:00
Yuri D'Elia 86d5e87a09 motion: Implement Position/CurPosition returning AxisUnit
These come in handy to avoid manual casts and enforce types at runtime.
2022-02-01 07:00:53 +01:00
Yuri D'Elia e318a9f9c1 tests/motion:: ensure stepTimerQuantum is always respected
This catches motion stutters as fixed in
502f42b7be
2022-01-31 14:38:37 +01:00
Yuri D'Elia e7003133f5 tests/motion: Do not step in test_motion::ResetMotionSim
Calling stepUntilDone defeats the purpose of the following REQUIRE().
The test should always start from a clean state.
2022-01-31 14:38:37 +01:00
Yuri D'Elia cabf284882 motion: Remove motion.ResetAxesData
Use motion.SetPosition directly to minimize redundant code which is used
for unit tests only.
2022-01-31 14:38:37 +01:00
D.R.racer ea8dd7e365 Unload now rechecks the position of filament after recovery
This solves a number of issues - if FINDA or FSensor failed,
the unload was never "complete" - filament was stuck in the selector
blocking it from normal operation.

Now, after all errors have been resolved, filament is explicitly FED
into FINDA and then RETRACTED to Pulley.
2022-01-19 17:08:35 +01:00
D.R.racer 97b362f2b7 Join feedrates of Load-to-FINDA and Load-to-Nozzle
MMU-105
2022-01-19 17:08:35 +01:00
D.R.racer 6973dbff13 Introduce intelligent homing if Idler and Selector
Both movable components now perform homing sequences transparently
whenever the logic layer invalidates the homingValid flag.
That reflects the fact, that the user may have moved the Idler or Selector
while trying to resolve a HW issue with un/loading filament.

Basic rules:
- Idler gets rehomed immediately and then moves into the target slot position
- Selector rehomes once it is possible - i.e. when filament load state
  is AtPulley - then it immediately and spontanneously executes the homing
  sequence and then returns to the desired state

Motivation:
- resolve startup issues (EEPROM says we have filament, but FINDA is not triggered)
- resolve accidental moves of Idler and/or Selector while
  digging out stuck filament from the unit
2021-11-25 13:04:22 +01:00
D.R.racer 7d423df583 Swap buttons left<->right 2021-11-23 12:55:39 +01:00
D.R.racer 6f982e2505 Cleanup compiler warnings 2021-11-17 08:48:59 +01:00
D.R.racer 151adf810a Add ToolChange Error resolve Button2 unit tests 2021-11-17 08:48:59 +01:00
D.R.racer 515119edc8 Test ToolChange error recovery by button 0 and 1 2021-11-17 08:48:59 +01:00
D.R.racer 7fe9d7f329 Finish UnloadFilament unit test - error state resolved by user + checks 2021-11-17 08:48:59 +01:00
D.R.racer c2325b687a Unittests: set buttons more consistently 2021-11-17 08:48:59 +01:00
D.R.racer 872b2206ed Cleanup error recovery of LoadFilament
+ cover all paths with unit tests
2021-11-17 08:48:59 +01:00
D.R.racer 96397ec16b Improve error handling of ToolChange state machines
... and fix an edge case in LoadFilament
2021-11-17 08:48:59 +01:00
D.R.racer ffd8924d8c Fix start MMU with filament blocking the selector 2021-11-03 10:37:51 +01:00
D.R.racer fa4e687fdc Fix chopping negative move values in PlanLongMove
+ use PlanLongMove in UnloadToFinda
+ fix comment in unit test
2021-11-03 10:13:03 +01:00
D.R.racer c3aec0bf92 Fix pulse gen unit tests with the larger block buffer 2021-11-03 10:13:03 +01:00
D.R.racer 5f1e3e018e Workaround planning moves longer than 32K steps 2021-11-03 10:13:03 +01:00
D.R.racer 7f9fc78cf6 Improve motion's unit tests 2021-11-03 10:13:03 +01:00
D.R.racer 22522c253f Update code after rebase onto main 2021-10-21 15:16:29 +02:00
D.R.racer 9438253106 Avoid trying to unload filament when not loaded
however, it looks like the EEPROM is not updated correctly, needs more testing
2021-10-21 15:16:29 +02:00
D.R.racer 021c79ff10 Fix unit test Feed to Bondtech 2021-10-21 07:55:41 +02:00
D.R.racer 63509af294 Fix cut filament unit tests
still, this may need some more work in relation to PR #128
2021-10-21 07:55:41 +02:00
D.R.racer 3d2a76b6a0 Fix feed_to_finda unit test 2021-10-21 07:55:41 +02:00
D.R.racer ee247246ee Fix unit tests
- fix homing procedure for Idler and Selector
  (homing now ends with a move to the Parking position)
- fix unit tests' startup conditions with regard to necessary
  homing of Idler and Selector

TODO: still test_cut_filament fails for minor reasons
2021-10-21 07:55:41 +02:00
D.R.racer 5b9c6ec36e Fix (workaround) LED blink when millis overflow + unit test 2021-10-18 16:30:08 +02:00
D.R.racer e1af08b3d5 Fix unit tests
That includes:
- introduce pulley slow feedrate and fsensor-to-nozzle distance
  in config necessary for slowly feeding the filament from fsensor into the nozzle.
  (the constant is subject to extraction into some other config as it has to be used in the printer as well).
- update FeedToBondtech accordingly to perform a gentle push into the nozzle
  after fsensor detects the filament + update its unit tests.
- slight cleanup of LoadFilament + fix its unit tests
- add FeedingToNozzle progress code, as it might be interesting
  to inform the printer about this task in the future
- revert non-clean changes from RetractFromFinda - it should not disengage the idler
- revert incorrect + fix ToolChange
- clean-up UnloadFilament
2021-10-12 18:11:05 +02:00
3d-gussner abf875bda0 After Load Filament is compeleted the slot LED should be off 2021-10-12 18:11:05 +02:00
D.R.racer c26cc30185 Add finer filament loaded states and improve unit tests
We need to know better where the filament is, a simple "filament loaded true/false"
does not correspond to the reality.
2021-10-12 18:11:05 +02:00
D.R.racer 5af0125672 LoadFilament should not set filament loaded (surprisingly)
because of the change of semantics of LoadFilament operation.
LoadFilament pushes the filament into FINDA and then retracts it back just to keep the
filament ready to be grabbed by the idler and pulley and loaded into the printer's nozzle.

So the selector is not blocked by the filament -> filament NOT loaded
2021-10-12 18:11:05 +02:00
D.R.racer 5cf4a496e3 Introduce checking for enabled/disabled Pulley axis in unit tests 2021-10-12 18:11:05 +02:00
D.R.racer a13f3b8a2d Fix CutFilament unit tests 2021-10-12 18:11:05 +02:00
D.R.racer bbd14ed217 Fix ToolChange operation + unit tests 2021-10-12 18:11:05 +02:00
D.R.racer 6426295e32 Change the semantics of load filament
Load filament performs feed to FINDA and retract:
- engage idler
- feed normal to FINDA with config::feedToFinda distance until FINDA triggers
- retract normal and as soon FINDA un-triggers move back to PTFE config::cuttingEdgeToFindaMidpoint
- disengage the idler

That implied introducing another substate machine - RetractFromFinda, which does the opposite
of FeedToFinda while also checking for the FINDA switching off while retracting filament.

Still, ToolChange and CutFilament need fixing with this change
2021-10-12 18:11:05 +02:00
D.R.racer 01b2280ea6 Fix Feed To Bondtech unit tests (disengage idler after success) 2021-10-12 18:11:05 +02:00
D.R.racer 06e4cd900f Fix Feed To Bondtech tests tags 2021-10-12 18:11:05 +02:00
D.R.racer 1563559685 Fix startup conditions for Unload to FINDA state machine tests 2021-10-12 18:11:05 +02:00
D.R.racer 2ca951ceea Fix test_unload_filament
only green LED status was not correct after the latest changes
2021-10-12 18:11:05 +02:00
D.R.racer 1a6f49410c Fix test_failing_tmc 2021-10-12 18:11:05 +02:00
D.R.racer bb574603ba Reformat helpers.ipp - makes placing breakpoint easier 2021-10-12 18:11:05 +02:00
3d-gussner 0bead533df clang-format 2021-10-12 18:11:05 +02:00
3d-gussner 5f28dbf056 Fix unit test feed to finda 2021-10-12 18:11:05 +02:00
D.R.racer 1402fb3dd6 Add 'F' and 'f' decoding + unit tests where necessary 2021-09-29 13:28:34 +02:00
3d-gussner d3d992da5b Cheange LED modes to be consistent. 2021-09-23 10:04:50 +02:00
Alex Voinea f01d3a342f Fix unit test compatibility with mingw
change __mingw32__ to __win32__
2021-09-22 09:08:30 +02:00
D.R.racer f8ac620379 Fix buttons' unit tests 2021-09-20 17:22:49 +02:00
Yuri D'Elia b7fcfa5cb5 Add tests for single and multi-axis AbortPlannedMoves()
This introduces a new #define UNITTEST_MOTION which is used to control
the testing scenario:

- Normal tests, we allow the stub to override the built-in definition.
- For motion tests, we stub the lower-level classes and test the
  effective implementation

We also repeat the prototype of the function, which IMHO is more
readable and more flexible: we need to use inline for the real
definition, which would require even more macros otherwise.
2021-09-07 15:09:49 +02:00
D.R.racer 37ff9b8a8f Fix unit tests for AbortPlannedMoves(axis) 2021-09-07 15:03:36 +02:00
D.R.racer 52a6d57704 Remove Motion::Home completely 2021-09-07 15:03:36 +02:00
D.R.racer 315530ec16 Rebase onto main, reflect FINDA change (ADC->digital pin) in unit tests 2021-09-02 12:15:55 +02:00
D.R.racer 5a53acd802 Force Tool Change to load the filament if same slot but not loaded
MMU-63
2021-09-02 12:15:55 +02:00
Yuri D'Elia e7cba346da Use relative paths for panic.h
Avoids adding the main directory as an include path
2021-09-02 12:00:59 +02:00
Yuri D'Elia ee8c80e5c4 Motion: Panic if queue is full
If the queue is full and a new move is queued, panic!

Introduce a new error code QUEUE_FULL to help diagnose situations where
the queue is handled improperly: likely one of the state machines not
waiting for the previous actions to finish.

PulseGen::PlanMove returns a boolean if the queue cannot be moved.
We could extend this to Motion::PlanMove, however all moves would then
have to check for this. Having a global check such as this ensures
we never ignore such situation.
2021-09-02 12:00:59 +02:00
D.R.racer b708e67a19 Verify repeated calls to Step do not change from ERRTMCFailed 2021-09-02 08:35:56 +02:00
D.R.racer 161e46b09a Add unit tests for failing TMC
more stuff will follow as these situations seem to cause various issues
2021-09-02 08:35:56 +02:00
D.R.racer 1d884d9099 Make motion::QueueEmpty inline for non-UNITTEST builds 2021-09-02 08:35:56 +02:00
D.R.racer ffe5bc2807 Make Idler and Selector only wait for their own axis
... and fix the unit tests for this
2021-09-02 08:35:56 +02:00
D.R.racer 74629f0103 Fix reporting progress of running commands
The problem was the error state while running a command - we never used the RUNNING error state.
2021-09-02 08:35:56 +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
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 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 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 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
Alex Voinea 36e63e678c Fix tests 2021-08-23 08:18:47 +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 d8454df5af Add rampgen as a dependency of tests 2021-08-12 17:50:07 +02:00
Yuri D'Elia 240f4c28ab Complete motion ramp checks
- Add additional information in the output generated by rampgen in order
  to allow recalculating the acceleration curves independently
- Implement motion ramp checks inside test_motion_ramp.py

test_motion_ramp reads the output of a merged stepping sequence and
splits the motion of each axis, checking the acceleration curves
independently.

This ensures both that the acceleration curves are correct (as generated
by the PulseGen class) and that the multiplexed moves are too.

The nominal rate is checked exactly, while the acceleration/deceleration
segment allow for some deviation from an ideal curve.

This is currently 5% for both expected speed and acceleration, with
an absolute limit of 20mm/s of maximum difference in each point.
2021-08-12 17:50:07 +02:00
Yuri D'Elia 89ab29dbde Move motion::dual_move_ramp into the separate motion::rampgen test
- Remove motion::dual_move_ramp from the Catch2 tests and reimplement
  it as a minimal c++ program for the ramp validation.
- Add a skeleton python validator to check the ramp output
- Use test "fixtures" to ensure the rampgen is run (both as a test,
  and to generate output) when the test_motion_ramp.py is requested.
2021-08-12 17:50:07 +02:00
Yuri D'Elia f37c9e363c Remove no-longer-needed operators import 2021-08-12 17:50:07 +02:00
D.R.racer 87d0f1c8f7 Add K1, 2, 3, 4 into unit tests 2021-08-12 10:55:27 +02:00
D.R.racer f0b8cc9895 Fix encoding of Query responses for high numbers of errors
+ improve unit tests directly for the enumerated errors in logic/error_codes.h
2021-08-12 10:55:27 +02:00
D.R.racer e0ea47595f Add unit tests for logic state machines reusal
as it will work in the real FW
2021-08-12 10:30:40 +02:00
D.R.racer 9ba116e06e Handle slot indices out of range correctly at top level
Besides Unload Filament, which only operates on active slot, all other
top level state machines check the validity of the command's parameter.
If the parameter is out of range for available slots, they return
ErrorCode::INVALID_TOOL now.
2021-08-12 10:30:40 +02:00
D.R.racer 2053729a75 Fix LED unit tests 2021-08-04 11:40:02 +02:00
D.R.racer 2f5dff6c5b Introduce short namespace aliases
especially for modules
2021-08-04 11:03:56 +02:00
D.R.racer 8694c53033 Fixes after rebase onto main 2021-08-02 10:52:18 +02:00
D.R.racer aa5995368d Update to latest main + fix unit tests
... in relation to the newly introduced stepping in physical units rather than in steps
2021-08-02 10:52:18 +02:00
D.R.racer 16dc129b49 Set real slot positions for the Idler and Selector
Extracted from the previous FW, may need some tuning based on units selected
for each of these axes (degrees, millimeters) - waiting for an update
of the motion implementation.

Updated starting conditions of the unit tests to reflect the global configuration.

MMU-58
2021-08-02 10:52:18 +02:00
D.R.racer ef96d998a3 Link top level error reporting to TMC2130 error flags 2021-08-02 07:45:45 +02:00
D.R.racer 751ee46450 Add bit masks for error codes for the TMC drivers
+ add common error handling for idler and selector
+ improve error handling in command_base
+ rename ERR1xxxx errors to ERRxxxx (remove the '1')
2021-08-02 07:45:45 +02:00
D.R.racer df2c1ba7fe Add prototype of unified handling of HW errors in the logic layer 2021-08-02 07:45:45 +02:00
D.R.racer f5df642eb5 Improve error codes
- Distinguish among FINDA on/off failuje
- The same applies to newly introduced Filament sensor errors
- Add TMC init error
- Add a communication error ID - to be used on the printer
2021-08-02 07:45:45 +02:00
D.R.racer a8147be803 Fix unit tests + rebase onto main + extract TMC parameters into config 2021-07-29 10:01:33 +02:00
D.R.racer 3d1880c006 Make tests compile
Introduces a nasty hack to forcefully write into the constexpr SPI descriptor's registers
(which is the correct way in ASM, but kind of cumbersome in C++ now)
2021-07-29 10:01:33 +02:00
DRracer dc36afb82c
Merge branch 'main' into motion_units 2021-07-26 09:35:13 +02:00
D.R.racer 6af65bc4c8 Rename ISR -> Isr to avoid clash with AVR libc ISR #define 2021-07-26 09:34:24 +02:00
Yuri D'Elia d955897829 Convert config::selectorSlotPositions to physical units 2021-07-25 23:13:28 +02:00
Yuri D'Elia 6daf7fd060 Convert config::idlerSlotPositions to physical units 2021-07-25 22:39:18 +02:00
Yuri D'Elia 888cdf7cd5 Introduce compile-time axis unit type checks and conversions
Introduces:

- config::Unit: base class for physical quantities
- motion::AxisUnit: type-checked steps type

"config/unit.h" defines basic physical quantities, which are not
normally used elsewhere besides config.h.

"modules/axisunit.h" extends the modules::motion namespace with
Axis-aware units, with one type per axis per unit.

P_pos_t defines step positions for the pulley, I_pos_t for the idler,
etc. These are defined through the literar operators which are
similarly named and automatically convert a physical quantity to an
AxisUnit at compile time:

P_pos_t pulley_pos = 10.0_P_mm;

Besides type-checking, AxisUnit are otherwise identical to raw step
counts and are intended to be used along with the updated Motion API.

PlanMove/PlanMoveTo has been extended to support moves using these units
or physical quantities. Again, conversion is performed at compile time.
2021-07-25 16:39:54 +02:00
Yuri D'Elia 5e04d4ccaf Add getters/setters for Jerk in Motion/PulseGen
This allows us to make tests that expect jerk to be the same across two
axes, even if they're statically configured differently.
2021-07-25 01:24:40 +02:00
D.R.racer f62cb99b13 Fix TMC2130 stub
so that motion unit tests build and run
2021-07-14 08:38:10 +02:00
Yuri D'Elia f28567a051 Motion tests: improve comments 2021-07-13 20:21:28 +02:00
Yuri D'Elia 324fb92fd5 Motion: implement timer multiplexing 2021-07-13 19:21:13 +02:00
Yuri D'Elia d0581bf494 Motion: Add more methods and tests
- Add SetPosition/CurPosition (not only) for testing
- Implement some real tests
2021-07-13 17:43:50 +02:00
Yuri D'Elia 4fd22f0656 Motion: add initial test infrastructure and stubs 2021-07-13 16:16:56 +02:00
Yuri D'Elia 18ced44341 Merge remote-tracking branch 'upstream/main' into motion_wip 2021-07-13 15:31:31 +02:00
Yuri D'Elia 98845008aa Rename Motion::CurrentPos to Position()
This matches PulseGen::Position() and avoids confusion around the term
"current": Position() returns the head position in the queue, not the
"live" axis position.

We have PulseGen::CurPosition() now for this purpose, although we don't
expose it to Motion yet.
2021-07-13 01:03:03 +02:00
Yuri D'Elia 16e7f62aee PulseGen: introduce CurPosition() for testing
CurPosition() returns the live axis position, which in this
implementation is inherently expensive to compute.

This shouldn't be required for the MMU, but it /will/ come in handy to
check for the axis position/s in Motion tests.
2021-07-13 00:48:44 +02:00
D.R.racer eed1c3f07a Fix buttons unit tests after ADC update 2021-07-12 18:01:57 +02:00
VintagePC 55637e6055 Fix pathing for gcovr 2021-07-12 12:50:06 +02:00
VintagePC b0c25e8bd4 Fix handling failed tests. 2021-07-12 12:50:06 +02:00
VintagePC dc161812f3 First take, WIP 2021-07-12 12:50:06 +02:00
Yuri D'Elia a5a91cbaa8 tests: remove relative cmake paths in pulse_gen/speed_table 2021-07-12 11:11:49 +02:00
Yuri D'Elia 787c73ecff Merge remote-tracking branch 'upstream/main' into motion_wip 2021-07-12 10:25:06 +02:00
Yuri D'Elia 9b0dd2d633 Motion: fix new Step() prototype 2021-07-12 09:58:53 +02:00
Alan Dragomirecký cf5b1c3955 Do not use hard-to-read relative paths in CMake 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 3a131cfa0a Remove mentions of the -m32 flag (commented code) 2021-07-12 09:09:21 +02:00
Alan Dragomirecký c3f0e59d12 Remove the empty integration tests directory 2021-07-12 09:09:21 +02:00
Yuri D'Elia 9b77623be1 PulseGen: ensure Abort calculates the current remainder correctly
Instead of stepping halfway, step ~1/3 of the way through.

This ensures we can check if the steps performed is correct due to the
internal step subtraction.
2021-07-11 22:19:44 +02:00
Yuri D'Elia 9e935f6a07 Comment Typo 2021-07-11 22:17:04 +02:00
Yuri D'Elia 7337e97765 Rename Motion::DisableAxis to Disable
Implement Motion::SetEnabled (for symmetry with TMC2130::SetEnabled).

Rename DisableAxis to Disable and use the new SetEnabled. This makes the
member names more consistent.
2021-07-11 21:38:01 +02:00
Yuri D'Elia 066aab7adc Move cpuFrequencyDivider to config::stepTimerFrequencyDivider 2021-07-11 21:17:08 +02:00
Yuri D'Elia 0c47d8f0d1 PulseGen: add comprehensive tests (no acceleration yet) 2021-07-11 20:52:27 +02:00
Yuri D'Elia 5250cfd4fe Implement the SHR16::SetTMCDir stub for testing 2021-07-11 20:33:59 +02:00
Yuri D'Elia 1ff9b81630 Rename PulseGen::Move to PlanMoveTo
Make Motion and PulseGen intentionally very similar.
2021-07-07 16:59:40 +02:00
Yuri D'Elia 16cf02726b test_speed_table: improve static assertion
Test against the resulting timer speed, not against the CPU clock
2021-07-07 16:59:40 +02:00
Yuri D'Elia d87db1ff76 Revised WIP for the Motion API
- Remove the combined PlanMove(a,b,c,rate) call. If we allow the units
  of the various motors to be changed at compile time, the unit of
  rate can vary between axes.
- Build PlanMove on top of the absolute PlanMoveTo.
- Add required stubs for TMC2130.
- Allow each axis mode to be set independently, since we have this
  feature for free anyway.
- Rework internals to use PulseGen data types and structs.
2021-07-07 16:59:39 +02:00
Yuri D'Elia ed04bd02e2 PulseGen/speed_tables: cleanup constants 2021-07-07 16:59:04 +02:00
Yuri D'Elia 006dfd4abc PulseGen: remove all floating point calculations
Work in steps, steps/s, steps/s2 directly.
2021-07-07 16:59:04 +02:00
Yuri D'Elia cf5be5aade PulseGen: initial version of the ramp/pulse generator 2021-07-07 16:59:04 +02:00
Yuri D'Elia de88ed4c6b Add initial Axis configuration static structs 2021-07-07 16:59:04 +02:00
Yuri D'Elia ef7c776461 Update Motion for the new TMC2130/pins definitions 2021-07-07 16:59:04 +02:00
Yuri D'Elia 531f60ed27 Add modules::speed_table for acceleration lookup tables 2021-07-07 16:59:04 +02:00