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
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
2144a3f440
Swap led direction
2021-08-23 08:18:47 +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
2c94e76ca9
Allow configurable LED's blinking period
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
Alex Voinea
9232e55563
millis interrupt
2021-08-04 10:51:33 +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
Yuri D'Elia
7dcd4975e1
Allow units to be scaled by an unitless quantity
...
This allows Unit<> and AxisUnit<> to be scaled with a fraction as
expected, promoting the scaler to the same unit:
0.2_mm * 10 => 2_mm (mm*f => mm)
Multiplication type is commutative:
10 * 0.2_mm => 2_mm (f*mm => mm)
Division isn't:
0.2_mm / 10 => 0.02_mm (mm*1/f => mm)
10 / 0.2_mm => error (illegal type conversion)
2021-08-02 07:41:26 +02:00
Alex Voinea
8577852b09
tmc2130: Stallguard and Isr
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
Alex Voinea
b97aefcb5c
tmc2130: More functions
2021-07-29 10:01:33 +02:00
Alex Voinea
1022603f9d
tmc2130: Initial spi communication
2021-07-29 10:01:33 +02:00
DRracer
151a672f56
Merge pull request #71 from wavexx/motion_units
...
Motion units
2021-07-27 06:34:32 +02:00
D.R.racer
7f39f07679
Avoid repeated Enable/Disable on an axis if already in desired state
2021-07-27 06:25:01 +02:00
DRracer
dc36afb82c
Merge branch 'main' into motion_units
2021-07-26 09:35:13 +02:00
D.R.racer
8a1df52d79
Add support for reporting MMU errors via S3 msg
2021-07-26 09:34:40 +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
D.R.racer
1f7a84a623
Support CR XOR LF in protocol's line ending implementation
...
Please note Windows CRLF sequence is not supported,
but a separate CR xor a separate LF works now.
This is a workaround for stupid terminals for debugging purposes,
and it is not necessary for the protocol to work on its own.
It may be removed in the future.
2021-07-26 09:34:02 +02:00
Alex Voinea
b109a520c2
buttons: Fix comment
2021-07-26 06:49:05 +02:00
Yuri D'Elia
5928ade6be
Improve motion::unitToAxisUnit template parameter names
2021-07-26 01:28:29 +02:00
Yuri D'Elia
051bce9098
Nicely format doxygen documentation
2021-07-25 23:50:01 +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
b133c8b975
Simplify and enhance unit conversion
...
- Move unit/step conversion to modules/axisunit.h
- Unify motion::unitToAxisUnit<> and motion::unitToSteps<>,
making conversion in other modules just as easy as motion.
- Improve the documentation
2021-07-25 22:25:48 +02:00
Yuri D'Elia
402a2b91ce
Define Motion::PlanMove/PlanMoveTo as constexpr
2021-07-25 17:08:15 +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
Yuri D'Elia
606b22a9ad
Make Motion::Acceleration const
2021-07-25 01:17:25 +02:00
Yuri D'Elia
4160d019be
Motion: implement InitAxis
2021-07-13 20:44:09 +02:00
Yuri D'Elia
8f0732a0cc
Motion: initial StallGuard support
...
Add the code in the right position to sample StallGuard and set/reset
the trigger flag.
2021-07-13 20:36:43 +02:00
Yuri D'Elia
eec95d6fb7
Motion: add assertions for stepTimerQuantum
2021-07-13 19:40:00 +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
c7459df05e
PulseGen: improve comments.
2021-07-13 15:10:47 +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
9bb1bf4a53
PulseGen: typos in comments
2021-07-13 00:54: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
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ý
09819cb1aa
Split the main CMakeLists.txt into more files within subdirectories
2021-07-12 09:09:21 +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
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
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
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
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
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
D.R.racer
ccda84df80
Make buttons' ADC decision levels "inclusive"
...
especially because of the zero level, which is very likely to be a valid button0 level
2021-07-05 18:07:54 +02:00
D.R.racer
b484eeacb6
Start using config.h
...
Added some constexpr vars for buttons, finda, fsensor and
applied them in the FW and unit tests accordingly.
2021-07-05 18:07:54 +02:00
vintagepc
e2ec745286
Simple config header with example ( #39 )
...
Simple config header with example
2021-07-01 06:47:40 +02:00
D.R.racer
9122a33693
Rebase onto upstream/main, adapt to cleaned-up circular buffer interface
2021-06-30 07:39:31 +02:00
D.R.racer
ffae941a28
Fix unit tests of load/unload filament
2021-06-30 07:39:31 +02:00
D.R.racer
9a8038ccb6
Add user_input module and use it instead of raw buttons
...
Encapsulates buttons and commands coming from the communication
2021-06-30 07:39:31 +02:00
D.R.racer
4df4bf59b4
Update doxyfile + document modules namespace
2021-06-30 07:39:31 +02:00
D.R.racer
c15b1d59c4
Introduce Doxyfile + fix modules documentation
2021-06-30 07:39:31 +02:00
D.R.racer
ce20f0b001
Greatly improve unload filament unit test
...
+ relevant changes for other unit tests -> prepare for improving
of the other unit tests as well
2021-06-30 07:39:31 +02:00
Yuri D'Elia
3ba072aea7
Define the global Timebase instance
2021-06-29 08:59:16 +02:00
Yuri D'Elia
f097aecbaa
Qualify leds::Mode in LED to fix build
2021-06-29 08:58:37 +02:00
D.R.racer
4d6d6fe0af
Add more checks (esp. positions of idler and selector)
...
that resulted in finding several weak spots and now Cut and Eject filament
do not pass the test (which is correct, they really have logical issues)
2021-06-21 10:28:56 +02:00
D.R.racer
1f8934c2c1
Fix+verify Cut filament unit test
...
it now finished ok, but future tweaks and improvements are expected
2021-06-21 10:22:17 +02:00
D.R.racer
ede475c5a6
Introduce Timebase module, refactor timing code + unit tests
2021-06-21 10:22:17 +02:00
D.R.racer
398181e26c
Feed to FINDA unit tests : green
2021-06-21 10:22:17 +02:00
D.R.racer
85910497f7
Unify buttons' API with other modules
...
- accepts millis() instead of doing the timing internally (which has
been a temporary solution just for the tests until now)
2021-06-21 10:22:17 +02:00
D.R.racer
3cb3cebed9
Add forced reinit of all automata for the unit tests
...
+ added a few constexpr to constructors on the way
2021-06-21 10:22:17 +02:00
D.R.racer
b8f6bc9a4e
Tune Feed to FINDA state machine and its unit test
...
so that it works as expected
Still, there is a task of resetting all of the state machines just for
the next unit test to be run.
2021-06-21 10:22:17 +02:00
D.R.racer
f0a042c1b6
Add unit tests for Feed to FINDA state machine
...
+ improve infrastructure
2021-06-21 10:22:17 +02:00
D.R.racer
925201d77a
Basic unit test structure for the logic layer
...
It compiles the Cut Filament unit test with all the necessary components.
Still, the unit test does nothing.
2021-06-21 10:22:17 +02:00
D.R.racer
58fe013471
Fix compilation
2021-06-16 06:43:20 +02:00
D.R.racer
d6c9e58e66
Add global state hive
...
+ solve many TODO's in the code (active slot/extruder and filament loaded flag)
2021-06-16 06:43:20 +02:00
D.R.racer
9e4bd97968
Add empty EEPROM HAL implementation
2021-06-14 07:34:59 +02:00
D.R.racer
dfb57bcae5
Add Load filament state machine
...
+ printer's fsensor (external) module
+ state machine for loading to bondtech
2021-06-14 07:34:59 +02:00
D.R.racer
7bfc1bad97
Cut filament prototype state machine
2021-06-14 07:34:59 +02:00
D.R.racer
d0095a01aa
Buttons - add AnyButtonPressed()
2021-06-14 07:34:59 +02:00
D.R.racer
ade5f11fe2
Motion - remove dummy Idler functions
2021-06-14 07:34:59 +02:00
D.R.racer
7555bbb906
Add Selector module
2021-06-14 07:34:59 +02:00
D.R.racer
b4e8c3fa5d
Add Idler module
2021-06-14 07:34:59 +02:00
D.R.racer
5b4eb0cee3
Extract Unload filament into a separate file
...
+ cleanup the object structure
+ add no_command as the starting "operation" to simplify the rest of the command handling at runtime
2021-06-14 07:34:59 +02:00
D.R.racer
6f1624b718
Make logic prototype compilable
2021-06-14 07:34:59 +02:00
D.R.racer
2159558d88
Prototype of Unload Filament command/operation
...
+ related stuff:
- command decoding+processing+reporting in main.cpp
- slight refactoring of modules
2021-06-14 07:34:59 +02:00
D.R.racer
ca6de101c3
Logic - first try
2021-06-14 07:34:59 +02:00
D.R.racer
019f74d6f2
Add debouncing for FINDA
2021-06-08 07:00:07 +02:00
D.R.racer
939b47d260
FINDA interface module
2021-06-08 07:00:07 +02:00
D.R.racer
3ef113cf6c
Add basic motion API
2021-06-08 06:59:49 +02:00
D.R.racer
8e994c3b17
Take over permanent storage implementation from MM-control-01
2021-06-08 06:59:14 +02:00
D.R.racer
bd335ec30d
Unit test for LEDs interface + fixes
2021-05-26 11:39:24 +02:00
D.R.racer
004db59da0
Add shift register interface and improve LED integration with it
2021-05-26 09:29:32 +02:00
D.R.racer
9226230fd5
Reformat sources to fit the new namespace formatting rules
2021-05-25 12:24:19 +02:00
D.R.racer
acc33bfacb
Do not indent namespaces
2021-05-25 12:23:29 +02:00
D.R.racer
fce2195558
Interface module for driving LEDs
...
+ start shaping up main.cpp
+ make the usage of namespaces and class names more consistent throughout the whole project
+ refactor related unit tests accordingly
2021-05-25 11:00:30 +02:00
D.R.racer
7611b98830
Add more unit tests and optimize (saved 1 byte per button on the AVR)
2021-05-25 10:02:02 +02:00
D.R.racer
7ece1fb28d
Add missing buttons.h
2021-05-25 10:02:02 +02:00
D.R.racer
ba8eacfe33
Buttons module implementation
...
A module representing a model of the 3 buttons
Includes a unit test project (empty at this stage)
2021-05-25 10:02:02 +02:00
D.R.racer
fe0ac4f9f9
More unit tests for decoding of response messages
...
+ related changes in code
2021-05-18 08:18:11 +02:00
D.R.racer
30fbf6d870
Unit tests for decoding requests and responses
...
+errors on requests
2021-05-18 08:18:11 +02:00
D.R.racer
0633dea881
Protocol implementation
...
+ unit tests for encoding of messages
API still subject to minor changes
2021-05-18 08:18:11 +02:00
D.R.racer
f848c8d550
Create basic FW structure
...
- Design API's based on our discussion and block diagrams
- Set doxygen rules/preferred syntax
2021-04-19 07:03:47 +02:00