External variables / V.E. variables

Data can be exchanged between the NC program and the PLC via the HLI with the aid of external variables. Each channel has a separate area for external variables known only on the channel. In addition, there is a cross-channel global data area which all channels may access.

At the PLC end, the data areas for the external variables are represented as an ARRAY OF UDINT. The index of the individual array elements starts with value 1.

A single external variable always takes up one memory block of HLI_VEByteCount (24) bytes, regardless of its data. If an array of external variables has been defined, the individual variables are saved packed in the memory area (several variables per memory block) whereby there may be several consecutive memory blocks used dependent on array size.

When accessing external variables by the PLC, the index of the variables in the memory area of the external variables must be determined initially:

Example, index computation: 4th variable (VarNo. = 4):

Offset = (VarNr –1 )* HLI_VEByteCount / 4 + 1

Thus, there is an offset in the memory of 13 for the variable with index = 3.

The memory area must then be accessed in accordance with the actual data type of the external variables. All information required for this is contained in the configuration list of the external variables.

Please refer to the documentation [EXTV] for further details of external variables.

If the NC kernel runs in the TwinCAT runtime environment, the number of external variables can be configured in the System Manager.

An example program for accessing external variables is available with name HLI-Ve1.pro.

External Variable

Description

Memory area for data exchange between NC program and PLC

Data type

VeData

ST path

pVeData : POINTER TO VEData;

VeOffset :DINT;

VeOffset := (VarNr –1) * HLI_VEByteCount / 4 + 1;

CNC global:

pVeData := ADR(pVeGlob^.addr);

Channel-specific:

pVeData := ADR(pVe[channelIdx]^.addr);

Access

pLRealVal : POINTER TO LREAL;

LRealVal : LREAL;

pLRealVal := ADR(pVeData^.AHLI_UNS32_Data[VeOffset]);

LRealVal := pLRealVal^;

Characteristics

When accessing, access must be performed in accordance with the data type of the external variables.