Integration in LabVIEW™

Integration in LabVIEW™ 1:

Use the TwinCAT 3 Interface for LabVIEW™

If you want to establish an ADS communication between LabVIEW™ and the TwinCAT 3 runtime, use in any case the extensively supported and documented product TwinCAT 3 Interface for LabVIEW™, see TF3710. The manual integration of free ADS components presented in the following are only application examples. These are not subject to Beckhoff support.

Necessary files

TcAdsDll.dll is located in the Windows 'System32' directory.

 

LabVIEW™ Function: Call Library Function

Integration in LabVIEW™ 2:

Configuration of DLL call

Integration in LabVIEW™ 3:

Integration in LabVIEW™ 4:

Library Name or Path

Use the button "Browse..." or enter the path of  TcAdsDll here.

Function Name

Selcet the name of the DLL function to be called.

Calling Conventions

The calling convention stdCall is used.

Parameter

The parameter list has to be adapted to the called function. The parameter list of the call is completed via the buttons 'Add a Parameter Before', 'Add a Parameter After' and 'Delete this Parameter' .The data types are adapted to the call parameter.

For the pointer passing of structures the type 'Adapt to Type' and the data format 'Handles by Value' is selected.

Example: Parameter pAddr of function AdsSyncReadReq

Integration in LabVIEW™ 5:

Function Prototype

The function prototype of the Called function must match the function prototype of the TcAdsDll. The function prototypes are listed in the documentation of the TcAdsDll functions.

Example of the function AdsSyncReadReq

C declaration:

LONG AdsSyncReadReq(
  PAmsAddr pAddr,
  ULONGnIndexGroup,
  ULONGnIndexOffset,
  ULONGnLength,
  PVOIDpData);

LabVIEW™:

Integration in LabVIEW™ 6:

 

Structures

Corresponding clusters are formed in LabVIEW™ for all structures used in the function calls.

AmsNetId

C declaration:

typedef struct {
  UCHARb[6];
} AmsNetId, *PAmsNetId;

Is formed in LabVIEW™ as a cluster of 6 x U8 values:

Integration in LabVIEW™ 7:

AmsAdr

C declaration:

typedef struct {
  AmsNetId netId;
  USHORTport;
} AmsAddr, *PAmsAddr;

Is formed in LabVIEW™ as a cluster from AmsNetId and a U16 value:

Integration in LabVIEW™ 8:

Of course, a LabVIEW™ control, e.g. for address inputs, can also be formed from the cluster formed in this way:

Integration in LabVIEW™ 9:

Parameter passing

For parameter passing it is important to pass all parameter variables to the Dll call. Especially to the parameter marked with [out] in the documentation  a place holder variable has to be passed, so that accordant memory is reserved.

Notice

System crash

Incorrect parameter passing causes memory protection violations and can crash the LabVIEW™ system!