HF-TMC9660 Driver
Hardware Agnostic C++ Driver for the TMC9660
Loading...
Searching...
No Matches
TMC9660::FeedbackSense Struct Reference

Subsystem for feedback sensor configuration. More...

#include <TMC9660.hpp>

Collaboration diagram for TMC9660::FeedbackSense:

Public Member Functions

bool configureHall (tmc9660::tmcl::HallSectorOffset sectorOffset=tmc9660::tmcl::HallSectorOffset::DEG_0, tmc9660::tmcl::Direction inverted=tmc9660::tmcl::Direction::NOT_INVERTED, tmc9660::tmcl::EnableDisable enableExtrapolation=tmc9660::tmcl::EnableDisable::DISABLED, uint8_t filterLength=0) noexcept
 Configure digital Hall sensors for BLDC commutation.
 
bool setHallPositionOffsets (int16_t offset0=0, int16_t offset60=10922, int16_t offset120=21845, int16_t offset180=-32768, int16_t offset240=-21846, int16_t offset300=-10923, int16_t globalOffset=0) noexcept
 Set Hall sensor position offsets for improved accuracy.
 
bool getHallPhiE (int16_t &phiE) noexcept
 Read the electrical angle (phi_e) calculated from Hall feedback.
 
bool configureABNEncoder (uint32_t countsPerRev, tmc9660::tmcl::Direction inverted=tmc9660::tmcl::Direction::NOT_INVERTED, tmc9660::tmcl::EnableDisable nChannelInverted=tmc9660::tmcl::EnableDisable::DISABLED) noexcept
 Configure an ABN incremental encoder for feedback.
 
bool configureABNInitialization (tmc9660::tmcl::AbnInitMethod initMethod=tmc9660::tmcl::AbnInitMethod::FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING, uint16_t initDelay=1000, int32_t initVelocity=5, int16_t nChannelOffset=0) noexcept
 Configure ABN encoder initialization method.
 
bool getABNInitializationState (tmc9660::tmcl::AbnInitState &state) noexcept
 Read the current state of ABN encoder initialization.
 
bool getABNPhiE (int16_t &phiE) noexcept
 Read the electrical angle (phi_e) calculated from ABN feedback.
 
bool getABNRawValue (uint32_t &value) noexcept
 Read the raw ABN encoder internal counter value.
 
bool configureABNNChannel (tmc9660::tmcl::AbnNChannelFiltering filterMode=tmc9660::tmcl::AbnNChannelFiltering::FILTERING_OFF, tmc9660::tmcl::EnableDisable clearOnNextNull=tmc9660::tmcl::EnableDisable::DISABLED) noexcept
 Configure N-channel filtering for ABN encoder.
 
bool configureSecondaryABNEncoder (uint32_t countsPerRev, tmc9660::tmcl::Direction inverted=tmc9660::tmcl::Direction::NOT_INVERTED, uint8_t gearRatio=1) noexcept
 Configure the secondary ABN encoder input.
 
bool getSecondaryABNCountsPerRev (uint32_t &counts) noexcept
 Read ABN_2_STEPS (encoder steps per rotation, 0…16777215).
 
bool getSecondaryABNDirection (tmc9660::tmcl::Direction &dir) noexcept
 Read ABN_2_DIRECTION (normal/inverted).
 
bool getSecondaryABNGearRatio (uint8_t &ratio) noexcept
 Read ABN_2_GEAR_RATIO (1…255).
 
bool setSecondaryABNEncoderEnabled (bool enable) noexcept
 Enable or disable the secondary ABN encoder.
 
bool getSecondaryABNEncoderValue (uint32_t &value) noexcept
 Read the raw ABN2 encoder internal counter value.
 
bool configureSPIEncoder (uint8_t cmdSize, uint16_t csSettleTimeNs, uint8_t csIdleTimeUs) noexcept
 Configure a SPI-based encoder for feedback.
 
bool configureSPIEncoderDataFormat (uint32_t positionMask, uint8_t positionShift=0, tmc9660::tmcl::Direction invertDirection=tmc9660::tmcl::Direction::NOT_INVERTED) noexcept
 Configure SPI encoder data format and processing.
 
bool setSPIEncoderRequestData (const uint8_t *requestData, uint8_t size) noexcept
 Set up SPI encoder request data for continuous transfer mode.
 
bool configureSPIEncoderInitialization (tmc9660::tmcl::SpiInitMethod initMethod, int16_t offset=0) noexcept
 Configure SPI encoder initialization method.
 
bool setSPIEncoderLUTCorrection (tmc9660::tmcl::EnableDisable enable, int8_t shiftFactor=0) noexcept
 Enable or disable SPI encoder lookup table correction.
 
bool uploadSPIEncoderLUTEntry (uint8_t index, int8_t value) noexcept
 Upload a single entry to the SPI encoder correction lookup table.
 
bool getSPIEncoderCSSettleDelay (uint16_t &timeNs) noexcept
 Read SPI_ENCODE_CS_SETTLE_DELAY_TIME (0…6375 ns).
 
bool getSPIEncoderCSIdleDelay (uint8_t &timeUs) noexcept
 Read SPI_ENCODER_CS_IDLE_DELAY_TIME (0…102 µs).
 
bool getSPIEncoderMainCmdSize (uint8_t &size) noexcept
 Read SPI_ENCODER_MAIN_TRANSFER_CMD_SIZE (1…16 bytes).
 
bool getSPIEncoderSecondaryCmdSize (uint8_t &size) noexcept
 Read SPI_ENCODER_SECONDARY_TRANSFER_CMD_SIZE (0…15 bytes).
 
bool getSPIEncoderPositionMask (uint32_t &mask) noexcept
 Read SPI_ENCODER_POSITION_COUNTER_MASK.
 
bool getSPIEncoderPositionShift (uint8_t &shift) noexcept
 Read SPI_ENCODER_POSITION_COUNTER_SHIFT.
 
bool getSPIEncoderPositionValue (uint32_t &value) noexcept
 Read SPI_ENCODER_POSITION_COUNTER_VALUE.
 
bool getSPIEncoderCommutationAngle (int16_t &angle) noexcept
 Read SPI_ENCODER_COMMUTATION_ANGLE (-32768…32767).
 
bool getSPIEncoderInitialization (tmc9660::tmcl::SpiInitMethod &method, int16_t &offset) noexcept
 Read SPI_ENCODER_INITIALIZATION_METHOD and SPI_ENCODER_OFFSET.
 
bool getSPIEncoderDirection (tmc9660::tmcl::Direction &dir) noexcept
 Read SPI_ENCODER_DIRECTION.
 
bool getSPIEncoderLUTAddress (uint8_t &address) noexcept
 Read SPI_LUT_ADDRESS_SELECT.
 
bool getSPIEncoderLUTData (int8_t &data) noexcept
 Read SPI_LUT_DATA.
 
bool getSPIEncoderLUTShiftFactor (int8_t &shiftFactor) noexcept
 Read SPI_LUT_COMMON_SHIFT_FACTOR.
 

Private Member Functions

 FeedbackSense (TMC9660 &parent) noexcept
 

Private Attributes

TMC9660driver
 

Friends

class TMC9660
 

Detailed Description

Subsystem for feedback sensor configuration.

Constructor & Destructor Documentation

◆ FeedbackSense()

TMC9660::FeedbackSense::FeedbackSense ( TMC9660 parent)
inlineexplicitprivatenoexcept

Member Function Documentation

◆ configureABNEncoder()

bool TMC9660::FeedbackSense::configureABNEncoder ( uint32_t  countsPerRev,
tmc9660::tmcl::Direction  inverted = tmc9660::tmcl::Direction::NOT_INVERTED,
tmc9660::tmcl::EnableDisable  nChannelInverted = tmc9660::tmcl::EnableDisable::DISABLED 
)
noexcept

Configure an ABN incremental encoder for feedback.

Sets up an incremental quadrature encoder with optional index (N) channel for position and velocity feedback.

Parameters
countsPerRevEncoder resolution (counts per revolution, 0-16777215).
invertedIf true, invert the encoder direction (tmc9660::tmcl::Direction).
nChannelInvertedIf true, invert the N-channel signal (active low instead of active high) (tmc9660::tmcl::EnableDisable).
Returns
true if encoder parameters were set successfully.

◆ configureABNInitialization()

bool TMC9660::FeedbackSense::configureABNInitialization ( tmc9660::tmcl::AbnInitMethod  initMethod = tmc9660::tmcl::AbnInitMethod::FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING,
uint16_t  initDelay = 1000,
int32_t  initVelocity = 5,
int16_t  nChannelOffset = 0 
)
noexcept

Configure ABN encoder initialization method.

Sets the method used to align the ABN encoder with the rotor's absolute position.

Parameters
initMethodInitialization method (tmc9660::tmcl::AbnInitMethod): FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING, FORCED_PHI_E_90_ZERO, USE_HALL, USE_N_CHANNEL_OFFSET
initDelayDelay in milliseconds to wait for mechanical oscillations to stop (1000-10000)
initVelocityVelocity used during N-channel initialization (-200000 to 200000)
nChannelOffsetOffset between phi_e zero and encoder index pulse position (-32768 to 32767)
Returns
true if ABN initialization parameters were set successfully.

◆ configureABNNChannel()

bool TMC9660::FeedbackSense::configureABNNChannel ( tmc9660::tmcl::AbnNChannelFiltering  filterMode = tmc9660::tmcl::AbnNChannelFiltering::FILTERING_OFF,
tmc9660::tmcl::EnableDisable  clearOnNextNull = tmc9660::tmcl::EnableDisable::DISABLED 
)
noexcept

Configure N-channel filtering for ABN encoder.

Sets up filtering for the N-channel (index pulse) to handle imprecise encoders.

Parameters
filterModeN-channel filtering mode (tmc9660::tmcl::AbnNChannelFiltering): FILTERING_OFF, N_EVENT_ON_A_HIGH_B_HIGH, N_EVENT_ON_A_HIGH_B_LOW, N_EVENT_ON_A_LOW_B_HIGH, N_EVENT_ON_A_LOW_B_LOW
clearOnNextNullIf true, clear position counter on next N-channel event (tmc9660::tmcl::EnableDisable).
Returns
true if N-channel settings were applied successfully.

◆ configureHall()

bool TMC9660::FeedbackSense::configureHall ( tmc9660::tmcl::HallSectorOffset  sectorOffset = tmc9660::tmcl::HallSectorOffset::DEG_0,
tmc9660::tmcl::Direction  inverted = tmc9660::tmcl::Direction::NOT_INVERTED,
tmc9660::tmcl::EnableDisable  enableExtrapolation = tmc9660::tmcl::EnableDisable::DISABLED,
uint8_t  filterLength = 0 
)
noexcept

Configure digital Hall sensors for BLDC commutation.

This enables Hall sensor inputs as the feedback for commutation. Typically used with tmc9660::tmcl::CommutationMode::FOC_HALL.

Parameters
sectorOffsetHall sensor 60-degree/sector offset (tmc9660::tmcl::HallSectorOffset): tmc9660::tmcl::HallSectorOffset::DEG_0, DEG_60, DEG_120, DEG_180, DEG_240, DEG_300 This combines both the 120° order offset and 180° polarity offset.
invertedIf true, invert the interpretation of hall sensor signals (tmc9660::tmcl::Direction).
enableExtrapolationIf true, enable hall extrapolation for higher resolution position signal (tmc9660::tmcl::EnableDisable).
filterLengthDigital filter length (0-255) for hall sensor inputs.
Returns
true if Hall sensor feedback is configured successfully.

◆ configureSecondaryABNEncoder()

bool TMC9660::FeedbackSense::configureSecondaryABNEncoder ( uint32_t  countsPerRev,
tmc9660::tmcl::Direction  inverted = tmc9660::tmcl::Direction::NOT_INVERTED,
uint8_t  gearRatio = 1 
)
noexcept

Configure the secondary ABN encoder input.

This allows the use of a second incremental encoder or a geared encoder setup. It writes ABN_2_* parameters to set the resolution, direction and optional gear ratio.

Parameters
countsPerRevEncoder resolution in counts per revolution.
invertedTrue to invert the encoder direction (tmc9660::tmcl::Direction).
gearRatioGear ratio between the second encoder and the motor shaft. Use 1 if directly coupled.
Returns
true if all parameters were written successfully.

◆ configureSPIEncoder()

bool TMC9660::FeedbackSense::configureSPIEncoder ( uint8_t  cmdSize,
uint16_t  csSettleTimeNs,
uint8_t  csIdleTimeUs 
)
noexcept

Configure a SPI-based encoder for feedback.

Sets up a digital SPI encoder (e.g., absolute magnetic encoder) for position feedback.

Parameters
cmdSizeSize of SPI transfer frame (1-16 bytes).
csSettleTimeNsCS settle time in nanoseconds (0-6375).
csIdleTimeUsCS idle time between frames in microseconds (0-102).
Returns
true if configured successfully.

◆ configureSPIEncoderDataFormat()

bool TMC9660::FeedbackSense::configureSPIEncoderDataFormat ( uint32_t  positionMask,
uint8_t  positionShift = 0,
tmc9660::tmcl::Direction  invertDirection = tmc9660::tmcl::Direction::NOT_INVERTED 
)
noexcept

Configure SPI encoder data format and processing.

Sets up how the position data is extracted from the SPI encoder response.

Parameters
positionMaskBit mask to extract position from SPI response.
positionShiftRight shift value to apply to position counter.
invertDirectionIf true, invert the direction of the SPI encoder (tmc9660::tmcl::Direction).
Returns
true if configuration was successful.

◆ configureSPIEncoderInitialization()

bool TMC9660::FeedbackSense::configureSPIEncoderInitialization ( tmc9660::tmcl::SpiInitMethod  initMethod,
int16_t  offset = 0 
)
noexcept

Configure SPI encoder initialization method.

Sets how the SPI encoder is initialized for commutation.

Parameters
initMethodInitialization method (tmc9660::tmcl::SpiInitMethod): FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING, FORCED_PHI_E_90_ZERO, USE_OFFSET
offsetManual offset value if using offset-based initialization.
Returns
true if initialization method was set successfully.

◆ getABNInitializationState()

bool TMC9660::FeedbackSense::getABNInitializationState ( tmc9660::tmcl::AbnInitState state)
noexcept

Read the current state of ABN encoder initialization.

Parameters
[out]stateCurrent initialization state (tmc9660::tmcl::AbnInitState): IDLE, BUSY, WAIT, DONE
Returns
true if the state was read successfully.

◆ getABNPhiE()

bool TMC9660::FeedbackSense::getABNPhiE ( int16_t &  phiE)
noexcept

Read the electrical angle (phi_e) calculated from ABN feedback.

Parameters
[out]phiEElectrical angle (-32768 to 32767).
Returns
true if the value was read successfully.

◆ getABNRawValue()

bool TMC9660::FeedbackSense::getABNRawValue ( uint32_t &  value)
noexcept

Read the raw ABN encoder internal counter value.

Parameters
[out]valueRaw counter value (0-16777215).
Returns
true if the value was read successfully.

◆ getHallPhiE()

bool TMC9660::FeedbackSense::getHallPhiE ( int16_t &  phiE)
noexcept

Read the electrical angle (phi_e) calculated from Hall feedback.

Parameters
[out]phiEElectrical angle (-32768 to 32767).
Returns
true if the value was read successfully.

◆ getSecondaryABNCountsPerRev()

bool TMC9660::FeedbackSense::getSecondaryABNCountsPerRev ( uint32_t &  counts)
noexcept

Read ABN_2_STEPS (encoder steps per rotation, 0…16777215).

Parameters
[out]countsCPR value.
Returns
true if read successful.

◆ getSecondaryABNDirection()

bool TMC9660::FeedbackSense::getSecondaryABNDirection ( tmc9660::tmcl::Direction dir)
noexcept

Read ABN_2_DIRECTION (normal/inverted).

Parameters
[out]dirDirection (tmc9660::tmcl::Direction).
Returns
true if read successful.

◆ getSecondaryABNEncoderValue()

bool TMC9660::FeedbackSense::getSecondaryABNEncoderValue ( uint32_t &  value)
noexcept

Read the raw ABN2 encoder internal counter value.

Parameters
[out]valueRaw counter value (0-4294967295).
Returns
true if the value was read successfully.

◆ getSecondaryABNGearRatio()

bool TMC9660::FeedbackSense::getSecondaryABNGearRatio ( uint8_t &  ratio)
noexcept

Read ABN_2_GEAR_RATIO (1…255).

Parameters
[out]ratioGear ratio.
Returns
true if read successful.

◆ getSPIEncoderCommutationAngle()

bool TMC9660::FeedbackSense::getSPIEncoderCommutationAngle ( int16_t &  angle)
noexcept

Read SPI_ENCODER_COMMUTATION_ANGLE (-32768…32767).

◆ getSPIEncoderCSIdleDelay()

bool TMC9660::FeedbackSense::getSPIEncoderCSIdleDelay ( uint8_t &  timeUs)
noexcept

Read SPI_ENCODER_CS_IDLE_DELAY_TIME (0…102 µs).

◆ getSPIEncoderCSSettleDelay()

bool TMC9660::FeedbackSense::getSPIEncoderCSSettleDelay ( uint16_t &  timeNs)
noexcept

Read SPI_ENCODE_CS_SETTLE_DELAY_TIME (0…6375 ns).

◆ getSPIEncoderDirection()

bool TMC9660::FeedbackSense::getSPIEncoderDirection ( tmc9660::tmcl::Direction dir)
noexcept

Read SPI_ENCODER_DIRECTION.

◆ getSPIEncoderInitialization()

bool TMC9660::FeedbackSense::getSPIEncoderInitialization ( tmc9660::tmcl::SpiInitMethod method,
int16_t &  offset 
)
noexcept

Read SPI_ENCODER_INITIALIZATION_METHOD and SPI_ENCODER_OFFSET.

◆ getSPIEncoderLUTAddress()

bool TMC9660::FeedbackSense::getSPIEncoderLUTAddress ( uint8_t &  address)
noexcept

Read SPI_LUT_ADDRESS_SELECT.

◆ getSPIEncoderLUTData()

bool TMC9660::FeedbackSense::getSPIEncoderLUTData ( int8_t &  data)
noexcept

Read SPI_LUT_DATA.

◆ getSPIEncoderLUTShiftFactor()

bool TMC9660::FeedbackSense::getSPIEncoderLUTShiftFactor ( int8_t &  shiftFactor)
noexcept

Read SPI_LUT_COMMON_SHIFT_FACTOR.

◆ getSPIEncoderMainCmdSize()

bool TMC9660::FeedbackSense::getSPIEncoderMainCmdSize ( uint8_t &  size)
noexcept

Read SPI_ENCODER_MAIN_TRANSFER_CMD_SIZE (1…16 bytes).

◆ getSPIEncoderPositionMask()

bool TMC9660::FeedbackSense::getSPIEncoderPositionMask ( uint32_t &  mask)
noexcept

Read SPI_ENCODER_POSITION_COUNTER_MASK.

◆ getSPIEncoderPositionShift()

bool TMC9660::FeedbackSense::getSPIEncoderPositionShift ( uint8_t &  shift)
noexcept

Read SPI_ENCODER_POSITION_COUNTER_SHIFT.

◆ getSPIEncoderPositionValue()

bool TMC9660::FeedbackSense::getSPIEncoderPositionValue ( uint32_t &  value)
noexcept

Read SPI_ENCODER_POSITION_COUNTER_VALUE.

◆ getSPIEncoderSecondaryCmdSize()

bool TMC9660::FeedbackSense::getSPIEncoderSecondaryCmdSize ( uint8_t &  size)
noexcept

Read SPI_ENCODER_SECONDARY_TRANSFER_CMD_SIZE (0…15 bytes).

◆ setHallPositionOffsets()

bool TMC9660::FeedbackSense::setHallPositionOffsets ( int16_t  offset0 = 0,
int16_t  offset60 = 10922,
int16_t  offset120 = 21845,
int16_t  offset180 = -32768,
int16_t  offset240 = -21846,
int16_t  offset300 = -10923,
int16_t  globalOffset = 0 
)
noexcept

Set Hall sensor position offsets for improved accuracy.

Compensates for Hall sensor mounting tolerances by setting precise electrical angle offsets.

Parameters
offset0Offset for 0° Hall position (-32768 to 32767)
offset60Offset for 60° Hall position (-32768 to 32767)
offset120Offset for 120° Hall position (-32768 to 32767)
offset180Offset for 180° Hall position (-32768 to 32767)
offset240Offset for 240° Hall position (-32768 to 32767)
offset300Offset for 300° Hall position (-32768 to 32767)
globalOffsetAdditional global offset applied to all positions (-32768 to 32767)
Returns
true if Hall position offsets were set successfully.

◆ setSecondaryABNEncoderEnabled()

bool TMC9660::FeedbackSense::setSecondaryABNEncoderEnabled ( bool  enable)
noexcept

Enable or disable the secondary ABN encoder.

Parameters
enableTrue to enable, false to disable.
Returns
true if the operation was successful.

◆ setSPIEncoderLUTCorrection()

bool TMC9660::FeedbackSense::setSPIEncoderLUTCorrection ( tmc9660::tmcl::EnableDisable  enable,
int8_t  shiftFactor = 0 
)
noexcept

Enable or disable SPI encoder lookup table correction.

Enables the lookup table-based correction for encoder nonlinearity.

Parameters
enableIf true, enable LUT correction (tmc9660::tmcl::EnableDisable).
shiftFactorCommon shift factor for all LUT entries.
Returns
true if LUT settings were applied successfully.

◆ setSPIEncoderRequestData()

bool TMC9660::FeedbackSense::setSPIEncoderRequestData ( const uint8_t *  requestData,
uint8_t  size 
)
noexcept

Set up SPI encoder request data for continuous transfer mode.

Sets the data to be sent to the SPI encoder during position acquisition.

Parameters
requestDataArray of data bytes to send to the encoder.
sizeSize of the request data (1-16 bytes).
Returns
true if transfer data was set successfully.

◆ uploadSPIEncoderLUTEntry()

bool TMC9660::FeedbackSense::uploadSPIEncoderLUTEntry ( uint8_t  index,
int8_t  value 
)
noexcept

Upload a single entry to the SPI encoder correction lookup table.

Parameters
indexIndex in the LUT (0-255).
valueCorrection value (-128 to 127).
Returns
true if the entry was uploaded successfully.

Friends And Related Symbol Documentation

◆ TMC9660

friend class TMC9660
friend

Member Data Documentation

◆ driver

TMC9660& TMC9660::FeedbackSense::driver
private

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