From 5b94d5e4cf50c2a36656015e0f1d14b8e4319678 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 21 Jun 2024 15:23:06 +0800 Subject: [PATCH] update --- .../pipette_module/pipette_ctrl_module_v2.cpp | 42 +++++++++++++--------- components/sensors/smtp2_v2/smtp2_v2.cpp | 8 ++--- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/components/pipette_module/pipette_ctrl_module_v2.cpp b/components/pipette_module/pipette_ctrl_module_v2.cpp index 7988a86..a802c5e 100644 --- a/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -40,7 +40,7 @@ void PipetteModule::initialize(int32_t id, config_t *config, StepMotorCtrlModule m_config.pump_vstart = 0; m_config.pump_vstop = 900; m_config.aspirate_distribut_pump_vel = 100; // - m_config.pump_vmax = 1400; + m_config.pump_vmax = 1000; m_config.lld_pump_vel = 100; // lld推荐使用速度为50->200,这里 m_config.lld_motor_vel_rpm = 50; m_config.lld_detect_period_ms = 100; // 100ms @@ -168,15 +168,8 @@ int32_t PipetteModule::pipette_lld_is_detect_liquid(int32_t *detect_liquid) { / * ACTION * ***********************************************************************************************************************/ int32_t PipetteModule::do_pipette_ctrl_init_device() { - creg.module_status = 1; - - // 检查tip头状态 - int32_t tipstate = 0; - int32_t ret = m_smtp2.pump_get_tip_state(&tipstate); - if (ret != 0) return ret; - if (tipstate != 0) return err::kpipette_error_tipisload_when_lld_prepare; - m_thread.stop(); + creg.module_status = 1; m_thread.start( [this]() { // DO_IN_THREAD(befor_run()); @@ -194,7 +187,7 @@ int32_t PipetteModule::do_pipette_ctrl_init_device() { }, [this]() { // exit fn after_run(); - + m_smtp2.pump_stop(); if (creg.module_errorcode == 0) { m_state.load_val_ul = 0; m_state.aspirated = 0; @@ -239,6 +232,8 @@ int32_t PipetteModule::do_pipette_ctrl_put_tip() { }, [this]() { // exit fn after_run(); + m_smtp2.pump_stop(); + if (creg.module_errorcode == 0) { m_state.load_val_ul = 0; m_state.aspirated = 0; @@ -269,6 +264,8 @@ int32_t PipetteModule::do_pipette_ctrl_move_to_ul(int32_t ul) { }, [this]() { // exit fn after_run(); + m_smtp2.pump_stop(); + ZLOGI(TAG, "do_pipette_ctrl_move_to_ul finish,ecode:%d", creg.module_errorcode); } // ); @@ -302,10 +299,11 @@ int32_t PipetteModule::do_pipette_lld_prepare() { if (tipstate != 0) return err::kpipette_error_tipisload_when_lld_prepare; m_thread.stop(); + creg.module_status = 1; m_thread.start( [this]() { // DO_IN_THREAD(befor_run()); - DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_config.pump_vmax, PIPETTE_PREPARE_POS)); // 移动到中点 + DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_config.pump_vmax, m_config.lld_prepare_pos)); // 移动到中点 while (true) { if (!check_when_run()) break; @@ -320,6 +318,8 @@ int32_t PipetteModule::do_pipette_lld_prepare() { }, [this]() { // exit fn after_run(); + m_smtp2.pump_stop(); + if (creg.module_errorcode == 0) { m_state.lld_prepared = 1; } @@ -377,18 +377,21 @@ int32_t PipetteModule::do_pipette_lld(lld_mode_t mode, int32_t zdpos, int32_t c_ ZLOGI(TAG, "start lld before distribut"); DO_IN_THREAD(m_smtp2.pump_distribut(m_config.pump_vmax, m_config.lld_prepare_distribut_pos)); while (true) { - if (!check_when_run()) break; - if (m_thread.getExitFlag()) break; + if (!check_when_run()) return; + if (m_thread.getExitFlag()) return; int32_t isbusy = 0; DO_IN_THREAD(m_smtp2.pump_get_state(&isbusy)); if (isbusy == 0) break; + + m_thread.sleep(10); } + m_smtp2.pump_stop(); ZLOGI(TAG, "lld before distribut ok"); ZLOGI(TAG, "start lld"); submotor->moveBy(zdpos, m_config.lld_motor_vel_rpm); - osDelay(50); + osDelay(10); if (mode == kclld) { DO_IN_THREAD(m_smtp2.pump_clld(c_threshold)); } else if (mode == kplld) { @@ -453,8 +456,6 @@ int32_t PipetteModule::do_pipette_lld(lld_mode_t mode, int32_t zdpos, int32_t c_ m_thread.sleep(m_config.lld_detect_period_ms); } - - }, [this]() { // exit fn auto submotor = m_zmotor->getMotor(); @@ -496,6 +497,7 @@ int32_t PipetteModule::do_pipette_aspirate(int32_t ul) { }, [this]() { // exit fn after_run(); + m_smtp2.pump_stop(); m_state.load_val_ul = m_state.load_val_ul + m_state.dul; if (m_state.load_val_ul < 0) { m_state.load_val_ul = 0; @@ -533,6 +535,8 @@ int32_t PipetteModule::do_pipette_distribut(int32_t ul) { }, [this]() { // exit fn after_run(); + m_smtp2.pump_stop(); + m_state.load_val_ul = m_state.load_val_ul + m_state.dul; if (m_state.load_val_ul < 0) { m_state.load_val_ul = 0; @@ -573,6 +577,9 @@ int32_t PipetteModule::pipette_write_cmd_direct(uint8_t *tx, int32_t len, uint8_ int32_t PipetteModule::befor_run() { // + ZLOGI(TAG, "befor_run"); + + m_smtp2.pump_stop(); creg.module_status = 1; creg.module_errorcode = 0; DO(module_active_cfg()); @@ -580,6 +587,9 @@ int32_t PipetteModule::befor_run() { return 0; } int32_t PipetteModule::after_run() { + ZLOGI(TAG, "after_run"); + m_smtp2.pump_stop(); + int32_t err = 0; err = creg.module_errorcode; if (err != 0) goto tag_err; diff --git a/components/sensors/smtp2_v2/smtp2_v2.cpp b/components/sensors/smtp2_v2/smtp2_v2.cpp index e428f30..f8a1568 100644 --- a/components/sensors/smtp2_v2/smtp2_v2.cpp +++ b/components/sensors/smtp2_v2/smtp2_v2.cpp @@ -11,7 +11,7 @@ using namespace smtp2; #define TAG "SMTP2" #define OVERTIME 100 -#define DUMP_HEX 0 +#define DUMP_HEX 1 #define SEND_CMD(fmt, ...) sendcmd(true, 1, "/1" fmt "R\r", ##__VA_ARGS__); #define SEND_CMD_AUTO_RETRY(retry_times, fmt, ...) sendcmd(true, retry_times, "/1" fmt "R\r", ##__VA_ARGS__); @@ -67,7 +67,7 @@ int32_t SMTP2V2::pump_get_motor_pos_ul(int32_t* ul) { return ret; } -int32_t SMTP2V2::pump_stop() { return SEND_CMD("T"); } +int32_t SMTP2V2::pump_stop() { return sendcmd(true, 1, "/1TR\r"); } int32_t SMTP2V2::pump_set_vstart(int32_t vel) { return SEND_CMD("v%d", vel); } int32_t SMTP2V2::pump_set_vstop(int32_t vel) { return SEND_CMD("c%d", vel); } int32_t SMTP2V2::pump_set_vmax(int32_t vel) { return SEND_CMD("V%d", vel); } @@ -108,12 +108,12 @@ int32_t SMTP2V2::pump_move_to_ul(int32_t v, int32_t ul) { int32_t SMTP2V2::pump_aspirate(int32_t v, int32_t ul) { ZLOGI(TAG, "pump_aspirate %d", ul); int stepNum = ul / 0.319 + 0.5; - return SEND_CMD("N%dV%dP%d", 1 /*模式*/, v, stepNum); + return SEND_CMD("N%dV%dP%d", 0 /*模式*/, v, stepNum); } int32_t SMTP2V2::pump_distribut(int32_t v, int32_t ul) { ZLOGI(TAG, "pump_distribut %d", ul); int stepNum = ul / 0.319 + 0.5; - return SEND_CMD("N%dV%dD%d", 2 /*模式*/, v, stepNum); + return SEND_CMD("N%dV%dD%d", 0 /*模式*/, v, stepNum); } int32_t SMTP2V2::pump_distribut_plld(int32_t pumpv, int32_t pressure_threshold) {