From 2e9fec51b0d4a43adc356ece63f43dec07b7b8fd Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 20 Sep 2024 16:44:42 +0800 Subject: [PATCH] update --- .../pipette_module/pipette_ctrl_module_v2.cpp | 48 +++++++++++++--------- .../pipette_module/pipette_ctrl_module_v2.hpp | 6 +-- sdk/components/zcancmder/zcan_protocol_parser.cpp | 8 ++-- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp index 976a23b..62cfcc4 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -33,10 +33,10 @@ #define THREAD_START_WORK(...) thread_start_work(__FUNCTION__, __VA_ARGS__) -#define PIPETTE_PREPARE_POS 400 +#define PIPETTE_PREPARE_POS 550 #define LLD_PREPARE_DISTRIBUT_POS 100 #define LLF_DPOS 1000 -#define ASPIRATE_POS 100 +#define ASPIRATE_POS 150 using namespace iflytop; // using namespace pipette_module_v3; @@ -77,8 +77,8 @@ void PipetteModuleV2::create_default_cfg(config_t *defaultcfg) { defaultcfg->aspirate_pump_vel = 500; // 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 = 110; + defaultcfg->lld_pump_vel = 80; // lld推荐使用速度为50->200,这里 + defaultcfg->lld_motor_vel_rpm = 80; defaultcfg->lld_detect_period_ms = 1; // 100ms defaultcfg->lld_prepare_pos = PIPETTE_PREPARE_POS; defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; @@ -345,12 +345,12 @@ int32_t PipetteModuleV2::pipette_lld_prepare() { return 0; } -int32_t PipetteModuleV2::pipette_lld_test(int32_t zdpos) { // - return do_pipette_lld(true, kplld, zdpos, 100, 1000); +int32_t PipetteModuleV2::pipette_lld_test(int32_t startpos, int32_t zdpos) { // + return do_pipette_lld(true, kplld, startpos, zdpos, 100, 1000); } -int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { // - return do_pipette_lld(false, lldtype, zdpos, c_threshold, p_threshold); +int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t startpos, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { // + return do_pipette_lld(false, lldtype, startpos, zdpos, c_threshold, p_threshold); } int32_t PipetteModuleV2::pipette_lld_is_detect_liquid(int32_t *detect) { @@ -426,9 +426,11 @@ int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { pump_waitfor_stop(); // 全部排空时,多分配10ul去掉挂液 - if ((m_state.load_val_ul - dul) == 0) { - m_smtp2.pump_aspirate(m_cfg.aspirate_pump_vel, -10); + if ((m_state.load_val_ul + dul) == 0) { + m_smtp2.pump_aspirate(m_cfg.aspirate_pump_vel, -50); pump_waitfor_stop(); + // for (size_t i = 0; i < 3; i++) { + // } } // stop @@ -616,15 +618,15 @@ void PipetteModuleV2::do_pipette_zmotor_move_to_zero_point_quick() { throw zapp_exception(err::kstep_motor_lost_step); } } -int32_t PipetteModuleV2::do_pipette_lld(bool recorddata, int32_t lldtype /*kclld = 0,kplld = 1, kmixlld = 2, */, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { +int32_t PipetteModuleV2::do_pipette_lld(bool recorddata, int32_t lldtype, int32_t startpos, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { // 检查泵机是否初始化过 if (lldtype < 0 || lldtype > klldtypemax) { return err::kparam_out_of_range; } - THREAD_START_WORK([this, recorddata, lldtype, zdpos, c_threshold, p_threshold]() { // - m_state.lld_prepared = 0; // 失效m_state.lld_prepared + THREAD_START_WORK([this, recorddata, lldtype, startpos, zdpos, c_threshold, p_threshold]() { // + m_state.lld_prepared = 0; // 失效m_state.lld_prepared int32_t start_capacitance = 0; // 启动时电容数值 int32_t start_pressure = 0; // 启动时压力数值 @@ -645,7 +647,10 @@ int32_t PipetteModuleV2::do_pipette_lld(bool recorddata, int32_t lldtype /*kclld ZLOGI(TAG, "lld before distribut ok"); ZLOGI(TAG, "start lld"); - zm_move_by(zdpos, m_cfg.lld_motor_vel_rpm); + + bool moveToStartPos = false; + + zm_move_to(startpos, m_cfg.zm_default_velocity); osDelay(10); if (lldtype == kclld) { DO_IN_THREAD(m_smtp2.pump_clld(c_threshold)); @@ -690,11 +695,16 @@ int32_t PipetteModuleV2::do_pipette_lld(bool recorddata, int32_t lldtype /*kclld // 电机停了也没有探测到液面 if (m_zm->isStoped()) { - ZLOGI(TAG, "motorstoped,but not detect liquid"); - creg.module_errorcode = 0; - m_state.detected_liquid = 0; - if (recorddata) push_snesor_sample_data(motorpos, capacitance, pressure); - break; + if (!moveToStartPos) { + zm_move_by(zdpos, m_cfg.lld_motor_vel_rpm); + moveToStartPos = true; + } else { + ZLOGI(TAG, "motorstoped,but not detect liquid"); + creg.module_errorcode = 0; + m_state.detected_liquid = 0; + if (recorddata) push_snesor_sample_data(motorpos, capacitance, pressure); + break; + } } if (recorddata) push_snesor_sample_data(motorpos, capacitance, pressure); diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp index 7787f26..3b2a9e0 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp @@ -170,8 +170,8 @@ class PipetteModuleV2 : public ZIModule { virtual int32_t pipette_init_device(); virtual int32_t pipette_put_tip(); virtual int32_t pipette_lld_prepare(); - virtual int32_t pipette_lld(int32_t lldtype /*kclld = 0,kplld = 1, kmixlld = 2, */, int32_t zdpos, int32_t c_threshold, int32_t p_threshold); - virtual int32_t pipette_lld_test(int32_t zdpos); + virtual int32_t pipette_lld(int32_t lldtype /*kclld = 0,kplld = 1, kmixlld = 2, */, int32_t startpos, int32_t zdpos, int32_t c_threshold, int32_t p_threshold); + virtual int32_t pipette_lld_test(int32_t startpos, int32_t zdpos); virtual int32_t pipette_lld_is_detect_liquid(int32_t *detect); virtual int32_t pipette_aspirate_prepare(); @@ -204,7 +204,7 @@ class PipetteModuleV2 : public ZIModule { private: void do_zm_move_0p(); void do_pipette_zmotor_move_to_zero_point_quick(); - int32_t do_pipette_lld(bool recorddata, int32_t lldtype /*kclld = 0,kplld = 1, kmixlld = 2, */, int32_t zdpos, int32_t c_threshold, int32_t p_threshold); + int32_t do_pipette_lld(bool recorddata, int32_t lldtype, int32_t startpos, int32_t zdpos, int32_t c_threshold, int32_t p_threshold); private: int32_t zm_get_now_pos(); diff --git a/sdk/components/zcancmder/zcan_protocol_parser.cpp b/sdk/components/zcancmder/zcan_protocol_parser.cpp index b6f4181..b7c4965 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.cpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.cpp @@ -986,8 +986,8 @@ int32_t ZCanProtocolParser::pipette_lld_prepare(cmdcontxt_t* cxt) { return module->pipette_lld_prepare(); } int32_t ZCanProtocolParser::pipette_lld(cmdcontxt_t* cxt) { - CHECK_AND_GET_MODULE(4); - return module->pipette_lld(cxt->params[0], cxt->params[1], cxt->params[2], cxt->params[3]); + CHECK_AND_GET_MODULE(5); + return module->pipette_lld(cxt->params[0], cxt->params[1], cxt->params[2], cxt->params[3], cxt->params[4]); } int32_t ZCanProtocolParser::pipette_aspirate_prepare(cmdcontxt_t* cxt) { CHECK_AND_GET_MODULE(0); @@ -1073,8 +1073,8 @@ int32_t ZCanProtocolParser::pipette_lld_is_detect_liquid(cmdcontxt_t* cxt) { } // pipette_lld_test int32_t ZCanProtocolParser::pipette_lld_test(cmdcontxt_t* cxt) { - CHECK_AND_GET_MODULE(1); - return module->pipette_lld_test(cxt->params[0]); + CHECK_AND_GET_MODULE(2); + return module->pipette_lld_test(cxt->params[0],cxt->params[1]); } #undef MODULE_CLASS \ No newline at end of file