From 7597f331ad3ef6c2e1d8699052e3709bbe178705 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 26 Jun 2024 15:34:57 +0800 Subject: [PATCH] update --- a8000_protocol | 2 +- sdk | 2 +- usrc/main.cpp | 4 - usrc/subboards/subboard10_hbot/pri_board.h | 58 ---------- usrc/subboards/subboard10_hbot/subboard10_hbot.cpp | 117 --------------------- usrc/subboards/subboard10_hbot/subboard10_hbot.hpp | 25 ----- .../subboard10_hbot/subboard10_hbot_board.c | 41 -------- .../subboard10_hbot/subboard10_hbot_board.h | 12 --- usrc/subboards/subboard10_hbot_v2/pri_board.h | 60 +---------- .../subboard10_hbot_v2/subboard10_hbot_v2.cpp | 101 +++++++++--------- 10 files changed, 56 insertions(+), 366 deletions(-) delete mode 100644 usrc/subboards/subboard10_hbot/pri_board.h delete mode 100644 usrc/subboards/subboard10_hbot/subboard10_hbot.cpp delete mode 100644 usrc/subboards/subboard10_hbot/subboard10_hbot.hpp delete mode 100644 usrc/subboards/subboard10_hbot/subboard10_hbot_board.c delete mode 100644 usrc/subboards/subboard10_hbot/subboard10_hbot_board.h diff --git a/a8000_protocol b/a8000_protocol index e4a8057..044d6a2 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit e4a80570d108c0a711401236f95bbc95b4ae7ecf +Subproject commit 044d6a286e8a6e7298cc15e5f5746f401ad68b7a diff --git a/sdk b/sdk index e5ce8da..0f185e7 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit e5ce8da2008bafe1ec519432807a1dfbfd12f17e +Subproject commit 0f185e7634bc9edb53206e3219a7021bca3abd9f diff --git a/usrc/main.cpp b/usrc/main.cpp index 6c9ecc7..5d43fc6 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -9,8 +9,6 @@ // #include "subboards/subboard100_idcard_reader/subboard100_id_card_reader.hpp" #include "subboards/subboard100_idcard_reader/subboard100_id_card_reader_board.h" -#include "subboards/subboard10_hbot/subboard10_hbot.hpp" -#include "subboards/subboard10_hbot/subboard10_hbot_board.h" #include "subboards/subboard10_hbot_v2/subboard10_hbot_board_v2.h" #include "subboards/subboard10_hbot_v2/subboard10_hbot_v2.hpp" #include "subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160.hpp" @@ -46,7 +44,6 @@ int32_t deviceId = 0; static void board_init() { switch (deviceId) { case 10: - // subboard10_hbot_board_init(); subboard10v2_hbot_board_init(); break; case 20: // 板夹仓 @@ -88,7 +85,6 @@ static void board_post_init() { GService::inst()->initialize(); switch (deviceId) { case 10: - // Subboard10Hbot::ins()->initialize(); Subboard10HbotV2::ins()->initialize(); break; case 20: diff --git a/usrc/subboards/subboard10_hbot/pri_board.h b/usrc/subboards/subboard10_hbot/pri_board.h deleted file mode 100644 index a64d665..0000000 --- a/usrc/subboards/subboard10_hbot/pri_board.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -/*********************************************************************************************************************** - * 板载扩展IO * - ***********************************************************************************************************************/ -#define EXT_INPUT_IO0 PD4, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO1 PD5, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO2 PD6, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO3 PD7, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO4 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO5 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO6 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO7 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO8 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true -#define EXT_INPUT_IO9 PinNull, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true - -#define EXT_OUTPUT_IO0 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO1 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO2 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO3 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO4 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO5 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO6 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO7 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO8 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ -#define EXT_OUTPUT_IO9 PinNull, ZGPIO::kMode_nopull, false /*mirror*/, true /*init val*/ - -#define TMC_MOTOR_SPI hspi1 - -/*********************************************************************************************************************** - * 左右移动 * - ***********************************************************************************************************************/ - -// MOTOR1 -#define TMC_MOTOR1_CHANNEL 1 -#define TMC_MOTOR1_SPI_SELECT1_IO PA4 -#define TMC_MOTOR1_nFREEZE_IO PC2 -#define TMC_MOTOR1_nRESET_IO PB3 -#define TMC_MOTOR1_SUB_IC_ENN_IO PC3 -#define TMC_MOTOR1_ENN_IO // unused - -// MOTOR2 -#define TMC_MOTOR2_CHANNEL 2 -#define TMC_MOTOR2_SPI_SELECT1_IO PA8 -#define TMC_MOTOR2_nFREEZE_IO PC6 -#define TMC_MOTOR2_nRESET_IO PB2 -#define TMC_MOTOR2_SUB_IC_ENN_IO PC7 -#define TMC_MOTOR2_ENN_IO // unused - -#define ARM_X_ZERO PD0 -#define ARM_X_LIMIT PD1 -#define ARM_Y_ZERO PD2 -#define ARM_Y_LIMIT PD3 - -#define ARM_SENSOR5_GPIO PD4 -#define ARM_SENSOR6_GPIO PD5 -#define ARM_SENSOR7_GPIO PD6 -#define ARM_SENSOR8_GPIO PD7 \ No newline at end of file diff --git a/usrc/subboards/subboard10_hbot/subboard10_hbot.cpp b/usrc/subboards/subboard10_hbot/subboard10_hbot.cpp deleted file mode 100644 index 56b7d31..0000000 --- a/usrc/subboards/subboard10_hbot/subboard10_hbot.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "subboard10_hbot.hpp" -extern "C" { -#include "subboard10_hbot_board.h" -} -#include "pri_board.h" -#include "public_service/instance_init.hpp" -#include "public_service/public_service.hpp" -#include "sdk/components/mini_servo_motor/feite_servo_motor.hpp" -#include "sdk/components/mini_servo_motor/mini_servo_motor_ctrl_module.hpp" -#include "sdk/components/sensors/m3078/m3078_code_scaner.hpp" -#include "sdk/components/step_motor_ctrl_module/step_motor_ctrl_module.hpp" -#include "sdk/components/tmc/ic/ztmc4361A.hpp" -#include "sdk\components\pipette_module\pipette_ctrl_module_v2.hpp" -#include "sdk\components\xy_robot_ctrl_module\xy_robot_ctrl_module.hpp" - -#define TAG "Subboard10Hbot" - -using namespace iflytop; - -/*********************************************************************************************************************** - * IMPL * - ***********************************************************************************************************************/ -void Subboard10Hbot::initialize() { - IO_INIT(); - GService::inst()->getZCanProtocolParser()->registerModule(this); -#if 1 - /*********************************************************************************************************************** - * ID1 * - ***********************************************************************************************************************/ - static XYRobotCtrlModule xyRobotCtrlModule; - static TMC4361A motora; // 1 - static TMC4361A motorb; // 2 - { - TMC4361A::cfg_t cfg = { - .spi = &TMC_MOTOR_SPI, // - .csgpio = TMC_MOTOR1_SPI_SELECT1_IO, // - .resetPin = TMC_MOTOR1_nRESET_IO, // - .fREEZEPin = TMC_MOTOR1_nFREEZE_IO, // - .ennPin = PinNull, // - .driverIC_ennPin = TMC_MOTOR1_SUB_IC_ENN_IO, // - .driverIC_resetPin = PinNull, // - }; - motora.initialize(&cfg); - motora.setMotorShaft(false); - motora.setGlobalScale(31); - ZLOGI(TAG, "motora initialize TMC4361A:%x DriverIC:%x", motora.readICVersion(), motora.driverIC_readICVersion()); - } - - { - TMC4361A::cfg_t cfg = { - .spi = &TMC_MOTOR_SPI, // - .csgpio = TMC_MOTOR2_SPI_SELECT1_IO, // - .resetPin = TMC_MOTOR2_nRESET_IO, // - .fREEZEPin = TMC_MOTOR2_nFREEZE_IO, // - .ennPin = PinNull, // - .driverIC_ennPin = TMC_MOTOR2_SUB_IC_ENN_IO, // - .driverIC_resetPin = PinNull, // - }; - motorb.initialize(&cfg); - motorb.setMotorShaft(false); - motorb.setGlobalScale(31); - ZLOGI(TAG, "motorb initialize TMC4361A:%x DriverIC:%x", motorb.readICVersion(), motorb.driverIC_readICVersion()); - } - - motora.setAcceleration(300); - motora.setDeceleration(300); - motora.setIHOLD_IRUN(0, 4, 10); - - motorb.setAcceleration(300); - motorb.setDeceleration(300); - motorb.setIHOLD_IRUN(0, 4, 10); - - motora.rotate(0); - motorb.rotate(0); - - /******************************************************************************* - * zcanXYRobotCtrlModule * - *******************************************************************************/ - static ZGPIO input[4]; - input[0].initAsInput(ARM_X_ZERO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[1].initAsInput(ARM_Y_ZERO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[2].initAsInput(ARM_X_LIMIT, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[3].initAsInput(ARM_Y_LIMIT, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - - static XYRobotCtrlModule::config_t xy_defaultcfg; - XYRobotCtrlModule::create_default_cfg(xy_defaultcfg); - xy_defaultcfg.configInited = true; - xy_defaultcfg.robot_type = 1; - - xy_defaultcfg.robot_type = XYRobotCtrlModule::khbot; - xy_defaultcfg.x_shaft = 0; - xy_defaultcfg.y_shaft = 1; - xy_defaultcfg.ihold = 3; - xy_defaultcfg.irun = 31; - xy_defaultcfg.iholddelay = 100; - xy_defaultcfg.distance_scale = 7344; - xy_defaultcfg.shift_x = 0; - xy_defaultcfg.shift_y = 0; - - // limit - xy_defaultcfg.acc = 400; - xy_defaultcfg.dec = 400; - xy_defaultcfg.min_x = 0; - xy_defaultcfg.max_x = 0; - xy_defaultcfg.min_y = 0; - xy_defaultcfg.max_y = 0; - xy_defaultcfg.default_velocity = 300; - - xy_defaultcfg.run_to_zero_speed = 40; - xy_defaultcfg.look_zero_edge_speed = 10; - - xyRobotCtrlModule.initialize(getmoduleId(1), &motora, &motorb, &input[0], 4, xy_defaultcfg); - - GService::inst()->registerModule(&xyRobotCtrlModule); - -#endif -} diff --git a/usrc/subboards/subboard10_hbot/subboard10_hbot.hpp b/usrc/subboards/subboard10_hbot/subboard10_hbot.hpp deleted file mode 100644 index 8dcb1a4..0000000 --- a/usrc/subboards/subboard10_hbot/subboard10_hbot.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -// -#include "configs/device_id_mgr.hpp" -#include "sdk/chip/chip.hpp" -#include "sdk/os/zos.hpp" -// -#include "sdk\components\step_motor_ctrl_module\step_motor_ctrl_module.hpp" -#include "sdk\components\tmc\ic\ztmc5130.hpp" -#include "public_service/public_service.hpp" - -namespace iflytop { -class Subboard10Hbot : public ExtBoardImpl { - public: - static Subboard10Hbot *ins() { - static Subboard10Hbot instance; - return &instance; - } - - void initialize(); -}; - -} // namespace iflytop - diff --git a/usrc/subboards/subboard10_hbot/subboard10_hbot_board.c b/usrc/subboards/subboard10_hbot/subboard10_hbot_board.c deleted file mode 100644 index 0c278eb..0000000 --- a/usrc/subboards/subboard10_hbot/subboard10_hbot_board.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "main.h" -#include "public_service/public_service.h" - -/* SPI1 init function */ -static void MX_SPI1_Init(void) { - __HAL_RCC_SPI1_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - - hspi1.Instance = SPI1; - hspi1.Init.Mode = SPI_MODE_MASTER; - hspi1.Init.Direction = SPI_DIRECTION_2LINES; - hspi1.Init.DataSize = SPI_DATASIZE_8BIT; - hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; - hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32; - hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi1.Init.TIMode = SPI_TIMODE_DISABLE; - hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi1.Init.CRCPolynomial = 10; - if (HAL_SPI_Init(&hspi1) != HAL_OK) { - Error_Handler(); - } - GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - hspi1_enable = true; -} -/** - * @brief 板夹仓初始化 - */ - -void subboard10_hbot_board_init() { - common_hardware_init(); - MX_SPI1_Init(); -} diff --git a/usrc/subboards/subboard10_hbot/subboard10_hbot_board.h b/usrc/subboards/subboard10_hbot/subboard10_hbot_board.h deleted file mode 100644 index ef021a6..0000000 --- a/usrc/subboards/subboard10_hbot/subboard10_hbot_board.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "main.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void subboard10_hbot_board_init(); - -#ifdef __cplusplus -} -#endif diff --git a/usrc/subboards/subboard10_hbot_v2/pri_board.h b/usrc/subboards/subboard10_hbot_v2/pri_board.h index 143accb..83a35f4 100644 --- a/usrc/subboards/subboard10_hbot_v2/pri_board.h +++ b/usrc/subboards/subboard10_hbot_v2/pri_board.h @@ -32,66 +32,14 @@ #define MOTOR1_CSN PA4 #define MOTOR1_ENN PB7 +#define MOTOR2_CSN PC4 +#define MOTOR2_ENN PE13 + + -#define MOTOR1_REFL PD0 -#define MOTOR1_REFR PinNull -#define MOTOR1_REFL_MIRROR true -#define MOTOR1_REFR_MIRROR true -#define MOTOR1_MOTOR_SHAFT true -#define MOTOR1_MOTOR_ONE_CIRCLE_PULSE 60 -#define MOTOR1_MOTOR_ONE_CIRCLE_PULSE_DENOMINATOR 1 -#define MOTOR1_STEPMOTOR_IHOLD 1 -#define MOTOR1_STEPMOTOR_IRUN 30 -#define MOTOR1_STEPMOTOR_IHOLDDELAY 100 -#define MOTOR1_STEPMOTOR_IGLOBALSCALER 32 -#define MOTOR1_MOTOR_DEFAULT_VELOCITY 1000 -#define MOTOR1_MIN_D 0 -#define MOTOR1_MAX_D 0 -#define MOTOR1_MOTOR_RUN_TO_ZERO_SPEED 400 -#define MOTOR1_MOTOR_LOOK_ZERO_EDGE_SPEED 50 -#define MOTOR1_MOTOR_VSTART TMC5130_DEFAULT__MOTOR_VSTART -#define MOTOR1_MOTOR_A1 TMC5130_DEFAULT__MOTOR_A1 -#define MOTOR1_MOTOR_AMAX 300 -#define MOTOR1_MOTOR_V1 TMC5130_DEFAULT__MOTOR_V1 -#define MOTOR1_MOTOR_DMAX 300 -#define MOTOR1_MOTOR_D1 TMC5130_DEFAULT__MOTOR_D1 -#define MOTOR1_MOTOR_VSTOP TMC5130_DEFAULT__MOTOR_VSTOP -#define MOTOR1_MOTOR_TZEROWAIT TMC5130_DEFAULT__MOTOR_TZEROWAIT -#define MOTOR1_ENC_RESOLUTION 0 -#define MOTOR1_ENABLE_ENC_RESOLUTION 0 /*********************************************************************************************************************** * 电机2 * ***********************************************************************************************************************/ -#define MOTOR2_CSN PC4 -#define MOTOR2_ENN PE13 - -#define MOTOR2_REFL PinNull -#define MOTOR2_REFR PinNull -#define MOTOR2_REFL_MIRROR true -#define MOTOR2_REFR_MIRROR true - -#define MOTOR2_MOTOR_SHAFT true -#define MOTOR2_MOTOR_ONE_CIRCLE_PULSE 80 -#define MOTOR2_MOTOR_ONE_CIRCLE_PULSE_DENOMINATOR 1 -#define MOTOR2_STEPMOTOR_IHOLD 1 -#define MOTOR2_STEPMOTOR_IRUN 30 -#define MOTOR2_STEPMOTOR_IHOLDDELAY 100 -#define MOTOR2_STEPMOTOR_IGLOBALSCALER 32 -#define MOTOR2_MOTOR_DEFAULT_VELOCITY 1000 -#define MOTOR2_MIN_D 0 -#define MOTOR2_MAX_D 0 -#define MOTOR2_MOTOR_RUN_TO_ZERO_SPEED 300 -#define MOTOR2_MOTOR_LOOK_ZERO_EDGE_SPEED 50 -#define MOTOR2_MOTOR_VSTART TMC5130_DEFAULT__MOTOR_VSTART -#define MOTOR2_MOTOR_A1 TMC5130_DEFAULT__MOTOR_A1 -#define MOTOR2_MOTOR_AMAX 300 -#define MOTOR2_MOTOR_V1 TMC5130_DEFAULT__MOTOR_V1 -#define MOTOR2_MOTOR_DMAX 300 -#define MOTOR2_MOTOR_D1 TMC5130_DEFAULT__MOTOR_D1 -#define MOTOR2_MOTOR_VSTOP TMC5130_DEFAULT__MOTOR_VSTOP -#define MOTOR2_MOTOR_TZEROWAIT TMC5130_DEFAULT__MOTOR_TZEROWAIT -#define MOTOR2_ENC_RESOLUTION 0 -#define MOTOR2_ENABLE_ENC_RESOLUTION 0 \ No newline at end of file diff --git a/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp b/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp index 420f799..c54f890 100644 --- a/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp +++ b/usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp @@ -43,46 +43,38 @@ void Subboard10HbotV2::initialize() { osDelay(10); motorPowerEnPin.initAsOutput(PB12, iflytop::ZGPIO::kMode_nopull, true, true); - TMC5130_MOTOR_INITER(/*motorid*/ 1, /*moduleid*/ 1); - TMC5130_MOTOR_INITER(/*motorid*/ 2, /*moduleid*/ 2); + // TMC5130_MOTOR_INITER(/*motorid*/ 1, /*moduleid*/ 1); + // TMC5130_MOTOR_INITER(/*motorid*/ 2, /*moduleid*/ 2); -#if 0 +#if 1 /*********************************************************************************************************************** * ID1 * ***********************************************************************************************************************/ static XYRobotCtrlModule xyRobotCtrlModule; - static TMC4361A motora; // 1 - static TMC4361A motorb; // 2 + static TMC51X0 motora; // 1 + static TMC51X0 motorb; // 2 { - TMC4361A::cfg_t cfg = { - .spi = &TMC_MOTOR_SPI, // - .csgpio = TMC_MOTOR1_SPI_SELECT1_IO, // - .resetPin = TMC_MOTOR1_nRESET_IO, // - .fREEZEPin = TMC_MOTOR1_nFREEZE_IO, // - .ennPin = PinNull, // - .driverIC_ennPin = TMC_MOTOR1_SUB_IC_ENN_IO, // - .driverIC_resetPin = PinNull, // + TMC51X0::cfg_t cfg = { + .spi = &TMC_MOTOR_SPI, // + .csgpio = MOTOR1_CSN, // + .ennPin = MOTOR1_ENN, // }; motora.initialize(&cfg); motora.setMotorShaft(false); motora.setGlobalScale(31); - ZLOGI(TAG, "motora initialize TMC4361A:%x DriverIC:%x", motora.readICVersion(), motora.driverIC_readICVersion()); + ZLOGI(TAG, "motora initialize TMC51X0:%x", motora.readICVersion()); } { - TMC4361A::cfg_t cfg = { - .spi = &TMC_MOTOR_SPI, // - .csgpio = TMC_MOTOR2_SPI_SELECT1_IO, // - .resetPin = TMC_MOTOR2_nRESET_IO, // - .fREEZEPin = TMC_MOTOR2_nFREEZE_IO, // - .ennPin = PinNull, // - .driverIC_ennPin = TMC_MOTOR2_SUB_IC_ENN_IO, // - .driverIC_resetPin = PinNull, // + TMC51X0::cfg_t cfg = { + .spi = &TMC_MOTOR_SPI, // + .csgpio = MOTOR2_CSN, // + .ennPin = MOTOR2_ENN, // }; motorb.initialize(&cfg); motorb.setMotorShaft(false); motorb.setGlobalScale(31); - ZLOGI(TAG, "motorb initialize TMC4361A:%x DriverIC:%x", motorb.readICVersion(), motorb.driverIC_readICVersion()); + ZLOGI(TAG, "motorb initialize TMC51X0:%x", motora.readICVersion()); } motora.setAcceleration(300); @@ -100,37 +92,44 @@ void Subboard10HbotV2::initialize() { * zcanXYRobotCtrlModule * *******************************************************************************/ static ZGPIO input[4]; - input[0].initAsInput(ARM_X_ZERO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[1].initAsInput(ARM_Y_ZERO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[2].initAsInput(ARM_X_LIMIT, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); - input[3].initAsInput(ARM_Y_LIMIT, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true); + + + input[0].initAsInput(EXT_INPUT_IO0); + input[1].initAsInput(EXT_INPUT_IO1); + input[2].initAsInput(EXT_INPUT_IO2); + input[3].initAsInput(EXT_INPUT_IO3); static XYRobotCtrlModule::config_t xy_defaultcfg; XYRobotCtrlModule::create_default_cfg(xy_defaultcfg); - xy_defaultcfg.configInited = true; - xy_defaultcfg.robot_type = 1; - - xy_defaultcfg.robot_type = XYRobotCtrlModule::khbot; - xy_defaultcfg.x_shaft = 0; - xy_defaultcfg.y_shaft = 1; - xy_defaultcfg.ihold = 3; - xy_defaultcfg.irun = 31; - xy_defaultcfg.iholddelay = 100; - xy_defaultcfg.distance_scale = 7344; - xy_defaultcfg.shift_x = 0; - xy_defaultcfg.shift_y = 0; - - // limit - xy_defaultcfg.acc = 400; - xy_defaultcfg.dec = 400; - xy_defaultcfg.min_x = 0; - xy_defaultcfg.max_x = 0; - xy_defaultcfg.min_y = 0; - xy_defaultcfg.max_y = 0; - xy_defaultcfg.default_velocity = 300; - - xy_defaultcfg.run_to_zero_speed = 40; - xy_defaultcfg.look_zero_edge_speed = 10; + + xy_defaultcfg.robot_type = XYRobotCtrlModule::khbot; + xy_defaultcfg.one_circle_pulse = 7344; + xy_defaultcfg.one_circle_pulse_denominator = 1; + xy_defaultcfg.ihold = 1; + xy_defaultcfg.irun = 31; + xy_defaultcfg.iholddelay = 100; + xy_defaultcfg.iglobalscaler = 32; + xy_defaultcfg.vstart = TMC5130_DEFAULT__MOTOR_VSTART; + xy_defaultcfg.a1 = TMC5130_DEFAULT__MOTOR_A1; + xy_defaultcfg.amax = TMC5130_DEFAULT__MOTOR_AMAX; + xy_defaultcfg.v1 = TMC5130_DEFAULT__MOTOR_V1; + xy_defaultcfg.dmax = TMC5130_DEFAULT__MOTOR_DMAX; + xy_defaultcfg.d1 = TMC5130_DEFAULT__MOTOR_D1; + xy_defaultcfg.vstop = TMC5130_DEFAULT__MOTOR_VSTOP; + xy_defaultcfg.tzerowait = TMC5130_DEFAULT__MOTOR_TZEROWAIT; + xy_defaultcfg.enc_resolution = 1000; + xy_defaultcfg.enable_enc = 1; + xy_defaultcfg.x_shaft = 0; + xy_defaultcfg.y_shaft = 1; + xy_defaultcfg.default_velocity = 300; + xy_defaultcfg.shift_x = 0; + xy_defaultcfg.shift_y = 0; + xy_defaultcfg.min_x = 0; + xy_defaultcfg.min_y = 0; + xy_defaultcfg.max_x = 0; + xy_defaultcfg.max_y = 0; + xy_defaultcfg.run_to_zero_speed = 40; + xy_defaultcfg.look_zero_edge_speed = 10; xyRobotCtrlModule.initialize(getmoduleId(1), &motora, &motorb, &input[0], 4, xy_defaultcfg);