Sample07: Receiving ADS Notifications

This article describes how to implement a TC3 C++ module which receives ADS Notifications about data changes on other modules.
Since all other ADS communication has to be implemented in a similar way, this sample is the general entry point to initialize ads communication from TwinCAT C++ modules.

Download

Here you can access the source code for this sample.

1. Unpack the downloaded ZIP file.
2. Using a Visual Studio with TwinCAT installed, open the project via Open Project ....
3. Configure signing for this project by switching on TwinCAT signing with a right-click on Project->Properties->Tc Sign and configure your certificate and password if necessary.
For more information on signing C++ projects, click here.
4. Select your target system.
5. Build the sample (e.g. Build->Build Solution).
6. Activate the configuration by clicking on Sample07: Receiving ADS Notifications 1:.
The sample is ready for operation.

Description

This sample describes the reception of ADS notifications in a TwinCAT C++ module.

The solution contains 2 modules for this purpose.

The address is prepared during the module transition PREOP->SAFEOP (SetObjStatePS). The CycleUpdate method contains a simple state machine, which sends the required ADS command. Corresponding methods show the receipts.

The inherited and overloaded method AdsDeviceNotificationInd is called when a notification is received.

During shutdown, ADS messages are sent during transition for the purpose of logoff (SetObjStateOS), and the module waits for receipts of confirmation until a timeout occurs.

Sample07: Receiving ADS Notifications 2:

Start of the module development

Creating a TwinCAT C++ module with the aid of the ADS port wizard. This sets up everything you need for establishing an ADS communication. Simply use and overwrite the required ADS methods of ADS.h, as shown in the sample.

See also

ADS Communication