readme updated

This commit is contained in:
Nicolas 2025-02-17 14:57:11 +01:00
parent f34eef3eb4
commit 5e52a3f866
1 changed files with 74 additions and 28 deletions

View File

@ -1,21 +1,40 @@
# pyhoff # pyhoff
The pyhoff package allows to read and write the most common ## Description
Beckhoff and WAGO bus terminals ("Busklemmen") using the bus The pyhoff package allows you to read and write the most common
coupler ("Busskoppler") BK9000, BK9050, BK9100 or WAGO 750_352 Beckhoff and WAGO bus terminals ("Busklemmen") using the Ethernet bus
coupler ("Busskoppler") BK9000, BK9050, BK9100, or WAGO 750_352
over Ethernet TCP/IP based on ModBus TCP. over Ethernet TCP/IP based on ModBus TCP.
It depends on the package pyModbusTCP. This can be installed with: ### Key Features
- Supports a wide range of Beckhoff and WAGO analog and digital bus
terminals.
- Very light weight: no dependencies; compact code base
- Easy to extend
- Using standardized ModBus TCP.
- Provides high-level abstractions for reading and writing data
from/to IO-terminals with minimal code
pip install pyModbusTCP ### Usage Scenarios
- Industrial test setups.
- Research automation setups.
- Data acquisition and monitoring.
## Installation
The package has no additional decencies. It can be installed with pip:
```bash
pip install pyhoff
```
## Usage
It is easy to use as the following example code shows: It is easy to use as the following example code shows:
```python ```python
from pyhoff import * from pyhoff.devices import *
# connect to the BK9050 by tcp/ip on default port 502 # connect to the BK9050 by tcp/ip on default port 502
bus_coupler = ModBusBK9050("172.16.17.1") bus_coupler = BK9050("172.16.17.1")
# list of all bus terminals connected to the bus coupler # list of all bus terminals connected to the bus coupler
# in the order of the physical arrangement # in the order of the physical arrangement
@ -26,27 +45,54 @@ terminal_list = [KL2404, KL2424, KL9100, KL1104, KL3202,
terminals = bus_coupler.add_bus_terminals(terminal_list) terminals = bus_coupler.add_bus_terminals(terminal_list)
# Set 1. output of the first bus terminal (KL2404) to hi # Set 1. output of the first bus terminal (KL2404) to hi
terminals[0].write_coil(0, True) terminals[0].write_coil(1, True)
# read the temperature from the 2. channel of the 5. bus # read the temperature from the 2. channel of the 5. bus
# terminal (KL3202) # terminal (KL3202)
t = terminals[4].read_temperature(1) t = terminals[4].read_temperature(2)
print(f"t = {t:.1f} °C") print(f"t = {t:.1f} °C")
# Set 1. output of the 6. bus terminal (KL4002) to 4.2 V # Set 1. output of the 6. bus terminal (KL4002) to 4.2 V
terminals[5].set_voltage(0, 4.2) terminals[5].set_voltage(1, 4.2)
``` ```
The following terminals are implemented: ## Contributing
- KL1104: 4x digital input 24 V Other analog and digital IO terminals are easy to complement. Contributions are welcome!
- KL2404: 4x digital output with 500 mA Please open an issue or submit a pull request on GitHub.
- KL2424: 4x digital output with 2000 mA
- KL3054: 4x analog input 4...20 mA 12 Bit single-ended
- KL3202: 2x analog input PT100 16 Bit 3-wire
- KL3214: 4x analog input PT100 16 Bit 3-wire
- KL4002: 2x analog output 0...10 V 12 Bit differentiell
- KL4004: 4x analog output 0...10 V 12 Bit differentiell
- Dummy terminals without io functionality: KL9100, KL9183, KL9188
Other analog and digital io-terminals are easy to complement. Pull requests are welcome. ## Developer Guide
To get started with developing the `pyhoff` package, follow these steps:
1. **Clone the Repository**
First, clone the repository to your local machine using Git:
```bash
git clone https://github.com/Nonannet/pyhoff.git
cd pyhoff
```
2. **Set Up a Virtual Environment**
It is recommended to use a virtual environment to manage dependencies. You can create one using `venv`:
```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```
3. **Install Dev Dependencies**
Install the dependencies required for development using `pip`:
```bash
pip install -r requirements-dev.txt
```
4. **Run Tests**
Ensure that everything is set up correctly by running the tests:
```bash
pytest
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.