Cleaning up

Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit is contained in:
Eduard Iten 2025-07-11 11:43:47 +02:00
parent 4466b677a6
commit c3c23efc95
10 changed files with 24 additions and 17 deletions

View File

@ -1,7 +1 @@
rsource "lib/Kconfig"
rsource "lib/shell_valve/Kconfig"
config SLAVE_NODE_APP
bool "Slave Node Application"
default y
select SHELL_VALVE

View File

@ -15,7 +15,7 @@
fault-reset-gpios = <&gpiob 3 GPIO_ACTIVE_LOW>;
io-channels = <&adc1 1>;
r-sense-ohms = <1500>;
k-vcc = <3816>;
k-vcc = <4000>;
};
};

View File

@ -26,6 +26,3 @@ CONFIG_MODBUS_BUFFER_SIZE=256
# Enable VND7050AJ
CONFIG_VND7050AJ=y
CONFIG_LOG_VALVE_LEVEL=4
CONFIG_VALVE_OBSTACLE_THRESHOLD_OPEN_MA=200
CONFIG_VALVE_OBSTACLE_THRESHOLD_CLOSE_MA=200

View File

@ -15,7 +15,8 @@
#define VALVE_CHANNEL_OPEN 0
#define VALVE_CHANNEL_CLOSE 1
#define VALVE_ENDPOSITION_CHECK_INTERVAL K_MSEC(100)
#define VALVE_CURRENT_CHECK_INTERVAL K_MSEC(CONFIG_VALVE_INTERVALL_CURRENT_CHECK_MS)
#define VALVE_INITIAL_CURRENT_CHECK_INTERVAL K_MSEC(CONFIG_VALVE_INITIAL_INTERVALL_CURRENT_CHECK_MS)
/**
* @brief Represents the static state of the valve (open or closed).

View File

@ -17,6 +17,7 @@
#include <zephyr/sys/reboot.h>
#include <zephyr/usb/usb_device.h>
#include <app_version.h>
#include <lib/fwu.h>
#include <lib/modbus_server.h>
#include <lib/valve.h>

View File

@ -12,6 +12,20 @@ config LOG_VALVE_LEVEL
Set the log level for the Valve Library.
0 = None, 1 = Error, 2 = Warning, 3 = Info, 4 = Debug
config VALVE_INTERVALL_CURRENT_CHECK_MS
int "Interval Current Check (ms)"
default 100
help
Set the interval in milliseconds for checking the motor current
during valve operation. This is used to detect obstacles.
config VALVE_INITIAL_INTERVALL_CURRENT_CHECK_MS
int "Initial Current Check (ms)"
default 200
help
Set the initial delay in milliseconds before the first current check
after starting the valve operation. This allows the motor to stabilize.
config VALVE_OBSTACLE_THRESHOLD_OPEN_MA
int "Obstacle Threshold Open (mA)"
default 200
@ -25,7 +39,7 @@ config VALVE_OBSTACLE_THRESHOLD_CLOSE_MA
default 200
help
Set the current threshold in milliamps for obstacle detection
during valve closing. If the motor current exceeds this value,
during vaslve closing. If the motor current exceeds this value,
an obstacle is detected and the valve stops.
endif # LIB_VALVE

View File

@ -58,7 +58,7 @@ static void valve_work_handler(struct k_work *work)
valve_stop();
return;
} else if (current_ma > end_current_threshold_open_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
k_work_schedule(&valve_work, VALVE_CURRENT_CHECK_INTERVAL);
return;
}
LOG_DBG("Valve finished opening");
@ -73,7 +73,7 @@ static void valve_work_handler(struct k_work *work)
valve_stop();
return;
} else if (current_ma > end_current_threshold_close_ma) {
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
k_work_schedule(&valve_work, VALVE_CURRENT_CHECK_INTERVAL);
return;
}
current_state = VALVE_STATE_CLOSED;
@ -158,7 +158,7 @@ void valve_open(void)
if (max_opening_time_s > 0) {
k_timer_start(&movement_timer, K_SECONDS(max_opening_time_s), K_NO_WAIT);
}
k_work_schedule(&valve_work, K_MSEC(100));
k_work_schedule(&valve_work, VALVE_INITIAL_CURRENT_CHECK_INTERVAL);
}
void valve_close(void)
@ -171,7 +171,7 @@ void valve_close(void)
k_timer_start(&movement_timer, K_SECONDS(max_closing_time_s), K_NO_WAIT);
}
current_movement = VALVE_MOVEMENT_CLOSING;
k_work_schedule(&valve_work, VALVE_ENDPOSITION_CHECK_INTERVAL);
k_work_schedule(&valve_work, VALVE_INITIAL_CURRENT_CHECK_INTERVAL);
}
void valve_stop(void)