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

Subsystem for velocity control (FOC middle loop). More...

#include <tmc9660.hpp>

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

Classes

struct  VelocityConfig
 Configuration structure for velocity control auto-configuration. More...
 

Public Member Functions

bool stop () noexcept
 Stop velocity control (SYSTEM_OFF).
 
bool setVelocitySensor (tmc9660::tmcl::VelocitySensorSelection sel) noexcept
 Select velocity feedback sensor.
 
bool getVelocitySensor (tmc9660::tmcl::VelocitySensorSelection &sel) noexcept
 Read velocity feedback sensor.
 
bool setTargetVelocity (int32_t velocity) noexcept
 Set target velocity.
 
bool getActualVelocity (int32_t &velocity) noexcept
 Read actual velocity.
 
bool setVelocityOffset (int32_t offset) noexcept
 Set velocity offset.
 
bool getVelocityOffset (int32_t &offset) noexcept
 Read velocity offset.
 
bool setVelocityLoopGains (uint16_t p, uint16_t i) noexcept
 Configure velocity PI gains.
 
bool setVelocityNormalization (tmc9660::tmcl::VelocityPiNorm p_norm, tmc9660::tmcl::VelocityPiNorm i_norm) noexcept
 Set velocity PI normalization.
 
bool getVelocityPiIntegrator (int32_t &integrator) noexcept
 Read velocity-PI integrator.
 
bool getVelocityPiError (int32_t &error) noexcept
 Read velocity-PI error.
 
bool setVelocityScalingFactor (uint16_t factor) noexcept
 Set velocity scaling factor.
 
bool getVelocityScalingFactor (uint16_t &factor) noexcept
 Read velocity scaling factor.
 
bool setStopOnVelocityDeviation (uint32_t max_error, bool softStop=true) noexcept
 Configure stop-on-velocity-deviation.
 
bool getStopOnVelocityDeviation (uint32_t &max_error, bool &soft_stop) noexcept
 Read stop-on-velocity-deviation settings.
 
bool setVelocityLoopDownsampling (uint8_t divider) noexcept
 Set velocity loop downsampling.
 
bool getVelocityLoopDownsampling (uint8_t &divider) noexcept
 Read velocity loop downsampling.
 
bool setVelocityMeterSwitchThreshold (uint32_t threshold) noexcept
 Set velocity meter switch threshold.
 
bool getVelocityMeterSwitchThreshold (uint32_t &threshold) noexcept
 Read velocity meter switch threshold.
 
bool setVelocityMeterSwitchHysteresis (uint16_t hysteresis) noexcept
 Set velocity meter hysteresis.
 
bool getVelocityMeterSwitchHysteresis (uint16_t &hysteresis) noexcept
 Read velocity meter hysteresis.
 
bool getVelocityMeterMode (tmc9660::tmcl::VelocityMeterMode &mode) noexcept
 Read current velocity meter mode.
 
bool configureAuto (const VelocityConfig &config) noexcept
 Auto-configure velocity control parameters.
 
Actual Velocity Biquad Filter (read/write)
bool setActualVelocityBiquadFilterEnable (bool enable) noexcept
 
bool getActualVelocityBiquadFilterEnable (bool &enable) noexcept
 
bool setActualVelocityBiquadFilterACoeff1 (int32_t coeff) noexcept
 
bool getActualVelocityBiquadFilterACoeff1 (int32_t &coeff) noexcept
 
bool setActualVelocityBiquadFilterACoeff2 (int32_t coeff) noexcept
 
bool getActualVelocityBiquadFilterACoeff2 (int32_t &coeff) noexcept
 
bool setActualVelocityBiquadFilterBCoeff0 (int32_t coeff) noexcept
 
bool getActualVelocityBiquadFilterBCoeff0 (int32_t &coeff) noexcept
 
bool setActualVelocityBiquadFilterBCoeff1 (int32_t coeff) noexcept
 
bool getActualVelocityBiquadFilterBCoeff1 (int32_t &coeff) noexcept
 
bool setActualVelocityBiquadFilterBCoeff2 (int32_t coeff) noexcept
 
bool getActualVelocityBiquadFilterBCoeff2 (int32_t &coeff) noexcept
 
Combined & integrated raw measurements (read-only)
bool getIntegratedActualVelocityValue (uint32_t &value) noexcept
 

Private Member Functions

 VelocityControl (TMC9660 &parent) noexcept
 

Private Attributes

TMC9660driver
 

Friends

class TMC9660
 

Detailed Description

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

Subsystem for velocity control (FOC middle loop).

Controls motor velocity using a PI controller that outputs torque commands. Covers TMCL parameters 123–139.

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

Constructor & Destructor Documentation

◆ VelocityControl()

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

Member Function Documentation

◆ configureAuto()

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

Auto-configure velocity control parameters.

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

Parameters
configVelocity control configuration (see VelocityConfig)
Returns
true if all configurations succeeded, false otherwise

◆ getActualVelocity()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocity ( int32_t & velocity)
noexcept

Read actual velocity.

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

◆ getActualVelocityBiquadFilterACoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterACoeff1 ( int32_t & coeff)
noexcept

◆ getActualVelocityBiquadFilterACoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterACoeff2 ( int32_t & coeff)
noexcept

◆ getActualVelocityBiquadFilterBCoeff0()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterBCoeff0 ( int32_t & coeff)
noexcept

◆ getActualVelocityBiquadFilterBCoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterBCoeff1 ( int32_t & coeff)
noexcept

◆ getActualVelocityBiquadFilterBCoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterBCoeff2 ( int32_t & coeff)
noexcept

◆ getActualVelocityBiquadFilterEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getActualVelocityBiquadFilterEnable ( bool & enable)
noexcept

◆ getIntegratedActualVelocityValue()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getIntegratedActualVelocityValue ( uint32_t & value)
noexcept

◆ getStopOnVelocityDeviation()

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

Read stop-on-velocity-deviation settings.

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

◆ getVelocityLoopDownsampling()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityLoopDownsampling ( uint8_t & divider)
noexcept

Read velocity loop downsampling.

Parameters
[out]dividerFactor.
Returns
true if read.

◆ getVelocityMeterMode()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityMeterMode ( tmc9660::tmcl::VelocityMeterMode & mode)
noexcept

Read current velocity meter mode.

Parameters
[out]modeCurrent mode.
Returns
true if read.

◆ getVelocityMeterSwitchHysteresis()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityMeterSwitchHysteresis ( uint16_t & hysteresis)
noexcept

Read velocity meter hysteresis.

Parameters
[out]hysteresisHysteresis.
Returns
true if read.

◆ getVelocityMeterSwitchThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityMeterSwitchThreshold ( uint32_t & threshold)
noexcept

Read velocity meter switch threshold.

Parameters
[out]thresholdThreshold.
Returns
true if read.

◆ getVelocityOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityOffset ( int32_t & offset)
noexcept

Read velocity offset.

Parameters
[out]offsetOffset in RPM.
Returns
true if read.

◆ getVelocityPiError()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityPiError ( int32_t & error)
noexcept

Read velocity-PI error.

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

◆ getVelocityPiIntegrator()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityPiIntegrator ( int32_t & integrator)
noexcept

Read velocity-PI integrator.

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

◆ getVelocityScalingFactor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocityScalingFactor ( uint16_t & factor)
noexcept

Read velocity scaling factor.

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

◆ getVelocitySensor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::getVelocitySensor ( tmc9660::tmcl::VelocitySensorSelection & sel)
noexcept

Read velocity feedback sensor.

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

◆ setActualVelocityBiquadFilterACoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterACoeff1 ( int32_t coeff)
noexcept

◆ setActualVelocityBiquadFilterACoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterACoeff2 ( int32_t coeff)
noexcept

◆ setActualVelocityBiquadFilterBCoeff0()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterBCoeff0 ( int32_t coeff)
noexcept

◆ setActualVelocityBiquadFilterBCoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterBCoeff1 ( int32_t coeff)
noexcept

◆ setActualVelocityBiquadFilterBCoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterBCoeff2 ( int32_t coeff)
noexcept

◆ setActualVelocityBiquadFilterEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setActualVelocityBiquadFilterEnable ( bool enable)
noexcept

◆ setStopOnVelocityDeviation()

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

Configure stop-on-velocity-deviation.

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

◆ setTargetVelocity()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setTargetVelocity ( int32_t velocity)
noexcept

Set target velocity.

Parameters
velocityTarget velocity (internal units).
Returns
true if written.

◆ setVelocityLoopDownsampling()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocityLoopDownsampling ( uint8_t divider)
noexcept

Set velocity loop downsampling.

Parameters
dividerDownsample factor.
Returns
true if written.

◆ setVelocityLoopGains()

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

Configure velocity PI gains.

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

◆ setVelocityMeterSwitchHysteresis()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocityMeterSwitchHysteresis ( uint16_t hysteresis)
noexcept

Set velocity meter hysteresis.

Parameters
hysteresisHysteresis value.
Returns
true if written.

◆ setVelocityMeterSwitchThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocityMeterSwitchThreshold ( uint32_t threshold)
noexcept

Set velocity meter switch threshold.

Parameters
thresholdThreshold value.
Returns
true if written.

◆ setVelocityNormalization()

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

Set velocity PI normalization.

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

◆ setVelocityOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocityOffset ( int32_t offset)
noexcept

Set velocity offset.

Parameters
offsetOffset in RPM.
Returns
true if written.

◆ setVelocityScalingFactor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocityScalingFactor ( uint16_t factor)
noexcept

Set velocity scaling factor.

Parameters
factorScale factor.
Returns
true if written.

◆ setVelocitySensor()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::VelocityControl::setVelocitySensor ( tmc9660::tmcl::VelocitySensorSelection sel)
noexcept

Select velocity feedback sensor.

Parameters
selSensor selection.
Returns
true if written.

◆ stop()

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

Stop velocity 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 >::VelocityControl::driver
private

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