Commit Graph

72 Commits (763e33f79a8d1cb6c17108877f68391e9e96e44d)

Author SHA1 Message Date
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 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 ef96d998a3 Link top level error reporting to TMC2130 error flags 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 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 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
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
Alan Dragomirecký cf5b1c3955 Do not use hard-to-read relative paths in CMake 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 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