diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp index 785f840..0e2eeba 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -36,7 +36,7 @@ #define PIPETTE_PREPARE_POS 800 #define LLD_PREPARE_DISTRIBUT_POS 100 #define LLF_DPOS 1000 -#define ASPIRATE_POS 0 +#define ASPIRATE_POS 100 using namespace iflytop; // using namespace pipette_module_v3; @@ -78,7 +78,7 @@ void PipetteModuleV2::create_default_cfg(config_t *defaultcfg) { defaultcfg->pump_vmax = 1000; defaultcfg->aspirate_zmotor_max_move_by = 400; // 50mm,tip头的长度 defaultcfg->lld_pump_vel = 100; // lld推荐使用速度为50->200,这里 - defaultcfg->lld_motor_vel_rpm = 150; + defaultcfg->lld_motor_vel_rpm = 110; defaultcfg->lld_detect_period_ms = 1; // 100ms defaultcfg->lld_prepare_pos = PIPETTE_PREPARE_POS; defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; @@ -363,8 +363,19 @@ int32_t PipetteModuleV2::pipette_aspirate_prepare() { m_state.aspirate_cfg_eigen_time = 0; m_state.aspirate_cfg_p_thre = 0; m_state.aspirate_cfg_llf_zm_rpm = 0; + + int32_t nowpos = zm_get_now_pos(); + int32_t bak = nowpos - 100; + if (bak < 0) bak = 0; + + zm_move_to(bak, m_cfg.zm_default_velocity); + zm_waitfor_stop(); + DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_cfg.pump_vmax, ASPIRATE_POS)); pump_waitfor_stop(); + + zm_move_to(nowpos, m_cfg.zm_default_velocity); + zm_waitfor_stop(); ZLOGI(TAG, "pipette_aspirate_prepare end..."); }); return 0; @@ -393,6 +404,12 @@ int32_t PipetteModuleV2::pipette_aspirate_set_operation_verifi_tolerance(int32_t } int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { + // pipette_aspirate + if (m_state.load_val_ul + ul > m_cfg.limit_ul) { + ZLOGE(TAG, "pipette_aspirate %d fail , final ul (%d + %d)> limit ul %d", ul, m_state.load_val_ul, ul, m_cfg.limit_ul); + return err::kparam_out_of_range; + } + THREAD_START_WORK([this, ul]() { m_state.lld_prepared = 0; @@ -419,6 +436,11 @@ int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { return 0; } int32_t PipetteModuleV2::pipette_aspirate_and_verify(int32_t ul) { + if (m_state.load_val_ul + ul > m_cfg.limit_ul) { + ZLOGE(TAG, "pipette_aspirate %d fail , final ul (%d + %d)> limit ul %d", ul, m_state.load_val_ul, ul, m_cfg.limit_ul); + return err::kparam_out_of_range; + } + THREAD_START_WORK([this, ul]() { m_state.lld_prepared = 0; @@ -818,37 +840,36 @@ int32_t PipetteModuleV2::bfcall(int32_t cmdid, uint8_t *param, int32_t len) { MODULE_BFCALL_DUMP_FN_CALL(cmdid, param32, paramNum); } - if (cmdid == kpipette_zmotor_move_zero) goto motor_check_bf_run; - if (cmdid == kpipette_zmotor_move_to_zero_point_quick) goto motor_move_to_check; - if (cmdid == kpipette_zmotor_measure_distance) goto motor_move_to_check; - if (cmdid == kpipette_zmotor_move_by) goto motor_check_bf_run; - if (cmdid == kpipette_zmotor_move_to) goto motor_move_to_check; - - if (cmdid == kpipette_init_device) goto check; - if (cmdid == kpipette_put_tip) goto check; - if (cmdid == kpipette_lld_prepare) goto check; - if (cmdid == kpipette_lld) goto motor_check_bf_run; - if (cmdid == kpipette_aspirate_prepare) goto check; - if (cmdid == kpipette_aspirate_set_llf_velocity) goto check; - if (cmdid == kpipette_aspirate_set_operation_verifi_p_thre) goto check; - if (cmdid == kpipette_aspirate_set_operation_verifi_eigen_time) goto check; - if (cmdid == kpipette_aspirate_set_operation_verifi_tolerance) goto check; - if (cmdid == kpipette_aspirate) goto motor_check_bf_run; - if (cmdid == kpipette_aspirate_and_verify) goto motor_check_bf_run; - if (cmdid == kpipette_shake_up) goto motor_check_bf_run; - if (cmdid == kpipette_aspirate_infer_pressure) goto check; - if (cmdid == kpipette_aspirate_infer_eigen_time) goto check; - - return 0; - -motor_move_to_check: - if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; - goto motor_check_bf_run; + if (cmdid == kpipette_zmotor_move_zero) goto check_motor_is_enable; + if (cmdid == kpipette_zmotor_move_by) goto check_motor_is_enable; + + if (cmdid == kpipette_zmotor_move_to_zero_point_quick) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_zmotor_measure_distance) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_zmotor_move_to) goto check_motor_has_moveto_zero; + + if (cmdid == kpipette_init_device) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_put_tip) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_lld_prepare) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_lld) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_lld_test) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_aspirate_prepare) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_aspirate) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_aspirate_and_verify) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_shake_up) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_aspirate_infer_pressure) goto check_motor_has_moveto_zero; + if (cmdid == kpipette_aspirate_infer_eigen_time) goto check_motor_has_moveto_zero; + + return 0; -motor_check_bf_run: +check_motor_is_enable: if (m_state.enable == 0) return err::kstep_motor_not_enable; goto check; +check_motor_has_moveto_zero: + if (m_state.enable == 0) return err::kstep_motor_not_enable; + if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; + goto check; + check: if (creg.module_errorcode == err::kstep_motor_subic_reset) { return creg.module_errorcode; @@ -862,7 +883,6 @@ check: */ return 0; } - return 0; } void PipetteModuleV2::aftercall(int32_t cmdid, uint8_t *param, int32_t len, uint8_t *ack, int32_t acklen, int32_t ret) { diff --git a/usrc/subboards/subboard80_cliptip/subboard80_cliptip.cpp b/usrc/subboards/subboard80_cliptip/subboard80_cliptip.cpp index 7ea9470..e0186a3 100644 --- a/usrc/subboards/subboard80_cliptip/subboard80_cliptip.cpp +++ b/usrc/subboards/subboard80_cliptip/subboard80_cliptip.cpp @@ -89,7 +89,6 @@ void Subboard80Cliptip::initialize() { cfg.zm_enc_resolution = MOTOR1_ENC_RESOLUTION; cfg.zm_enable_enc = MOTOR1_ENABLE_ENC_RESOLUTION; // - cfg.limit_ul = 30; PipetteModuleV2::hardward_config_t hardwarecfg = { .uart = &huart2,