HF-TMC9660 Driver
Hardware Agnostic C++ Driver for the TMC9660
|
Subsystem for feedback sensor configuration. More...
#include <TMC9660.hpp>
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 | |
TMC9660 & | driver |
Friends | |
class | TMC9660 |
Subsystem for feedback sensor configuration.
|
inlineexplicitprivatenoexcept |
|
noexcept |
Configure an ABN incremental encoder for feedback.
Sets up an incremental quadrature encoder with optional index (N) channel for position and velocity feedback.
countsPerRev | Encoder resolution (counts per revolution, 0-16777215). |
inverted | If true, invert the encoder direction (tmc9660::tmcl::Direction). |
nChannelInverted | If true, invert the N-channel signal (active low instead of active high) (tmc9660::tmcl::EnableDisable). |
|
noexcept |
Configure ABN encoder initialization method.
Sets the method used to align the ABN encoder with the rotor's absolute position.
initMethod | Initialization method (tmc9660::tmcl::AbnInitMethod): FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING, FORCED_PHI_E_90_ZERO, USE_HALL, USE_N_CHANNEL_OFFSET |
initDelay | Delay in milliseconds to wait for mechanical oscillations to stop (1000-10000) |
initVelocity | Velocity used during N-channel initialization (-200000 to 200000) |
nChannelOffset | Offset between phi_e zero and encoder index pulse position (-32768 to 32767) |
|
noexcept |
Configure N-channel filtering for ABN encoder.
Sets up filtering for the N-channel (index pulse) to handle imprecise encoders.
filterMode | N-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 |
clearOnNextNull | If true, clear position counter on next N-channel event (tmc9660::tmcl::EnableDisable). |
|
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.
sectorOffset | Hall 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. |
inverted | If true, invert the interpretation of hall sensor signals (tmc9660::tmcl::Direction). |
enableExtrapolation | If true, enable hall extrapolation for higher resolution position signal (tmc9660::tmcl::EnableDisable). |
filterLength | Digital filter length (0-255) for hall sensor inputs. |
|
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.
countsPerRev | Encoder resolution in counts per revolution. |
inverted | True to invert the encoder direction (tmc9660::tmcl::Direction). |
gearRatio | Gear ratio between the second encoder and the motor shaft. Use 1 if directly coupled. |
|
noexcept |
Configure a SPI-based encoder for feedback.
Sets up a digital SPI encoder (e.g., absolute magnetic encoder) for position feedback.
cmdSize | Size of SPI transfer frame (1-16 bytes). |
csSettleTimeNs | CS settle time in nanoseconds (0-6375). |
csIdleTimeUs | CS idle time between frames in microseconds (0-102). |
|
noexcept |
Configure SPI encoder data format and processing.
Sets up how the position data is extracted from the SPI encoder response.
positionMask | Bit mask to extract position from SPI response. |
positionShift | Right shift value to apply to position counter. |
invertDirection | If true, invert the direction of the SPI encoder (tmc9660::tmcl::Direction). |
|
noexcept |
Configure SPI encoder initialization method.
Sets how the SPI encoder is initialized for commutation.
initMethod | Initialization method (tmc9660::tmcl::SpiInitMethod): FORCED_PHI_E_ZERO_WITH_ACTIVE_SWING, FORCED_PHI_E_90_ZERO, USE_OFFSET |
offset | Manual offset value if using offset-based initialization. |
|
noexcept |
Read the current state of ABN encoder initialization.
[out] | state | Current initialization state (tmc9660::tmcl::AbnInitState): IDLE, BUSY, WAIT, DONE |
|
noexcept |
Read the electrical angle (phi_e) calculated from ABN feedback.
[out] | phiE | Electrical angle (-32768 to 32767). |
|
noexcept |
Read the raw ABN encoder internal counter value.
[out] | value | Raw counter value (0-16777215). |
|
noexcept |
Read the electrical angle (phi_e) calculated from Hall feedback.
[out] | phiE | Electrical angle (-32768 to 32767). |
|
noexcept |
Read ABN_2_STEPS (encoder steps per rotation, 0…16777215).
[out] | counts | CPR value. |
|
noexcept |
Read ABN_2_DIRECTION (normal/inverted).
[out] | dir | Direction (tmc9660::tmcl::Direction). |
|
noexcept |
Read the raw ABN2 encoder internal counter value.
[out] | value | Raw counter value (0-4294967295). |
|
noexcept |
Read ABN_2_GEAR_RATIO (1…255).
[out] | ratio | Gear ratio. |
|
noexcept |
Read SPI_ENCODER_COMMUTATION_ANGLE (-32768…32767).
|
noexcept |
Read SPI_ENCODER_CS_IDLE_DELAY_TIME (0…102 µs).
|
noexcept |
Read SPI_ENCODE_CS_SETTLE_DELAY_TIME (0…6375 ns).
|
noexcept |
Read SPI_ENCODER_DIRECTION.
|
noexcept |
Read SPI_ENCODER_INITIALIZATION_METHOD and SPI_ENCODER_OFFSET.
|
noexcept |
Read SPI_LUT_ADDRESS_SELECT.
|
noexcept |
Read SPI_LUT_DATA.
|
noexcept |
Read SPI_LUT_COMMON_SHIFT_FACTOR.
|
noexcept |
Read SPI_ENCODER_MAIN_TRANSFER_CMD_SIZE (1…16 bytes).
|
noexcept |
Read SPI_ENCODER_POSITION_COUNTER_MASK.
|
noexcept |
Read SPI_ENCODER_POSITION_COUNTER_SHIFT.
|
noexcept |
Read SPI_ENCODER_POSITION_COUNTER_VALUE.
|
noexcept |
Read SPI_ENCODER_SECONDARY_TRANSFER_CMD_SIZE (0…15 bytes).
|
noexcept |
Set Hall sensor position offsets for improved accuracy.
Compensates for Hall sensor mounting tolerances by setting precise electrical angle offsets.
offset0 | Offset for 0° Hall position (-32768 to 32767) |
offset60 | Offset for 60° Hall position (-32768 to 32767) |
offset120 | Offset for 120° Hall position (-32768 to 32767) |
offset180 | Offset for 180° Hall position (-32768 to 32767) |
offset240 | Offset for 240° Hall position (-32768 to 32767) |
offset300 | Offset for 300° Hall position (-32768 to 32767) |
globalOffset | Additional global offset applied to all positions (-32768 to 32767) |
|
noexcept |
Enable or disable the secondary ABN encoder.
enable | True to enable, false to disable. |
|
noexcept |
Enable or disable SPI encoder lookup table correction.
Enables the lookup table-based correction for encoder nonlinearity.
enable | If true, enable LUT correction (tmc9660::tmcl::EnableDisable). |
shiftFactor | Common shift factor for all LUT entries. |
|
noexcept |
Set up SPI encoder request data for continuous transfer mode.
Sets the data to be sent to the SPI encoder during position acquisition.
requestData | Array of data bytes to send to the encoder. |
size | Size of the request data (1-16 bytes). |
|
noexcept |
Upload a single entry to the SPI encoder correction lookup table.
index | Index in the LUT (0-255). |
value | Correction value (-128 to 127). |
|
friend |
|
private |