Compute vSense dynamically from iRun/iHold
parent
7e8ad83e25
commit
b16ac63c5d
|
|
@ -24,7 +24,6 @@ enum MRes : uint8_t {
|
|||
struct AxisConfig {
|
||||
bool dirOn; ///< direction ON state (for inversion)
|
||||
MRes mRes; ///< microstepping [0-8, where 0 is x256 and 8 is fullstepping]
|
||||
bool vSense; ///< vSense scaling
|
||||
uint8_t iRun; ///< running current
|
||||
uint8_t iHold; ///< holding current
|
||||
bool stealth; ///< Default to Stealth mode
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ static constexpr U_mm fsensorUnloadCheckDistance = 40.0_mm;
|
|||
static constexpr AxisConfig pulley = {
|
||||
.dirOn = false,
|
||||
.mRes = MRes_8,
|
||||
.vSense = true,
|
||||
.iRun = 20, /// 348mA
|
||||
.iHold = 0, /// 17mA in SpreadCycle, freewheel in StealthChop
|
||||
.stealth = false,
|
||||
|
|
@ -126,7 +125,6 @@ static constexpr U_mm_s pulleySlowFeedrate = 20._mm_s;
|
|||
static constexpr AxisConfig selector = {
|
||||
.dirOn = true,
|
||||
.mRes = MRes_8,
|
||||
.vSense = true,
|
||||
.iRun = 31, /// 530mA
|
||||
.iHold = 0, /// 17mA in SpreadCycle, freewheel in StealthChop
|
||||
.stealth = false,
|
||||
|
|
@ -177,7 +175,6 @@ static constexpr U_mm_s selectorHomingFeedrate = 30._mm_s;
|
|||
static constexpr AxisConfig idler = {
|
||||
.dirOn = true,
|
||||
.mRes = MRes_16,
|
||||
.vSense = true,
|
||||
.iRun = 31, /// 530mA
|
||||
.iHold = 5, /// 99mA - parked current
|
||||
.stealth = false,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ struct MotorCurrents {
|
|||
bool vSense; ///< VSense current scaling
|
||||
uint8_t iRun; ///< Running current
|
||||
uint8_t iHold; ///< Holding current
|
||||
|
||||
constexpr MotorCurrents(uint8_t ir, uint8_t ih)
|
||||
: vSense((ir < 32) ? 1 : 0)
|
||||
, iRun((ir < 32) ? ir : (ir >> 1))
|
||||
, iHold((ir < 32) ? ih : (ih >> 1)) {}
|
||||
};
|
||||
|
||||
struct __attribute__((packed)) ErrorFlags {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static AxisParams axisParams[NUM_AXIS] = {
|
|||
{
|
||||
.name = 'P',
|
||||
.params = { .spi = hal::spi::TmcSpiBus, .idx = Pulley, .dirOn = config::pulley.dirOn, .csPin = PULLEY_CS_PIN, .stepPin = PULLEY_STEP_PIN, .sgPin = PULLEY_SG_PIN, .mRes = config::pulley.mRes, .sg_thrs = config::pulley.sg_thrs, Axis::Pulley },
|
||||
.currents = { .vSense = config::pulley.vSense, .iRun = config::pulley.iRun, .iHold = config::pulley.iHold },
|
||||
.currents = MotorCurrents(config::pulley.iRun, config::pulley.iHold), //{ .vSense = config::pulley.vSense, .iRun = config::pulley.iRun, .iHold = config::pulley.iHold },
|
||||
.mode = DefaultMotorMode(config::pulley),
|
||||
.jerk = unitToSteps<P_speed_t>(config::pulleyLimits.jerk),
|
||||
.accel = unitToSteps<P_accel_t>(config::pulleyLimits.accel),
|
||||
|
|
@ -52,7 +52,7 @@ static AxisParams axisParams[NUM_AXIS] = {
|
|||
{
|
||||
.name = 'S',
|
||||
.params = { .spi = hal::spi::TmcSpiBus, .idx = Selector, .dirOn = config::selector.dirOn, .csPin = SELECTOR_CS_PIN, .stepPin = SELECTOR_STEP_PIN, .sgPin = SELECTOR_SG_PIN, .mRes = config::selector.mRes, .sg_thrs = config::selector.sg_thrs, Axis::Selector },
|
||||
.currents = { .vSense = config::selector.vSense, .iRun = config::selector.iRun, .iHold = config::selector.iHold },
|
||||
.currents = MotorCurrents(config::selector.iRun, config::selector.iHold), //{ .vSense = config::selector.vSense, .iRun = config::selector.iRun, .iHold = config::selector.iHold },
|
||||
.mode = DefaultMotorMode(config::selector),
|
||||
.jerk = unitToSteps<S_speed_t>(config::selectorLimits.jerk),
|
||||
.accel = unitToSteps<S_accel_t>(config::selectorLimits.accel),
|
||||
|
|
@ -61,7 +61,7 @@ static AxisParams axisParams[NUM_AXIS] = {
|
|||
{
|
||||
.name = 'I',
|
||||
.params = { .spi = hal::spi::TmcSpiBus, .idx = Idler, .dirOn = config::idler.dirOn, .csPin = IDLER_CS_PIN, .stepPin = IDLER_STEP_PIN, .sgPin = IDLER_SG_PIN, .mRes = config::idler.mRes, .sg_thrs = config::idler.sg_thrs, Axis::Idler },
|
||||
.currents = { .vSense = config::idler.vSense, .iRun = config::idler.iRun, .iHold = config::idler.iHold },
|
||||
.currents = MotorCurrents(config::idler.iRun, config::idler.iHold), //{ .vSense = config::idler.vSense, .iRun = config::idler.iRun, .iHold = config::idler.iHold },
|
||||
.mode = DefaultMotorMode(config::idler),
|
||||
.jerk = unitToSteps<I_speed_t>(config::idlerLimits.jerk),
|
||||
.accel = unitToSteps<I_accel_t>(config::idlerLimits.accel),
|
||||
|
|
|
|||
|
|
@ -24,16 +24,7 @@ void MovableBase::PlanHome() {
|
|||
}
|
||||
|
||||
void MovableBase::SetCurrents(uint8_t iRun, uint8_t iHold) {
|
||||
hal::tmc2130::MotorCurrents tempCurrent = mm::axisParams[axis].currents;
|
||||
if (iRun < 32) {
|
||||
tempCurrent.vSense = 1;
|
||||
tempCurrent.iRun = iRun;
|
||||
tempCurrent.iHold = iHold;
|
||||
} else {
|
||||
tempCurrent.vSense = 0;
|
||||
tempCurrent.iRun = iRun >> 1;
|
||||
tempCurrent.iHold = iHold >> 1;
|
||||
}
|
||||
hal::tmc2130::MotorCurrents tempCurrent(iRun, iHold);
|
||||
mm::motion.DriverForAxis(axis).SetCurrents(mm::axisParams[axis].params, tempCurrent);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue