|
|
@ -10,7 +10,7 @@ using namespace iflytop; |
|
|
|
* @brief 静态方法,创建默认的TMC5130配置参数,使用时只需修改自己需要的参数即可 |
|
|
|
* |
|
|
|
* 注意: |
|
|
|
* 1. 该方法内部使用的是一个静态变量,所以每次调用该方法时,返回的都是同一个对象的地址?? |
|
|
|
* 1. 该方法内部使用的是个静态变量,所以每次调用该方法时,返回的都是同一个对象的地址?? |
|
|
|
* 2. 该方法返回的数值不需要被释放?? |
|
|
|
* @param config |
|
|
|
*/ |
|
|
@ -62,13 +62,19 @@ void TMC5130::initialize(cfg_t *cfg) { |
|
|
|
writeInt(TMC5130_XACTUAL, 0x00000000); |
|
|
|
writeInt(TMC5130_VACTUAL, 0x00000000); |
|
|
|
|
|
|
|
writeInt(TMC5130_VSTART, 5); |
|
|
|
|
|
|
|
writeInt(TMC5130_VSTART, 100); |
|
|
|
writeInt(TMC5130_A1, 1000); |
|
|
|
writeInt(TMC5130_V1, 0); |
|
|
|
|
|
|
|
writeInt(TMC5130_D1, 1000); |
|
|
|
writeInt(TMC5130_VSTOP, 10); |
|
|
|
writeInt(TMC5130_TZEROWAIT, 1000); |
|
|
|
writeInt(TMC5130_VSTOP, 100); |
|
|
|
writeInt(TMC5130_TZEROWAIT, 0); |
|
|
|
|
|
|
|
// writeInt(TMC5130_VSTART, 100);
|
|
|
|
// writeInt(TMC5130_V1, 0);
|
|
|
|
// writeInt(TMC5130_VSTOP, 100);
|
|
|
|
// writeInt(TMC5130_TZEROWAIT, 0);
|
|
|
|
|
|
|
|
setAcceleration(100); |
|
|
|
setDeceleration(100); |
|
|
@ -76,6 +82,16 @@ void TMC5130::initialize(cfg_t *cfg) { |
|
|
|
enableIC(true); |
|
|
|
} |
|
|
|
|
|
|
|
void TMC5130::setNoAccLimit(bool enable) { |
|
|
|
if (!enable) { |
|
|
|
writeInt(TMC5130_VSTART, 100); |
|
|
|
writeInt(TMC5130_VSTOP, 100); |
|
|
|
} else { |
|
|
|
writeInt(TMC5130_VSTART, 262144 - 1); // 2^18-1
|
|
|
|
writeInt(TMC5130_VSTOP, 262144 - 1); // 2^18-1
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void TMC5130::enableIC(bool enable) { |
|
|
|
// m_port->TMC5130Port_setENNPinState(m_channel, !enable);
|
|
|
|
SET_PIN(m_ennpin, !enable); |
|
|
@ -211,7 +227,8 @@ int32_t TMC5130::readInt(uint8_t address) { |
|
|
|
return ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | (data[3] << 8) | data[4]; |
|
|
|
} |
|
|
|
int32_t TMC5130::to_motor_acc(int32_t acc) { //
|
|
|
|
int32_t val = acc / 60.0 * 51200; |
|
|
|
int32_t val = acc / 60.0 * 51200; // 65535
|
|
|
|
// if (val > 65535) val = 65535;
|
|
|
|
return val; |
|
|
|
} |
|
|
|
int32_t TMC5130::to_motor_vel(int32_t vel) { //
|
|
|
|