full version of beta including resources and binary

This commit is contained in:
2026-04-12 18:21:05 +02:00
parent ce1d6e52ab
commit 429b28ef67
24 changed files with 4491 additions and 2 deletions

View File

@ -0,0 +1,25 @@
{
"name": "battery_discharge_cutoff",
"sample_period_ms": 1000,
"safety": {
"max_voltage": 5.0,
"max_current": 0.5,
"max_power": 2.5,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{ "action": "set_current", "value": 0.20 },
{ "action": "output", "enabled": true },
{
"action": "hold_until",
"timeout_s": 14400,
"condition": { "type": "voltage_below", "value": 3.00 },
"break_if": { "type": "temperature_above", "value": 50.0 }
},
{ "action": "output", "enabled": false }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,28 @@
{
"name": "cc_step_sweep",
"sample_period_ms": 500,
"safety": {
"max_voltage": 6.0,
"max_current": 0.8,
"max_power": 4.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{ "action": "set_current", "value": 0.10 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 10 },
{
"action": "ramp_current",
"start": 0.10,
"stop": 0.50,
"step": 0.10,
"dwell_s": 10,
"break_if": { "type": "temperature_above", "value": 45.0 }
},
{ "action": "output", "enabled": false }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,21 @@
{
"name": "cp_step_sweep",
"sample_period_ms": 500,
"safety": {
"max_voltage": 6.0,
"max_current": 0.8,
"max_power": 3.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CP" },
{ "action": "set_power", "value": 0.50 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 10 },
{ "action": "ramp_power", "start": 0.50, "stop": 2.50, "step": 0.50, "dwell_s": 10 },
{ "action": "output", "enabled": false }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,21 @@
{
"name": "cr_step_sweep",
"sample_period_ms": 500,
"safety": {
"max_voltage": 6.0,
"max_current": 0.8,
"max_power": 4.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CR" },
{ "action": "set_resistance", "value": 50.0 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 10 },
{ "action": "ramp_resistance", "start": 50.0, "stop": 10.0, "step": 10.0, "dwell_s": 10 },
{ "action": "output", "enabled": false }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,21 @@
{
"name": "load_test_cc",
"sample_period_ms": 500,
"safety": {
"max_voltage": 30.0,
"max_current": 2.0,
"max_power": 20.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{ "action": "set_current", "value": 0.20 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 30 },
{ "action": "ramp_current", "start": 0.20, "stop": 1.00, "step": 0.10, "dwell_s": 20 },
{ "action": "hold_until", "timeout_s": 300, "condition": { "type": "voltage_below", "value": 3.00 } }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,103 @@
#define _POSIX_C_SOURCE 200809L
#include "mightywatt_controller.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
static void sleep_ms(int ms) {
struct timespec ts;
if (ms < 0) {
ms = 0;
}
ts.tv_sec = ms / 1000;
ts.tv_nsec = (long)(ms % 1000) * 1000000L;
nanosleep(&ts, NULL);
}
int main(int argc, char **argv) {
mw_controller *controller = NULL;
mw_controller_config config;
mw_controller_snapshot snapshot;
uint64_t cmd_id = 0;
int i;
if (argc < 2) {
fprintf(stderr, "usage: %s /dev/ttyACM0\n", argv[0]);
return 2;
}
mw_controller_config_init(&config);
config.port_path = argv[1];
config.poll_interval_ms = 500;
config.reconnect_ms = 1500;
if (mw_controller_start(&controller, &config) != 0) {
fprintf(stderr, "controller start failed\n");
return 1;
}
for (i = 0; i < 20; ++i) {
if (mw_controller_get_snapshot(controller, &snapshot) != 0) {
fprintf(stderr, "snapshot failed\n");
mw_controller_stop(controller);
return 1;
}
printf("[%02d] state=%s connected=%s pending=%zu error=%s\n",
i,
mw_controller_connection_state_name(snapshot.connection_state),
snapshot.connected ? "yes" : "no",
snapshot.pending_commands,
snapshot.last_error[0] ? snapshot.last_error : "-");
if (snapshot.connected) {
break;
}
sleep_ms(250);
}
if (!snapshot.connected) {
fprintf(stderr, "device did not connect in time\n");
mw_controller_stop(controller);
return 1;
}
if (mw_controller_queue_load_on(controller, MW_MODE_CURRENT, 250, &cmd_id) != 0) {
fprintf(stderr, "queue load-on failed\n");
mw_controller_stop(controller);
return 1;
}
printf("queued command id=%" PRIu64 "\n", cmd_id);
for (;;) {
if (mw_controller_wait_for_update(controller, snapshot.snapshot_seq, 2000, NULL) < 0) {
fprintf(stderr, "wait for update failed\n");
break;
}
if (mw_controller_get_snapshot(controller, &snapshot) != 0) {
fprintf(stderr, "snapshot failed\n");
break;
}
if (snapshot.last_completed_command_id >= cmd_id) {
printf("command result=%d completed=%" PRIu64 " state=%s\n",
snapshot.last_completed_result,
snapshot.last_completed_command_id,
mw_controller_connection_state_name(snapshot.connection_state));
if (snapshot.app_state_valid && snapshot.app_state.report_valid) {
printf("I=%.3f A V=%.3f V remote=%s status=%u\n",
snapshot.app_state.last_report.current_ma / 1000.0,
snapshot.app_state.last_report.voltage_mv / 1000.0,
snapshot.app_state.last_report.remote ? "on" : "off",
(unsigned)snapshot.app_state.last_report.status);
}
break;
}
}
mw_controller_queue_safe(controller, NULL);
sleep_ms(400);
mw_controller_stop(controller);
return 0;
}

View File

@ -0,0 +1,24 @@
{
"name": "quick_cc_test",
"sample_period_ms": 500,
"safety": {
"max_voltage": 6.0,
"max_current": 0.6,
"max_power": 3.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{ "action": "set_current", "value": 0.10 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 5 },
{ "action": "set_current", "value": 0.25 },
{ "action": "hold", "duration_s": 5 },
{ "action": "set_current", "value": 0.50 },
{ "action": "hold", "duration_s": 5 },
{ "action": "output", "enabled": false }
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,30 @@
{
"name": "repeat_n_pulse_test",
"sample_period_ms": 500,
"safety": {
"max_voltage": 6.0,
"max_current": 0.8,
"max_power": 4.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{
"action": "repeat",
"times": 5,
"break_if": { "type": "temperature_above", "value": 45.0 },
"steps": [
{ "action": "set_current", "value": 0.20 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 5 },
{ "action": "set_current", "value": 0.50 },
{ "action": "hold", "duration_s": 5 },
{ "action": "output", "enabled": false },
{ "action": "hold", "duration_s": 2 }
]
}
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,29 @@
{
"name": "repeat_until_cutoff",
"sample_period_ms": 1000,
"safety": {
"max_voltage": 5.0,
"max_current": 0.6,
"max_power": 3.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{
"action": "repeat_until",
"timeout_s": 14400,
"condition": { "type": "voltage_below", "value": 3.20 },
"break_if": { "type": "temperature_above", "value": 45.0 },
"steps": [
{ "action": "set_current", "value": 0.30 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 60 },
{ "action": "output", "enabled": false },
{ "action": "hold", "duration_s": 10 }
]
}
],
"abort_sequence": [
{ "action": "safe" }
]
}

View File

@ -0,0 +1,29 @@
{
"name": "repeat_while_burn_in",
"sample_period_ms": 1000,
"safety": {
"max_voltage": 6.0,
"max_current": 0.5,
"max_power": 3.0,
"abort_on_disconnect": true
},
"steps": [
{ "action": "set_mode", "mode": "CC" },
{
"action": "repeat_while",
"timeout_s": 7200,
"condition": { "type": "temperature_above", "value": 20.0 },
"break_if": { "type": "temperature_above", "value": 50.0 },
"steps": [
{ "action": "set_current", "value": 0.15 },
{ "action": "output", "enabled": true },
{ "action": "hold", "duration_s": 30 },
{ "action": "output", "enabled": false },
{ "action": "hold", "duration_s": 15 }
]
}
],
"abort_sequence": [
{ "action": "safe" }
]
}