Show HN:Pyhoff - 将Python ML模型连接到Beckhoff/Wago IO硬件
Show HN: Pyhoff – Connect Python ML Models to Beckhoff/WAGO IO Hardware

原始链接: https://github.com/Nonannet/pyhoff

“ Pyhoff”软件包通过以太网总线耦合器(如BK9000,BK9050,BK9100,BK9100和Wago 750-352)通过以太网总线耦合器与贝克霍夫和Wago Bus Terminals(Busklemmen)相互作用,提供了轻巧,无依赖性解决方案。它利用以太网上的Modbus TCP进行通信,提供了高级抽象,以最小的代码向I/O终端读取数据。 关键功能包括对各种模拟和数字终端的支持,易于扩展以及对工业测试设置的适用性,研究自动化以及数据获取/监视。 提供的示例展示了如何连接到总线耦合器,添加终端,控制数字输出(线圈),读取模拟值(温度)并设置模拟输出(电压)。 为了做出贡献,该项目鼓励在Github上提交开头问题或提交拉动请求。开发设置涉及克隆存储库,创建虚拟环境并安装开发依赖性,然后运行测试以确保正确配置。 该软件包是根据MIT许可证获得许可的。

这是黑客新闻帖子的摘要: Saloc推出了Pyhoff,这是一种用于将机器学习模型连接到Beckhoff/Wago Industrial I/O硬件的Python软件包。 Saloc对传统PLC工具链的复杂性(仅Windows,许可,专有版本控制)的复杂性感到沮丧,创建了Pyhoff,以使用Python进行直接硬件控制,这是原型制作和精确时机并不重要的原型应用程序的理想选择。 Pyhoff提供了快速的迭代和易用性,除了Python之外没有依赖关系,并且已通过MIT许可完全输入通知。它使用Modbus/TCP进行通信,实现将作为客户端库公开。 Saloc寻求有关用例,特征想法和PLC工具链体验的反馈。 在评论中,用户讨论了成本效益,强调了使用硬件选项的非专业应用程序可以负担得起,并且在专业设置中节省的调试时间和空间效率通常证明硬件成本是合理的。
相关文章

原文

The pyhoff package allows you to read and write the most common 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.

  • Supports a wide range of Beckhoff and WAGO analog and digital bus terminals.
  • Very lightweight: 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
  • Industrial test setups.
  • Research automation setups.
  • Data acquisition and monitoring.

The package has no additional decencies. It can be installed with pip:

It is easy to use as the following example code shows:

from pyhoff.devices import *

# connect to the BK9050 by tcp/ip on default port 502
bk = BK9050("172.16.17.1")

# add all bus terminals connected to the bus coupler
# in the order of the physical arrangement
bk.add_bus_terminals(KL2404, KL2424, KL9100, KL1104, KL3202,
                     KL3202, KL4002, KL9188, KL3054, KL3214,
                     KL4004, KL9010)

# Set 1. output of the first KL2404-type bus terminal to hi
bk.select(KL2404, 0).write_coil(1, True)

# read temperature from the 2. channel of the 2. KL3202-type
# bus terminal
t = bk.select(KL3202, 1).read_temperature(2)
print(f"t = {t:.1f} °C")

# Set 1. output of the 1. KL4002-type bus terminal to 4.2 V
bk.select(KL4002, 0).set_voltage(1, 4.2)

Other analog and digital IO terminals are easy to complement. Contributions are welcome! Please open an issue or submit a pull request on GitHub.

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:

    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:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install Dev Dependencies Install pyhoff from source plus the dependencies required for development using pip:

  4. Run Tests Ensure that everything is set up correctly by running the tests:

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

联系我们 contact @ memedata.com