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 Counsyl
git clone [email protected]:rako223/rako-pyads.git
cd rako-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:
- Find your local IP address (
ifconfig | grep inet
should help), e.g.192.168.4.13
- Dream up an Ams ID for your local machine. The Ams ID is a program identifier used by the ADS protocol. It's often
IP address + .1.1
but any six byte sequence works, for example192.168.192.168.1.1
. See the Beckoff Documentation for more information. - Connect to the PLC computer and log in
- Open the System Manager (right click Twincat tray icon, then select System Manager)
- Navigate to
SYSTEM - Configuration
,Route Settings
, then open theStatic Routes
tab - Click
Add
. In theAdd Route Dialog
window, you need to fill out the bottom half of the formRoute 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 address- Select
IP Address
Connection Timeout
: 5Target Route
: StaticRemote Route
: None
The 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.