Integration in LabVIEW™
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 - Dynamic Function Library
TcAdsDll.dll is located in the Windows 'System32' directory.
LabVIEW™ Function: Call Library Function
Configuration of DLL call
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
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™:
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:
AmsAdr
C declaration:
typedef struct {
AmsNetId netId;
USHORTport;
} AmsAddr, *PAmsAddr;
Is formed in LabVIEW™ as a cluster from AmsNetId and a U16 value:
Of course, a LabVIEW™ control, e.g. for address inputs, can also be formed from the cluster formed in this way:
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! |