Browse Source

tmc4361闭环控制电机OK

master
zhaohe 2 years ago
parent
commit
a0914f54c0
  1. 60
      app/MDK-ARM/app.uvguix.h_zha
  2. 2
      app/MDK-ARM/app.uvoptx
  3. 2
      dep/libtrinamic
  4. 18
      src/umain.cpp

60
app/MDK-ARM/app.uvguix.h_zha
File diff suppressed because it is too large
View File

2
app/MDK-ARM/app.uvoptx

@ -140,7 +140,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U23520538 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F407VETx$CMSIS\Flash\STM32F4xx_512.FLM)</Name>
<Name>-U23520538 -O78 -S5 -ZTIFSpeedSel1000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F407VETx$CMSIS\Flash\STM32F4xx_512.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>

2
dep/libtrinamic

@ -1 +1 @@
Subproject commit 1665bb75e0e73e8fe76e2f5bbc81a5e10c2942d1
Subproject commit f1a65503a8e2af9a02dbd46c8b5aac138faf9865

18
src/umain.cpp

@ -12,6 +12,7 @@
//
// port_tmc_DRV_ENN_pin_set_state
using namespace iflytop;
class TMC4361AImpl : public TMC4361A {
protected:
virtual void setResetPinState(bool state) { port_tmc_nRESET_pin_set_state(m_channel, state); };
@ -37,7 +38,6 @@ class TMC2160Impl : public TMC2160 {
virtual void sleepus(int32_t us) { port_delay_us(us); };
virtual void readWriteArray(uint8_t *data, size_t length) { m_tmc4361->readWriteCover(data, length); };
};
static TMC4361AImpl tmc4361motor1;
static TMC2160Impl tmc2160motor1;
@ -48,8 +48,14 @@ int umain(int argc, char const *argv[]) {
port_tmc_extern_clk_enable();
// tmc4361motor1.init();
tmc4361motor1.initialize(MOTOR_1_TMC4361A_CHANNEL, TMC4361A::IC_TMC2160);
TMC4361AImpl::TMC4361AConfig_t *tmc4361aconfig = TMC4361AImpl::createDeafultTMC4361AConfig();
tmc4361motor1.initialize(MOTOR_1_TMC4361A_CHANNEL, TMC4361A::IC_TMC2160, tmc4361aconfig);
tmc2160motor1.initialize(MOTOR_1_TMC2160_CHANNEL, &tmc4361motor1);
// 2160初始化
tmc2160motor1.setMaximumCurrent(3);
HAL_Delay(100);
tmc4361motor1.enableIC(true);
tmc2160motor1.enableIC(true);
@ -60,14 +66,18 @@ int umain(int argc, char const *argv[]) {
int32_t ic4361Version = tmc4361motor1.readICVersion();
int32_t ic2160Version = tmc2160motor1.readICVersion();
// 期望 4361Version:2 ic2160Version:30
ZLOGI(TAG, "4361Version:%x ic2160Version:%x", ic4361Version, ic2160Version);
ZLOGI(TAG, "TMC4361Version:%x TMC2160VERSION:%x", ic4361Version, ic2160Version);
tmc4361motor1.setMaximumAcceleration(300000);
tmc4361motor1.setMaximumDeceleration(300000);
tmc4361motor1.rotate(100000);
tmc4361motor1.moveTo(41370340, 500000);
while (true) {
port_do_debug_light_state();
HAL_Delay(30);
int32_t encpos = tmc4361motor1.getENC_POS();
int32_t xactual = tmc4361motor1.getXACTUAL();
ZLOGI(TAG, "encpos:%d xactual:%d %d", encpos, xactual, tmc4361motor1.getENC_POS_DEV());
}
return 0;
}

Loading…
Cancel
Save