parent
4466b677a6
commit
c3c23efc95
|
|
@ -1,7 +1 @@
|
||||||
rsource "lib/Kconfig"
|
rsource "lib/Kconfig"
|
||||||
rsource "lib/shell_valve/Kconfig"
|
|
||||||
|
|
||||||
config SLAVE_NODE_APP
|
|
||||||
bool "Slave Node Application"
|
|
||||||
default y
|
|
||||||
select SHELL_VALVE
|
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
project(slave_node LANGUAGES C)
|
project(slave_node LANGUAGES C)
|
||||||
zephyr_include_directories(../../include)
|
zephyr_include_directories(../../include)
|
||||||
add_subdirectory(../../lib lib)
|
add_subdirectory(../../lib lib)
|
||||||
target_sources(app PRIVATE src/main.c)
|
target_sources(app PRIVATE src/main.c)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
fault-reset-gpios = <&gpiob 3 GPIO_ACTIVE_LOW>;
|
fault-reset-gpios = <&gpiob 3 GPIO_ACTIVE_LOW>;
|
||||||
io-channels = <&adc1 1>;
|
io-channels = <&adc1 1>;
|
||||||
r-sense-ohms = <1500>;
|
r-sense-ohms = <1500>;
|
||||||
k-vcc = <3816>;
|
k-vcc = <4000>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,3 @@ CONFIG_MODBUS_BUFFER_SIZE=256
|
||||||
|
|
||||||
# Enable VND7050AJ
|
# Enable VND7050AJ
|
||||||
CONFIG_VND7050AJ=y
|
CONFIG_VND7050AJ=y
|
||||||
CONFIG_LOG_VALVE_LEVEL=4
|
|
||||||
CONFIG_VALVE_OBSTACLE_THRESHOLD_OPEN_MA=200
|
|
||||||
CONFIG_VALVE_OBSTACLE_THRESHOLD_CLOSE_MA=200
|
|
||||||
|
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
#define VALVE_CHANNEL_OPEN 0
|
#define VALVE_CHANNEL_OPEN 0
|
||||||
#define VALVE_CHANNEL_CLOSE 1
|
#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).
|
* @brief Represents the static state of the valve (open or closed).
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include <zephyr/sys/reboot.h>
|
#include <zephyr/sys/reboot.h>
|
||||||
#include <zephyr/usb/usb_device.h>
|
#include <zephyr/usb/usb_device.h>
|
||||||
#include <app_version.h>
|
#include <app_version.h>
|
||||||
|
#include <lib/fwu.h>
|
||||||
#include <lib/modbus_server.h>
|
#include <lib/modbus_server.h>
|
||||||
#include <lib/valve.h>
|
#include <lib/valve.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,20 @@ config LOG_VALVE_LEVEL
|
||||||
Set the log level for the Valve Library.
|
Set the log level for the Valve Library.
|
||||||
0 = None, 1 = Error, 2 = Warning, 3 = Info, 4 = Debug
|
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
|
config VALVE_OBSTACLE_THRESHOLD_OPEN_MA
|
||||||
int "Obstacle Threshold Open (mA)"
|
int "Obstacle Threshold Open (mA)"
|
||||||
default 200
|
default 200
|
||||||
|
|
@ -25,7 +39,7 @@ config VALVE_OBSTACLE_THRESHOLD_CLOSE_MA
|
||||||
default 200
|
default 200
|
||||||
help
|
help
|
||||||
Set the current threshold in milliamps for obstacle detection
|
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.
|
an obstacle is detected and the valve stops.
|
||||||
|
|
||||||
endif # LIB_VALVE
|
endif # LIB_VALVE
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ static void valve_work_handler(struct k_work *work)
|
||||||
valve_stop();
|
valve_stop();
|
||||||
return;
|
return;
|
||||||
} else if (current_ma > end_current_threshold_open_ma) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
LOG_DBG("Valve finished opening");
|
LOG_DBG("Valve finished opening");
|
||||||
|
|
@ -73,7 +73,7 @@ static void valve_work_handler(struct k_work *work)
|
||||||
valve_stop();
|
valve_stop();
|
||||||
return;
|
return;
|
||||||
} else if (current_ma > end_current_threshold_close_ma) {
|
} 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;
|
return;
|
||||||
}
|
}
|
||||||
current_state = VALVE_STATE_CLOSED;
|
current_state = VALVE_STATE_CLOSED;
|
||||||
|
|
@ -158,7 +158,7 @@ void valve_open(void)
|
||||||
if (max_opening_time_s > 0) {
|
if (max_opening_time_s > 0) {
|
||||||
k_timer_start(&movement_timer, K_SECONDS(max_opening_time_s), K_NO_WAIT);
|
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)
|
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);
|
k_timer_start(&movement_timer, K_SECONDS(max_closing_time_s), K_NO_WAIT);
|
||||||
}
|
}
|
||||||
current_movement = VALVE_MOVEMENT_CLOSING;
|
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)
|
void valve_stop(void)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue