Type Resolving

The TwinCAT 3 Interface for LabVIEW™ provides TypeResolver, to parse the ADS data stream from LabVIEW™ data type to TC3 data type or vice versa. A comparison is first made between the LabVIEW™ data type and the TC3 data type. If the data types are the same, the ADS data stream is parsed and copied appropriately. The TypeResolver supports the following operation modes:

  1. Resolve ADS data stream from TC3.
  2. Resolve ADS data stream for TC3.

Resolve ADS data stream from TC3

The From TC block initializes the TypeResolver, parses and converts the ADS data read from TwinCAT with ADS Read into the LabVIEW™ data type Variant. The block Type Release releases the TypeResolver from memory. Variant is converted to the appropriate LabVIEW™ data type via Variant-to-Data VI.

The following graphic shows how the composition of TypeResolver from the Low Level VIs. In this example we assume a structure in TwinCAT that consists of three elements.

Definition of the structure:

TYPE ST_toLabVIEW :
STRUCT
    TCSignedWord  : INT;
    TCUnsignedInt : UINT;
    TCStringArray : ARRAY [1..5] OF STRING;
END_STRUCT
END_TYPE

The TC3 data type and the LabVIEW™ data type must match for the conversion process. In the appendix you will find a translation table as an overview. On the right side of the block diagram is a LabVIEW™ container that mirrors the above structure.

Structure of the LabVIEW™ container (not initialized, merely defined):

Copying data may fail for the following reasons:

Type Resolving 1:

Resolve ADS data stream for TC3

The To TC block initializes the TypeResolver, compares the LabVIEW™ data type with the TC3 data type and converts the LabVIEW™ data into ADS raw data. The block then releases the TypeResolver from the memory. The converted ADS data can then be passed directly to an ADS Write block.

The diagram below shows a similar scenario as described earlier for From TC. In this case the data are converted from a LabVIEW™ data type to a TC3 data type. The conversion may fail for the following reasons:

Type Resolving 2:

Initialization of the LabVIEW™ data type

When converting from LabVIEW™ to TC3 data type, the LabVIEW™ data type must be pre-initialized. For a complex data type, such as a structure, the complete data type must be initialized. For an array the individual elements must be initialized.

Type Resolving 3:

For the diagram above, for example, the following TwinCAT structure is conceivable in the PLC as a target for writing:

TYPE ST_fromLabVIEW :
STRUCT
    TCSignedDoubleInt  : DINT;
    TCUnsignedLongInt : ULINT;
    TCStringArray : ARRAY [1..6] OF STRING(80);
END_STRUCT
END_TYPE

The matching initialized LabVIEW™ container is then structured as follows:

Automatic type generation

Manual creation of matching data types in LabVIEW™ can be time consuming and error-prone. The TwinCAT Interface for LabVIEW™ offers the possibility of automatic type generation. Use the TypeResolver and the Utilities wrapper block for this purpose. See the chapter Examples for several variations on how to use these VIs effectively: Example Type Resolver.