|
@ -78,8 +78,8 @@ void PipetteModuleV2::create_default_cfg(config_t *defaultcfg) { |
|
|
defaultcfg->pump_vmax = 1000; |
|
|
defaultcfg->pump_vmax = 1000; |
|
|
defaultcfg->aspirate_zmotor_max_move_by = 400; // 50mm,tip头的长度
|
|
|
defaultcfg->aspirate_zmotor_max_move_by = 400; // 50mm,tip头的长度
|
|
|
defaultcfg->lld_pump_vel = 100; // lld推荐使用速度为50->200,这里
|
|
|
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_pos = PIPETTE_PREPARE_POS; |
|
|
defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; |
|
|
defaultcfg->lld_prepare_pre_distribut_ul = LLD_PREPARE_DISTRIBUT_POS; |
|
|
|
|
|
|
|
@ -343,100 +343,13 @@ int32_t PipetteModuleV2::pipette_lld_prepare() { |
|
|
}); |
|
|
}); |
|
|
return 0; |
|
|
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) { |
|
|
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); |
|
|
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) { |
|
|
int32_t PipetteModuleV2::pipette_zmotor_read_zero_point_state(int32_t *state) { |
|
|
*state = zm0p_is_trigger(); |
|
|
*state = zm0p_is_trigger(); |
|
@ -943,11 +944,15 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function<void()> fn) |
|
|
// do fn
|
|
|
// do fn
|
|
|
if (fn) fn(); |
|
|
if (fn) fn(); |
|
|
|
|
|
|
|
|
|
|
|
m_zm->stop(); |
|
|
|
|
|
m_smtp2.pump_stop(); |
|
|
|
|
|
|
|
|
// after do
|
|
|
// after do
|
|
|
DO_IN_THREAD(m_smtp2.pump_get_motor_pos_ul(&pump_after_pos_ul)); |
|
|
DO_IN_THREAD(m_smtp2.pump_get_motor_pos_ul(&pump_after_pos_ul)); |
|
|
int32_t endpos = zm_get_now_pos(); |
|
|
int32_t endpos = zm_get_now_pos(); |
|
|
m_state.dul = pump_after_pos_ul - pump_before_pos_ul; |
|
|
m_state.dul = pump_after_pos_ul - pump_before_pos_ul; |
|
|
m_state.dpos = endpos - startpos; |
|
|
m_state.dpos = endpos - startpos; |
|
|
|
|
|
|
|
|
} catch (const zapp_thread_stoped_exception &e) { // break by usr
|
|
|
} catch (const zapp_thread_stoped_exception &e) { // break by usr
|
|
|
ZLOGI(TAG, "break by usr"); |
|
|
ZLOGI(TAG, "break by usr"); |
|
|
m_zm->stop(); |
|
|
m_zm->stop(); |
|
@ -958,6 +963,7 @@ void PipetteModuleV2::thread_start_work(const char *fnname, function<void()> fn) |
|
|
m_smtp2.pump_stop(); |
|
|
m_smtp2.pump_stop(); |
|
|
creg.module_errorcode = e.ecode(); |
|
|
creg.module_errorcode = e.ecode(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
creg.module_status = 0; |
|
|
creg.module_status = 0; |
|
|
ZLOGI(TAG, "<- end work"); |
|
|
ZLOGI(TAG, "<- end work"); |
|
|
}); |
|
|
}); |
|
|