The functions adsRead(), adsReadFloat(), adsReadDouble(),
adsWrite(), adsWriteFloat() and adsWriteDouble()
implement the ADS/AMS
interface of Beckhoff (www.beckhoff.de
).
$ret = adsRead( $host, $AMSPort, $indexGroup, $indexOffset, $length); $ret = adsWrite( $host, $AMSPort, $indexGroup, $indexOffset, $length, $data); $ret = adsReadFloat( $host, $AMSPort, $indexGroup, $indexOffset, 4); $ret = adsWriteFloat( $host, $AMSPort, $indexGroup, $indexOffset, 4, $xdata); $ret = adsReadDouble( $host, $AMSPort, $indexGroup, $indexOffset, 8); $ret = adsWriteDouble( $host, $AMSPort, $indexGroup, $indexOffset, 8, $xdata); $ret = adsRead( "hasc1", 801, 0xf020, 0x59, 4) $ret = adsWrite( "131.169.123.123", 801, 0xf020, 0x59, 4, 0x3f800000)
The $AMSPort
is 801 for the 'SPS Laufzeitsystem 1', for example.
$indexGroup
and $indexOffset
identify the register.
$length
can be 1, 2, or 4 for int I/O or 4 for float I/O.
Note: Before a client can connect to a TwinCAD system via ADS, the corresponding host has to be authorized on the server by name, AMS Net Id ( e.g.: 131.169.123.123.1.1) and address. The TwinCAD system has to be re-started after a new host has been authorized. TwinCAD runs on Windows PCs. The wirewall of this PC has to be disabled. ADS uses the TCP/IP port 48808.
Note: Before a client can connect to a CX system a static route has to be added on the CX. You have a TwinCat running on a Windows PC and use 'Zielsystem waehlen' to select the CX. Then restart the CX, enter Config mode, double-click Routing Einstellungen, add a static route and make sure the remote route is static (login information will be prompted).