项目作者: numat

项目描述 :
Python interface and command-line tool for Productivity Series PLCs.
高级语言: Python
项目地址: git://github.com/numat/productivity.git
创建时间: 2019-08-08T15:29:40Z
项目社区:https://github.com/numat/productivity

开源协议:GNU General Public License v2.0

下载


Productivity

NOTE: This is in very early stages of development.

Python ≥3.8 driver and command-line tool for AutomationDirect Productivity Series PLCs.



Installation

  1. pip install productivity

Usage

PLC Configuration

This driver uses Modbus TCP/IP for communication. Unlike the ClickPLC, modbus
addresses need to be manually configured in the Productivity PLC firmware (see
manual).

To use this driver, go to Write Program → Tag Database, scroll down to the values
you care about, and double click the Mod Start cell of each value to assign an address.
Then, go to File → Export → Tags to export a csv file. The file is used here so
you don’t need to remember the addresses.

Command Line

To print the tags and their values, simply call the library with the PLC IP address and the tags file.

  1. $ productivity the-plc-ip-address path/to/tags.csv

Use —set to set values on the PLC:

  1. $ productivity the-plc-ip-address path/to/tags.csv -s "{int_test: 4, float_test: 4.45, string_test: foo}"

The —set parameter takes YAML, a simple data format that allows you to easily set multiple tags at once.

See productivity --help for more.

Python

This driver uses Python ≥3.5’s async/await syntax to asynchronously communicate with
a Productivity2000 PLC. For example (note that asyncio.run() requires Python >=3.7):

  1. import asyncio
  2. from productivity import ProductivityPLC
  3. async def run():
  4. async with ProductivityPLC('the-plc-ip-address', 'path/to/tags.csv') as plc:
  5. print(await plc.get())
  6. asyncio.run(run())

It is also possible to set tag values:

  1. async def run():
  2. async with ProductivityPLC('the-plc-ip-address', 'path/to/tags.csv') as plc:
  3. await plc.set(start=True, setpoint=1.1)
  4. asyncio.run(run())