docs: Update German documentation and project plan
- Updated Doxygen comments in header files (valve.h, fwu.h, modbus_server.h) to be consistent and in English. - Translated German register names in docs/modbus-registers.de.md to English. - Updated docs/concept.de.md to reflect new details on current measurement and sensors. - Updated docs/planning.de.md to reflect completed tasks in Phase 1. - Implemented VND7050AJ and core functionality including current and voltage measurement and end-position detection.
This commit is contained in:
@@ -1,91 +1,41 @@
|
||||
#include <zephyr/dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
vnd7050aj: vnd7050aj {
|
||||
compatible = "vnd7050aj-valve-controller";
|
||||
status = "okay";
|
||||
|
||||
// VND7050AJ GPIO pin definitions
|
||||
in0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; // IN0 (PB7) - Input 0 control signal
|
||||
in1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; // IN1 (PB9) - Input 1 control signal
|
||||
rst-gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; // RST (PB3) - Reset pin for VND7050AJ
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; // SEN (PB4) - Sense Enable for current monitoring
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; // S0 (PB6) - Status/Select 0 output from VND7050AJ
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; // S1 (PB5) - Status/Select 1 output from VND7050AJ
|
||||
};
|
||||
aliases {
|
||||
vnd7050aj = &vnd7050aj;
|
||||
};
|
||||
|
||||
adc_sensors {
|
||||
compatible = "adc-sensors";
|
||||
|
||||
supply_voltage: supply-voltage {
|
||||
compatible = "custom,supply-voltage";
|
||||
io-channels = <&adc1 1>; /* ADC1 channel 1 (PA0) */
|
||||
io-channel-names = "voltage";
|
||||
reference-mv = <3300>;
|
||||
voltage-divider-ratio = <4>; /* Adjust based on your voltage divider */
|
||||
|
||||
/* GPIO control pins using VND7050AJ pins */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
|
||||
measurement-delay-ms = <5>; /* 5ms delay after GPIO setup */
|
||||
};
|
||||
|
||||
motor_current_open: motor-current-open {
|
||||
compatible = "custom,motor-current";
|
||||
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
|
||||
io-channel-names = "current";
|
||||
reference-mv = <3300>;
|
||||
current-sense-resistor-mohm = <1500000>; /* 1.5kΩ sense resistor in mΩ */
|
||||
k-factor = <10>; /* Current sense amplification factor */
|
||||
|
||||
/* GPIO control pins using VND7050AJ pins */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
|
||||
measurement-delay-ms = <10>; /* 10ms delay for current settling */
|
||||
};
|
||||
|
||||
motor_current_close: motor-current-close {
|
||||
compatible = "custom,motor-current";
|
||||
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
|
||||
io-channel-names = "current";
|
||||
reference-mv = <3300>;
|
||||
current-sense-resistor-mohm = <1500000>; /* 1.5kΩ sense resistor in mΩ */
|
||||
k-factor = <10>; /* Current sense amplification factor */
|
||||
|
||||
/* GPIO control pins using VND7050AJ pins */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
|
||||
measurement-delay-ms = <10>; /* 10ms delay for current settling */
|
||||
};
|
||||
};
|
||||
vnd7050aj: vnd7050aj {
|
||||
compatible = "st,vnd7050aj";
|
||||
status = "okay";
|
||||
|
||||
input0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>;
|
||||
input1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>;
|
||||
select0-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>;
|
||||
select1-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>;
|
||||
sense-enable-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>;
|
||||
fault-reset-gpios = <&gpiob 3 GPIO_ACTIVE_LOW>;
|
||||
io-channels = <&adc1 1>;
|
||||
r-sense-ohms = <1500>;
|
||||
k-vcc = <4139>;
|
||||
};
|
||||
};
|
||||
|
||||
// Clock configuration: Uncomment the following section to use calibrated HSI instead of HSE
|
||||
//&clk_hse {
|
||||
// status = "disabled"; // Disable external crystal oscillator
|
||||
//};
|
||||
//
|
||||
//&clk_hsi {
|
||||
// status = "okay"; // Enable internal high-speed oscillator (16 MHz, calibrated)
|
||||
//};
|
||||
//
|
||||
//&pll {
|
||||
// // Change PLL source from HSE to HSI
|
||||
// clocks = <&clk_hsi>;
|
||||
// // Adjust multipliers to maintain 144 MHz system clock with 16 MHz HSI input
|
||||
// // HSI = 16 MHz, div-m = 4, mul-n = 72, div-r = 2
|
||||
// // PLL_VCO = (16 MHz / 4) * 72 = 288 MHz
|
||||
// // SYSCLK = 288 MHz / 2 = 144 MHz
|
||||
// div-m = <4>; // Divide HSI by 4 (16 MHz / 4 = 4 MHz)
|
||||
// mul-n = <72>; // Multiply by 72 (4 MHz * 72 = 288 MHz)
|
||||
// div-r = <2>; // Divide by 2 for system clock (288 MHz / 2 = 144 MHz)
|
||||
//};
|
||||
&adc1 {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&adc1_in1_pa0>;
|
||||
pinctrl-names = "default";
|
||||
st,adc-clock-source = "SYNC";
|
||||
st,adc-prescaler = <4>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
channel@1 {
|
||||
reg = <1>;
|
||||
zephyr,gain = "ADC_GAIN_1";
|
||||
zephyr,reference = "ADC_REF_INTERNAL";
|
||||
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
|
||||
zephyr,resolution = <12>;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
modbus0 {
|
||||
@@ -95,21 +45,4 @@
|
||||
status = "okay";
|
||||
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; // PA9=TX, PA10=RX for Modbus communication
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
&adc1 { // ADC1 wird für PA0 verwendet
|
||||
status = "okay"; // ADC1 aktivieren
|
||||
pinctrl-0 = <&adc1_in1_pa0>; // Pinmux für PA0 als ADC1_IN1
|
||||
pinctrl-names = "default";
|
||||
st,adc-clock-source = "SYNC";
|
||||
st,adc-prescaler = <4>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
|
||||
&pinctrl {
|
||||
// Pinmux für PA0 als ADC1_IN1 (Analogmodus)
|
||||
adc1_in1_pa0: adc1_in1_pa0 {
|
||||
pinmux = <STM32_PINMUX('A', 0, ANALOG)>; // PA0 in den Analogmodus setzen
|
||||
};
|
||||
};
|
||||
@@ -1,78 +1,5 @@
|
||||
#include <zephyr/dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
vnd7050aj: vnd7050aj {
|
||||
compatible = "vnd7050aj-valve-controller";
|
||||
status = "okay";
|
||||
|
||||
// VND7050AJ GPIO pin definitions
|
||||
in0-gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; // IN0 (PB7) - Input 0 control signal
|
||||
in1-gpios = <&gpiob 9 GPIO_ACTIVE_HIGH>; // IN1 (PB9) - Input 1 control signal
|
||||
rst-gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; // RST (PB3) - Reset pin for VND7050AJ
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; // SEN (PB4) - Sense Enable for current monitoring
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; // S0 (PB6) - Status/Select 0 output from VND7050AJ
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; // S1 (PB5) - Status/Select 1 output from VND7050AJ
|
||||
};
|
||||
|
||||
adc_sensors {
|
||||
compatible = "adc-sensors";
|
||||
|
||||
supply_voltage: supply-voltage {
|
||||
compatible = "custom,supply-voltage";
|
||||
io-channels = <&adc1 1>; /* ADC1 channel 1 (PA0) */
|
||||
io-channel-names = "voltage";
|
||||
reference-mv = <3300>;
|
||||
voltage-divider-ratio = <4>; /* Adjust based on your voltage divider */
|
||||
sensor-mux = <&vnd7050aj>; /* Reference to VND7050AJ mux */
|
||||
mux-channel = <3>; /* VCC sense channel */
|
||||
measurement-delay-ms = <5>; /* 5ms delay after GPIO setup */
|
||||
};
|
||||
|
||||
motor_current_open: motor-current-open {
|
||||
compatible = "custom,motor-current";
|
||||
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
|
||||
io-channel-names = "current";
|
||||
reference-mv = <3300>;
|
||||
current-sense-resistor-mohm = <1500000>; /* 1.5kΩ sense resistor in mΩ */
|
||||
k-factor = <10>; /* Current sense amplification factor */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
measurement-delay-ms = <10>; /* 10ms delay for current settling */
|
||||
};
|
||||
|
||||
motor_current_close: motor-current-close {
|
||||
compatible = "custom,motor-current";
|
||||
io-channels = <&adc1 1>; /* Same ADC channel, different mux setting */
|
||||
io-channel-names = "current";
|
||||
reference-mv = <3300>;
|
||||
current-sense-resistor-mohm = <1500000>; /* 1.5kΩ sense resistor in mΩ */
|
||||
k-factor = <10>; /* Current sense amplification factor */
|
||||
sen-gpios = <&gpiob 4 GPIO_ACTIVE_HIGH>; /* SEN (PB4) - enable sensor */
|
||||
s0-gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; /* S0 (PB6) - mux select bit 0 */
|
||||
s1-gpios = <&gpiob 5 GPIO_ACTIVE_HIGH>; /* S1 (PB5) - mux select bit 1 */
|
||||
measurement-delay-ms = <10>; /* 10ms delay for current settling */
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&adc1 { // ADC1 wird für PA0 verwendet
|
||||
status = "okay"; // ADC1 aktivieren
|
||||
pinctrl-0 = <&adc1_in1_pa0>; // Pinmux für PA0 als ADC1_IN1
|
||||
pinctrl-names = "default";
|
||||
st,adc-clock-source = "SYNC";
|
||||
st,adc-prescaler = <4>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
|
||||
&pinctrl {
|
||||
// Pinmux für PA0 als ADC1_IN1 (Analogmodus)
|
||||
adc1_in1_pa0: adc1_in1_pa0 {
|
||||
pinmux = <STM32_PINMUX('A', 0, ANALOG)>; // PA0 in den Analogmodus setzen
|
||||
};
|
||||
};
|
||||
|
||||
&zephyr_udc0 {
|
||||
cdc_acm_uart0: cdc_acm_uart0 {
|
||||
compatible = "zephyr,cdc-acm-uart";
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# Custom motor current sensor binding
|
||||
description: Motor current sensor using VND7050AJ multiplexer
|
||||
|
||||
compatible: "custom,motor-current"
|
||||
|
||||
properties:
|
||||
io-channels:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: ADC channel phandle and specifier
|
||||
|
||||
io-channel-names:
|
||||
type: string-array
|
||||
required: true
|
||||
description: Names for the ADC channels
|
||||
|
||||
reference-mv:
|
||||
type: int
|
||||
required: true
|
||||
description: ADC reference voltage in millivolts
|
||||
|
||||
current-sense-resistor-mohm:
|
||||
type: int
|
||||
required: true
|
||||
description: Current sense resistor value in milliohms
|
||||
|
||||
k-factor:
|
||||
type: int
|
||||
required: true
|
||||
description: Current sense amplification factor for VND7050AJ
|
||||
|
||||
sen-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for sensor enable (SEN pin)
|
||||
|
||||
s0-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for multiplexer select bit 0 (S0 pin)
|
||||
|
||||
s1-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for multiplexer select bit 1 (S1 pin)
|
||||
|
||||
measurement-delay-ms:
|
||||
type: int
|
||||
required: false
|
||||
default: 10
|
||||
description: Delay in milliseconds after setting GPIO pins before reading ADC
|
||||
@@ -1,41 +0,0 @@
|
||||
# Custom supply voltage sensor binding
|
||||
description: Supply voltage sensor using VND7050AJ multiplexer
|
||||
|
||||
compatible: "custom,supply-voltage"
|
||||
|
||||
properties:
|
||||
io-channels:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: ADC channel phandle and specifier
|
||||
|
||||
io-channel-names:
|
||||
type: string-array
|
||||
required: true
|
||||
description: Names for the ADC channels
|
||||
|
||||
reference-mv:
|
||||
type: int
|
||||
required: true
|
||||
description: ADC reference voltage in millivolts
|
||||
|
||||
sensor-mux:
|
||||
type: phandle
|
||||
required: true
|
||||
description: Reference to the VND7050AJ sensor multiplexer node
|
||||
|
||||
voltage-divider-ratio:
|
||||
type: int
|
||||
required: true
|
||||
description: Voltage divider ratio for scaling measurements
|
||||
|
||||
mux-channel:
|
||||
type: int
|
||||
required: true
|
||||
description: Multiplexer channel number (0-3) for this sensor
|
||||
|
||||
measurement-delay-ms:
|
||||
type: int
|
||||
required: false
|
||||
default: 5
|
||||
description: Delay in milliseconds after GPIO setup before measurement
|
||||
@@ -1,60 +0,0 @@
|
||||
# VND7050AJ Sensor Multiplexer binding
|
||||
description: VND7050AJ sensor multiplexer for ADC channel selection
|
||||
|
||||
compatible: "vnd7050aj,sensor-mux"
|
||||
|
||||
properties:
|
||||
io-channels:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: ADC channel phandle and specifier for sensor input
|
||||
|
||||
io-channel-names:
|
||||
type: string-array
|
||||
required: true
|
||||
description: Names for the ADC channels
|
||||
|
||||
reference-mv:
|
||||
type: int
|
||||
required: true
|
||||
description: ADC reference voltage in millivolts
|
||||
|
||||
sen-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for sensor enable (SEN pin)
|
||||
|
||||
s0-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for multiplexer select bit 0 (S0 pin)
|
||||
|
||||
s1-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: GPIO for multiplexer select bit 1 (S1 pin)
|
||||
|
||||
in0-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
||||
description: GPIO for valve input 0 control (IN0 pin)
|
||||
|
||||
in1-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
||||
description: GPIO for valve input 1 control (IN1 pin)
|
||||
|
||||
rst-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
||||
description: GPIO for reset control (RST pin)
|
||||
|
||||
sense-resistor-ohm:
|
||||
type: int
|
||||
required: true
|
||||
description: Current sense resistor value in ohms
|
||||
|
||||
k-factor:
|
||||
type: int
|
||||
required: true
|
||||
description: Current sense ratio for VND7050AJ (typical ~1200:1)
|
||||
@@ -1,35 +0,0 @@
|
||||
# VND7050AJ Valve Controller binding
|
||||
description: VND7050AJ valve controller GPIO configuration
|
||||
|
||||
compatible: "vnd7050aj-valve-controller"
|
||||
|
||||
properties:
|
||||
in0-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for IN0 control signal
|
||||
required: true
|
||||
|
||||
in1-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for IN1 control signal
|
||||
required: true
|
||||
|
||||
rst-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for reset pin
|
||||
required: true
|
||||
|
||||
sen-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for sense enable pin
|
||||
required: true
|
||||
|
||||
s0-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for status/select 0 pin
|
||||
required: true
|
||||
|
||||
s1-gpios:
|
||||
type: phandle-array
|
||||
description: GPIO for status/select 1 pin
|
||||
required: true
|
||||
@@ -13,6 +13,7 @@ CONFIG_NVS=y
|
||||
CONFIG_FLASH=y
|
||||
CONFIG_FLASH_MAP=y
|
||||
CONFIG_FLASH_PAGE_LAYOUT=y
|
||||
CONFIG_SETTINGS_LOG_LEVEL_DBG=y
|
||||
|
||||
# Config modbus
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
@@ -20,7 +21,6 @@ CONFIG_MODBUS=y
|
||||
CONFIG_MODBUS_ROLE_SERVER=y
|
||||
CONFIG_MODBUS_BUFFER_SIZE=256
|
||||
|
||||
# ADC Sensor Configuration - Use real ADC readings
|
||||
CONFIG_ADC_SENSOR_SIMULATED=n
|
||||
CONFIG_ADC=y
|
||||
# Enable VND7050AJ
|
||||
CONFIG_VND7050AJ=y
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <app_version.h>
|
||||
#include <lib/fwu.h>
|
||||
#include <lib/modbus_server.h>
|
||||
#include <lib/valve.h>
|
||||
@@ -9,9 +8,7 @@
|
||||
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
|
||||
|
||||
int main(void) {
|
||||
int rc;
|
||||
LOG_INF("Starting Irrigation System Slave Node version %s (Build version %s)",
|
||||
APP_VERSION_STRING, STRINGIFY(APP_BUILD_VERSION));
|
||||
LOG_INF("Starting Irrigation System Slave Node");
|
||||
|
||||
if (settings_subsys_init() || settings_load()) {
|
||||
LOG_ERR("Settings initialization or loading failed");
|
||||
@@ -20,9 +17,8 @@ int main(void) {
|
||||
valve_init();
|
||||
fwu_init();
|
||||
|
||||
rc = modbus_server_init();
|
||||
if (rc < 0) {
|
||||
LOG_ERR("Modbus RTU server initialization failed: %d", rc);
|
||||
if (modbus_server_init()) {
|
||||
LOG_ERR("Modbus RTU server initialization failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user