Browse Source

移除编码器堵转逻辑

master
HSZ_HeSongZhen 5 months ago
parent
commit
df796795ce
  1. 6
      .idea/vcs.xml
  2. 57
      User/BSP/status/elc_motor.cpp
  3. 3
      User/BSP/status/elc_motor.h
  4. 16
      cmake-build-debug-mingw-stm32/CMakeCache.txt

6
.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

57
User/BSP/status/elc_motor.cpp

@ -57,10 +57,6 @@ void ECLMotor::readMotorPosition() {
x_actual = motor->getXACTUAL(); // 获取实时位置 x_actual = motor->getXACTUAL(); // 获取实时位置
rt_speed = motor->getVACTUAL(); // 获取实时速度 rt_speed = motor->getVACTUAL(); // 获取实时速度
#if 1
handlePosEnc(x_actual, enc_val); // 用于处理 回 HOME 逻辑
#endif
TMC5130RampStat ramp_stat = motor->getRampStat(); TMC5130RampStat ramp_stat = motor->getRampStat();
is_reached = motor->isReachTarget(&ramp_stat); is_reached = motor->isReachTarget(&ramp_stat);
@ -534,19 +530,6 @@ void ECLMotor::homingTask(void *arg) {
} }
break; break;
} }
case EVENT_ENCODER_BIG_DIFF: {
// ZLOGI(TAG, "[]EVENT_ENCODER_BIG_DIFF");
if (eclMotor->homeState_ == STATE_BACK_TO_ORIGIN_MIDDLE) {
eclMotor->homeState_ = STATE_FORWARD_TO_ORIGIN_MIDDLE;
// 停止
// 中速向前
int speed = ELCMotorHelper::getRPerMinMiddleSpeed(eclMotor->index_);
eclMotor->ECL_Rotate(speed);
ZLOGI(TAG, "【ENCODER BIG DIFF】");
ZLOGI(TAG, "【HOME】 FORWARD TO ORIGIN MIDDLE");
}
break;
}
case EVENT_IN_ORIGIN: { case EVENT_IN_ORIGIN: {
// ZLOGI(TAG, "[]EVENT_IN_ORIGIN"); // ZLOGI(TAG, "[]EVENT_IN_ORIGIN");
if (eclMotor->homeState_ == STATE_INIT) { if (eclMotor->homeState_ == STATE_INIT) {
@ -599,46 +582,6 @@ void ECLMotor::homingTask(void *arg) {
} }
} }
void ECLMotor::handlePosEnc(int32_t pos, int32_t enc_val) {
const bool isDoHoming = this->isHoming();
if (!isDoHoming) {
return;
}
if (isHomed()) {
// 处理加减速的问题
DistanceLevel level = ELCMotorHelper::getDistanceLevel(this->index_, x_actual_, enc_val_);
if (level != level_) {
level_ = level;
ZLOGI(TAG, "【HOMED LEVEL CHANGED】");
switch (level) {
case DistanceLow: {
home_event_.event_type = EVENT_ENCODER_NEAR_ORIGN;
osMessageQueuePut(homeEventQueue, &home_event_, 0U, 0U);
break;
}
case DistanceMiddle: {
home_event_.event_type = EVENT_ENCODER_MODERATE_ORIGIN;
osMessageQueuePut(homeEventQueue, &home_event_, 0U, 0U);
break;
}
case DistanceHigh: {
home_event_.event_type = EVENT_ENCODER_FAR_ORIGIN;
osMessageQueuePut(homeEventQueue, &home_event_, 0U, 0U);
break;
}
}
}
} else {
// 倒转的时候发生堵转
if (ELCMotorHelper::isLockRotor(index_, pos, enc_val)) {
home_event_.event_type = EVENT_ENCODER_BIG_DIFF;
ZLOGI(TAG, "isLockRotor");
osMessageQueuePut(homeEventQueue, &home_event_, 0U, 0U);
}
}
}
void ECLMotor::moveToHome() { void ECLMotor::moveToHome() {
#if 0 #if 0

3
User/BSP/status/elc_motor.h

@ -100,9 +100,6 @@ public:
void setMoveFinishSeqId(uint8_t seq_id); void setMoveFinishSeqId(uint8_t seq_id);
// Send
void handlePosEnc(int32_t pos, int32_t enc_val);
int32_t getPosition(); int32_t getPosition();
void setTargetPosition(int32_t target); void setTargetPosition(int32_t target);
void setShiftPosition(int32_t shift_target); void setShiftPosition(int32_t shift_target);

16
cmake-build-debug-mingw-stm32/CMakeCache.txt

@ -1,5 +1,5 @@
# This is the CMakeCache file. # This is the CMakeCache file.
# For build in directory: d:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake-build-debug-mingw-stm32
# For build in directory: d:/code/stm32/Sub_Spray_STM32/cmake-build-debug-mingw-stm32
# It was generated by CMake: C:/Program Files/JetBrains/CLion 2024.1.4/bin/cmake/win/x64/bin/cmake.exe # It was generated by CMake: C:/Program Files/JetBrains/CLion 2024.1.4/bin/cmake/win/x64/bin/cmake.exe
# You can edit this file to change values found and used by cmake. # You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor. # If you do not want to change any of the values, simply exit the editor.
@ -121,7 +121,7 @@ CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING= CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Value Computed by CMake. //Value Computed by CMake.
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake-build-debug-mingw-stm32/CMakeFiles/pkgRedirects
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=D:/code/stm32/Sub_Spray_STM32/cmake-build-debug-mingw-stm32/CMakeFiles/pkgRedirects
//Install path prefix, prepended onto install directories. //Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86) CMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86)
@ -230,22 +230,22 @@ CMAKE_TAPI:FILEPATH=CMAKE_TAPI-NOTFOUND
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
//Value Computed by CMake //Value Computed by CMake
STM32F429GT6_BINARY_DIR:STATIC=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake-build-debug-mingw-stm32
STM32F429GT6_BINARY_DIR:STATIC=D:/code/stm32/Sub_Spray_STM32/cmake-build-debug-mingw-stm32
//Value Computed by CMake //Value Computed by CMake
STM32F429GT6_IS_TOP_LEVEL:STATIC=ON STM32F429GT6_IS_TOP_LEVEL:STATIC=ON
//Value Computed by CMake //Value Computed by CMake
STM32F429GT6_SOURCE_DIR:STATIC=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6
STM32F429GT6_SOURCE_DIR:STATIC=D:/code/stm32/Sub_Spray_STM32
//Value Computed by CMake //Value Computed by CMake
stm32cubemx_BINARY_DIR:STATIC=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake-build-debug-mingw-stm32/cmake/stm32cubemx
stm32cubemx_BINARY_DIR:STATIC=D:/code/stm32/Sub_Spray_STM32/cmake-build-debug-mingw-stm32/cmake/stm32cubemx
//Value Computed by CMake //Value Computed by CMake
stm32cubemx_IS_TOP_LEVEL:STATIC=OFF stm32cubemx_IS_TOP_LEVEL:STATIC=OFF
//Value Computed by CMake //Value Computed by CMake
stm32cubemx_SOURCE_DIR:STATIC=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake/stm32cubemx
stm32cubemx_SOURCE_DIR:STATIC=D:/code/stm32/Sub_Spray_STM32/cmake/stm32cubemx
######################## ########################
@ -272,7 +272,7 @@ CMAKE_ASM_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_ASM_FLAGS_RELWITHDEBINFO //ADVANCED property for variable: CMAKE_ASM_FLAGS_RELWITHDEBINFO
CMAKE_ASM_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1 CMAKE_ASM_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//This is the directory where this CMakeCache.txt was created //This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=d:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6/cmake-build-debug-mingw-stm32
CMAKE_CACHEFILE_DIR:INTERNAL=d:/code/stm32/Sub_Spray_STM32/cmake-build-debug-mingw-stm32
//Major version of cmake used to create the current loaded cache //Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3 CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache //Minor version of cmake used to create the current loaded cache
@ -343,7 +343,7 @@ CMAKE_GENERATOR_PLATFORM:INTERNAL=
CMAKE_GENERATOR_TOOLSET:INTERNAL= CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this //Source directory with the top level CMakeLists.txt file for this
// project // project
CMAKE_HOME_DIRECTORY:INTERNAL=D:/code/stm32/SubSpray/kkk/SubSpray/SubSpray_STM32F429GT6
CMAKE_HOME_DIRECTORY:INTERNAL=D:/code/stm32/Sub_Spray_STM32
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM //ADVANCED property for variable: CMAKE_MAKE_PROGRAM
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1 CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS //ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS

Loading…
Cancel
Save