Linking into Visual Basic

Select the ADS-OCX

In order to select the ADS-OCX you must choose the command Components... under the Project menu item in Visual Basic, and mark the AdsOcx OLE Control module entry.

Linking into Visual Basic 1:

The ADS-OCX then appears in the Visual Basic toolbox (bottom right).

Linking into Visual Basic 2:

Define properties

Before you can use the ADS-OCX you must drag it onto a form and adjust the properties. The general properties can be configured or read using either the properties pages of the ADS-OCX or the Visual Basic properties list. The representation displayed on the properties page is particularly clear, since the properties are sorted here into groups. In order to make the Visual Basic program more readable, the names of (almost) all of the properties, methods and events begin with Ads.

AMS Properties

This page describes the communication channel between the ADS-OCX and the ADS device that is to be addressed. The terms ADS client and ADS server are also used here. The ADS client is the program that requests information or services from the ADS server. In our case, the Visual Basic program with the ADS-OCX is the ADS client. In most of the samples the TwinCAT PLC server is the ADS server.

Linking into Visual Basic 3:

Each ADS device within TwinCAT has a unique address. This address is composed of a NetId and the port number. The NetId must be unique for each TwinCAT system within a network. The NetId of a computer can be read through the system control in the TwinCAT system properties dialog on the AMS router page. The NetId consists of 6 digits, separated from one another by a point. Do not provide a NetId when you want to address local ADS devices. In addition to the NetId, each ADS device is also addressed by a port number. Each port number may only exist once on a TwinCAT computer. Further information is to be found under TwinCAT ADS.

If, for instance, you want to address runtime system 1 in the PLC in the local computer, you should leave the server's NetId field empty, and enter port number 801 as the server port. The fields under Client can have different values in your case from those illustrated above. 

If you want to address a number of ADS devices with the ADS-OCX (e.g. PLC and NC), you should use an ADS-OCX for each of these ADS devices. You should not alter the port number of the NetId while the system is running.

ADS Client Properties

This page shows the type and version of the ADS device with the ADS-OCX, as well as the current state of the ADS interface within the ADS-OCX.

Linking into Visual Basic 4:

The Identification properties group shows the type, version, revision and build of the ADS-OCX. The other communication partner is able to interrogate these values in order to obtain more information about the ADS device. These fields can be released by the application.
In the property group Control/State the current state of the ADS interface within the ADS-OCX is displayed.

ADS Server Properties

This page shows the type and version of the ADS device that is to be addressed by the ADS-OCX. The current state of the ADS device is also displayed.

Linking into Visual Basic 5:

The Identification properties group shows the type, version, revision and build of the ADS device that is addressed by the ADS-OCX. These properties are read-only.
The property group Control/State displays the current state of the ADS interface within the ADS device.
The property group Refresh is reserved and not yet supported.

The PLC is addressed by the ADS-OCX in the dialog shown above. This is in the RUN state, and is of version 2.6.0.

The ADS-OCX is now configured in such a way that it can address the PLC.