|
@ -116,7 +116,7 @@ Tmc5130RampStat TMC5130::getTMC5130_RAMPSTAT2() { |
|
|
void TMC5130::stop() { rotate(0); } |
|
|
void TMC5130::stop() { rotate(0); } |
|
|
void TMC5130::rotate(int32_t velocity) { |
|
|
void TMC5130::rotate(int32_t velocity) { |
|
|
// velocity *= m_scale;
|
|
|
// velocity *= m_scale;
|
|
|
to_motor_vel(velocity); |
|
|
|
|
|
|
|
|
velocity = to_motor_vel(velocity); |
|
|
writeInt(TMC5130_VMAX, abs(velocity)); |
|
|
writeInt(TMC5130_VMAX, abs(velocity)); |
|
|
writeInt(TMC5130_RAMPMODE, (velocity >= 0) ? TMC5130_MODE_VELPOS : TMC5130_MODE_VELNEG); |
|
|
writeInt(TMC5130_RAMPMODE, (velocity >= 0) ? TMC5130_MODE_VELPOS : TMC5130_MODE_VELNEG); |
|
|
} |
|
|
} |
|
@ -125,8 +125,9 @@ void TMC5130::left(int32_t velocity) { rotate(-velocity); } |
|
|
void TMC5130::moveTo(int32_t position, uint32_t velocityMax) { |
|
|
void TMC5130::moveTo(int32_t position, uint32_t velocityMax) { |
|
|
// position *= m_scale;
|
|
|
// position *= m_scale;
|
|
|
// velocityMax *= m_scale;
|
|
|
// velocityMax *= m_scale;
|
|
|
to_motor_pos(position); |
|
|
|
|
|
to_motor_vel(velocityMax); |
|
|
|
|
|
|
|
|
position = to_motor_pos(position); |
|
|
|
|
|
velocityMax = to_motor_vel(velocityMax); |
|
|
|
|
|
// ZLOGI("TMC5130", "moveTo %d %d", position, velocityMax);
|
|
|
writeInt(TMC5130_RAMPMODE, TMC5130_MODE_POSITION); |
|
|
writeInt(TMC5130_RAMPMODE, TMC5130_MODE_POSITION); |
|
|
writeInt(TMC5130_VMAX, velocityMax); |
|
|
writeInt(TMC5130_VMAX, velocityMax); |
|
|
writeInt(TMC5130_XTARGET, position); |
|
|
writeInt(TMC5130_XTARGET, position); |
|
@ -159,7 +160,7 @@ bool TMC5130::isReachTarget() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void TMC5130::setScale(float scale) { m_scale = scale; } |
|
|
|
|
|
|
|
|
void TMC5130::setScale(int32_t scale) { m_scale = scale; } |
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
/*******************************************************************************
|
|
|
* basic * |
|
|
* basic * |
|
@ -225,9 +226,9 @@ int32_t TMC5130::to_motor_pos(int32_t pos) { // |
|
|
|
|
|
|
|
|
int32_t TMC5130::to_user_pos(int32_t pos) { //
|
|
|
int32_t TMC5130::to_user_pos(int32_t pos) { //
|
|
|
int32_t val = pos / 51200.0 * m_scale; |
|
|
int32_t val = pos / 51200.0 * m_scale; |
|
|
return 0; |
|
|
|
|
|
|
|
|
return val; |
|
|
} //
|
|
|
} //
|
|
|
int32_t TMC5130::to_user_vel(int32_t vel) { //
|
|
|
int32_t TMC5130::to_user_vel(int32_t vel) { //
|
|
|
int32_t val = vel * 60.0 / 51200.0; |
|
|
int32_t val = vel * 60.0 / 51200.0; |
|
|
return 0; |
|
|
|
|
|
|
|
|
return val; |
|
|
} |
|
|
} |