Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
Classes | Typedefs | Functions | Variables
modules::motion Namespace Reference

Classes

struct  AxisUnit
 
struct  AxisScale
 Axis type conversion table for template expansion. More...
 
class  SuspendIsr
 
struct  AxisParams
 Main axis enumeration. More...
 
class  Motion
 
class  MovableBase
 Base class for movable modules - modules::idler::Idler and modules::selector::Selector contains the common code. More...
 

Typedefs

typedef AxisUnit< pos_t, Pulley, Lenght > P_pos_t
 Pulley position type (steps)
 
typedef AxisUnit< steps_t, Pulley, Speed > P_speed_t
 Pulley speed type (steps/s)
 
typedef AxisUnit< steps_t, Pulley, Accel > P_accel_t
 Pulley acceleration type (steps/s2)
 
typedef AxisUnit< pos_t, Selector, Lenght > S_pos_t
 Selector position type (steps)
 
typedef AxisUnit< steps_t, Selector, Speed > S_speed_t
 Selector speed type (steps/s)
 
typedef AxisUnit< steps_t, Selector, Accel > S_accel_t
 Selector acceleration type (steps/s2)
 
typedef AxisUnit< pos_t, Idler, Lenght > I_pos_t
 Idler position type (steps)
 
typedef AxisUnit< steps_t, Idler, Speed > I_speed_t
 Idler speed type (steps/s)
 
typedef AxisUnit< steps_t, Idler, Accel > I_accel_t
 Idler acceleration type (steps/s2)
 

Functions

template<typename T , Axis A, config::UnitType U>
constexpr AxisUnit< T, A, U > operator* (const long double f, const AxisUnit< T, A, U > u)
 
template<typename AU , typename U >
static constexpr AU unitToAxisUnit (U v)
 
template<typename U , typename AU , typename T = int32_t>
static constexpr T axisUnitToTruncatedUnit (AU v, long double mul=1.)
 
template<typename U , typename T = int32_t>
static constexpr T truncatedUnit (U v, long double mul=1.)
 
template<typename AU , typename U >
static constexpr AU::type_t unitToSteps (U v)
 
static constexpr P_pos_t operator""_P_mm (long double mm)
 
static constexpr P_speed_t operator""_P_mm_s (long double mm_s)
 
static constexpr P_accel_t operator""_P_mm_s2 (long double mm_s2)
 
static constexpr S_pos_t operator""_S_mm (long double mm)
 
static constexpr S_speed_t operator""_S_mm_s (long double mm_s)
 
static constexpr S_accel_t operator""_S_mm_s2 (long double mm_s2)
 
static constexpr I_pos_t operator""_I_deg (long double deg)
 
static constexpr I_speed_t operator""_I_deg_s (long double deg_s)
 
static constexpr I_accel_t operator""_I_deg_s2 (long double deg_s2)
 
static void IsrSetEnabled (bool state)
 ISR state manipulation.
 
static bool IsrDisable ()
 
static void Isr ()
 
void Init ()
 ISR initialization.
 
static constexpr MotorMode DefaultMotorMode (const config::AxisConfig &axis)
 Return the default motor mode for an Axis.
 
void __attribute__ ((noinline)) MovableBase
 

Variables

static constexpr AxisScale axisScale [config::NUM_AXIS]
 
Motion motion
 
static AxisParams axisParams [NUM_AXIS]
 Static axis configuration. More...
 

Detailed Description

Logic of motor handling Ideally enable stepping of motors under ISR (all timers have higher priority than serial)

Function Documentation

◆ axisUnitToTruncatedUnit()

template<typename U , typename AU , typename T = int32_t>
static constexpr T modules::motion::axisUnitToTruncatedUnit ( AU  v,
long double  mul = 1. 
)
staticconstexpr

Convert an AxisUnit to a physical unit with a truncated integer type (normally int32_t). Inverse of unitToAxisUnit, with the additional constraint that type casts are performed earlier so that no floating point computation is required at runtime.

Template Parameters
UBase unit type (normally U_mm)
AUAxisUnit type (implicit)
TResulting integer type
Parameters
vValue to truncate
mulOptional pre-multiplier
Returns
Truncated unit (v * mul)
See also
unitToAxisUnit

◆ truncatedUnit()

template<typename U , typename T = int32_t>
static constexpr T modules::motion::truncatedUnit ( v,
long double  mul = 1. 
)
staticconstexpr

Truncate an Unit type to an integer (normally int32_t)

Parameters
vValue to truncate
mulOptional pre-multiplier
Returns
Truncated unit (v * mul)

◆ unitToAxisUnit()

template<typename AU , typename U >
static constexpr AU modules::motion::unitToAxisUnit ( v)
staticconstexpr

Convert a unit::Unit to AxisUnit. The scaling factor is stored with the pair config::AxisConfig::uSteps and config::AxisConfig::stepsPerUnit (one per-axis).

◆ unitToSteps()

template<typename AU , typename U >
static constexpr AU::type_t modules::motion::unitToSteps ( v)
staticconstexpr

Convert a unit::Unit to a steps type (pos_t or steps_t). Extract the raw step count from an AxisUnit with type checking.

Variable Documentation

◆ axisParams

AxisParams modules::motion::axisParams[NUM_AXIS]
static
Initial value:
= {
{
.name = 'P',
.params = { .spi = hal::spi::TmcSpiBus, .idx = Pulley, .dirOn = config::pulley.dirOn, .csPin = PULLEY_CS_PIN, .stepPin = PULLEY_STEP_PIN, .sgPin = PULLEY_SG_PIN, .mRes = config::pulley.mRes, .sg_thrs = config::pulley.sg_thrs, Axis::Pulley },
.currents = MotorCurrents(config::pulley.iRun, config::pulley.iHold),
.jerk = unitToSteps<P_speed_t>(config::pulleyLimits.jerk),
.accel = unitToSteps<P_accel_t>(config::pulleyLimits.accel),
},
{
.name = 'S',
.params = { .spi = hal::spi::TmcSpiBus, .idx = Selector, .dirOn = config::selector.dirOn, .csPin = SELECTOR_CS_PIN, .stepPin = SELECTOR_STEP_PIN, .sgPin = SELECTOR_SG_PIN, .mRes = config::selector.mRes, .sg_thrs = config::selector.sg_thrs, Axis::Selector },
.jerk = unitToSteps<S_speed_t>(config::selectorLimits.jerk),
.accel = unitToSteps<S_accel_t>(config::selectorLimits.accel),
},
{
.name = 'I',
.params = { .spi = hal::spi::TmcSpiBus, .idx = Idler, .dirOn = config::idler.dirOn, .csPin = IDLER_CS_PIN, .stepPin = IDLER_STEP_PIN, .sgPin = IDLER_SG_PIN, .mRes = config::idler.mRes, .sg_thrs = config::idler.sg_thrs, Axis::Idler },
.currents = MotorCurrents(config::idler.iRun, config::idler.iHold),
.jerk = unitToSteps<I_speed_t>(config::idlerLimits.jerk),
.accel = unitToSteps<I_accel_t>(config::idlerLimits.accel),
},
}
static constexpr AxisConfig selector
End: Pulley axis configuration.
Definition: config.h:136
static constexpr IdlerLimits idlerLimits
Idler motion limits.
Definition: config.h:197
static constexpr SelectorLimits selectorLimits
Selector motion limits.
Definition: config.h:149
static constexpr AxisConfig idler
End: Selector configuration.
Definition: config.h:186
static constexpr PulleyLimits pulleyLimits
Pulley motion limits.
Definition: config.h:122
static constexpr AxisConfig pulley
Begin: Pulley axis configuration.
Definition: config.h:111
static constexpr MotorMode DefaultMotorMode(const config::AxisConfig &axis)
Return the default motor mode for an Axis.
Definition: motion.h:36
bool dirOn
direction ON state (for inversion)
Definition: axis.h:25
MRes mRes
microstepping [0-8, where 0 is x256 and 8 is fullstepping]
Definition: axis.h:26
Definition: tmc2130.h:32

Static axis configuration.

◆ axisScale

constexpr AxisScale modules::motion::axisScale[config::NUM_AXIS]
staticconstexpr
Initial value: