Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
Classes | Public Member Functions | List of all members
modules::motion::Motion Class Reference

Public Member Functions

bool InitAxis (Axis axis)
 
bool InitAxis (Axis axis, MotorCurrents mc)
 
bool Enabled (Axis axis) const
 Return the axis power status.
 
void SetEnabled (Axis axis, bool enabled)
 
void Disable (Axis axis)
 
void SetMode (Axis axis, MotorMode mode)
 
void SetMode (MotorMode mode)
 Set the same mode of TMC/motors operation for all axes. More...
 
bool StallGuard (Axis axis)
 
void StallGuardReset (Axis axis)
 clear StallGuard flag reported on an axis
 
void PlanStallGuardThreshold (Axis axis, int8_t sg_thrs)
 
void PlanMoveTo (Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rate=0)
 
template<Axis A>
constexpr void PlanMoveTo (AxisUnit< pos_t, A, Lenght > pos, AxisUnit< steps_t, A, Speed > feed_rate, AxisUnit< steps_t, A, Speed > end_rate={ 0 })
 
template<Axis A, config::UnitBase B>
constexpr void PlanMoveTo (config::Unit< long double, B, Lenght > pos, config::Unit< long double, B, Speed > feed_rate, config::Unit< long double, B, Speed > end_rate={ 0 })
 
void PlanMove (Axis axis, pos_t delta, steps_t feed_rate, steps_t end_rate=0)
 
template<Axis A>
constexpr void PlanMove (AxisUnit< pos_t, A, Lenght > delta, AxisUnit< steps_t, A, Speed > feed_rate, AxisUnit< steps_t, A, Speed > end_rate={ 0 })
 
template<Axis A, config::UnitBase B>
constexpr void PlanMove (config::Unit< long double, B, Lenght > delta, config::Unit< long double, B, Speed > feed_rate, config::Unit< long double, B, Speed > end_rate={ 0 })
 
pos_t Position (Axis axis) const
 
template<Axis A>
constexpr AxisUnit< pos_t, A, Lenght > Position () const
 
pos_t CurPosition (Axis axis) const
 
template<Axis A>
constexpr AxisUnit< pos_t, A, Lenght > CurPosition () const
 
void SetPosition (Axis axis, pos_t x)
 
steps_t Acceleration (Axis axis) const
 
void SetAcceleration (Axis axis, steps_t accel)
 
template<Axis A>
void SetAcceleration (AxisUnit< steps_t, A, Accel > accel)
 
template<Axis A, config::UnitBase B>
void SetAcceleration (config::Unit< long double, B, Accel > accel)
 
steps_t Jerk (Axis axis) const
 
void SetJerk (Axis axis, steps_t max_jerk)
 
steps_t Rate (Axis axis) const
 
st_timer_t Step ()
 
bool QueueEmpty () const
 
bool QueueEmpty (Axis axis) const
 
uint8_t PlannedMoves (Axis axis) const
 
bool Full (Axis axis) const
 
void AbortPlannedMoves (Axis axis, bool halt=true)
 
void AbortPlannedMoves (bool halt=true)
 
hal::tmc2130::TMC2130DriverForAxis (Axis axis)
 
hal::tmc2130::TMC2130MMU_NEEDS_ATTENTION_DriverForAxis (Axis axis)
 
const pulse_gen::PulseGenCtrlForAxis (Axis axis) const
 
const MotorCurrentsCurrentsForAxis (Axis axis) const
 
void SetIRunForAxis (Axis axis, uint8_t i)
 

Member Function Documentation

◆ AbortPlannedMoves() [1/2]

void modules::motion::Motion::AbortPlannedMoves ( Axis  axis,
bool  halt = true 
)

Stop whatever moves are being done for one axis

Parameters
axisaxis requested
haltWhen true, also abruptly stop axis movement.

◆ AbortPlannedMoves() [2/2]

void modules::motion::Motion::AbortPlannedMoves ( bool  halt = true)

Stop whatever moves are being done on all axes

Parameters
haltWhen true, also abruptly stop axis movement.

◆ Acceleration()

steps_t modules::motion::Motion::Acceleration ( Axis  axis) const
inline

Get current acceleration for the selected axis

Parameters
axisaxis affected
Returns
acceleration

◆ CtrlForAxis()

const pulse_gen::PulseGen& modules::motion::Motion::CtrlForAxis ( Axis  axis) const
inline
Returns
the controller associated with the particular axis

◆ CurPosition() [1/2]

template<Axis A>
constexpr AxisUnit<pos_t, A, Lenght> modules::motion::Motion::CurPosition ( ) const
inlineconstexpr

Fetch the current axis position, but in AxisUnit. This function is expensive! The Axis needs to be supplied as the first template argument: CurPosition<axis>().

See also
CurPosition

◆ CurPosition() [2/2]

pos_t modules::motion::Motion::CurPosition ( Axis  axis) const

Fetch the current position of the axis while stepping. This function is expensive! It's necessary only in exceptional cases. For regular usage, Position() should probably be used instead.

Parameters
axisaxis affected
Returns
the current position of the axis

◆ Disable()

void modules::motion::Motion::Disable ( Axis  axis)
inline

Disable axis motor. One must manually ensure no moves are currently being performed by calling QueueEmpty().

◆ DriverForAxis()

hal::tmc2130::TMC2130& modules::motion::Motion::DriverForAxis ( Axis  axis)
inline
Returns
the TMC213 driver associated with the particular axis

◆ Full()

bool modules::motion::Motion::Full ( Axis  axis) const
inline
Returns
false if new moves can still be planned for one axis
Parameters
axisaxis requested

◆ InitAxis()

bool modules::motion::Motion::InitAxis ( Axis  axis)

Init axis driver - @TODO this should be probably hidden somewhere deeper ... something should manage the axes and their state especially when the TMC may get randomly reset (deinited)

Returns
true if the init was successful (TMC2130 responded ok)

◆ Jerk()

steps_t modules::motion::Motion::Jerk ( Axis  axis) const
inline

Get current jerk for the selected axis

Parameters
axisaxis affected
Returns
jerk

◆ MMU_NEEDS_ATTENTION_DriverForAxis()

hal::tmc2130::TMC2130& modules::motion::Motion::MMU_NEEDS_ATTENTION_DriverForAxis ( Axis  axis)
inline
Returns
the (non-const) TMC2130 driver associated with the particular axis. Do not use unless you know exactly what you're doing, (i.e., nothing else can possibly be using the axis. Currently the only valid usage is in the hw sanity module.

◆ PlanMove() [1/3]

void modules::motion::Motion::PlanMove ( Axis  axis,
pos_t  delta,
steps_t  feed_rate,
steps_t  end_rate = 0 
)
inline

Enqueue a single axis move in steps starting and ending at zero speed with maximum feedrate. Moves can only be enqueued if the axis is not Full().

Parameters
axisaxis affected
deltarelative to current position
feed_ratemaximum feedrate
end_rateendding feedrate (may not be reached!)

◆ PlanMove() [2/3]

template<Axis A>
constexpr void modules::motion::Motion::PlanMove ( AxisUnit< pos_t, A, Lenght >  delta,
AxisUnit< steps_t, A, Speed >  feed_rate,
AxisUnit< steps_t, A, Speed >  end_rate = { 0 } 
)
inlineconstexpr

Enqueue a single axis move using PlanMove, but using AxisUnit. The Axis needs to be supplied as the first template argument: PlanMove<axis>(pos, rate).

See also
PlanMove, unitToSteps

◆ PlanMove() [3/3]

template<Axis A, config::UnitBase B>
constexpr void modules::motion::Motion::PlanMove ( config::Unit< long double, B, Lenght >  delta,
config::Unit< long double, B, Speed >  feed_rate,
config::Unit< long double, B, Speed >  end_rate = { 0 } 
)
inlineconstexpr

Enqueue a single axis move using PlanMove, but using physical units. The Axis needs to be supplied as the first template argument: PlanMove<axis>(pos, rate).

See also
PlanMove, unitToSteps

◆ PlanMoveTo() [1/3]

void modules::motion::Motion::PlanMoveTo ( Axis  axis,
pos_t  pos,
steps_t  feed_rate,
steps_t  end_rate = 0 
)

Enqueue a single axis move in steps starting and ending at zero speed with maximum feedrate. Moves can only be enqueued if the axis is not Full().

Parameters
axisaxis affected
postarget position
feed_ratemaximum feedrate
end_rateendding feedrate (may not be reached!)

◆ PlanMoveTo() [2/3]

template<Axis A>
constexpr void modules::motion::Motion::PlanMoveTo ( AxisUnit< pos_t, A, Lenght >  pos,
AxisUnit< steps_t, A, Speed >  feed_rate,
AxisUnit< steps_t, A, Speed >  end_rate = { 0 } 
)
inlineconstexpr

Enqueue a single axis move using PlanMoveTo, but using AxisUnit. The Axis needs to be supplied as the first template argument: PlanMoveTo<axis>(pos, rate).

See also
PlanMoveTo, unitToSteps

◆ PlanMoveTo() [3/3]

template<Axis A, config::UnitBase B>
constexpr void modules::motion::Motion::PlanMoveTo ( config::Unit< long double, B, Lenght >  pos,
config::Unit< long double, B, Speed >  feed_rate,
config::Unit< long double, B, Speed >  end_rate = { 0 } 
)
inlineconstexpr

Enqueue a single axis move using PlanMoveTo, but using physical units. The Axis needs to be supplied as the first template argument: PlanMoveTo<axis>(pos, rate).

See also
PlanMoveTo, unitToSteps

◆ PlannedMoves()

uint8_t modules::motion::Motion::PlannedMoves ( Axis  axis) const
inline
Returns
number of planned moves on an axis

◆ PlanStallGuardThreshold()

void modules::motion::Motion::PlanStallGuardThreshold ( Axis  axis,
int8_t  sg_thrs 
)

Sets (plans) StallGuard threshold for an axis (basically the higher number the lower sensitivity) The new SGTHRS value gets applied in Init(), it is NOT written into the TMC immediately in this method.

◆ Position() [1/2]

template<Axis A>
constexpr AxisUnit<pos_t, A, Lenght> modules::motion::Motion::Position ( ) const
inlineconstexpr
Returns
head position of an axis, but in AxisUnit. The Axis needs to be supplied as the first template argument: Position<axis>().
See also
Position

◆ Position() [2/2]

pos_t modules::motion::Motion::Position ( Axis  axis) const
Returns
head position of an axis (last enqueued position)
Parameters
axisaxis affected

◆ QueueEmpty() [1/2]

bool modules::motion::Motion::QueueEmpty ( ) const
Returns
true if all planned moves have been finished for all axes

◆ QueueEmpty() [2/2]

bool modules::motion::Motion::QueueEmpty ( Axis  axis) const
inline
Returns
true if all planned moves have been finished for one axis
Parameters
axisrequested

◆ Rate()

steps_t modules::motion::Motion::Rate ( Axis  axis) const
inline

Fetch the target rate of the last planned segment for the requested axis, or the current effective rate when the move has been aborted.

Parameters
axisaxis affected
Returns
last rate

◆ SetAcceleration() [1/3]

void modules::motion::Motion::SetAcceleration ( Axis  axis,
steps_t  accel 
)
inline

Set acceleration for the selected axis

Parameters
axisaxis affected
accelacceleration

◆ SetAcceleration() [2/3]

template<Axis A>
void modules::motion::Motion::SetAcceleration ( AxisUnit< steps_t, A, Accel >  accel)
inline

Set acceleration for the selected axis, but using AxisUnit. The Axis needs to be supplied as the first template argument: SetAcceleration<axis>(accel).

See also
SetAcceleration, unitToSteps

◆ SetAcceleration() [3/3]

template<Axis A, config::UnitBase B>
void modules::motion::Motion::SetAcceleration ( config::Unit< long double, B, Accel >  accel)
inline

Set acceleration for the selected axis, but using physical units. The Axis needs to be supplied as the first template argument: SetAcceleration<axis>(accel).

Template Parameters
Aaxis affected
Bunit base for the axis
Parameters
accelacceleration

◆ SetEnabled()

void modules::motion::Motion::SetEnabled ( Axis  axis,
bool  enabled 
)

Set axis power status. One must manually ensure no moves are currently being performed by calling QueueEmpty().

◆ SetJerk()

void modules::motion::Motion::SetJerk ( Axis  axis,
steps_t  max_jerk 
)
inline

Set maximum jerk for the selected axis

Parameters
axisaxis affected
max_jerkmaximum jerk

◆ SetMode() [1/2]

void modules::motion::Motion::SetMode ( Axis  axis,
MotorMode  mode 
)

Set mode of TMC/motors operation. One must manually ensure no moves are currently being performed by calling QueueEmpty().

◆ SetMode() [2/2]

void modules::motion::Motion::SetMode ( MotorMode  mode)

Set the same mode of TMC/motors operation for all axes.

See also
SetMode

◆ SetPosition()

void modules::motion::Motion::SetPosition ( Axis  axis,
pos_t  x 
)
inline

Set the position of an axis. Should only be called when the queue is empty.

Parameters
axisaxis affected
xposition to set

◆ StallGuard()

bool modules::motion::Motion::StallGuard ( Axis  axis)
Returns
true if a StallGuard event occurred recently on the axis

◆ Step()

st_timer_t modules::motion::Motion::Step ( )
inline

State machine doing all the planning and stepping. Called by the stepping ISR.

Returns
the interval for the next tick

The documentation for this class was generated from the following files: