diff --git a/a8000_protocol b/a8000_protocol index 60bf493..6c53aa3 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit 60bf4933a4ad9ef89802826dd5cc253efe4af94d +Subproject commit 6c53aa3ab6e9888e39bcc92f7956d9fc6ad135a9 diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp index bcdaa06..785f840 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -78,8 +78,8 @@ 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 = 200; - defaultcfg->lld_detect_period_ms = 5; // 100ms + defaultcfg->lld_motor_vel_rpm = 150; + defaultcfg->lld_detect_period_ms = 1; // 100ms defaultcfg->lld_prepare_pos = PIPETTE_PREPARE_POS; defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; @@ -343,100 +343,13 @@ int32_t PipetteModuleV2::pipette_lld_prepare() { }); return 0; } -int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, 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, lldtype, zdpos, c_threshold, p_threshold]() { // - m_state.lld_prepared = 0; // 失效m_state.lld_prepared - - int32_t start_capacitance = 0; // 启动时电容数值 - int32_t start_pressure = 0; // 启动时压力数值 - int32_t start_motor_pos = 0; // 启动时电机位置 - - // 准备 - capturedata_num = 0; - - // 读取初值 - DO_IN_THREAD(m_smtp2.pump_get_capacitance(&start_capacitance)); - DO_IN_THREAD(m_smtp2.pump_get_pressure(&start_pressure)); - start_motor_pos = m_zm->getXACTUAL(); - - // 先分配一点体积,消除一些误差。 - ZLOGI(TAG, "start lld before distribut %d ul", m_cfg.lld_prepare_pre_distribut_ul); - DO_IN_THREAD(m_smtp2.pump_distribut(m_cfg.pump_vmax, m_cfg.lld_prepare_pre_distribut_ul)); - pump_waitfor_stop(); - ZLOGI(TAG, "lld before distribut ok"); - - ZLOGI(TAG, "start lld"); - zm_move_by(zdpos, m_cfg.lld_motor_vel_rpm); - osDelay(10); - if (lldtype == kclld) { - DO_IN_THREAD(m_smtp2.pump_clld(c_threshold)); - } else if (lldtype == kplld) { - DO_IN_THREAD(m_smtp2.pump_distribut_plld(m_cfg.lld_pump_vel, p_threshold)); - } else if (lldtype == kmixlld) { - DO_IN_THREAD(m_smtp2.pump_distribut_mlld(m_cfg.lld_pump_vel, c_threshold, p_threshold)); - } - while (true) { - bool motorstoped = false; - int32_t motorerror = 0; - - int32_t motorpos = 0; - int32_t capacitance = 0; - int32_t pressure = 0; - - // 获取状态 - DO_IN_THREAD(m_smtp2.pump_get_capacitance(&capacitance)); - DO_IN_THREAD(m_smtp2.pump_get_pressure(&pressure)); - motorpos = m_zm->getXACTUAL() - start_motor_pos; - - // 液面探测检测 - int32_t detect_liquid = 0; - if (lldtype == kclld) { - DO_IN_THREAD(m_smtp2.pump_clld_get_state(&detect_liquid)); - } else if (lldtype == kplld) { - DO_IN_THREAD(m_smtp2.pump_distribut_plld_get_state(&detect_liquid)); - } else if (lldtype == kmixlld) { - DO_IN_THREAD(m_smtp2.pump_distribut_mlld_get_state(&detect_liquid)); - } - - // 探测到液面 - if (detect_liquid == 1) { - ZLOGI(TAG, "detect liquid"); - m_state.detected_liquid = 1; - m_zm->stop(); - push_snesor_sample_data(motorpos, capacitance, pressure); - break; - } - - // Z轴电机是否停止运动 - m_zm->readMotorState(&motorstoped, &motorerror); - if (motorerror != 0) { - creg.module_errorcode = motorerror; - ZLOGI(TAG, "motorerror %d", motorerror); - return; - } - - // 电机停了也没有探测到液面 - if (motorstoped) { - ZLOGI(TAG, "motorstoped,but not detect liquid"); - creg.module_errorcode = 0; - m_state.detected_liquid = 0; - push_snesor_sample_data(motorpos, capacitance, pressure); - return; - } - - push_snesor_sample_data(motorpos, capacitance, pressure); - m_thread.sleep(m_cfg.lld_detect_period_ms); - } +int32_t PipetteModuleV2::pipette_lld_test(int32_t zdpos) { // + return do_pipette_lld(true, kplld, zdpos, 100, 1000); +} - }); - return 0; +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_is_detect_liquid(int32_t *detect) { @@ -662,6 +575,94 @@ 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) { + // 检查泵机是否初始化过 + + 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 + + int32_t start_capacitance = 0; // 启动时电容数值 + int32_t start_pressure = 0; // 启动时压力数值 + int32_t start_motor_pos = 0; // 启动时电机位置 + + // 准备 + capturedata_num = 0; + + // 读取初值 + DO_IN_THREAD(m_smtp2.pump_get_capacitance(&start_capacitance)); + DO_IN_THREAD(m_smtp2.pump_get_pressure(&start_pressure)); + start_motor_pos = m_zm->getXACTUAL(); + + // 先分配一点体积,消除一些误差。 + ZLOGI(TAG, "start lld before distribut %d ul", m_cfg.lld_prepare_pre_distribut_ul); + DO_IN_THREAD(m_smtp2.pump_distribut(m_cfg.pump_vmax, m_cfg.lld_prepare_pre_distribut_ul)); + pump_waitfor_stop(); + ZLOGI(TAG, "lld before distribut ok"); + + ZLOGI(TAG, "start lld"); + zm_move_by(zdpos, m_cfg.lld_motor_vel_rpm); + osDelay(10); + if (lldtype == kclld) { + DO_IN_THREAD(m_smtp2.pump_clld(c_threshold)); + } else if (lldtype == kplld) { + DO_IN_THREAD(m_smtp2.pump_distribut_plld(m_cfg.lld_pump_vel, p_threshold)); + } else if (lldtype == kmixlld) { + DO_IN_THREAD(m_smtp2.pump_distribut_mlld(m_cfg.lld_pump_vel, c_threshold, p_threshold)); + } + + while (true) { + bool motorstoped = false; + int32_t motorerror = 0; + + int32_t motorpos = 0; + int32_t capacitance = 0; + int32_t pressure = 0; + + // 获取状态 + if (recorddata) { + DO_IN_THREAD(m_smtp2.pump_get_capacitance(&capacitance)); + DO_IN_THREAD(m_smtp2.pump_get_pressure(&pressure)); + motorpos = m_zm->getXACTUAL() - start_motor_pos; + } + + // 液面探测检测 + int32_t detect_liquid = 0; + if (lldtype == kclld) { + DO_IN_THREAD(m_smtp2.pump_clld_get_state(&detect_liquid)); + } else if (lldtype == kplld) { + DO_IN_THREAD(m_smtp2.pump_distribut_plld_get_state(&detect_liquid)); + } else if (lldtype == kmixlld) { + DO_IN_THREAD(m_smtp2.pump_distribut_mlld_get_state(&detect_liquid)); + } + + // 探测到液面 + if (detect_liquid == 1) { + ZLOGI(TAG, "detect liquid"); + m_state.detected_liquid = 1; + if (recorddata) push_snesor_sample_data(motorpos, capacitance, pressure); + break; + } + + // 电机停了也没有探测到液面 + 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 (recorddata) push_snesor_sample_data(motorpos, capacitance, pressure); + m_thread.sleep(m_cfg.lld_detect_period_ms); + } + + }); + return 0; +} int32_t PipetteModuleV2::pipette_zmotor_read_zero_point_state(int32_t *state) { *state = zm0p_is_trigger(); @@ -943,11 +944,15 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function fn) // do fn if (fn) fn(); + m_zm->stop(); + m_smtp2.pump_stop(); + // after do DO_IN_THREAD(m_smtp2.pump_get_motor_pos_ul(&pump_after_pos_ul)); int32_t endpos = zm_get_now_pos(); m_state.dul = pump_after_pos_ul - pump_before_pos_ul; m_state.dpos = endpos - startpos; + } catch (const zapp_thread_stoped_exception &e) { // break by usr ZLOGI(TAG, "break by usr"); m_zm->stop(); @@ -958,6 +963,7 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function fn) m_smtp2.pump_stop(); creg.module_errorcode = e.ecode(); } + creg.module_status = 0; ZLOGI(TAG, "<- end work"); }); diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp index c7e587c..7787f26 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp @@ -171,6 +171,7 @@ class PipetteModuleV2 : public ZIModule { 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_is_detect_liquid(int32_t *detect); virtual int32_t pipette_aspirate_prepare(); @@ -196,15 +197,14 @@ class PipetteModuleV2 : public ZIModule { private: int32_t module_xxx_reg_impl(int32_t param_id, bool read, int32_t &val); - void beforecallfn(const char *fn); - void aftercallfn(const char *fn); /*********************************************************************************************************************** * MOTOR * ***********************************************************************************************************************/ private: - void do_zm_move_0p(); - void do_pipette_zmotor_move_to_zero_point_quick(); + 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); 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 92eee79..b6f4181 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.cpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.cpp @@ -179,6 +179,7 @@ void ZCanProtocolParser::initialize(IZCanReceiver* cancmder) { REGFN(pipette_zmotor_read_zero_point_state); REGFN(pipette_zmotor_read_dev_status_cache); REGFN(pipette_lld_is_detect_liquid); + REGFN(pipette_lld_test); } void ZCanProtocolParser::_registerModule(uint16_t id, ZIModule* module) { m_modulers[id] = module; } void ZCanProtocolParser::registerModule(ZIModule* module) { @@ -1070,5 +1071,10 @@ int32_t ZCanProtocolParser::pipette_lld_is_detect_liquid(cmdcontxt_t* cxt) { cxt->acklen = 4; return module->pipette_lld_is_detect_liquid(&ack[0]); } +// 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]); +} #undef MODULE_CLASS \ No newline at end of file diff --git a/sdk/components/zcancmder/zcan_protocol_parser.hpp b/sdk/components/zcancmder/zcan_protocol_parser.hpp index 6e42505..cc6a798 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.hpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.hpp @@ -213,6 +213,8 @@ class ZCanProtocolParser : public IZCanReceiverListener { CMDFN(pipette_zmotor_read_zero_point_state); CMDFN(pipette_zmotor_read_dev_status_cache); CMDFN(pipette_lld_is_detect_liquid); + CMDFN(pipette_lld_test); + }; } // namespace iflytop \ No newline at end of file diff --git a/usrc/subboards/subboard80_cliptip/pri_board.h b/usrc/subboards/subboard80_cliptip/pri_board.h index 9823124..2cfb40d 100644 --- a/usrc/subboards/subboard80_cliptip/pri_board.h +++ b/usrc/subboards/subboard80_cliptip/pri_board.h @@ -47,7 +47,7 @@ #define MOTOR1_STEPMOTOR_IRUN 8 #define MOTOR1_STEPMOTOR_IHOLDDELAY 10 #define MOTOR1_STEPMOTOR_IGLOBALSCALER 0 -#define MOTOR1_MOTOR_DEFAULT_VELOCITY 500 +#define MOTOR1_MOTOR_DEFAULT_VELOCITY 800 #define MOTOR1_MIN_D TMC5130_DEFAULT__MIN_D #define MOTOR1_MAX_D TMC5130_DEFAULT__MAX_D #define MOTOR1_MOTOR_RUN_TO_ZERO_SPEED 200