This is a python wrapper for TwinCATs ADS library. It provides python functions for communicating with TwinCAT devices. pyads uses the C API provided by TcAdsDll.dll on Windows adslib.so on Linux. The documentation for the ADS API is available on infosys.beckhoff.com.
Documentation: http://pyads.readthedocs.io/en/latest/index.html
From PyPi:
$ pip install pyads
From Github:
$ git clone https://github.com/MrLeeh/pyads.git --recursive
$ cd pyads
$ python setup.py install
- connect to a remote TwinCAT device like a plc or a PC with TwinCAT
- create routes on Linux devices and on remote plcs
- supports TwinCAT 2 and TwinCAT 3
- read and write values by name or address
- read DUTs (structures) from the plc
- notification callbacks
import pyads
# add route to remote plc
pyads.add_route("192.168.1.12.1.1", "192.168.1.12")
# connect to plc and open connection
plc = pyads.Connection('127.0.0.1.1.1', pyads.PORT_SPS1)
plc.open()
# read int value by name
i = plc.read_by_name("GVL.int_val", pyads.PLCTYPE_INT)
# write int value by name
plc.write_by_name("GVL.int_val", i, pyads.PLCTYPE_INT)
# close connection
plc.close()