This Python package contains a Python-only implementation of the AMS/ADS (Automation Device Specification) protocol for communicating directly with Beckhoff PLCs. No router is included or required. It is a fork of the pyads library by Christoph Wiedemann, with support for more data types (including arrays).
git clone git@github.com:counsyl/counsyl-pyads.git
cd counsyl-pyads
# consider making yourself a virtualenv
pip install -r requirements.txt
python setup.py install
Beckhoff PLCs won't accept connections from just anyone. The Twincat System Manager on the PLC contains a list of "routes" that define allowed clients. Perform the following steps to add the host where you plan to use counsyl_pyads
to the list of routes:
ifconfig | grep inet
should help), e.g. 192.168.4.13
IP address + .1.1
but any six byte sequence works, for example192.168.192.168.1.1
. See the Beckoff Documentation for more information.SYSTEM - Configuration
, Route Settings
, then open the Static Routes
tabAdd
. In the Add Route Dialog
window, you need to fill out the bottom half of the form
Route Name (Target)
: Something descriptive to describe this route, consider including your nameAmsNetId
: The Ams ID you dreamed up aboveTransport Type
: TCP/IP
Address Info
: Your IP addressIP Address
Connection Timeout
: 5Target Route
: StaticRemote Route
: NoneThe script bin/twincat_plc_info.py
should get you started with the basics. You can use it to query system information and a list of all varibles on a PLC.
twincat_plc_info.py 5.21.172.208.1.1:801 10.1.0.99 801 192.168.192.168.1.1:5555
This assumes that you have a PLC with Ams ID 5.21.172.208.1.1
available at IP 10.1.0.99
that is set up to accept connections from you (see PLC setup section above). Port 801
is default. 192.168.192.168.1.1:5555
is your arbitrary local Ams ID including a port that isn't used for anything.