LabVIEW and TwinCAT Communication via ADS Protocol

Application Description: LabVIEW is a very popular software for measurement and control. As a supervisory data acquisition software, LabVIEW can conveniently handle data analysis, display, and storage. LabVIEW can also easily communicate with Beckhoff's TwinCAT real-time kernel using the ADS protocol.


Step 1: Install TwinCAT and Scan to Connect to the Target Controller


  1. Install TwinCAT CP or higher level TwinCAT software on the PC platform running LabVIEW.

  2. Scan the target controller and add an ADS route (ads Router).

    For basic TwinCAT operations, consult a Beckhoff engineer for details.


Step 2: Implement Data Communication in LabVIEW


To achieve data communication between LabVIEW and TwinCAT, there are two main methods: one through the dynamic link library (TcAdsDll.dll), and the other via an OCX control (AdsOcx.ocx). This article primarily discusses the first method.


A. Create a 4-layer Stacked Sequence Structure, and in Step 0, add the AdsPortOpen function node and bind the AMS NetId for subsequent read/write calls.


  1. Call the function node from the function palette.
  2. Configure the AdsPortOpen function, select the dynamic link library, and set parameters according to AdsOpenPort.


  1. Bind the AMS NetId, and enter the AMS NetId of the target controller.
  2. The completed structure of Layer 0: