|
HF-TMC9660 Driver 0.1.0-dev
Hardware Agnostic C++ Driver for the TMC9660
|
Configuration structure for torque/flux control auto-configuration. More...
#include <tmc9660.hpp>
Public Attributes | |
| std::optional< uint16_t > | torqueP |
| Direct PI gain configuration (optional). | |
| std::optional< uint16_t > | torqueI |
| Torque I gain [0-32767] (optional, defaults to 100 if not provided) | |
| bool | separateTorqueFluxLoops |
| Use separate PI parameters for torque and flux loops. | |
| std::optional< uint16_t > | fluxP |
| Flux PI gains (only used if separateTorqueFluxLoops = true). | |
| std::optional< uint16_t > | fluxI |
| Flux I gain [0-32767] (optional, only used if separateTorqueFluxLoops = true) | |
| std::optional< tmc9660::tmcl::CurrentPiNormalization > | pNormalization |
| PI normalization format (optional). | |
| std::optional< tmc9660::tmcl::CurrentPiNormalization > | iNormalization |
| I-term normalization format (optional, defaults to SHIFT_16_BIT) | |
| bool | enableFieldWeakening = false |
| Enable field weakening for high-speed operation. | |
| float | fieldWeakeningVoltageThresholdPercent |
| Field weakening voltage threshold as percentage of OUTPUT_VOLTAGE_LIMIT. | |
| uint16_t | fieldWeakeningI = 100 |
| Field weakening I-controller gain. | |
| int16_t | torqueOffset_mA = 0 |
| Current offset compensation. | |
| int16_t | fluxOffset_mA = 0 |
| Flux offset in m_a [-4700 to 4700] (default: 0) | |
| bool | enableTorqueBiquadFilter |
| Enable biquad filter on target torque command. | |
| std::optional< int32_t > | biquadACoeff1 |
| Biquad filter coefficients (optional, only used if enableTorqueBiquadFilter = true). | |
| std::optional< int32_t > | biquadACoeff2 |
| std::optional< int32_t > | biquadBCoeff0 |
| std::optional< int32_t > | biquadBCoeff1 |
| std::optional< int32_t > | biquadBCoeff2 |
Configuration structure for torque/flux control auto-configuration.
This structure provides high-level, user-friendly parameters for configuring the torque and flux current control loops. Complex low-level parameters are automatically derived from these intuitive settings.
| std::optional<int32_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::biquadACoeff1 |
Biquad filter coefficients (optional, only used if enableTorqueBiquadFilter = true).
These coefficients define the biquad filter difference equation: Y(n) = X(n)*b0 + X(n-1)*b1 + X(n-2)*b2 - Y(n-1)*a1 - Y(n-2)*a2
Or in z-domain transfer function form: H(z) = (B0 + B1*z^-1 + B2*z^-2) / (1 + A1*z^-1 + A2*z^-2)
Coefficient Format: All coefficients are 24-bit values in Q4.20 fixed-point format:
coeff = (float_value * 1048576.0f)Default Values: If not provided, the filter uses default coefficients:
Typical Use Cases:
Note: For most applications, leave these unset unless you have specific filtering requirements. The default values provide a simple pass-through filter. Biquad A coefficient 1 (a1) in Q4.20 format [-2147483648 to 2147483647] (optional, default: 0)
| std::optional<int32_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::biquadACoeff2 |
Biquad A coefficient 2 (a2) in Q4.20 format [-2147483648 to 2147483647] (optional, default: 0)
| std::optional<int32_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::biquadBCoeff0 |
Biquad B coefficient 0 (b0) in Q4.20 format [-2147483648 to 2147483647] (optional, default: 1048576 = 1.0)
| std::optional<int32_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::biquadBCoeff1 |
Biquad B coefficient 1 (b1) in Q4.20 format [-2147483648 to 2147483647] (optional, default: 0)
| std::optional<int32_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::biquadBCoeff2 |
Biquad B coefficient 2 (b2) in Q4.20 format [-2147483648 to 2147483647] (optional, default: 0)
| bool tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::enableFieldWeakening = false |
Enable field weakening for high-speed operation.
Field weakening allows the motor to operate beyond its base speed by reducing the back-EMF through negative flux current. This is essential for high-speed BLDC/stepper motors.
When enabled, field weakening activates automatically when the motor voltage exceeds field_weakening_voltage_threshold_percent. Enable field weakening (default: false)
| bool tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::enableTorqueBiquadFilter |
Enable biquad filter on target torque command.
The biquad filter can be used to smooth the torque command, reducing high-frequency noise or oscillations. This is particularly useful when using velocity or position control, where the velocity/position controller output is used as the target torque.
When enabled, you can optionally provide filter coefficients below. If coefficients are not provided, the filter is enabled but uses default coefficient values (BCOEFF_0 = 1048576, others = 0).
Default: Disabled (filter is off by default). Most users should leave this disabled unless experiencing torque command oscillations or need to smooth controller outputs. Enable biquad filter on target torque (default: false)
| uint16_t tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::fieldWeakeningI = 100 |
Field weakening I-controller gain.
Higher values = more aggressive field weakening (faster response to voltage limit, but may cause instability). Lower values = gentler field weakening (slower response, more stable).
Typical values:
| float tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::fieldWeakeningVoltageThresholdPercent |
Field weakening voltage threshold as percentage of OUTPUT_VOLTAGE_LIMIT.
Field weakening activates when motor voltage exceeds this threshold. Expressed as a fraction (0.0 to 1.0) of the OUTPUT_VOLTAGE_LIMIT.
Typical values:
Example: If OUTPUT_VOLTAGE_LIMIT = 8000 and threshold = 0.85, field weakening activates at 6800 (85% of 8000). Voltage threshold for field weakening [0.0-1.0] as fraction of OUTPUT_VOLTAGE_LIMIT (default: 0.85 = 85%)
| std::optional<uint16_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::fluxI |
Flux I gain [0-32767] (optional, only used if separateTorqueFluxLoops = true)
| int16_t tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::fluxOffset_mA = 0 |
Flux offset in m_a [-4700 to 4700] (default: 0)
| std::optional<uint16_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::fluxP |
Flux PI gains (only used if separateTorqueFluxLoops = true).
If separate_torque_flux_loops is true and these are not provided, they default to the same values as torqueP/torqueI. Flux P gain [0-32767] (optional, only used if separateTorqueFluxLoops = true)
| std::optional<tmc9660::tmcl::CurrentPiNormalization> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::iNormalization |
I-term normalization format (optional, defaults to SHIFT_16_BIT)
| std::optional<tmc9660::tmcl::CurrentPiNormalization> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::pNormalization |
PI normalization format (optional).
These control how the PI gains are normalized internally. If not provided, defaults are used (SHIFT_8_BIT for P, SHIFT_16_BIT for I) which match the datasheet defaults and work well for most applications.
Typically, P uses 8-bit (faster, standard) and I uses 16-bit (better precision). Only override if you have specific requirements. P-term normalization format (optional, defaults to SHIFT_8_BIT)
| bool tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::separateTorqueFluxLoops |
Use separate PI parameters for torque and flux loops.
When false (default): Torque and flux share the same PI gains. When true: Torque and flux have independent PI gains (flux_p, flux_i).
Separate loops are useful when torque and flux have different response requirements, but most applications work fine with combined loops. Use separate PI parameters for torque and flux (default: false, combined)
| std::optional<uint16_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::torqueI |
Torque I gain [0-32767] (optional, defaults to 100 if not provided)
| int16_t tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::torqueOffset_mA = 0 |
Current offset compensation.
These offsets are added to the torque/flux commands to compensate for measurement errors or motor asymmetries. Usually set to 0 unless calibration reveals systematic offsets. Torque offset in m_a [-4700 to 4700] (default: 0)
| std::optional<uint16_t> tmc9660::TMC9660< CommType >::TorqueFluxControl::TorqueFluxConfig::torqueP |
Direct PI gain configuration (optional).
If provided, these values are used directly. If not provided, default values are used (P=50, I=100). Use this for fine-tuning or when you know the exact gains you need.
Typical values: