Updated motor currents and added freewheeling

pull/120/head
Alex Voinea 2021-09-02 13:19:21 +03:00 committed by DRracer
parent ad096c9d14
commit e0babfa4ba
2 changed files with 18 additions and 9 deletions

View File

@ -80,8 +80,8 @@ static constexpr AxisConfig pulley = {
.dirOn = false, .dirOn = false,
.mRes = MRes_2, .mRes = MRes_2,
.vSense = true, .vSense = true,
.iRun = 30, .iRun = 20, /// 348mA
.iHold = 1, .iHold = 0, /// 17mA in SpreadCycle, freewheel in StealthChop
.stealth = false, .stealth = false,
.stepsPerUnit = (200 * 2 / 19.147274), .stepsPerUnit = (200 * 2 / 19.147274),
}; };
@ -97,9 +97,9 @@ static constexpr PulleyLimits pulleyLimits = {
static constexpr AxisConfig selector = { static constexpr AxisConfig selector = {
.dirOn = true, .dirOn = true,
.mRes = MRes_2, .mRes = MRes_2,
.vSense = false, .vSense = true,
.iRun = 17, .iRun = 18, /// 315mA
.iHold = 5, .iHold = 5, /// 99mA
.stealth = false, .stealth = false,
.stepsPerUnit = (200 * 2 / 8.), .stepsPerUnit = (200 * 2 / 8.),
}; };
@ -115,9 +115,9 @@ static constexpr SelectorLimits selectorLimits = {
static constexpr AxisConfig idler = { static constexpr AxisConfig idler = {
.dirOn = true, .dirOn = true,
.mRes = MRes_16, .mRes = MRes_16,
.vSense = false, .vSense = true,
.iRun = 23, .iRun = 31, /// 530mA
.iHold = 11, .iHold = 23, /// 398mA
.stealth = false, .stealth = false,
.stepsPerUnit = (200 * 16 / 360.), .stepsPerUnit = (200 * 16 / 360.),
}; };
@ -152,4 +152,12 @@ static_assert(tmc2130_PWM_FREQ <= 3, "tmc2130_PWM_GRAD out of range");
static constexpr uint32_t tmc2130_PWM_AUTOSCALE = 1; static constexpr uint32_t tmc2130_PWM_AUTOSCALE = 1;
static_assert(tmc2130_PWM_AUTOSCALE <= 1, "tmc2130_PWM_AUTOSCALE out of range"); static_assert(tmc2130_PWM_AUTOSCALE <= 1, "tmc2130_PWM_AUTOSCALE out of range");
/// Freewheel options for standstill:
/// 0: Normal operation (IHOLD is supplied to the motor at standstill)
/// 1: Freewheeling (as if the driver was disabled, no breaking except for detent torque)
/// 2: Coil shorted using LS drivers (stronger passive breaking)
/// 3: Coil shorted using HS drivers (weaker passive breaking)
static constexpr uint32_t tmc2130_freewheel = 1;
static_assert(tmc2130_PWM_AUTOSCALE <= 3, "tmc2130_freewheel out of range");
} // namespace config } // namespace config

View File

@ -51,7 +51,8 @@ bool TMC2130::Init(const MotorParams &params, const MotorCurrents &currents, Mot
constexpr uint32_t pwmconf = ((uint32_t)(config::tmc2130_PWM_AMPL) << 0U) constexpr uint32_t pwmconf = ((uint32_t)(config::tmc2130_PWM_AMPL) << 0U)
| ((uint32_t)(config::tmc2130_PWM_GRAD) << 8U) | ((uint32_t)(config::tmc2130_PWM_GRAD) << 8U)
| ((uint32_t)(config::tmc2130_PWM_FREQ) << 16U) | ((uint32_t)(config::tmc2130_PWM_FREQ) << 16U)
| ((uint32_t)(config::tmc2130_PWM_AUTOSCALE & 0x01U) << 18U); | ((uint32_t)(config::tmc2130_PWM_AUTOSCALE & 0x01U) << 18U)
| ((uint32_t)(config::tmc2130_freewheel & 0x03U) << 20U); //special freewheeling mode only active in stealthchop when IHOLD=0 and CS=0 (actual current)
WriteRegister(params, Registers::PWMCONF, pwmconf); WriteRegister(params, Registers::PWMCONF, pwmconf);
/// TPWMTHRS: switching velocity between stealthChop and spreadCycle. /// TPWMTHRS: switching velocity between stealthChop and spreadCycle.