16 changed files with 375 additions and 110 deletions
-
2sdk
-
8usrc/main.cpp
-
50usrc/public_service/instance_init.hpp
-
31usrc/subboards/subboard100_idcard_reader/pri_board.h
-
93usrc/subboards/subboard10_hbot_v2/pri_board.h
-
38usrc/subboards/subboard10_hbot_v2/subboard10_hbot_board_v2.c
-
12usrc/subboards/subboard10_hbot_v2/subboard10_hbot_board_v2.h
-
194usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.cpp
-
25usrc/subboards/subboard10_hbot_v2/subboard10_hbot_v2.hpp
-
3usrc/subboards/subboard200_ext_tmc5160/pri_board.h
-
5usrc/subboards/subboard200_ext_tmc5160/subboard200_ext_tmc5160.cpp
-
8usrc/subboards/subboard20_plate_clamp_case/pri_board.h
-
3usrc/subboards/subboard70_incubation_turntable/pri_board.h
-
2usrc/subboards/subboard70_incubation_turntable/subboard70_incubation_turntable.cpp
-
3usrc/subboards/subboard80_cliptip/pri_board.h
-
8usrc/subboards/subboard90_optical_module/pri_board.h
@ -1 +1 @@ |
|||
Subproject commit 7ab0d4ae00c6053d0a6aa35b1fa8fd26d027cfd1 |
|||
Subproject commit 375cae628409bb2773c208d2979b27f8e4b2de1f |
@ -0,0 +1,93 @@ |
|||
#pragma once |
|||
/*********************************************************************************************************************** |
|||
* 板载扩展IO * |
|||
***********************************************************************************************************************/ |
|||
#define EXT_INPUT_IO0 PD0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true |
|||
#define EXT_INPUT_IO1 PD1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true |
|||
#define EXT_INPUT_IO2 PD2, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true |
|||
#define EXT_INPUT_IO3 PD3, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true |
|||
#define EXT_INPUT_IO4 PD10, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true |
|||
#define EXT_INPUT_IO5 PD11, 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 PD9, ZGPIO::kMode_nopull, true /*mirror*/, false /*init val*/ |
|||
#define EXT_OUTPUT_IO1 PD10, ZGPIO::kMode_nopull, true /*mirror*/, false /*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 |
|||
|
|||
/*********************************************************************************************************************** |
|||
* 电机1 * |
|||
***********************************************************************************************************************/ |
|||
|
|||
#define MOTOR1_CSN PA4 |
|||
#define MOTOR1_ENN PB7 |
|||
|
|||
#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 5 |
|||
#define MOTOR1_STEPMOTOR_IHOLDDELAY 100 |
|||
#define MOTOR1_STEPMOTOR_IGLOBALSCALER 0 |
|||
#define MOTOR1_MOTOR_DEFAULT_VELOCITY 500 |
|||
#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 |
|||
|
|||
/*********************************************************************************************************************** |
|||
* 电机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 5 |
|||
#define MOTOR2_STEPMOTOR_IHOLDDELAY 100 |
|||
#define MOTOR2_STEPMOTOR_IGLOBALSCALER 0 |
|||
#define MOTOR2_MOTOR_DEFAULT_VELOCITY 500 |
|||
#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 |
@ -0,0 +1,38 @@ |
|||
#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; |
|||
} |
|||
|
|||
void subboard10v2_hbot_board_init() { |
|||
common_hardware_init(); |
|||
MX_SPI1_Init(); |
|||
} |
@ -0,0 +1,12 @@ |
|||
#pragma once |
|||
#include "main.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
void subboard10v2_hbot_board_init(); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
@ -0,0 +1,194 @@ |
|||
#include "subboard10_hbot_v2.hpp"
|
|||
extern "C" { |
|||
#include "subboard10_hbot_board_v2.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 "Subboard10HbotV2"
|
|||
|
|||
using namespace iflytop; |
|||
|
|||
/***********************************************************************************************************************
|
|||
* IMPL * |
|||
***********************************************************************************************************************/ |
|||
void Subboard10HbotV2::initialize() { |
|||
// IO_INIT();
|
|||
GService::inst()->getZCanProtocolParser()->registerModule(this); |
|||
|
|||
// PB12
|
|||
|
|||
static ZGPIO motorPowerEnPin; |
|||
static ZGPIO motor1ENNPin; |
|||
static ZGPIO motor2ENNPin; |
|||
|
|||
static ZGPIO TMC51X0_1_SPI_MODE; |
|||
static ZGPIO TMC51X0_1_SD_MODE; |
|||
static ZGPIO TMC51X0_2_SPI_MODE; |
|||
static ZGPIO TMC51X0_2_SD_MODE; |
|||
|
|||
motor1ENNPin.initAsOutput(MOTOR1_ENN, iflytop::ZGPIO::kMode_nopull, false, true); |
|||
motor2ENNPin.initAsOutput(MOTOR2_ENN, iflytop::ZGPIO::kMode_nopull, false, true); |
|||
motorPowerEnPin.initAsOutput(PB12, iflytop::ZGPIO::kMode_nopull, true, true); |
|||
|
|||
osDelay(100); |
|||
|
|||
// #define MOTOR1_CSN PA4
|
|||
// #define MOTOR1_ENN PB7
|
|||
// #define MOTOR1_SPI_MODE_SELECT PB4
|
|||
// #define MOTOR1_nFREEZE_IO PE12
|
|||
// #define MOTOR1_nRESET_IO PinNull
|
|||
|
|||
{ |
|||
{ |
|||
static TMC51X0 motor; |
|||
static StepMotorCtrlModule module; |
|||
int subid = 1; |
|||
TMC51X0::cfg_t tmc5130cfg = { |
|||
.spi = &hspi1, |
|||
.csgpio = PA4, |
|||
.ennPin = PB7 |
|||
}; |
|||
motor.initialize(&tmc5130cfg); |
|||
motor.setIHOLD_IRUN(1, 3, 100); |
|||
motor.enable(true); |
|||
motor.rotate(800); |
|||
// motor.setMotorShaft(false);
|
|||
// static ZGPIO input[2];
|
|||
// input[0].initAsInput(PD0, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|||
// input[1].initAsInput(PD1, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
|
|||
// StepMotorCtrlModule::config_t stepcfg = {0};
|
|||
// StepMotorCtrlModule::create_default_cfg(stepcfg);
|
|||
// stepcfg.motor_shaft = false;
|
|||
// stepcfg.motor_one_circle_pulse = 10000;
|
|||
// stepcfg.motor_one_circle_pulse_denominator = 1;
|
|||
// stepcfg.stepmotor_ihold = 5;
|
|||
// stepcfg.stepmotor_irun = 20;
|
|||
// stepcfg.stepmotor_iholddelay = 10;
|
|||
// stepcfg.stepmotor_iglobalscaler = 0;
|
|||
// stepcfg.motor_default_velocity = 600;
|
|||
// stepcfg.min_d = 0;
|
|||
// stepcfg.max_d = 0;
|
|||
// stepcfg.motor_run_to_zero_speed = 300;
|
|||
// stepcfg.motor_look_zero_edge_speed = 200;
|
|||
// stepcfg.motor_vstart = 100;
|
|||
// stepcfg.motor_a1 = 50;
|
|||
// stepcfg.motor_amax = 100;
|
|||
// stepcfg.motor_v1 = 300;
|
|||
// stepcfg.motor_dmax = 100;
|
|||
// stepcfg.motor_d1 = 50;
|
|||
// stepcfg.motor_vstop = 100;
|
|||
// stepcfg.motor_tzerowait = 0;
|
|||
// module.initialize(getmoduleId(subid), &motor, input, ((int32_t)(sizeof(input) / sizeof(input[0]))), &stepcfg);
|
|||
// GService::inst()->getZCanProtocolParser()->registerModule(&module);
|
|||
if (g_enable_log) { |
|||
zos_log( |
|||
"%08lu INFO [%-10s] " |
|||
"motor%d readic version %x" |
|||
"\n", |
|||
zchip_clock_get_ticket(), "Subboard200ExtTmc5160", subid, motor.readICVersion()); |
|||
}; |
|||
} |
|||
} |
|||
// { TMC5130_MOTOR_INITER(2, 2); }
|
|||
|
|||
#if 0
|
|||
/***********************************************************************************************************************
|
|||
* 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
|
|||
} |
@ -0,0 +1,25 @@ |
|||
#include <stddef.h>
|
|||
#include <stdio.h>
|
|||
|
|||
//
|
|||
#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 Subboard10HbotV2 : public ExtBoardImpl { |
|||
public: |
|||
static Subboard10HbotV2 *ins() { |
|||
static Subboard10HbotV2 instance; |
|||
return &instance; |
|||
} |
|||
|
|||
void initialize(); |
|||
}; |
|||
|
|||
} // namespace iflytop
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue