|
@ -79,7 +79,7 @@ static void initsubmodule() { |
|
|
float enc_const_fractional = 0.8; |
|
|
float enc_const_fractional = 0.8; |
|
|
|
|
|
|
|
|
int32_t setval = (enc_const_integral << 16) + enc_const_fractional * 10000; |
|
|
int32_t setval = (enc_const_integral << 16) + enc_const_fractional * 10000; |
|
|
setval = -setval; |
|
|
|
|
|
|
|
|
// setval = -setval;
|
|
|
ZLOGI(TAG, "setval:%d", setval); |
|
|
ZLOGI(TAG, "setval:%d", setval); |
|
|
g_motor.writeInt(TMC5130_ENC_CONST, setval); |
|
|
g_motor.writeInt(TMC5130_ENC_CONST, setval); |
|
|
g_motor.writeInt(TMC5130_ENCMODE, 0x1 << 10); |
|
|
g_motor.writeInt(TMC5130_ENCMODE, 0x1 << 10); |
|
@ -87,16 +87,17 @@ static void initsubmodule() { |
|
|
g_motor.setIHOLD_IRUN(2, 6, 1000); |
|
|
g_motor.setIHOLD_IRUN(2, 6, 1000); |
|
|
g_motor.setENCVAL(0); |
|
|
g_motor.setENCVAL(0); |
|
|
g_motor.enable(true); |
|
|
g_motor.enable(true); |
|
|
osDelay(100); |
|
|
|
|
|
|
|
|
osDelay(100); |
|
|
g_motor.setENCVAL(0); |
|
|
g_motor.setENCVAL(0); |
|
|
// g_motor.moveBy(51200, 100000);
|
|
|
// g_motor.moveBy(51200, 100000);
|
|
|
g_motor.moveBy(51200, 100000); |
|
|
|
|
|
|
|
|
// g_motor.moveBy(51200, 100000);
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
while (true) { |
|
|
int32_t enc = g_motor.readInt(TMC5130_XENC); |
|
|
int32_t enc = g_motor.readInt(TMC5130_XENC); |
|
|
int32_t xactual = g_motor.readInt(TMC5130_XACTUAL); |
|
|
int32_t xactual = g_motor.readInt(TMC5130_XACTUAL); |
|
|
ZLOGI(TAG, "enc:%d %d %d", enc, xactual, enc - xactual); |
|
|
ZLOGI(TAG, "enc:%d %d %d", enc, xactual, enc - xactual); |
|
|
osDelay(1000); |
|
|
|
|
|
|
|
|
osDelay(3000); |
|
|
|
|
|
g_motor.moveBy(51200/4, 100000); |
|
|
} |
|
|
} |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|