HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
tmc9660::TMC9660< CommType >::PositionControl Struct Reference

Subsystem for position control (FOC outer loop). More...

#include <tmc9660.hpp>

Collaboration diagram for tmc9660::TMC9660< CommType >::PositionControl:
[legend]

Classes

struct  PositionConfig
 Configuration structure for position control auto-configuration. More...
 

Public Member Functions

bool stop () noexcept
 Stop position control (SYSTEM_OFF).
 
bool setPositionSensor (tmc9660::tmcl::PositionSensorSelection sel) noexcept
 Select position feedback sensor.
 
bool getPositionSensor (tmc9660::tmcl::PositionSensorSelection &sel) noexcept
 Read position feedback sensor.
 
bool setTargetPosition (int32_t position) noexcept
 Set target position.
 
bool getActualPosition (int32_t &position) noexcept
 Read actual position.
 
bool setPositionScalingFactor (uint16_t factor) noexcept
 Set position scaling factor.
 
bool getPositionScalingFactor (uint16_t &factor) noexcept
 Read position scaling factor.
 
bool setPositionLoopGains (uint16_t p, uint16_t i) noexcept
 Configure position PI gains.
 
bool setPositionNormalization (tmc9660::tmcl::VelocityPiNorm p_norm, tmc9660::tmcl::VelocityPiNorm i_norm) noexcept
 Set position PI normalization.
 
bool getPositionPiIntegrator (int32_t &integrator) noexcept
 Read position-PI integrator.
 
bool getPositionPiError (int32_t &error) noexcept
 Read position-PI error.
 
bool setStopOnPositionDeviation (uint32_t max_error, bool softStop=true) noexcept
 Configure stop-on-position-deviation.
 
bool getStopOnPositionDeviation (uint32_t &max_error, bool &soft_stop) noexcept
 Read stop-on-position-deviation settings.
 
bool setPositionLoopDownsampling (uint8_t divider) noexcept
 Set position loop downsampling.
 
bool getPositionLoopDownsampling (uint8_t &divider) noexcept
 Read position loop downsampling.
 
bool setPositionLimitLow (int32_t limit) noexcept
 Set low position limit.
 
bool getPositionLimitLow (int32_t &limit) noexcept
 Read low position limit.
 
bool setPositionLimitHigh (int32_t limit) noexcept
 Set high position limit.
 
bool getPositionLimitHigh (int32_t &limit) noexcept
 Read high position limit.
 
bool setPositionReachedThreshold (uint32_t threshold) noexcept
 Set position reached threshold.
 
bool getPositionReachedThreshold (uint32_t &threshold) noexcept
 Read position reached threshold.
 
bool setReferenceSwitchEnable (tmc9660::tmcl::ReferenceSwitchEnable enable) noexcept
 Enable/disable reference switch stops.
 
bool getReferenceSwitchEnable (tmc9660::tmcl::ReferenceSwitchEnable &enable) noexcept
 Read reference switch enable mask.
 
bool setReferenceSwitchPolaritySwap (tmc9660::tmcl::ReferenceSwitchPolaritySwap config) noexcept
 Configure switch polarity and swap.
 
bool getReferenceSwitchPolaritySwap (tmc9660::tmcl::ReferenceSwitchPolaritySwap &config) noexcept
 Read switch polarity/swap config.
 
bool setReferenceSwitchLatchSettings (tmc9660::tmcl::ReferenceSwitchLatchSettings setting) noexcept
 Configure switch latch settings.
 
bool getReferenceSwitchLatchSettings (tmc9660::tmcl::ReferenceSwitchLatchSettings &setting) noexcept
 Read switch latch settings.
 
bool setEventStopSettings (tmc9660::tmcl::EventStopSettings settings) noexcept
 Configure event-stop settings.
 
bool getEventStopSettings (tmc9660::tmcl::EventStopSettings &settings) noexcept
 Read event-stop settings.
 
bool setReferenceSwitchSearchMode (tmc9660::tmcl::ReferenceSwitchSearchMode mode) noexcept
 Set reference search mode.
 
bool getReferenceSwitchSearchMode (tmc9660::tmcl::ReferenceSwitchSearchMode &mode) noexcept
 Read reference search mode.
 
bool setReferenceSwitchSearchSpeed (int32_t speed) noexcept
 Set reference search speed.
 
bool getReferenceSwitchSearchSpeed (int32_t &speed) noexcept
 Read reference search speed.
 
bool setReferenceSwitchSpeed (int32_t speed) noexcept
 Set reference positioning speed.
 
bool getReferenceSwitchSpeed (int32_t &speed) noexcept
 Read reference positioning speed.
 
bool getRightLimitSwitchPosition (int32_t &position) noexcept
 Read right-limit-switch position.
 
bool getHomeSwitchPosition (int32_t &position) noexcept
 Read home-switch position.
 
bool getLastReferencePosition (int32_t &position) noexcept
 Read last reference position.
 
bool configureAuto (const PositionConfig &config) noexcept
 Auto-configure position control parameters.
 
Raw Inputs (read-only)
bool getMccInputsRaw (uint16_t &inputs) noexcept
 

Private Member Functions

 PositionControl (TMC9660 &parent) noexcept
 

Private Attributes

TMC9660driver
 

Friends

class TMC9660
 

Detailed Description

template<typename CommType>
struct tmc9660::TMC9660< CommType >::PositionControl

Subsystem for position control (FOC outer loop).

Controls motor position using a PI controller that outputs velocity commands. Covers TMCL parameters 142–157, 161–170.

This control loop operates at a downsampled frequency relative to velocity loop. Position feedback can come from various sensors (ABN, SPI encoder).

Constructor & Destructor Documentation

◆ PositionControl()

template<typename CommType >
tmc9660::TMC9660< CommType >::PositionControl::PositionControl ( TMC9660 & parent)
inlineexplicitprivatenoexcept

Member Function Documentation

◆ configureAuto()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::configureAuto ( const PositionConfig & config)
noexcept

Auto-configure position control parameters.

Configures position sensor selection, PI gains, scaling, limits, and other position control parameters based on high-level characteristics.

Parameters
configPosition control configuration (see PositionConfig)
Returns
true if all configurations succeeded, false otherwise

◆ getActualPosition()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getActualPosition ( int32_t & position)
noexcept

Read actual position.

Parameters
[out]positionMeasured position.
Returns
true if read.

◆ getEventStopSettings()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getEventStopSettings ( tmc9660::tmcl::EventStopSettings & settings)
noexcept

Read event-stop settings.

Parameters
[out]settingsStop conditions.
Returns
true if read.

◆ getHomeSwitchPosition()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getHomeSwitchPosition ( int32_t & position)
noexcept

Read home-switch position.

Parameters
[out]positionPosition value.
Returns
true if read.

◆ getLastReferencePosition()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getLastReferencePosition ( int32_t & position)
noexcept

Read last reference position.

Parameters
[out]positionPosition value.
Returns
true if read.

◆ getMccInputsRaw()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getMccInputsRaw ( uint16_t & inputs)
noexcept

◆ getPositionLimitHigh()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionLimitHigh ( int32_t & limit)
noexcept

Read high position limit.

Parameters
[out]limitMaximum allowed position.
Returns
true if read.

◆ getPositionLimitLow()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionLimitLow ( int32_t & limit)
noexcept

Read low position limit.

Parameters
[out]limitMinimum allowed position.
Returns
true if read.

◆ getPositionLoopDownsampling()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionLoopDownsampling ( uint8_t & divider)
noexcept

Read position loop downsampling.

Parameters
[out]dividerFactor.
Returns
true if read.

◆ getPositionPiError()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionPiError ( int32_t & error)
noexcept

Read position-PI error.

Parameters
[out]errorPI error.
Returns
true if read.

◆ getPositionPiIntegrator()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionPiIntegrator ( int32_t & integrator)
noexcept

Read position-PI integrator.

Parameters
[out]integratorIntegrator value.
Returns
true if read.

◆ getPositionReachedThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionReachedThreshold ( uint32_t & threshold)
noexcept

Read position reached threshold.

Parameters
[out]thresholdLatch threshold.
Returns
true if read.

◆ getPositionScalingFactor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionScalingFactor ( uint16_t & factor)
noexcept

Read position scaling factor.

Parameters
[out]factorScale factor.
Returns
true if read.

◆ getPositionSensor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getPositionSensor ( tmc9660::tmcl::PositionSensorSelection & sel)
noexcept

Read position feedback sensor.

Parameters
[out]selSensor selection.
Returns
true if read.

◆ getReferenceSwitchEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchEnable ( tmc9660::tmcl::ReferenceSwitchEnable & enable)
noexcept

Read reference switch enable mask.

Parameters
[out]enableMask.
Returns
true if read.

◆ getReferenceSwitchLatchSettings()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchLatchSettings ( tmc9660::tmcl::ReferenceSwitchLatchSettings & setting)
noexcept

Read switch latch settings.

Parameters
[out]settingLatch behavior.
Returns
true if read.

◆ getReferenceSwitchPolaritySwap()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchPolaritySwap ( tmc9660::tmcl::ReferenceSwitchPolaritySwap & config)
noexcept

Read switch polarity/swap config.

Parameters
[out]configConfig.
Returns
true if read.

◆ getReferenceSwitchSearchMode()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchSearchMode ( tmc9660::tmcl::ReferenceSwitchSearchMode & mode)
noexcept

Read reference search mode.

Parameters
[out]modeSearch sequence.
Returns
true if read.

◆ getReferenceSwitchSearchSpeed()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchSearchSpeed ( int32_t & speed)
noexcept

Read reference search speed.

Parameters
[out]speedSearch velocity.
Returns
true if read.

◆ getReferenceSwitchSpeed()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getReferenceSwitchSpeed ( int32_t & speed)
noexcept

Read reference positioning speed.

Parameters
[out]speedApproach speed.
Returns
true if read.

◆ getRightLimitSwitchPosition()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getRightLimitSwitchPosition ( int32_t & position)
noexcept

Read right-limit-switch position.

Parameters
[out]positionPosition value.
Returns
true if read.

◆ getStopOnPositionDeviation()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::getStopOnPositionDeviation ( uint32_t & max_error,
bool & soft_stop )
noexcept

Read stop-on-position-deviation settings.

Parameters
[out]max_errorConfigured max deviation.
[out]soft_stopSoft/hard stop flag.
Returns
true if read.

◆ setEventStopSettings()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setEventStopSettings ( tmc9660::tmcl::EventStopSettings settings)
noexcept

Configure event-stop settings.

Parameters
settingsStop conditions.
Returns
true if written.

◆ setPositionLimitHigh()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionLimitHigh ( int32_t limit)
noexcept

Set high position limit.

Parameters
limitMaximum allowed position.
Returns
true if written.

◆ setPositionLimitLow()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionLimitLow ( int32_t limit)
noexcept

Set low position limit.

Parameters
limitMinimum allowed position.
Returns
true if written.

◆ setPositionLoopDownsampling()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionLoopDownsampling ( uint8_t divider)
noexcept

Set position loop downsampling.

Parameters
dividerDownsample factor.
Returns
true if written.

◆ setPositionLoopGains()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionLoopGains ( uint16_t p,
uint16_t i )
noexcept

Configure position PI gains.

Parameters
pP gain.
iI gain.
Returns
true if written.

◆ setPositionNormalization()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionNormalization ( tmc9660::tmcl::VelocityPiNorm p_norm,
tmc9660::tmcl::VelocityPiNorm i_norm )
noexcept

Set position PI normalization.

Parameters
p_normP-term norm.
i_normI-term norm.
Returns
true if written.

◆ setPositionReachedThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionReachedThreshold ( uint32_t threshold)
noexcept

Set position reached threshold.

Parameters
thresholdLatch threshold.
Returns
true if written.

◆ setPositionScalingFactor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionScalingFactor ( uint16_t factor)
noexcept

Set position scaling factor.

Parameters
factorScale factor.
Returns
true if written.

◆ setPositionSensor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setPositionSensor ( tmc9660::tmcl::PositionSensorSelection sel)
noexcept

Select position feedback sensor.

Parameters
selSensor selection.
Returns
true if written.

◆ setReferenceSwitchEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchEnable ( tmc9660::tmcl::ReferenceSwitchEnable enable)
noexcept

Enable/disable reference switch stops.

Parameters
enableBitmask of switch stops.
Returns
true if written.

◆ setReferenceSwitchLatchSettings()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchLatchSettings ( tmc9660::tmcl::ReferenceSwitchLatchSettings setting)
noexcept

Configure switch latch settings.

Parameters
settingLatch behavior.
Returns
true if written.

◆ setReferenceSwitchPolaritySwap()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchPolaritySwap ( tmc9660::tmcl::ReferenceSwitchPolaritySwap config)
noexcept

Configure switch polarity and swap.

Parameters
configPolarity/swap config.
Returns
true if written.

◆ setReferenceSwitchSearchMode()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchSearchMode ( tmc9660::tmcl::ReferenceSwitchSearchMode mode)
noexcept

Set reference search mode.

Parameters
modeSearch sequence.
Returns
true if written.

◆ setReferenceSwitchSearchSpeed()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchSearchSpeed ( int32_t speed)
noexcept

Set reference search speed.

Parameters
speedSearch velocity.
Returns
true if written.

◆ setReferenceSwitchSpeed()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setReferenceSwitchSpeed ( int32_t speed)
noexcept

Set reference positioning speed.

Parameters
speedApproach speed.
Returns
true if written.

◆ setStopOnPositionDeviation()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setStopOnPositionDeviation ( uint32_t max_error,
bool softStop = true )
noexcept

Configure stop-on-position-deviation.

Parameters
max_errorMax allowed deviation.
soft_stoptrue for ramp down, false for hard stop.
Returns
true if written.

◆ setTargetPosition()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::setTargetPosition ( int32_t position)
noexcept

Set target position.

Parameters
positionDesired position (internal units).
Returns
true if written.

◆ stop()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::PositionControl::stop ( )
noexcept

Stop position control (SYSTEM_OFF).

Returns
true on success.

Friends And Related Symbol Documentation

◆ TMC9660

template<typename CommType >
friend class TMC9660
friend

Member Data Documentation

◆ driver

template<typename CommType >
TMC9660& tmc9660::TMC9660< CommType >::PositionControl::driver
private

The documentation for this struct was generated from the following file: