Python wrapper for TwinCAT ADS library
Project description
This is a python wrapper for TwinCATs ADS library. It provides python functions for communicating with TwinCAT devices. pyads uses the C API AdsDLL.dll. The documentation for the ADS API is available on infosys.beckhoff.com.
Some Samples
open port, set port number to 801
>>> port = adsPortOpen()
>>> adr = adsGetLocalAddress()
>>> adr.setPort(PORT_SPS1)
set ADS-state and machine-state
>>> adsSyncWriteControlReq(adr, ADSSTATE_STOP, 0, 0)
read bit %MX100.0, toggle it and write back to plc
>>> data = adsSyncReadReq(adr, INDEXGROUP_MEMORYBIT, 100*8 + 0, PLCTYPE_BOOL)
>>> adsSyncWriteReq(adr, INDEXGROUP_MEMORYBIT, 100*8 + 0, not data)
write an UDINT value to MW0 and read it from plc
>>> adsSyncWriteReq(adr, INDEXGROUP_MEMORYBYTE, 0, 65536, PLCTYPE_UDINT)
>>> adsSyncReadReq(adr, INDEXGROUP_MEMORYBYTE, 0, PLCTYPE_UDINT)
write a string value in MW0 and read it from plc
>>> adsSyncWriteReq(adr, INDEXGROUP_MEMORYBYTE, 0, "Hallo, wie geht es?", PLCTYPE_STRING)
>>> adsSyncReadReq(adr, INDEXGROUP_MEMORY_BYTE, 0, PLCTYPE_STRING)
read a value of type real from global variable foo
>>> adsSyncReadByName(adr, ".foo", PLCTYPE_REAL)
write a value of type real to global variable bar
>>> adsSyncWriteByName(adr, ".bar", 1.234, PLCTYPE_REAL)
close port
>>> adsPortClose()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyads-1.3.0.zip
(26.4 kB
view details)
File details
Details for the file pyads-1.3.0.zip
.
File metadata
- Download URL: pyads-1.3.0.zip
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55027c3a350a8b66c71c10945d3b7071576ff84fa7bd0d0b33cf55edbd88992d |
|
MD5 | 40c366e46b6a7a7c887cec1109f1bb12 |
|
BLAKE2b-256 | bc80ed1070192112cce98e0c0038af737e2eb111cbd6f8f5a9a948be27cfdb08 |