Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eeprom): Add resin-tip dispense tracking #823

Merged
merged 10 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion head/core/can_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ using MotionControllerDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::SetMotionConstraints, can::messages::ReadLimitSwitchRequest,
can::messages::MotorPositionRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::IncreaseEvoDispenseRequest>;
using SystemDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::system::SystemMessageHandler<
head_tasks::HeadQueueClient>,
Expand Down
2 changes: 2 additions & 0 deletions include/bootloader/core/ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ typedef enum {
can_messageid_gear_read_motor_driver_request = 0x507,
can_messageid_max_sensor_value_request = 0x70,
can_messageid_max_sensor_value_response = 0x71,
can_messageid_increase_evo_disp_count_request = 0x80,
can_messageid_batch_read_sensor_response = 0x81,
can_messageid_read_sensor_request = 0x82,
can_messageid_write_sensor_request = 0x83,
Expand Down Expand Up @@ -277,5 +278,6 @@ typedef enum {
can_motorusagevaluetype_force_application_time = 0x3,
can_motorusagevaluetype_total_error_count = 0x4,
can_motorusagevaluetype_overpressure_error_count = 0x5,
can_motorusagevaluetype_resin_tip_dispense_count = 0x6,
} CANMotorUsageValueType;

2 changes: 2 additions & 0 deletions include/can/core/ids.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ enum class MessageId {
gear_read_motor_driver_request = 0x507,
max_sensor_value_request = 0x70,
max_sensor_value_response = 0x71,
increase_evo_disp_count_request = 0x80,
batch_read_sensor_response = 0x81,
read_sensor_request = 0x82,
write_sensor_request = 0x83,
Expand Down Expand Up @@ -278,6 +279,7 @@ enum class MotorUsageValueType {
force_application_time = 0x3,
total_error_count = 0x4,
overpressure_error_count = 0x5,
resin_tip_dispense_count = 0x6,
};

} // namespace can::ids
2 changes: 1 addition & 1 deletion include/can/core/message_handlers/motion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MotionHandler {
GetMotionConstraintsRequest, SetMotionConstraints,
ReadLimitSwitchRequest, MotorPositionRequest,
UpdateMotorPositionEstimationRequest, GetMotorUsageRequest,
MotorStatusRequest>;
MotorStatusRequest, IncreaseEvoDispenseRequest>;

MotionHandler(MotionTaskClient &motion_client)
: motion_client{motion_client} {}
Expand Down
3 changes: 3 additions & 0 deletions include/can/core/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ using ReadLimitSwitchRequest = Empty<MessageId::limit_sw_request>;

using MotorPositionRequest = Empty<MessageId::motor_position_request>;

using IncreaseEvoDispenseRequest =
Empty<MessageId::increase_evo_disp_count_request>;

using UpdateMotorPositionEstimationRequest =
Empty<MessageId::update_motor_position_estimation_request>;

Expand Down
3 changes: 2 additions & 1 deletion include/gantry/core/can_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ using MotionControllerDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::SetMotionConstraints, can::messages::ReadLimitSwitchRequest,
can::messages::MotorPositionRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::IncreaseEvoDispenseRequest>;
using SystemDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::system::SystemMessageHandler<
gantry::queues::QueueClient>,
Expand Down
3 changes: 2 additions & 1 deletion include/gripper/core/can_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ using MotionControllerDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::SetMotionConstraints, can::messages::ReadLimitSwitchRequest,
can::messages::MotorPositionRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::IncreaseEvoDispenseRequest>;
using SystemDispatchTarget = can::dispatch::DispatchParseTarget<
can::message_handlers::system::SystemMessageHandler<
gripper_tasks::QueueClient>,
Expand Down
6 changes: 4 additions & 2 deletions include/motor-control/core/tasks/messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ using MotionControlTaskMessage = std::variant<
can::messages::HomeRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::AddSensorMoveRequest>;
can::messages::AddSensorMoveRequest,
can::messages::IncreaseEvoDispenseRequest>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
Expand All @@ -34,7 +35,8 @@ using MotionControlTaskMessage = std::variant<
can::messages::MotorPositionRequest, can::messages::ReadLimitSwitchRequest,
can::messages::HomeRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::IncreaseEvoDispenseRequest>;

using MoveGroupTaskMessage =
std::variant<std::monostate, can::messages::AddLinearMoveRequest,
Expand Down
27 changes: 22 additions & 5 deletions include/motor-control/core/tasks/motion_controller_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ class MotionControllerMessageHandler {
using MotorControllerType = motion_controller::MotionController<MEConfig>;
MotionControllerMessageHandler(MotorControllerType& controller,
CanClient& can_client,
UsageClient& usage_client)
UsageClient& usage_client,
uint16_t evo_disp_count_key)
: controller{controller},
can_client{can_client},
usage_client{usage_client} {}
usage_client{usage_client},
evo_disp_count_key{evo_disp_count_key} {}
MotionControllerMessageHandler(const MotionControllerMessageHandler& c) =
delete;
MotionControllerMessageHandler(const MotionControllerMessageHandler&& c) =
Expand Down Expand Up @@ -134,6 +136,16 @@ class MotionControllerMessageHandler {
}
}
#endif
void handle(const can::messages::IncreaseEvoDispenseRequest& m) {
if (evo_disp_count_key == 0) {
return;
}
auto message =
usage_messages::IncreaseErrorCount{.key = evo_disp_count_key};
usage_client.send_usage_storage_queue(message);
can_client.send_can_message(can::ids::NodeId::host,
can::messages::ack_from_request(m));
}

void handle(const can::messages::HomeRequest& m) {
LOG("Motion Controller Received home request: velocity=%d, "
Expand Down Expand Up @@ -200,6 +212,7 @@ class MotionControllerMessageHandler {
MotorControllerType& controller;
CanClient& can_client;
UsageClient& usage_client;
uint16_t evo_disp_count_key;
};

/**
Expand All @@ -211,7 +224,10 @@ class MotionControllerTask {
public:
using Messages = TaskMessage;
using QueueType = QueueImpl<TaskMessage>;
MotionControllerTask(QueueType& queue) : queue{queue} {}
MotionControllerTask(QueueType& queue, uint16_t evo_disp_count_key)
: queue{queue}, evo_disp_count_key{evo_disp_count_key} {}
MotionControllerTask(QueueType& queue)
: queue{queue}, evo_disp_count_key{0} {}
MotionControllerTask(const MotionControllerTask& c) = delete;
MotionControllerTask(const MotionControllerTask&& c) = delete;
auto operator=(const MotionControllerTask& c) = delete;
Expand All @@ -227,8 +243,8 @@ class MotionControllerTask {
[[noreturn]] void operator()(
motion_controller::MotionController<MEConfig>* controller,
CanClient* can_client, UsageClient* usage_client) {
auto handler = MotionControllerMessageHandler{*controller, *can_client,
*usage_client};
auto handler = MotionControllerMessageHandler{
*controller, *can_client, *usage_client, evo_disp_count_key};
TaskMessage message{};
bool first_run = true;
for (;;) {
Expand All @@ -246,6 +262,7 @@ class MotionControllerTask {

private:
QueueType& queue;
uint16_t evo_disp_count_key;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion include/pipettes/core/dispatch_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ using MotionControllerDispatchTarget = can::dispatch::DispatchParseTarget<
can::messages::SetMotionConstraints, can::messages::ReadLimitSwitchRequest,
can::messages::MotorPositionRequest,
can::messages::UpdateMotorPositionEstimationRequest,
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest>;
can::messages::GetMotorUsageRequest, can::messages::MotorStatusRequest,
can::messages::IncreaseEvoDispenseRequest>;

using GearMotionControllerDispatchTarget = can::dispatch::DispatchParseTarget<
gear_motion_handler::GearMotorMotionHandler<gear_motor_tasks::QueueClient>,
Expand Down
5 changes: 5 additions & 0 deletions include/pipettes/firmware/eeprom_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@ static constexpr uint16_t PLUNGER_MOTOR_STEP_KEY = 0;

static constexpr uint16_t P_SM_ERROR_COUNT_KEY = 1;
static constexpr uint16_t OVERPRESSURE_COUNT_KEY_SM = 2;
static constexpr uint16_t EVOTIP_DISPENSE_COUNT_KEY_SM = 3;

static constexpr uint16_t GEAR_LEFT_MOTOR_KEY = 1;
static constexpr uint16_t GEAR_RIGHT_MOTOR_KEY = 2;
static constexpr uint16_t P_96_ERROR_COUNT_KEY = 3;
static constexpr uint16_t L_ERROR_COUNT_KEY = 4;
static constexpr uint16_t R_ERROR_COUNT_KEY = 5;
static constexpr uint16_t OVERPRESSURE_COUNT_KEY_96 = 6;
static constexpr uint16_t EVOTIP_DISPENSE_COUNT_KEY_96 = 7;

extern const eeprom::data_rev_task::DataTableUpdateMessage
data_table_rev1_sing_mult;
extern const eeprom::data_rev_task::DataTableUpdateMessage
data_table_rev2_sing_mult;
extern const eeprom::data_rev_task::DataTableUpdateMessage
data_table_rev3_sing_mult;
extern const eeprom::data_rev_task::DataTableUpdateMessage
data_table_rev4_sing_mult;
extern const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev1_96ch;
extern const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev2_96ch;
extern const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev3_96ch;
extern const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev4_96ch;

extern const std::vector<eeprom::data_rev_task::DataTableUpdateMessage>
table_updater;
8 changes: 5 additions & 3 deletions pipettes/core/linear_motor_tasks.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pipettes/core/linear_motor_tasks.hpp"

#include "common/core/freertos_task.hpp"
#include "pipettes/core/pipette_type.h"
#include "pipettes/core/sensor_tasks.hpp"
#include "pipettes/firmware/eeprom_keys.hpp"

Expand All @@ -15,9 +16,10 @@ static auto tmc2160_tasks = linear_motor_tasks::tmc2160_driver::Tasks{};
static auto tmc2160_queue_client =
linear_motor_tasks::tmc2160_driver::QueueClient{};

static auto mc_task_builder =
freertos_task::TaskStarter<256,
motion_controller_task::MotionControllerTask>{};
static auto mc_task_builder = freertos_task::TaskStarter<
256, motion_controller_task::MotionControllerTask, uint16_t>{
get_pipette_type() == NINETY_SIX_CHANNEL ? EVOTIP_DISPENSE_COUNT_KEY_96
: EVOTIP_DISPENSE_COUNT_KEY_SM};
static auto tmc2130_driver_task_builder =
freertos_task::TaskStarter<256, tmc2130::tasks::MotorDriverTask>{};
static auto tmc2160_driver_task_builder =
Expand Down
14 changes: 13 additions & 1 deletion pipettes/firmware/eeprom_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev3_sing_mult{
.data_table = {std::make_pair(OVERPRESSURE_COUNT_KEY_SM,
usage_storage_task::error_count_usage_len)}};

const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev4_sing_mult{
.data_rev = 4,
.data_table = {std::make_pair(EVOTIP_DISPENSE_COUNT_KEY_SM,
usage_storage_task::error_count_usage_len)}};

const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev1_96ch{
.data_rev = 1,
.data_table = {
Expand All @@ -46,6 +51,11 @@ const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev3_96ch{
.data_table = {std::make_pair(OVERPRESSURE_COUNT_KEY_96,
usage_storage_task::error_count_usage_len)}};

const eeprom::data_rev_task::DataTableUpdateMessage data_table_rev4_96ch{
.data_rev = 4,
.data_table = {std::make_pair(EVOTIP_DISPENSE_COUNT_KEY_96,
usage_storage_task::error_count_usage_len)}};

const std::vector<eeprom::data_rev_task::DataTableUpdateMessage> table_updater =
{
// anytime there is an update to the data table add a message to this
Expand All @@ -55,4 +65,6 @@ const std::vector<eeprom::data_rev_task::DataTableUpdateMessage> table_updater =
get_pipette_type() == NINETY_SIX_CHANNEL ? data_table_rev2_96ch
: data_table_rev2_sing_mult,
get_pipette_type() == NINETY_SIX_CHANNEL ? data_table_rev3_96ch
: data_table_rev3_sing_mult};
: data_table_rev3_sing_mult,
get_pipette_type() == NINETY_SIX_CHANNEL ? data_table_rev4_96ch
: data_table_rev4_sing_mult};
15 changes: 11 additions & 4 deletions pipettes/firmware/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ auto linear_motor::get_interrupt(motor_hardware::MotorHardware& hw,
}

struct motor_hardware::UsageEEpromConfig plunger_usage_config {
std::array<UsageRequestSet, 3> {
std::array<UsageRequestSet, 4> {
UsageRequestSet{
.eeprom_key = PLUNGER_MOTOR_STEP_KEY,
.type_key =
Expand All @@ -87,12 +87,19 @@ struct motor_hardware::UsageEEpromConfig plunger_usage_config {
.type_key =
uint16_t(can::ids::MotorUsageValueType::total_error_count),
.length = usage_storage_task::error_count_usage_len},
UsageRequestSet{
.eeprom_key = get_pipette_type() == NINETY_SIX_CHANNEL
? OVERPRESSURE_COUNT_KEY_96
: OVERPRESSURE_COUNT_KEY_SM,
.type_key = uint16_t(
can::ids::MotorUsageValueType::overpressure_error_count),
.length = usage_storage_task::error_count_usage_len},
UsageRequestSet {
.eeprom_key = get_pipette_type() == NINETY_SIX_CHANNEL
? OVERPRESSURE_COUNT_KEY_96
: OVERPRESSURE_COUNT_KEY_SM,
? EVOTIP_DISPENSE_COUNT_KEY_96
: EVOTIP_DISPENSE_COUNT_KEY_SM,
.type_key = uint16_t(
can::ids::MotorUsageValueType::overpressure_error_count),
can::ids::MotorUsageValueType::resin_tip_dispense_count),
.length = usage_storage_task::error_count_usage_len
}
}
Expand Down
Loading