Skip to main content

🐍 PyVaem

📋 Overview

This Python API provides control for the Festo VAEM valve control module via Modbus TCP/IP communication. It is based on the original VAEM driver and features comprehensive refactoring and improvements.

🛠️ Requirements

  • Python: 3.10 or higher

📚 Core Dependencies

🚀 Installation

Option 1: From PyPI (Recommended)

# Create virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install the latest release from PyPI
pip install pyvaem

Option 2: From GitHub Releases

# Create virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install the latest release from GitHub
pip install https://github.com/jlmoraleshellin/pyvaem/releases/download/v1.0.0/pyvaem-1.0.0-py3-none-any.whl

📖 Quick Start

Basic Usage

from pyvaem import VaemDriver, VaemConfig, ValveSettings

# Set the VAEM connection configuration
config = VaemConfig(
    ip='192.168.1.100',
    port=502, # Default VAEM port
    slave_id=1
)

# Initialize the driver
vaem = VaemDriver(config)

# Select and open a single valve
vaem.select_valve(1)  # Select valve 1
vaem.open_valves()    # Open selected valves

# Close all valves before 
vaem.close_valves()

# Select multiple valves at once
valve_states = [1, 0, 1, 0, 0, 0, 0, 0]  # Open valves 1 and 3
vaem.select_valves(valve_states)
vaem.open_valves()

vaem.close_valves()

Valve Configuration

# Configure valve settings
settings = ValveSettings(
    NominalVoltage=24000,
    InrushCurrent=300,
    HoldingCurrent=100,
    ResponseTime=500,
    PickUpTime=125,
    TimeDelay=0,
    HitNHold=100
)

# You can also specify only the settings to change - others use defaults
settings = ValveSettings(
    InrushCurrent=300,
    HoldingCurrent=100,
    ResponseTime=500,
    PickUpTime=125,
    # NominalVoltage will be 24000 (default)
    # TimeDelay will be 0 (default)
    # HitNHold will be 100 (default)
)

# Apply settings to valve 1
vaem.set_valve_settings(1, settings)

# Or use a dictionary for better compatibility
settings_dict = {
    'NominalVoltage': 12000,
    'InrushCurrent': 250
    # All other parameter will use default values
}
vaem.set_valve_settings(2, settings_dict)

# Save settings to device memory (optional)
vaem.save_settings()

📝 Complete usage example

See example_usage.py.

🎯 API Reference

Core classes and methods

VaemDriver

The main driver class for controlling VAEM devices.

Constructor:

  • VaemDriver(vaem_config: VaemConfig)

VaemConfig

Configuration dataclass for VAEM connection parameters.

@dataclass
class VaemConfig:
    ip: str          # Device IP address
    port: int        # Modbus TCP port (typically 502)
    slave_id: int    # Modbus slave ID

ValveSettings

Configuration dataclass for valve parameters with VAEM defaults.

@dataclass
class ValveSettings:
    NominalVoltage: int = 24000    # Voltage (8000-24000 mV)
    ResponseTime: int = 500        # Response time (1-2³²-1 ms)
    TimeDelay: int = 0             # Time delay (0-2³²-1 ms)
    PickUpTime: int = 125          # Pick-up time (1-500 ms)
    InrushCurrent: int = 300       # Inrush current (20-1000 mA)
    HitNHold: int = 100            # Hit & hold (0-1000 ms)
    HoldingCurrent: int = 100      # Holding current (20-400 mA)

Valve Selection Methods

  • select_valve(valve_id: int) - Select a single valve (1-8)
  • deselect_valve(valve_id: int) - Deselect a single valve (1-8)
  • select_valves(states: list[int]) - Select multiple valves with 8-element list of 0s and 1s
  • select_all_valves() - Select all valves
  • deselect_all_valves() - Deselect all valves
  • read_valves_state() - Get current valve selection as tuple

Valve Operation Methods

  • open_valves() - Open all selected valves
  • close_valves() - Close all valves
  • clear_error() - Clear any device errors

Configuration Methods

  • set_valve_settings(valve_id: int, settings: ValveSettings | dict | None) - Configure valve parameters
  • read_valve_settings(valve_id: int) - Read current valve settings
  • save_settings() - Save current configuration to device memory

Status Methods

  • get_status() - Get device status including valve states and errors

🚨 Error Handling

The driver includes comprehensive error handling with specific exception types:

  • IndexError - Invalid parameter index or subindex
  • PermissionError - Read/write operation not allowed
  • ValueError - Parameter value out of range or invalid
  • TypeError - Incorrect data type
  • RuntimeError - Command execution failed
  • ConnectionError - Failed to connect to VAEM device

All valve operations are automatically wrapped with error checking and clearing.

📚 Documentation

For detailed documentation check the operating manual

🤝 Contributing

Contributions are welcome!

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

🙏 Attribution

This project is based on the original VAEM driver developed by Milen Kolev (milen.kolev@festo.com) and the Festo team. The original project provided the foundation for this improved implementation.

Original Repository: Festo VAEM Driver

📧 Contact

For questions, issues, or contributions:

🔄 Changelog

Version 1.0.0 (Current)

  • Complete rewrite with improved architecture
  • Enhanced error handling with specific exception types
  • Comprehensive valve configuration with ValveSettings dataclass
  • Improved logging and connection management
  • Better API design with clear method separation
  • Support for multiple valve selection patterns
  • Automatic error clearing on operations

Version 0.0.2 (Original)

  • Basic VAEM control functionality
  • Modbus TCP communication
  • Simple valve operations

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvaem-1.0.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvaem-1.0.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file pyvaem-1.0.1.tar.gz.

File metadata

  • Download URL: pyvaem-1.0.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyvaem-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4a927df2592fd693fe5f655089f9761f2b6fe3d48cbaca2642ce59916a90f2ed
MD5 ad9471c10c0b1dd6e8949c3b23d7b809
BLAKE2b-256 740a8b1e53236841d4d78a1224a15ef6300c4420b24f48faee16a1996950d6d5

See more details on using hashes here.

File details

Details for the file pyvaem-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyvaem-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pyvaem-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d312b6a1fb973200af29719fd1a645916a196620a0aeb090e26dac9d1f4135b2
MD5 0bad72483c81063f17875bb78973965e
BLAKE2b-256 bf3161e71832254ea9a2c2f5cf5648eb6179644c79753eea6d52bf55a10dd2d2

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.2

2 files

This release

1.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page