Commit Graph

39 Commits

Author SHA1 Message Date
Your Name 76d0d0647c feat: Implement obstacle detection for valve movement
Implement obstacle detection for valve movement that stops the motor if the current exceeds a predefined threshold during opening or closing.

- :
    - Added new defines  and  with a default value of 500 mA.
- :
    - Modified  function to compare the measured current with the new obstacle thresholds.
    - If the threshold is exceeded, the valve movement is stopped and the status is set to .

Signed-off-by: Your Name <your.email@example.com>
2025-07-11 01:21:41 +02:00
Eduard Iten 3de42a46c2 refactor: Entferne ungenutzte Funktion
Die Funktion  wurde aus  und  entfernt, da sie im Code nicht mehr verwendet wird. Die Stromwerte werden stattdessen über  und  abgerufen.

Diese Änderung entfernt ungenutzten Code und verbessert die Code-Sauberkeit.
2025-07-11 01:09:46 +02:00
Eduard Iten ddaaa8988d feat: Modbus-Register für Endstromschwellenwerte korrigiert
Behebt ein Problem, bei dem das Python-Tool 0 mA für die Endstromschwellenwerte anzeigte.

Die Zephyr-Anwendung definierte zuvor nur ein einzelnes Modbus-Register für den Endstromschwellenwert, während das Python-Tool separate Register für das Öffnen und Schließen erwartete.

Änderungen:
- :
    -  wurde in  umbenannt.
    -  wurde als neues Register hinzugefügt.
- :
    - Implementierung der Lese- und Schreib-Callbacks für  und  unter Verwendung der entsprechenden -Bibliotheksfunktionen.

Diese Änderungen stellen sicher, dass die Zephyr-Anwendung die Endstromschwellenwerte korrekt über Modbus bereitstellt und das Python-Tool diese Werte nun richtig lesen und schreiben kann.
2025-07-11 01:01:45 +02:00
Eduard Iten b937c52bcc Revert "feat(valve): Implement obstacle detection with configurable thresholds"
This reverts commit 3c2235733b.
2025-07-11 00:35:19 +02:00
Eduard Iten 3c2235733b feat(valve): Implement obstacle detection with configurable thresholds
Introduces separate configurable current thresholds for obstacle detection
during valve opening and closing movements.

- Added  state to .
- Added  and
   to .
- Modified  to implement obstacle detection in ,
  setting  on high current, and to load/save
  these new thresholds via settings.
- Added new setter/getter functions for obstacle thresholds to  and .
- Updated  with new shell commands (, )
  and updated  to display these settings.
- Updated  to document the new registers and error states.
- Updated  to include new register definitions, menu options,
  and display of obstacle current thresholds.
2025-07-11 00:27:31 +02:00
Eduard Iten a3e8d5c168 refactor(shell): Improve shell command naming and output formatting
- Renamed shell commands in  and  to be shorter
  and remove underscores (e.g.,  to ).
- Consolidated get functions into a single show command for both valve
  and Modbus settings (e.g., , ).
- Adjusted output formatting for show commands to be right-aligned and
  remove horizontal lines for better readability.
- Fixed missing getter function implementations in  and their
  declarations in .
- Ensured  is correctly selected in
  to make valve shell commands available.
2025-07-11 00:16:43 +02:00
Eduard Iten 5fd904de9e fix(valve): Start movement timer only if timeout is greater than 0
Ensures that the k_timer for valve movement timeouts is only started if
the configured max_opening_time_s or max_closing_time_s is greater than 0.
This prevents unnecessary timer activations when timeouts are disabled or zero.
2025-07-10 23:45:21 +02:00
Eduard Iten 92bb171e85 feat(valve): Make end-position current thresholds configurable
Introduces separate Modbus holding registers for configurable end-position
current thresholds for both opening and closing valve movements.

- Added REG_HOLDING_VALVE_END_CURRENT_THRESHOLD_OPEN_MA and
  REG_HOLDING_VALVE_END_CURRENT_THRESHOLD_CLOSE_MA to modbus_server.h.
- Modified valve.c to use these new thresholds and save/load them via settings.
- Added new setter functions to valve.h.
- Created new shell_valve library with commands to set/get these thresholds.
- Updated modbus_tool.py to include new menu options for setting thresholds.
- Updated docs/modbus-registers.de.md to document the new registers.

This enhances the flexibility and calibration of the valve control system.
2025-07-10 23:42:41 +02:00
Eduard Iten bd8a7a766c style: Apply clang-format to C/C++ source files
Applied consistent code formatting using clang-format to all C/C++ source
and header files in the 'software/' directory.
2025-07-10 23:33:50 +02:00
Eduard Iten 8f89713866 feat(modbus_tool): Add set functions for max open/close times
Adds new menu options to the Modbus tool to allow setting the maximum
opening and closing times for the valve via Modbus registers.
2025-07-10 23:31:32 +02:00
Eduard Iten bf29061db6 feat(slave): Implement VND7050AJ and core valve functionality; 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.
2025-07-10 21:13:17 +02:00
Eduard Iten c1622bb01c Just saving 2025-07-10 17:23:22 +02:00
Eduard Iten 222ffea568 Refactor VND7050AJ sensor configuration to eliminate redundancy
- Create centralized sensor multiplexer node (vnd7050aj_mux) with shared configuration
- Consolidate ADC channel, GPIO pins, and reference voltage in single location
- Update sensor bindings to reference centralized mux via sensor-mux property
- Add channel-based sensor selection using mux-channel property (0-3)
- Refactor ADC sensor library to use centralized GPIO and channel control
- Update valve library to use new vnd7050aj_mux node reference
- Eliminate duplicate ADC/GPIO definitions between voltage and current sensors
- Ensure configuration consistency and prevent mismatched settings

Benefits:
- Single source of truth for VND7050AJ hardware configuration
- Impossible to have inconsistent GPIO/ADC settings between sensors
- Simplified maintenance and scalability for additional sensors
- Clean channel-based multiplexer selection interface
2025-07-08 17:05:34 +02:00
Eduard Iten a9a0626913 Implement real ADC readings with VND7050AJ sensor multiplexing
- Switch from simulated to real ADC readings in adc_sensor library
- Add GPIO control for VND7050AJ sensor selection (sen, s0, s1 pins)
- Implement proper ADC device and channel setup for voltage/current measurements
- Enable ADC driver in prj.conf (CONFIG_ADC=y)
- Disable simulation mode (CONFIG_ADC_SENSOR_SIMULATED=n)
- Add devicetree bindings for custom supply voltage and motor current sensors
- Update overlay with adc_sensors nodes using PB4, PB5, PB6 pins
- Integrate real ADC readings into Modbus server registers
- Support HSE/HSI clock source toggling in overlay configuration
2025-07-08 16:50:27 +02:00
Eduard Iten b11f844415 feat: Add ADC sensor device tree bindings and configuration
Introduces device tree bindings for custom ADC voltage and current sensors,
allowing for flexible configuration of sensor inputs and associated GPIOs.
This enables proper hardware abstraction for ADC measurements.

The example overlay file
has been removed as its content is now integrated or superseded by the new
binding definitions.
2025-07-08 16:43:27 +02:00
Eduard Iten 9b7159d5a4 added formatting 2025-07-08 16:06:11 +02:00
Eduard Iten bc327acc41 docs: Add Doxygen comments to library files
Added Doxygen-style comments to all C source and header files in the
 and  directories. This improves
code documentation and enables VSCode tooltip help.

Additionally, short inline comments were added to all global variables
for better clarity.
2025-07-08 15:48:13 +02:00
Eduard Iten c9b0f38576 feat(lib): Introduce adc_sensor library
Adds a new `adc_sensor` library to abstract reading analog values from ADC channels. The output of this library is currently simulated.

This library is now used by the `modbus_server` to read the motor current and the main supply voltage, replacing the previous implementation. This change improves modularity by centralizing ADC-related code into a dedicated module.

The build system has been updated to include the new library.
2025-07-08 15:19:44 +02:00
Eduard Iten 537d76ef5d feat(app): Integrate application versioning
This commit introduces application versioning, exposing version information through the Modbus server and logging it at startup.

- Add  to provide version information
- Update  to log the application version at startup
- Update  to expose firmware version via Modbus
- Add file association for  in
2025-07-08 14:41:01 +02:00
Eduard Iten 45d011952f fix(valve): Correct VND7050AJ initialization and pin configuration
- Initialize RST pin as active to keep VND7050AJ out of reset state
- Clarify S0/S1 pins as output select pins with descriptive comments
- Add initialization logging to show configured max open/close times
- Ensure proper valve controller startup sequence
2025-07-03 19:04:20 +02:00
Eduard Iten bb25134b6c feat(modbus): Implement persistent and improved reconfiguration for Modbus server
This commit enhances the Modbus server's configuration handling by:

- Loading saved baudrate and unit ID settings during initialization, ensuring persistence across reboots.
- Providing improved feedback during `modbus_reconfigure`, including logging for successful changes and informing the user when a device restart is required for changes to take effect.
- Saving new configuration settings even if immediate reinitialization fails, allowing them to be applied on the next boot.
2025-07-03 18:59:01 +02:00
Eduard Iten b543579393 feat(modbus): Add supply voltage register and display in tool
This commit introduces a new Modbus input register for the system's supply voltage.

- The `modbus-registers.de.md` documentation is updated to include the `SUPPLY_VOLTAGE_MV` register at address `0x00F5` within the system block.
- The `modbus_server.h` header defines the new register.
- The `modbus_server.c` implementation provides a fixed value (12300 mV) for this register.
- The `modbus_tool.py` script is updated to read and display this new supply voltage value in the UI.

This lays the groundwork for integrating actual voltage measurements in the future.
2025-07-03 18:47:48 +02:00
Eduard Iten 69cf7e9511 feat(valve): Implement GPIO control for VND7050AJ
This commit implements the real valve control using the GPIOs connected to the VND7050AJ driver.

- The `weact_stm32g431_core.overlay` is updated with a specific compatible string and a device tree label for the valve controller.
- `valve.h` is extended to include GPIO device specifications.
- `valve.c` now initializes and controls the GPIOs for opening and closing the valve, including the reset logic. The IN0 and IN1 pins are interlocked to prevent simultaneous activation. The RST pin is activated before each movement and deactivated afterward.

This replaces the previous virtual/simulated valve logic with actual hardware control.
2025-07-03 18:17:31 +02:00
Eduard Iten 6c1ff0c4df feat(refactor): Restructure project for improved modularity and clarity
This commit introduces a major refactoring of the project structure to align
with Zephyr's recommended multi-application and library organization.

Key changes include:
- Relocation of custom modules from 'software/modules/' to 'software/lib/'.
- Introduction of a central 'software/CMakeLists.txt' to manage application
  and library subdirectories.
- Creation of new Kconfig files for 'software/' and 'software/apps/slave_node/'
  to define project-wide and application-specific configurations.
- Removal of the 'gateway' and 'stm32g431_tests' applications.
- Removal of 'shell_modbus.c' and 'shell_system.c' from 'slave_node' application's
  direct source files, indicating a shift towards library-based shell commands.
- Updates to 'software/apps/slave_node/CMakeLists.txt', 'prj.conf', and
  'boards/bluepill_f103rb.conf' to reflect the new structure and dependencies.
2025-07-03 16:58:43 +02:00
Eduard Iten c3df6565b7 Refactor fwu library into a Zephyr module 2025-07-02 21:30:15 +02:00
Eduard Iten 711341f362 Refactor slave_node application to use Zephyr modules 2025-07-02 20:47:16 +02:00
Eduard Iten 2418d4e218 fix: resolve build error by moving modbus register enums to header 2025-07-02 10:02:40 +02:00
Eduard Iten 85d493f24a feat: implement modbus reset command and update docs/tool 2025-07-02 09:55:42 +02:00
Eduard Iten f486d4c4ab cleanup: remove unused CMakeLists.txt and empty modbus directory 2025-07-02 09:54:01 +02:00
Eduard Iten 6cfd4b8b4d refactor: restructure slave_node into libraries 2025-07-02 09:45:22 +02:00
Eduard Iten fbeaa916b9 feat(project): Restructure software for multi-app setup
- Reorganize the software directory to support multiple Zephyr applications (gateway, slave_node).

- Create a clear separation between applications and shared libraries.

- Add placeholder files for gateway and slave_node applications.
2025-07-01 08:20:25 +02:00
Eduard Iten a4aeaa5f91 Fixed modbus init 2025-06-19 17:09:46 +02:00
Eduard Iten e9fc370094 canbus, modbus working, valve has to be implemented in real 2025-06-19 16:56:21 +02:00
Eduard Iten 852c5c72be Added shell functions 2025-06-17 16:43:13 +02:00
Eduard Iten 9d017f9f8d Zwischenspeichern 2025-06-16 13:09:27 +02:00
Eduard Iten 1a85b40444 Fixed setting in canbus 2025-06-13 10:26:57 +02:00
Eduard Iten ade514cbf3 startet canbus implementation 2025-06-13 09:57:34 +02:00
Eduard Iten 5ab33e3a7b minimal changes 2025-06-13 08:26:49 +02:00
Eduard Iten 57f7060c0e Added modbus lib and test 2025-06-12 17:04:34 +02:00