Skip to main content

Python driver for Koyo Ethernet ClickPLCs.

Project description

clickplc

Python ≥3.8 driver and command-line tool for Koyo Ethernet ClickPLCs.

Installation

pip install clickplc

Usage

Command Line

$ clickplc the-plc-ip-address

This will print all the X, Y, DS, and DF registers to stdout as JSON. You can pipe this as needed. However, you'll likely want the python functionality below.

Python

This uses Python ≥3.5's async/await syntax to asynchronously communicate with a ClickPLC. For example:

import asyncio
from syscon_clickplc import ClickPLC


async def get():
    async with ClickPLC('the-plc-ip-address') as plc:
        print(await plc.get('df1-df500'))


asyncio.run(get())

The entire API is get and set, and takes a range of inputs:

>>> await plc.get('df1')
0.0
>>> await plc.get('df1-df20')
{'df1': 0.0, 'df2': 0.0, ..., 'df20': 0.0}
>>> await plc.get('y101-y316')
{'y101': False, 'y102': False, ..., 'y316': False}

>>> await plc.set('df1', 0.0)  # Sets DF1 to 0.0
>>> await plc.set('df1', [0.0, 0.0, 0.0])  # Sets DF1-DF3 to 0.0.
>>> await plc.set('y101', True)  # Sets Y101 to true

Currently, only X, Y, C, DS, DF, and CTD are supported:

x bool Input point
y bool Output point
c bool (C)ontrol relay
df float (D)ata register, (f)loating point
ds int16 (D)ata register, (s)igned int
ctd int32 (C)oun(t)er Current Values, (d)ouble int

We personally haven't needed to use the other categories, but they are straightforward to add if needed.

Tags / Nicknames

Recent ClickPLC software provides the ability to export a "tags file", which contains all variables with user-assigned nicknames. The tags file can be used with this driver to improve code readability. (Who really wants to think about modbus addresses and register/coil types?)

To export a tags file, open the ClickPLC software, go to the Address Picker, select "Display MODBUS address", and export the file.

Once you have this file, simply pass the file path to the driver. You can now set variables by name and get all named variables by default.

async with ClickPLC('the-plc-ip-address', 'path-to-tags.csv') as plc:
    await plc.set('my-nickname', True)  # Set variable by nickname
    print(await plc.get())  # Get all named variables in tags file

Additionally, the tags file can be used with the commandline tool to provide more informative output:

$ clickplc the-plc-ip-address tags-filepath

Project details


Download files

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

Source Distribution

syscon_clickplc-0.0.3.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

syscon_clickplc-0.0.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file syscon_clickplc-0.0.3.tar.gz.

File metadata

  • Download URL: syscon_clickplc-0.0.3.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for syscon_clickplc-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6f7262ae9ad8f721e32a5ae5dbedce56d2427610cf1422a83d724944e38df629
MD5 d1eaa9c60b210f197d6f2212072af80a
BLAKE2b-256 8c00abf766d59636adb2ecaaf21fd72639d9cd27f9d7b5901d4101cbb8997dcb

See more details on using hashes here.

File details

Details for the file syscon_clickplc-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for syscon_clickplc-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f26d49e9ccd2cbd09a3b6200c12354dcc88483dde43feb1ef543fd6601f1ce9c
MD5 12584eeee58e732d917015348d09ff3f
BLAKE2b-256 e9aabe0c4a152a16cd06d931328c86d0e1579e105dc57ad4eea7ec0db157ea30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page