diff --git a/a8000_protocol b/a8000_protocol index befb0cf..60bf493 160000 --- a/a8000_protocol +++ b/a8000_protocol @@ -1 +1 @@ -Subproject commit befb0cfa58db25acb9e3a496e5e4414ac8797f88 +Subproject commit 60bf4933a4ad9ef89802826dd5cc253efe4af94d diff --git a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp index 633e5b3..bcdaa06 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.cpp @@ -60,6 +60,10 @@ void PipetteModuleV2::initialize(int32_t id, config_t *config, hardward_config_t m_zm = hardwaredcfg->zmotor; m_zm0p = hardwaredcfg->zmotor_0point; + // m_smtp2.pump_init(m_cfg.pump_vmax); + // osDelay(3000); + // m_smtp2.write_cmd("/1?23R\r"); + m_zm->getGState(); // 读取状态,清空下复位标识 module_active_cfg(); } @@ -75,7 +79,7 @@ void PipetteModuleV2::create_default_cfg(config_t *defaultcfg) { 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 = 10; // 100ms + defaultcfg->lld_detect_period_ms = 5; // 100ms defaultcfg->lld_prepare_pos = PIPETTE_PREPARE_POS; defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; @@ -324,9 +328,15 @@ int32_t PipetteModuleV2::pipette_put_tip() { } int32_t PipetteModuleV2::pipette_lld_prepare() { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - THREAD_START_WORK([this]() { + ZLOGI(TAG, "zmotor move to zero"); + zm_move_to(0, m_cfg.zm_default_velocity); + zm_waitfor_stop(); + ZLOGI(TAG, "pump move to 0 pos"); + DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_cfg.pump_vmax, 0)); // 移动到零点 + pump_waitfor_stop(); + + ZLOGI(TAG, "pump move to lld_prepare_pos %d", m_cfg.lld_prepare_pos); DO_IN_THREAD(m_smtp2.pump_move_to_ul(m_cfg.pump_vmax, m_cfg.lld_prepare_pos)); // 移动到中点 pump_waitfor_stop(); m_state.lld_prepared = 1; @@ -335,17 +345,11 @@ int32_t PipetteModuleV2::pipette_lld_prepare() { } int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t zdpos, int32_t c_threshold, int32_t p_threshold) { // 检查泵机是否初始化过 - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; if (lldtype < 0 || lldtype > klldtypemax) { return err::kparam_out_of_range; } - // 检查tip头状态 - int32_t tipstate = 0; - DO(m_smtp2.pump_get_tip_state(&tipstate)); - if (tipstate != 0) return err::kpipette_error_tipisload_when_lld_prepare; - THREAD_START_WORK([this, lldtype, zdpos, c_threshold, p_threshold]() { // m_state.lld_prepared = 0; // 失效m_state.lld_prepared @@ -435,9 +439,12 @@ int32_t PipetteModuleV2::pipette_lld(int32_t lldtype, int32_t zdpos, int32_t c_t return 0; } -int32_t PipetteModuleV2::pipette_aspirate_prepare() { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; +int32_t PipetteModuleV2::pipette_lld_is_detect_liquid(int32_t *detect) { + *detect = m_state.detected_liquid; + return 0; +} +int32_t PipetteModuleV2::pipette_aspirate_prepare() { THREAD_START_WORK([this]() { // ZLOGI(TAG, "pipette_aspirate_prepare"); m_state.aspirate_cfg_eigen_time = 0; @@ -473,8 +480,6 @@ int32_t PipetteModuleV2::pipette_aspirate_set_operation_verifi_tolerance(int32_t } int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - THREAD_START_WORK([this, ul]() { m_state.lld_prepared = 0; @@ -501,8 +506,6 @@ int32_t PipetteModuleV2::pipette_aspirate(int32_t ul) { return 0; } int32_t PipetteModuleV2::pipette_aspirate_and_verify(int32_t ul) { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - THREAD_START_WORK([this, ul]() { m_state.lld_prepared = 0; @@ -525,8 +528,6 @@ int32_t PipetteModuleV2::pipette_aspirate_and_verify(int32_t ul) { } int32_t PipetteModuleV2::pipette_shake_up(int32_t ul, int32_t times) { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - THREAD_START_WORK([this, ul, times]() { // int32_t dpos = 0; @@ -566,8 +567,6 @@ int32_t PipetteModuleV2::pipette_shake_up(int32_t ul, int32_t times) { } int32_t PipetteModuleV2::pipette_aspirate_infer_pressure(int32_t ul) { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - THREAD_START_WORK([this, ul]() { // ZLOGI(TAG, "pipette_aspirate_infer_pressure %d", ul); @@ -584,8 +583,6 @@ int32_t PipetteModuleV2::pipette_get_aspirate_infer_pressure_result(int32_t *res return 0; } int32_t PipetteModuleV2::pipette_aspirate_infer_eigen_time(int32_t ul) { - if (m_state.pipette_is_inited == 0) return err::kpipette_error_uninited; - // THREAD_START_WORK([this, ul]() { // @@ -820,39 +817,38 @@ 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 check; - if (cmdid == kpipette_zmotor_move_to_zero_point_quick) { - if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; - goto check; - } - if (cmdid == kpipette_zmotor_measure_distance) goto check; - if (cmdid == kpipette_zmotor_read_measure_distance_result) goto check; - if (cmdid == kpipette_zmotor_move_by) goto check; - if (cmdid == kpipette_zmotor_move_to) { - if (m_state.has_move_to_zero == 0) return err::kstep_motor_not_move_to_zero; - goto check; - } + 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 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 check; - if (cmdid == kpipette_aspirate_and_verify) goto check; - if (cmdid == kpipette_shake_up) 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; + +motor_check_bf_run: + if (m_state.enable == 0) return err::kstep_motor_not_enable; + goto check; + check: - if (!m_state.enable) { - return err::kstep_motor_not_enable; - } if (creg.module_errorcode == err::kstep_motor_subic_reset) { return creg.module_errorcode; } else if (creg.module_errorcode == err::kstep_motor_drv_err) { @@ -899,17 +895,17 @@ void PipetteModuleV2::runingcheck() { // 检查电机状态 { - // auto state = m_zm->getGState(); - // if (state.reset) { - // ZLOGE(TAG, "motor reset when run"); - // throw zapp_exception(err::kstep_motor_subic_reset); - // } else if (state.uv_cp) { - // ZLOGE(TAG, "motor uv_cp when run"); - // throw zapp_exception(err::kstep_motor_uv_cp); - // } else if (state.drv_err) { - // ZLOGE(TAG, "motor drv_err when run"); - // throw zapp_exception(err::kstep_motor_drv_err); - // } + auto state = m_zm->getGState(); + if (state.reset) { + ZLOGE(TAG, "motor reset when run"); + throw zapp_exception(err::kstep_motor_subic_reset); + } else if (state.uv_cp) { + ZLOGE(TAG, "motor uv_cp when run"); + throw zapp_exception(err::kstep_motor_uv_cp); + } else if (state.drv_err) { + ZLOGE(TAG, "motor drv_err when run"); + throw zapp_exception(err::kstep_motor_drv_err); + } } } @@ -925,6 +921,10 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function fn) creg.module_status = 1; creg.module_errorcode = 0; + m_state.detected_liquid = 0; + m_asynchronous_result.result0 = 0; + m_asynchronous_result.result1 = 0; + m_thread.start([this, fnname, fn]() { osDelay(1); ZLOGI(TAG, "start work -> %s", fnname); @@ -958,7 +958,6 @@ 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 0e9374d..c7e587c 100644 --- a/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp +++ b/sdk/components/pipette_module/pipette_ctrl_module_v2.hpp @@ -171,6 +171,8 @@ 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_is_detect_liquid(int32_t *detect); + virtual int32_t pipette_aspirate_prepare(); virtual int32_t pipette_aspirate_set_llf_velocity(int32_t llf_zm_rpm); virtual int32_t pipette_aspirate_set_operation_verifi_p_thre(int32_t p_thre); diff --git a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp index 9f3d649..ed36f65 100644 --- a/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp +++ b/sdk/components/sensors/smtp2_v2/smtp2_v2.cpp @@ -48,6 +48,8 @@ int32_t SMTP2V2::pump_get_state_as_int(int32_t state_index, int32_t* val) { return err::ksucc; } + + int32_t SMTP2V2::pump_get_capacitance(int32_t* capacitance) { return pump_get_state_as_int(kstate_capacitance, capacitance); } int32_t SMTP2V2::pump_get_pressure(int32_t* pressure) { // return pump_get_state_as_int(kstate_pressure_ad, pressure); diff --git a/sdk/components/tmc/ic/ztmc5130.cpp b/sdk/components/tmc/ic/ztmc5130.cpp index 4009e10..f19e55f 100644 --- a/sdk/components/tmc/ic/ztmc5130.cpp +++ b/sdk/components/tmc/ic/ztmc5130.cpp @@ -133,11 +133,12 @@ uint8_t TMC51X0::reset() { } int32_t TMC51X0::getXACTUAL() { return to_user_pos(readInt(TMC5130_XACTUAL)); } void TMC51X0::setXACTUAL(int32_t value) { - // change mode to vel - // set xactual to val - // set xtarget to val - + /** + * @brief 切换到速度模式之后再调整位置,防止电机异常移动 + */ + rotate(0); writeInt(TMC5130_XACTUAL, to_motor_pos(value)); + writeInt(TMC5130_XTARGET, to_motor_pos(value)); } int32_t TMC51X0::getVACTUAL() { return to_user_pos(readInt(TMC5130_VACTUAL)); } void TMC51X0::setAcceleration(float accelerationpps2) { writeInt(TMC5130_AMAX, (int32_t)(to_motor_acc(accelerationpps2))); } // 设置最大加速度 diff --git a/sdk/components/zcancmder/zcan_protocol_parser.cpp b/sdk/components/zcancmder/zcan_protocol_parser.cpp index aa7a9de..92eee79 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.cpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.cpp @@ -178,6 +178,7 @@ void ZCanProtocolParser::initialize(IZCanReceiver* cancmder) { REGFN(pipette_get_sensor_sample_data_num); REGFN(pipette_zmotor_read_zero_point_state); REGFN(pipette_zmotor_read_dev_status_cache); + REGFN(pipette_lld_is_detect_liquid); } void ZCanProtocolParser::_registerModule(uint16_t id, ZIModule* module) { m_modulers[id] = module; } void ZCanProtocolParser::registerModule(ZIModule* module) { @@ -1063,4 +1064,11 @@ int32_t ZCanProtocolParser::pipette_zmotor_read_dev_status_cache(cmdcontxt_t* cx cxt->acklen = 4; return module->pipette_zmotor_read_dev_status_cache(&ack[0]); } +int32_t ZCanProtocolParser::pipette_lld_is_detect_liquid(cmdcontxt_t* cxt) { + CHECK_AND_GET_MODULE(0); + int32_t* ack = (int32_t*)cxt->ackbuf; + cxt->acklen = 4; + return module->pipette_lld_is_detect_liquid(&ack[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 caee362..6e42505 100644 --- a/sdk/components/zcancmder/zcan_protocol_parser.hpp +++ b/sdk/components/zcancmder/zcan_protocol_parser.hpp @@ -212,6 +212,7 @@ class ZCanProtocolParser : public IZCanReceiverListener { CMDFN(pipette_get_sensor_sample_data_num); CMDFN(pipette_zmotor_read_zero_point_state); CMDFN(pipette_zmotor_read_dev_status_cache); + CMDFN(pipette_lld_is_detect_liquid); }; } // namespace iflytop \ No newline at end of file