Commit Graph

931 Commits (9e3b300b2e5bbbd5c9b8cb90110b10ee9539abff)

Author SHA1 Message Date
Alan Dragomirecký c3f0e59d12 Remove the empty integration tests directory 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 332c740a8b Do not build the firmware target when crosscompiling 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 5018c44489 Do not include the utils directory 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 09819cb1aa Split the main CMakeLists.txt into more files within subdirectories 2021-07-12 09:09:21 +02:00
Alan Dragomirecký ed72b07e04 Remove `include` from header search paths 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 6f68fc6e76 Remove empty CMakeLists from the utils directory 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 99b847bf98 Remove the PRINTER cmake option and other irrelevant code 2021-07-12 09:09:21 +02:00
Yuri D'Elia b3f3f0538e Shim <limits> on AVR
Instead of adding #ifdefs for missing headers, create a shim that can be
included everywhere.

"limits.h" includes a bare-bone implementation of numeric_limits (to be
extended as needed).
2021-07-12 09:02:05 +02:00
Alan Dragomirecký 3dbba6ca88 holly: Temporarily disable builds of the firmware (as there is no
avr-gcc available)
2021-07-12 08:52:57 +02:00
Alan Dragomirecký ba19208469 Add Dockerfile/Jenkinsfile for Holly 2021-07-12 08:52:57 +02:00
Alan Dragomirecký 8361bd1027 Replace urls for gcc-avr with dummy (but working) ones 2021-07-12 08:52:57 +02:00
Alan Dragomirecký 86f5e19b54 Remove unused Python dependecies 2021-07-12 08:52:57 +02:00
Yuri D'Elia 2db97c0f5e Fix CMake "files" expression in pre-commit 2021-07-12 08:51:10 +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 e53a91d563 Implement more methods in Motion, remove Motion::Full()
Motion::Full() (without a specific axis) is counter-productive.

When planning new moves the axis needs to be known beforehand, so it
might be as well be given to Full() to check the proper queue.
2021-07-11 22:07:23 +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 b01a819644 Make Read/Write/Toggle pin functional for testing
Make ReadPin return the last value set by WritePin for proper testing.

Add a slow-path to TogglePin that goes through a read-write cycle. This
is useful both for testing and for platforms that don't have an
efficient toggle like AVR.
2021-07-11 20:25:52 +02:00
Yuri D'Elia 32e09afd4c Fix return value of gpio::ReadPin
The cast to Level is incorrect, since the expression returns either 0 or
a positive value if the pin is set. The value is directly assigned to
the underlying uint8_t, meaning that Level::high won't match for levels
greater than 0.

Return a boolean and cast that to Level instead.
2021-07-11 20:23:21 +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 be30314634 Motion: initialize axes in the same order as the enumeration 2021-07-07 16:59:40 +02:00
Yuri D'Elia 2875e61484 Motion: allow to query the buffer per-axis
We might want to schedule new moves while a single motor is moving.
Allow to do that by introducing per-axis query functions.

The main QueueEmpty() and Full() still function as before:

- Call QueueEmpty() to wait for all moves to finish.
- Use !Full() to know that a Plan() move will never be discarded.
2021-07-07 16:59:40 +02:00
Yuri D'Elia 94f11642e0 PulseGen: perform an extra queue check in Move()
Since scheduling a move on a block which is being executed will jolt the
motors, be extra-safe and perform an extra lower-level check before
committing even if the caller is responsible.

Return the status, which can be useful to build a simple busy loop.
2021-07-07 16:59:40 +02:00
Yuri D'Elia bd8ae62211 PulseGen: cleanup AxisData initialization 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 e990b703e3 CMake: reformat 2021-07-07 16:59:04 +02:00
Yuri D'Elia d7874d5336 PulseGen: implement AbortPlannedMoves 2021-07-07 16:59:04 +02:00
Yuri D'Elia 44a263d334 PulseGen: move Step() to header for inlining 2021-07-07 16:59:04 +02:00
Yuri D'Elia 6f518f1ed2 PulseGen: complete implementation 2021-07-07 16:59:04 +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 7d2329cf85 Add src/cmath.h for <math.h> portability between platforms 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
Yuri D'Elia 1d6736cff6 Add modules::math for specialized math functions
Currently include reduced-precision 8x16 and 16x16 multiplication
functions used by the speed lookup tables.
2021-07-07 16:59:04 +02:00
Alan Dragomirecký 996f0f5dc0 Fix formatting of cmake files 2021-07-07 16:33:16 +02:00
Alan Dragomirecký e3d8147890 Ignore .cmake-format.py file by cmake-format 2021-07-07 16:33:16 +02:00
Alan Dragomirecký 9448c04b36 Disable preprocessor code indentation 2021-07-07 16:33:03 +02:00
Yuri D'Elia f95c47638d CircularIndex: fight against type promotion in size checks
To generate optimal code, size itself needs to be of the same type as
the index to avoid promotion to the largest type.

In full(), wrap the subtraction explicity in another type cast to avoid
another automatic type promotion.
2021-07-06 12:51:56 +02:00
Yuri D'Elia f57a1c3b17 CircularIndex: add static checks for index/size limits
The empty/full distinction fails to work if size matches the number of
representable positions for the index type.

Add a static check to ensure this invariant is met where possible.
2021-07-06 12:51:56 +02:00
Yuri D'Elia 4362d77083 CircularIndex: alternate index management for full capacity
Comparing head/tail indexes cannot distinguish between empty/full cases,
so we end up wasting one item in the circular buffer. This also limits
the smallest and efficient size choice to be 4.

If the circular buffer is large, there's no issue, however for the
motion planner the block size is significant, and I was planning to use
exactly a ring buffer of two: one busy block, plus one planned.

Modify the indexer to store the internal "index" (aka cursor) pointer to
be one extra bit deeper than the final index. Comparing the underlying
cursor allow to distinguish the empty/full case due to the extra bit,
while producing the final index requires simple masking.

This is just as efficient if the size is a power of two with
2-complement wrap-around logic, which is the optimized case. However
the implementation also works for non-power-of-two sizes.

Add tests for more failure cases in the CircularBuffer which is built on
top.

(tecnique described in the Art of Computer Programming by Knuth)
2021-07-06 12:51:56 +02:00
Yuri D'Elia 477539c791 Split CircularBuffer into CircularIndex+CircularBuffer
Allow the lower-level index to be used without an actual container by
splitting off the index management into CircularIndex.

Rebuild CircularBuffer using CircularIndex itself.
2021-07-06 12:51:56 +02:00
D.R.racer 43a423f299 Change buttons' ADC limits into an array
as proposed by @vintagePC

cleaned-up some of the unit tests by this change
2021-07-05 18:07:54 +02:00
D.R.racer 552fec9abf Parametrize Idler and Selector in common config.h 2021-07-05 18:07:54 +02:00