beckhoff · TwinCAT 2 ADS OCX · 144 pp.
Beckhoff TwinCAT 2 ADS OCX Manual — API & Installation Guide PDF
Руководство по ADS OCX для TwinCAT 2: доступ к ADS-устройствам, установка OCX, описание API (общие, синхронные, асинхронные методы, connect, события, свойства), примеры для Visual Basic, Delphi и LabVIEW, коды возврата ADS.
Related manuals
Contents
Document text
Manual | EN TX1000 TwinCAT 2 | ADS OCX 2025-11-06 | Version: 1.2
Table of contents
Table of contents Table of contents 1 Foreword.................................................................................................................................................... 7 1.1 Notes on the documentation ............................................................................................................. 7 1.2 For your safety .................................................................................................................................. 7 1.3 Notes on information security............................................................................................................
9 2 Access to the ADS devices .................................................................................................................... 10 3 Manual installation of the ADS OCX...................................................................................................... 12 4 API ............................................................................................................................................................ 13 4.1 general ............................................................................................................................................
13 4.1.1 AboutBox.......................................................................................................................... 13 4.1.2 AdsAmsDisconnect.......................................................................................................... 13 4.1.3 AdsAmsPortEnabled........................................................................................................ 14 4.1.4 AdsCreateVarHandle ....................................................................................................... 14 4.1.5 AdsDeleteVarHandle........................................................................................................
15 4.1.6 AdsEnableLogNotification................................................................................................ 15 4.1.7 AdsEnumSymbols............................................................................................................ 16 4.1.8 AdsSetFirstDynSymbol .................................................................................................... 17 4.1.9 AdsGetNextDynSymbol ................................................................................................... 18 4.1.10 AdsLogFmtString .............................................................................................................
19 4.1.11 AdsReadSymbolDesc ...................................................................................................... 20 4.1.12 AdsReadSymbolInfo ........................................................................................................ 21 4.1.13 AdsSyncWriteControlReq ................................................................................................ 22 4.1.14 AdsWriteControlReq ........................................................................................................ 22 4.1.15 ShowPropertyPages ........................................................................................................
23 4.2 synchron.......................................................................................................................................... 24 4.2.1 AdsSyncRead[Datatype]VarReq...................................................................................... 24 4.2.2 AdsSyncReadReq............................................................................................................ 26 4.2.3 AdsSyncRead[Datatype]Req ........................................................................................... 27 4.2.4 AdsSyncWrite[Datatype]VarReq......................................................................................
28 4.2.5 AdsSyncWriteReq............................................................................................................ 29 4.2.6 AdsSyncWrite[Datatype]Req............................................................................................ 30 4.3 asynchron........................................................................................................................................ 31 4.3.1 AdsRead[Datatype]Req ................................................................................................... 31 4.4 connect............................................................................................................................................
33 4.3.2 AdsWrite[Datatype]Req.................................................................................................... 32 4.4.1 AdsReadVarConnectEx ................................................................................................... 33 4.4.2 AdsReadVarConnectEx2 ................................................................................................. 35 4.4.3 AdsReadVarConvertConnect........................................................................................... 36 4.4.4 AdsRead[Datatype]VarConnect.......................................................................................
38 4.4.5 AdsDisconnectEx............................................................................................................. 40 4.4.6 AdsReadConnect............................................................................................................. 40 4.4.7 AdsReadDisconnect......................................................................................................... 41 4.4.8 AdsRead[Datatype]Connect............................................................................................. 42 4.4.9 AdsRead[Datatype]Disconnect ........................................................................................ 43 TX1000 3 Version: 1.2
Table of contents
Table of contents 4.4.10 AdsWriteDisconnect......................................................................................................... 44 4.4.11 AdsWrite[Datatype]Disconnect ........................................................................................ 44 4.4.12 AdsWriteVarConnect........................................................................................................ 45 4.4.13 AdsWrite[Datatype]VarConnect ....................................................................................... 46 4.4.14 AdsWriteConnect .............................................................................................................
48 4.4.15 AdsWrite[Datatype]Connect............................................................................................. 49 4.5 Events ............................................................................................................................................. 50 4.5.1 AdsAmsConnectTimeout ................................................................................................. 50 4.5.2 AdsAmsTimeout............................................................................................................... 50 4.5.3 AdsConnectError..............................................................................................................
51 4.5.4 AdsLogNotification ........................................................................................................... 51 4.5.5 AdsReadConnectUpdate ................................................................................................. 52 4.5.6 AdsReadConnectUpdateEx ............................................................................................. 53 4.5.7 AdsReadConnectUpdateEx2 ........................................................................................... 53 4.5.8 AdsReadConvertConnectUpdate.....................................................................................
54 4.5.9 AdsRead[Datatype]Conf .................................................................................................. 55 4.5.10 AdsRouterRemove........................................................................................................... 55 4.5.11 AdsRouterShutdown ........................................................................................................ 56 4.5.12 AdsRouterStart................................................................................................................. 56 4.5.13 AdsServerStateChanged .................................................................................................
56 4.5.14 AdsServerSymChanged................................................................................................... 57 4.5.15 AdsWriteConf................................................................................................................... 57 4.6 Properties........................................................................................................................................ 57 4.6.1 AdsAmsClientNetId.......................................................................................................... 57 4.6.2 AdsAmsClientPort............................................................................................................
58 4.6.3 AdsAmsCommTimeout .................................................................................................... 58 4.6.4 AdsAmsConnected .......................................................................................................... 58 4.6.5 AdsAmsSaveClientPort.................................................................................................... 58 4.6.6 AdsAmsServerNetId......................................................................................................... 59 4.6.7 AdsAmsServerPort...........................................................................................................
59 4.6.8 AdsClientAdsState ........................................................................................................... 59 4.6.9 AdsClientBuild.................................................................................................................. 60 4.6.10 AdsClientRevision............................................................................................................ 60 4.6.11 AdsClientType.................................................................................................................. 60 4.6.12 AdsClientVersion..............................................................................................................
60 4.6.13 AdsServerAdsState.......................................................................................................... 61 4.6.14 AdsServerBuild ................................................................................................................ 61 4.6.15 AdsServerRevision........................................................................................................... 61 4.6.16 AdsServerType ................................................................................................................ 61 4.6.17 AdsServerVersion ............................................................................................................
62 4.6.18 EnableErrorHandling........................................................................................................ 62 4.6.19 Index ................................................................................................................................ 62 4.6.20 Name................................................................................................................................ 62 4.6.21 Object...............................................................................................................................
63 4.6.22 Parent............................................................................................................................... 63 4.6.23 Tag................................................................................................................................... 63 TX1000 4 Version: 1.2
Table of contents
Table of contents 4.7 Enums ............................................................................................................................................. 63 4.7.1 ADSDATATYPEID ........................................................................................................... 63 4.7.2 ADSLOGMSGTYPE......................................................................................................... 64 4.7.3 ADSOCXTRANSMODE................................................................................................... 64 4.7.4 ADSSTATE ......................................................................................................................
64 4.7.5 ADSGETDYNSYMBOLTYPE .......................................................................................... 65 5 Samples ................................................................................................................................................... 66 5.1 Visual Basic - samples .................................................................................................................... 66 5.1.1 Linking into Visual Basic .................................................................................................. 66 5.1.2 Visual Basic 6.0 variable lengths .....................................................................................
68 5.1.3 Accessing an array in the PLC......................................................................................... 69 5.1.4 Transmitting structures to the PLC................................................................................... 70 5.1.5 Event driven reading ........................................................................................................ 73 5.1.6 Read PLC variable declaration ........................................................................................ 75 5.1.7 Detect/alter state of the router and the PLC.....................................................................
77 5.1.8 Send/receive messages via the router............................................................................. 79 5.1.9 Delete handle of a PLC variable ...................................................................................... 82 5.1.10 Event-driven reading (with conversion to another type)................................................... 82 5.2 Delphi - samples ............................................................................................................................. 87 5.2.1 Integration in Delphi .........................................................................................................
87 5.2.2 Accessing PLC variables in synchronous/asynchronous/connected modes ................. 105 5.2.3 Read the List of an ADS Device's Declared Variables................................................... 110 5.2.4 Write array to PLC or read array from PLC.................................................................... 115 5.2.5 Call ADS-OCX property page ........................................................................................ 116 5.2.6 Working with handles of PLC variables.......................................................................... 117 5.2.7 Write string to PLC or read array from PLC ...................................................................
118 5.2.8 Read multiple boolean variables into an array with one access .................................... 120 5.2.9 Transmitting structures to/from the PLC ........................................................................ 121 5.3 TwinCAT ADS OCX ...................................................................................................................... 124 5.3.1 Integration in LabVIEW™ in TwinCAT 2........................................................................ 124 5.3.2 Samples using AdsOcx properties................................................................................. 126 5.3.3 synchron methods:
Read via address............................................................................ 126 5.3.4 synchron methods: Read via name................................................................................ 127 5.3.5 synchron methods: Write via address............................................................................ 128 5.3.6 synchron methods: Write via name................................................................................ 129 5.3.7 Event driven reading, registering Callback-vi.................................................................
130 5.3.8 Event driven reading, simple data types ........................................................................ 132 5.3.9 Event driven reading, structure variables....................................................................... 133 5.3.10 Event driven reading with data reference passing to Callback-vi................................... 135 5.3.11 General Methods............................................................................................................ 136 6 ADS Return Codes ................................................................................................................................ 139 TX1000 5 Version: 1.2