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

Subsystem for torque and flux current control (FOC inner loop). More...

#include <tmc9660.hpp>

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

Classes

struct  TorqueFluxConfig
 Configuration structure for torque/flux control auto-configuration. More...
 

Public Member Functions

bool stop () noexcept
 Stop torque/flux control (SYSTEM_OFF).
 
bool setTargetTorque (int16_t milliamps) noexcept
 Set desired torque.
 
bool getActualTorque (int16_t &milliamps) noexcept
 Read actual torque.
 
bool setTargetFlux (int16_t milliamps) noexcept
 Set desired flux current.
 
bool getActualFlux (int32_t &milliamps) noexcept
 Read actual flux current.
 
bool setTorqueOffset (int16_t milliamps) noexcept
 Set torque offset (feed-forward).
 
bool getTorqueOffset (int16_t &milliamps) noexcept
 Read torque offset.
 
bool setFluxOffset (int16_t milliamps) noexcept
 Set flux offset (feed-forward).
 
bool getFluxOffset (int16_t &milliamps) noexcept
 Read flux offset.
 
bool setCurrentLoopGains (uint16_t p, uint16_t i, bool separate=false, uint16_t fluxP=0, uint16_t fluxI=0) noexcept
 Configure current-loop PI gains.
 
bool setTorqueFluxPiSeparation (tmc9660::tmcl::TorqueFluxPiSeparation sep) noexcept
 Select combined or separate torque/flux PI parameters.
 
bool setCurrentNormalization (tmc9660::tmcl::CurrentPiNormalization p_norm, tmc9660::tmcl::CurrentPiNormalization i_norm) noexcept
 Set normalization for current-PI outputs.
 
bool getTorquePiError (int32_t &error) noexcept
 Read torque PI error.
 
bool getFluxPiError (int32_t &error) noexcept
 Read flux PI error.
 
bool getTorquePiIntegrator (int32_t &integrator) noexcept
 Read torque-PI integrator state.
 
bool getFluxPiIntegrator (int32_t &integrator) noexcept
 Read flux-PI integrator state.
 
bool getOpenloopAngle (int16_t &angle) noexcept
 Read open-loop angle.
 
bool setOpenloopCurrent (uint16_t milliamps) noexcept
 Set open-loop current.
 
bool getOpenloopCurrent (uint16_t &milliamps) noexcept
 Read open-loop current.
 
bool setOpenloopVoltage (uint16_t voltage) noexcept
 Set open-loop voltage.
 
bool getOpenloopVoltage (uint16_t &voltage) noexcept
 Read open-loop voltage.
 
bool configureAuto (const TorqueFluxConfig &config) noexcept
 Auto-configure torque/flux control parameters.
 
Field-weakening (read/write)
bool setFieldWeakeningI (uint16_t milliamps) noexcept
 
bool getFieldWeakeningI (uint16_t &milliamps) noexcept
 
bool setFieldWeakeningVoltageThreshold (uint16_t voltage) noexcept
 
bool getFieldWeakeningVoltageThreshold (uint16_t &voltage) noexcept
 
Target Torque Biquad Filter (read/write)
bool setTargetTorqueBiquadFilterEnable (bool enable) noexcept
 
bool getTargetTorqueBiquadFilterEnable (bool &enable) noexcept
 
bool setTargetTorqueBiquadFilterACoeff1 (int32_t coeff) noexcept
 
bool getTargetTorqueBiquadFilterACoeff1 (int32_t &coeff) noexcept
 
bool setTargetTorqueBiquadFilterACoeff2 (int32_t coeff) noexcept
 
bool getTargetTorqueBiquadFilterACoeff2 (int32_t &coeff) noexcept
 
bool setTargetTorqueBiquadFilterBCoeff0 (int32_t coeff) noexcept
 
bool getTargetTorqueBiquadFilterBCoeff0 (int32_t &coeff) noexcept
 
bool setTargetTorqueBiquadFilterBCoeff1 (int32_t coeff) noexcept
 
bool getTargetTorqueBiquadFilterBCoeff1 (int32_t &coeff) noexcept
 
bool setTargetTorqueBiquadFilterBCoeff2 (int32_t coeff) noexcept
 
bool getTargetTorqueBiquadFilterBCoeff2 (int32_t &coeff) noexcept
 
Intermediate FOC Voltages (read-only)
bool getFocVoltageUx (int16_t &voltage) noexcept
 
bool getFocVoltageWy (int16_t &voltage) noexcept
 
bool getFocVoltageV (int16_t &voltage) noexcept
 
bool getFocVoltageUq (int16_t &voltage) noexcept
 
Intermediate FOC Currents (read-only)
bool getFocCurrentUx (int16_t &milliamps) noexcept
 
bool getFocCurrentV (int16_t &milliamps) noexcept
 
bool getFocCurrentWy (int16_t &milliamps) noexcept
 
bool getFocCurrentIq (int16_t &milliamps) noexcept
 
Combined & integrated raw measurements (read-only)
bool getTorqueFluxCombinedTargetValues (uint32_t &value) noexcept
 
bool getTorqueFluxCombinedActualValues (uint32_t &value) noexcept
 
bool getVoltageDqCombinedActualValues (uint32_t &value) noexcept
 
bool getIntegratedActualTorqueValue (uint32_t &value) noexcept
 

Private Member Functions

 TorqueFluxControl (TMC9660 &parent) noexcept
 

Private Attributes

TMC9660driver
 

Friends

class TMC9660
 

Detailed Description

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

Subsystem for torque and flux current control (FOC inner loop).

Controls the motor currents (torque and flux) using hardware PI controllers. Covers TMCL parameters 104–120, 308, 310.

This is the innermost control loop, operating at PWM frequency. Torque control is used for direct current control, while flux control enables field weakening for high-speed operation.

Constructor & Destructor Documentation

◆ TorqueFluxControl()

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

Member Function Documentation

◆ configureAuto()

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

Auto-configure torque/flux control parameters.

Configures PI gains, normalization, field weakening, and offsets based on high-level control characteristics.

Parameters
configTorque/flux control configuration (see TorqueFluxConfig)
Returns
true if all configurations succeeded, false otherwise

◆ getActualFlux()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getActualFlux ( int32_t & milliamps)
noexcept

Read actual flux current.

Parameters
[out]milliampsActual flux in m_a.
Returns
true if read.

◆ getActualTorque()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getActualTorque ( int16_t & milliamps)
noexcept

Read actual torque.

Parameters
[out]milliampsActual torque in m_a.
Returns
true if read.

◆ getFieldWeakeningI()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFieldWeakeningI ( uint16_t & milliamps)
noexcept

◆ getFieldWeakeningVoltageThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFieldWeakeningVoltageThreshold ( uint16_t & voltage)
noexcept

◆ getFluxOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFluxOffset ( int16_t & milliamps)
noexcept

Read flux offset.

Parameters
[out]milliampsOffset in m_a.
Returns
true if read.

◆ getFluxPiError()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFluxPiError ( int32_t & error)
noexcept

Read flux PI error.

Parameters
[out]errorCurrent flux-PI error.
Returns
true if read.

◆ getFluxPiIntegrator()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFluxPiIntegrator ( int32_t & integrator)
noexcept

Read flux-PI integrator state.

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

◆ getFocCurrentIq()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocCurrentIq ( int16_t & milliamps)
noexcept

◆ getFocCurrentUx()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocCurrentUx ( int16_t & milliamps)
noexcept

◆ getFocCurrentV()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocCurrentV ( int16_t & milliamps)
noexcept

◆ getFocCurrentWy()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocCurrentWy ( int16_t & milliamps)
noexcept

◆ getFocVoltageUq()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocVoltageUq ( int16_t & voltage)
noexcept

◆ getFocVoltageUx()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocVoltageUx ( int16_t & voltage)
noexcept

◆ getFocVoltageV()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocVoltageV ( int16_t & voltage)
noexcept

◆ getFocVoltageWy()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getFocVoltageWy ( int16_t & voltage)
noexcept

◆ getIntegratedActualTorqueValue()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getIntegratedActualTorqueValue ( uint32_t & value)
noexcept

◆ getOpenloopAngle()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getOpenloopAngle ( int16_t & angle)
noexcept

Read open-loop angle.

Parameters
[out]angleElectrical angle.
Returns
true if read.

◆ getOpenloopCurrent()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getOpenloopCurrent ( uint16_t & milliamps)
noexcept

Read open-loop current.

Parameters
[out]milliampsCurrent in m_a.
Returns
true if read.

◆ getOpenloopVoltage()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getOpenloopVoltage ( uint16_t & voltage)
noexcept

Read open-loop voltage.

Parameters
[out]voltageVoltage unit.
Returns
true if read.

◆ getTargetTorqueBiquadFilterACoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterACoeff1 ( int32_t & coeff)
noexcept

◆ getTargetTorqueBiquadFilterACoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterACoeff2 ( int32_t & coeff)
noexcept

◆ getTargetTorqueBiquadFilterBCoeff0()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterBCoeff0 ( int32_t & coeff)
noexcept

◆ getTargetTorqueBiquadFilterBCoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterBCoeff1 ( int32_t & coeff)
noexcept

◆ getTargetTorqueBiquadFilterBCoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterBCoeff2 ( int32_t & coeff)
noexcept

◆ getTargetTorqueBiquadFilterEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTargetTorqueBiquadFilterEnable ( bool & enable)
noexcept

◆ getTorqueFluxCombinedActualValues()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTorqueFluxCombinedActualValues ( uint32_t & value)
noexcept

◆ getTorqueFluxCombinedTargetValues()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTorqueFluxCombinedTargetValues ( uint32_t & value)
noexcept

◆ getTorqueOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTorqueOffset ( int16_t & milliamps)
noexcept

Read torque offset.

Parameters
[out]milliampsOffset in m_a.
Returns
true if read.

◆ getTorquePiError()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTorquePiError ( int32_t & error)
noexcept

Read torque PI error.

Parameters
[out]errorCurrent torque-PI error.
Returns
true if read.

◆ getTorquePiIntegrator()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getTorquePiIntegrator ( int32_t & integrator)
noexcept

Read torque-PI integrator state.

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

◆ getVoltageDqCombinedActualValues()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::getVoltageDqCombinedActualValues ( uint32_t & value)
noexcept

◆ setCurrentLoopGains()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setCurrentLoopGains ( uint16_t p,
uint16_t i,
bool separate = false,
uint16_t fluxP = 0,
uint16_t fluxI = 0 )
noexcept

Configure current-loop PI gains.

Parameters
pProportional gain for torque (and flux if not separate).
iIntegral gain for torque (and flux if not separate).
separatetrue to use separate flux gains.
flux_pProportional gain for flux loop.
flux_iIntegral gain for flux loop.
Returns
true if written.

◆ setCurrentNormalization()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setCurrentNormalization ( tmc9660::tmcl::CurrentPiNormalization p_norm,
tmc9660::tmcl::CurrentPiNormalization i_norm )
noexcept

Set normalization for current-PI outputs.

Parameters
p_normNormalization for P-term.
i_normNormalization for I-term.
Returns
true if written.

◆ setFieldWeakeningI()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setFieldWeakeningI ( uint16_t milliamps)
noexcept

◆ setFieldWeakeningVoltageThreshold()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setFieldWeakeningVoltageThreshold ( uint16_t voltage)
noexcept

◆ setFluxOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setFluxOffset ( int16_t milliamps)
noexcept

Set flux offset (feed-forward).

Parameters
milliampsOffset in m_a.
Returns
true if written.

◆ setOpenloopCurrent()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setOpenloopCurrent ( uint16_t milliamps)
noexcept

Set open-loop current.

Parameters
milliampsCurrent in m_a.
Returns
true if written.

◆ setOpenloopVoltage()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setOpenloopVoltage ( uint16_t voltage)
noexcept

Set open-loop voltage.

Parameters
voltageVoltage unit (0…32767).
Returns
true if written.

◆ setTargetFlux()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetFlux ( int16_t milliamps)
noexcept

Set desired flux current.

Parameters
milliampsTarget flux in m_a.
Returns
true if written.

◆ setTargetTorque()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorque ( int16_t milliamps)
noexcept

Set desired torque.

Parameters
milliampsTarget torque in m_a.
Returns
true if written.

◆ setTargetTorqueBiquadFilterACoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterACoeff1 ( int32_t coeff)
noexcept

◆ setTargetTorqueBiquadFilterACoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterACoeff2 ( int32_t coeff)
noexcept

◆ setTargetTorqueBiquadFilterBCoeff0()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterBCoeff0 ( int32_t coeff)
noexcept

◆ setTargetTorqueBiquadFilterBCoeff1()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterBCoeff1 ( int32_t coeff)
noexcept

◆ setTargetTorqueBiquadFilterBCoeff2()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterBCoeff2 ( int32_t coeff)
noexcept

◆ setTargetTorqueBiquadFilterEnable()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTargetTorqueBiquadFilterEnable ( bool enable)
noexcept

◆ setTorqueFluxPiSeparation()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTorqueFluxPiSeparation ( tmc9660::tmcl::TorqueFluxPiSeparation sep)
noexcept

Select combined or separate torque/flux PI parameters.

Parameters
sepSeparation mode.
Returns
true if written.

◆ setTorqueOffset()

template<typename CommType >
bool tmc9660::TMC9660< CommType >::TorqueFluxControl::setTorqueOffset ( int16_t milliamps)
noexcept

Set torque offset (feed-forward).

Parameters
milliampsOffset in m_a.
Returns
true if written.

◆ stop()

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

Stop torque/flux 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 >::TorqueFluxControl::driver
private

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