Prusa-MMU-Private
PrusaMultiMaterialUpgradev3firmwareforMK3SMK4
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
modules::motion::MovableBase Class Referenceabstract

Base class for movable modules - modules::idler::Idler and modules::selector::Selector contains the common code. More...

#include <movable_base.h>

Inheritance diagram for modules::motion::MovableBase:
Inheritance graph
[legend]
Collaboration diagram for modules::motion::MovableBase:
Collaboration graph
[legend]

Public Types

enum  {
  Ready = 0 , Moving = 1 , PlannedHome = 2 , HomeForward = 3 ,
  HomeBack = 4 , TMCFailed = 5 , HomingFailed = 6 , OnHold = 0x80
}
 Internal states of the state machine. More...
 
enum class  OperationResult : uint8_t { Accepted , Refused , Failed }
 Operation (Engage/Disengage/MoveToSlot) return values. More...
 

Public Member Functions

constexpr MovableBase (config::Axis axis)
 
uint8_t Slot () const
 virtual ~MovableBase(); intentionally disabled, see description in logic::CommandBase More...
 
uint8_t State () const
 
hal::tmc2130::ErrorFlags TMCErrorFlags () const
 
void InvalidateHoming ()
 
OperationResult PlanHome ()
 
bool HomingValid () const
 
config::Axis Axis () const
 
void SetCurrents (uint8_t iRun, uint8_t iHold)
 
void HoldOn ()
 
bool IsOnHold () const
 
void Resume ()
 Allows the movable to move/home again after begin suspended by HoldOn.
 

Protected Member Functions

virtual void PrepareMoveToPlannedSlot ()=0
 
virtual void PlanHomingMoveForward ()=0
 
virtual void PlanHomingMoveBack ()=0
 
virtual bool FinishHomingAndPlanMoveToParkPos ()=0
 
virtual void FinishMove ()=0
 
virtual bool StallGuardAllowed (bool forward) const
 
OperationResult InitMovement ()
 
OperationResult InitMovementNoReinitAxis ()
 Initializes movement of a movable module without reinitializing the axis/TMC driver.
 
void PerformMove ()
 
void PerformHomeForward ()
 
void PerformHomeBack ()
 
void HomeFailed ()
 
void CheckTMC ()
 
uint16_t AxisDistance (int32_t curPos) const
 

Protected Attributes

uint8_t state
 internal state of the automaton
 
uint8_t plannedSlot
 planned slot - where to move to
 
uint8_t currentSlot
 current slot
 
bool homingValid
 true if the axis is considered as homed
 
hal::tmc2130::ErrorFlags tmcErrorFlags
 cached TMC2130 error flags - being read only if the axis is enabled and doing something (moving)
 
config::Axis axis
 
int32_t axisStart
 

Detailed Description

Base class for movable modules - modules::idler::Idler and modules::selector::Selector contains the common code.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Internal states of the state machine.

Enumerator
OnHold 

needs to be a separate bit due to homing recovery infrastructure

◆ OperationResult

Operation (Engage/Disengage/MoveToSlot) return values.

Enumerator
Accepted 

the operation has been successfully started

Refused 

another operation is currently underway, cannot start a new one

Failed 

the operation could not been started due to HW issues

Member Function Documentation

◆ FinishHomingAndPlanMoveToParkPos()

virtual bool modules::motion::MovableBase::FinishHomingAndPlanMoveToParkPos ( )
protectedpure virtual
Returns
true if the measured axis length is within the expected range, false otherwise

Implemented in modules::selector::Selector, modules::pulley::Pulley, and modules::idler::Idler.

◆ HoldOn()

void modules::motion::MovableBase::HoldOn ( )

Puts the movable on-hold Also, disables the axis

◆ InitMovement()

MovableBase::OperationResult modules::motion::MovableBase::InitMovement ( )
protected

Initializes movement of a movable module. Beware: this operation reinitializes the axis/TMC driver as well (may introduce axis creep as we have seen on the Idler)

◆ InvalidateHoming()

void modules::motion::MovableBase::InvalidateHoming ( )
inline

Invalidates the homing flag - that is now used to inform the movable component (Idler or Selector) that their current coordinates may have been compromised and a new homing move is to be performed. Each movable component performs the homing move immediately after it is possible to do so:

  • Idler immediately (and then moves to desired slot again)
  • Selector once there is no filament stuck in it (and then moves to desired slot again) Homing procedure therefore becomes completely transparent to upper layers and it will not be necessary to call it explicitly. Please note this method does not clear any planned move on the component
  • on the contrary - the planned move will be peformed immediately after homing (which makes homing completely transparent)

◆ IsOnHold()

bool modules::motion::MovableBase::IsOnHold ( ) const
inline
Returns
true if the movable is on-hold

◆ PlanHome()

MovableBase::OperationResult modules::motion::MovableBase::PlanHome ( )

Prepare a homing move of the axis

Returns
true if the move has been planned successfully (i.e. movable is NOT on-hold)

◆ SetCurrents()

void modules::motion::MovableBase::SetCurrents ( uint8_t  iRun,
uint8_t  iHold 
)

Set TMC2130 iRun current level for this axis iRun == 0 means set the default from config

◆ Slot()

uint8_t modules::motion::MovableBase::Slot ( ) const
inline

virtual ~MovableBase(); intentionally disabled, see description in logic::CommandBase

Returns
currently active slot This state is updated only when a planned move is successfully finished, so it is safe for higher-level state machines to use this call as a waiting condition for the desired state of the derive class (idler/selector) While homing, Slot() returns 0xff as the current slot index is invalid.

◆ StallGuardAllowed()

virtual bool modules::motion::MovableBase::StallGuardAllowed ( bool  forward) const
inlineprotectedvirtual
Returns
true if the StallGuard signal is to be considered while homing. It may sound counterintuitive, but due to SG/homing issues on the Idler, it needs to avoid processing the SG while rotating over the filament. The Idler must consider SG signal only when close to its real end stops. Selector considers the SG signal all the time while homing, therefore the default implementation is empty

Reimplemented in modules::idler::Idler.

◆ State()

uint8_t modules::motion::MovableBase::State ( ) const
inline
Returns
internal state of the state machine

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