Commit Graph

10 Commits (aa20e01ef246bf68e8a6756daaa261316b916b23)

Author SHA1 Message Date
Guðni Már Gilbert aa20e01ef2 Improve accuracy in axisUnitToTruncatedUnit
When converting 800mm/s2, it would be truncated to 795mm/s2 for the pulley. This is due to cutting out significant decimal digits.

Instead let's multiply in floating point, this needs quite a bit of resources. So to optimise against this, multiply with the recoprical. Then the cost is not more than 20 bytes.

Testing:
M707 A0x0e; Read Pulley Acceleration (default at boot up is 800mm/s2)
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; Read Pulley Acceleration (should be 790mm/s2)

The results before this commit:

M707 A0x0e -> returns 805
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 795

After this commit:

M707 A0x0e -> returns 799
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 789

NOTE:
axisUnitToTruncatedUnit is used in Idler homing, selector homing, and pulley positioning. I am not sure yet how this improvement will affect those areas.
2024-12-25 14:54:13 +00:00
D.R.racer 7e2375deee Introduce TMC2130 currents doxy group
and clean-up doxygen warnings a bit
2023-02-17 15:50:20 +01:00
Yuri D'Elia 53d285280d Avoid runtime conversions of floats in UnloadToFinda
Introduce axisUnitToTruncatedUnit to convert from an AxisUnit (now
conveniently returned from Motion::CurPosition) to a physical unit *but*
directly into a truncated integer type, avoiding conversions to long
double types at runtime.

The related function truncatedUnit perform the same truncation of a
constant unit, so that the result of axisUnitToTruncatedUnit and
truncatedUnit(unit) result in the same type for clarity.

Both functions accept a pre-multiplier, which is applied at compile
time for constant values when optimizations are enabled.
2022-02-01 07:00:53 +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 0fbcb9dac2 Tag all source files with @file for doxygen 2021-10-18 17:59:46 +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
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 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 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