Function and characteristics

Any values can be exchanged via external variables between NC (NC-channel), graphical user interface (GUI) and PLC, whereby the variables are handled transparently by the NC, i.e. the significance of the variables is determined purely by the application (NC-program, graphical user interface and PLC). The NC has only the task of transporting these variables and making them available to the user in the NC-program. During the configuration phase, a name, a type and access authorization (write and/or read), in additional to a memory location, are assigned to the external variables. The external variables are configured on the basis of an ASCII list only once during boot-up.

In addition to the simple variables, it is also possible to create one-dimensional fields which are accessed with indexing. The variables can be created in a channel-specific or also cross-channel memory. The values apply throughout the lifetime of an NC-program, i.e. they are not cleared for instance when a new NC-program is started.

There are two options determining the instant of writing/reading a variable from the NC-program:

1. Writing/reading of a variable is performed synchronously with current NC-program execution, i.e. the temporal sequence of the NC-commands and variable access operations is ensured.

2. Writing/reading of a variable is performed at the time of decoding.

Access via the GUI or the PLC is non-synchronous with respect to NC-program execution.

Fig. 1-1: Use of external variables


Memory size

The entire available memory for the external variables of each channel has to be defined before start-up of the control:

Ø For TwinCAT systems the dimensioning is defined in the System Manager (CNCTask-GEO) on the HLI mask under the VE entry.

Ø For all other systems the size of the VE memory is defined by the parameter P-STUP-00037 (ext_var_max) in the start-up list [STUP].

The here-defined value determines the number of 24 bytes blocks, of which the VE memory of each channel consists. The global external variables (cross-channel scope) use an own memory of equal size. The reserved VE memory of each channel and the global one has to be larger than the used memory area, defined by the memory layout (see following chapter).

If the available memory is not enough for the external variables, configurated in the list, the error message P-ERR-21148 is generated. In this case either the reserved memory has to be extended or the size and number of configurated external variables has to be decreased.


Memory layout

Each channel has access to two different memory blocks. One of them is available locally only for the current NC-channel and the other, by contrast, is cross-channel, i.e. it can be used jointly by all NC-channels. The configuration of the external variables is specified in a file per NC-channel, and this file lists both global and channel-specific variables jointly.

Fig. 2-1: Scope of validity of the memories

More:

button Memory layout (from version V254 onwards)

button Memory layout (from version V2.10.1025.00 onwards)


Memory layout (from version V254 onwards)

The configuration defines the view of the channel onto the memory and, thus, its logical structuring. The entire memory is structured as an array of 24 bytes blocks (union of the types of all contents). When defining each variable, the start position is specified by specifying the block index in this array.

Fig. 2-2: Memory layout resulting from the given configuration

A VE variable (also VE array) is saved continuously from the specified start position. If it is larger than a 24-byte grid, the following memory area (grid) must also be used. Basically, it is also possible to place several logical variables at the identical memory location, i.e. it is possible to enable several views onto a memory location. The NC does not monitor whether the individual variables overlap.

If individual variables are placed in memory, a non-used memory area per memory grid is left over, depending on the size of the variable. This unused area is no more addressable.


Memory layout (from version V2.10.1025.00 onwards)

From CNC version V2.10.1025.00 onwards V.E. variables can be placed at any position of the V.E. variable memory by defining an address offset (see chapter 2.4), the 24 byte grid is not necessary any longer. But also the declaration of the address offset is optional. If it is missing, the variables in the V.E. memory are stored without any gap.

However the use of configuration lists of older syntax is possible in future.

Fig. 2 - 3 : Memory layout from CNC version V2.10.1025.00 onwards resulting from the given configuration


Syntax (from Version V254 onwards)

In addition, from Version V254 onwards, the configuration has been extended in such a manner that elements have default values and settings can be made using textual constants.

Comments can be whole-lined or can be added at the end of a line.

In the case of whole-lined comments, at the beginning of the line the comment character # must be added followed by a space character.

If at the end of a line a comment is to be added, then in front of the comment, at least one space character must be there. If, however, in the line a string is defined, then the comment character ( must precede the comment.

Blank lines are also possible.

Examples for comments:

# ************************************************************************

# Data

# ************************************************************************

#

# Listing

dummy[1] 1 Comment

dummy[2] 1 # Comment

dummy[3] 1 ( Comment

dummy[4] 1 /* Comment

...

example[0].name STRING_2 (Comment, here comment brackets necessary !)

Example for an ASCII list:

# ***************************************

# External variables V254

# ****************************************

#

anzahl_belegt 2

#

var[0].name GLOBAL_SWR (Global VE)

var[0].index 0

var[0].type SGN16

var[0].scope GLOBAL

var[0].synchronisation FALSE

var[0].access_rights READ_ONLY

var[0].array_size 0

var[0].size 2 # 2 bytes per element

var[0].create_hmi_interface FALSE

#

var[1].name CHANNEL_WR (Channel VE)

var[1].index 0

var[1].type SGN32

var[0].scope CHANNEL

var[1].synchronisation FALSE

var[1].access_rights READ_ONLY

var[0].array_size 10

var[1].size 4 # 4 bytes per element

var[0].create_hmi_interface FALSE

#

Ende

Designator

Value range

Default

Significance

anzahl_belegt

[0; MAX_UNS16]

0

If var[i].* is assigned without gap, here the index of the variable defined last +1 is entered (ilast+1).

If var[i].* is assigned with gaps, here the highest index of the defined variables +1 is entered (imax+1).

var[i].*

i:= [0; 214]

Data records for the definition of variables.

name

ASCII string

The variable is identified on the basis of the name. The name is used to compose an overall name for the NC-channel and the GUI (e.g. V.E.<name>). The name consists of maximum 20 characters.

Upper case letters and lower case letters are differentiated.

index

[0; MAX_SGN32]

-1

The index defines the position in the memory at which the variable is saved. The overall memory is structured as an array of units with a size of 24 bytes.

An index of 1 indicates that the entry is not used.

type

[BOOLEAN,
SGN08, UNS08, SGN16, UNS16, SGN32; UNS32, REAL64, STRING]

UNS32

The type indicates the data type of the variable. Besides elementary data types (SGN08, ..., REAL64), there is data type STRING which currently comprises 24 bytes including end mark.

scope

[GLOBAL; CHANNEL ]

CHANNEL

In the case of the scope of validity, a distinction is made between a channel-specific scope and a cross-channel, global scope.

synchronization

[TRUE, FALSE]

TRUE

Write/read access is normally performed synchronously with processing. In individual cases, this implicit synchronization may be suppressed (see Chapter 3.1.1).

access_rights

[READ_WRITE, READ_ONLY, WRITE_ONLY]

READ_WRITE

Write/read access to the variables is possible by default, and this access can be restricted by access protection.

array_size

[0; MAX_UNS16]

0

If the variable is not structured as an array, the array size must be specified as 0. Otherwise, the total size of the array is defined at this point.

size

[0; MAX_UNS32]

4

Indicates the size of the variable including any alignment bytes, i.e. the difference between to consecutive elements of an array. Depending on computer architecture and alignment strategy, this size may comprise the real wanted data and additional alignment bytes. Size of the data types:

1 BYTE- BOOLEAN,UNS08, SGN08

2-BYTE -SGN16, UNS16

4 BYTE -SGN32, UNS32, STRING

8 BYTE- REAL64

24 BYTE -STRING (maximum 20 characters )

create_hmi_interface

[TRUE, FALSE]

FALSE

Create interface objects for HMI access for this variable, if flag is set.


Syntax (from version V2.10.1025.00 onwards)

From CNC version V2.10.1025.00 onwards for external variables user defined variable types can be set. Now by this feature it is possible to use complex external variable structures both in NC program and the PLC. But a condition for that is, that byte alignment is used for the structures in the PLC.

In the following description of the configuration of external variables there is made a distinction between the definition of variable types and the instanciation of variables.

More:

button Definition of variable types

button Definition of external variables

button Example of a configuration list


Definition of variable types

Beside the user defined variable types also the elementary data types (BOOLEAN, ..., REAL64) and the character strings of type STRING can be used.

Variable type

Size

BOOLEAN, UNS08, SGN08

1 Byte

UNS16, SGN16

2 Byte

UNS32, SGN32

4 Byte

REAL64

8 Byte

STRING

128 Byte

From CNC version V2.10.1025.00 onwards string variables can contain up to 128 characters including the end mark.

For downgrade compatibility reasons for the use of string variables with more than 20 characters the parameter use_extended_string_var has to be set to 1. Depending on the parameter use_extended_string_var string variables are limited on the following length (including the end mark):

use_extended_string_var = 0: 21 Byte (Default)

use_extended_string_var = 1: 128 Byte

Table 2-1: Size of the default variable types

If there is a later change on 128 byte size string variables (use_extended_string_var = 1) within an existing configuration, in the memory and in the PLC the addresses of the external variables have to be adapted (index, byte offset), to avoid the overwriting of following variables!

The definition of the variable types is done in the same configuration list like the definition of the external variables.

Comments can be whole-lined or can be added at the end of a line. In the case of whole-lined comments, at the beginning of the line the comment character # must be added followed by a space character.

If at the end of a line a comment is to be added, then in front of the comment, at least one space character must be there. If, however, in the line a string is defined, then the comment character ( must precede the comment.

Blank lines are also possible.

Definition of variable types:

Designator

Value range

Default

Significance

use_extended_string_var

[0; 1]

0

This parameter enables the increasing of the number of characters of string variables from 21 to 128 characters (each including the end mark).

If the addresses of the V.E. variables are predefined in 24 byte block (see 2.2.1 ) for the STRING variables of 128 byte size it has to take into account, that they allocate several 24 byte blocks in the memory layout and that the index has to be incremented accordingly (see variable arrays).

struct[i] .*

i:= [0; 29]

Data sets for the definition of the variable types. The key word struct replaces the common token type used in older CNC-versions. However, due to downward compatibility the token type is still supported.

struct[i]. name

ASCII-String

The variable type is identified by the name. The name consists of maximum 20 characters. Upper case letters and lower case letters are differentiated.

struct[i]. element[j] .*

j:= [0; 49]

Data sets for the definition of the elements of the variable type.

struct[i]. element[j].name

ASCII-String

The structure element is identified by the name. The name consists of maximum 20 characters. Upper case letters and lower case letters are differentiated.

struct[i]. element[j].type

ASCII-String

[BOOLEAN,
SGN08, UNS08, SGN16, UNS16, SGN32; UNS32, REAL64, STRING or user defined]

UNS32

The type indicates the data type of the structure element. Besides elementary data types (SGN08, ..., REAL64), here also the data type STRING or an user defined data type can be defined.

struct[i]. element[j].

synchronisation

[TRUE, FALSE]

Is inherited from variable instanciation (see 2.4.2 )

Normally all structure elements inherit the synchronisation type for the write/ read access from the variable instanciation (see 3.1.1 ). This parameter enables the individual definition of the synchronisation type of the structure element.

struct[i]. element[j].

access_rights

[READ_WRITE, READ_ONLY, WRITE_ONLY]

Is inherited from variable instanciation (see 2.4.2 )

Normally all structure elements inherit the access rights from the variable instanciation. This parameter enables the individual definition of the access right of the structure element.

struct[i]. element[j].

array_elements

[0; MAX_UNS16]

0

If the variable is not structured as an array, the array size must be specified as 0. Otherwise, the total size of the array is defined at this point.


Definition of external variables

Designator

Value range

Default

Significance

anzahl_belegt

[0; MAX_UNS16]

0

If var[i].* is assigned without gap, here the index of the variable defined last +1 is entered (ilast+1).

If var[i].* is assigned with gaps, here the highest index of the defined variables +1 is entered (imax+1).

var[i].*

i:= [0; 214]

Data records for the definition of variables.

name

ASCII-String

The variable is identified on the basis of the name. The name is used to compose an overall name for the NC-channel and the GUI (e.g. V.E.<name>). The name consists of maximum 20 characters.

Upper case letters and lower case letters are differentiated.

byte_offset

[0; MAX_SGN32]

-1

This parameter defines the position in the memory at which the variable is saved.

The indication of this parameter is optional. All variables with byte_offset of 1 are entered in an unbroken order (start with offset 0) in the V.E.memory.

type

[BOOLEAN,
SGN08, UNS08, SGN16, UNS16, SGN32; UNS32, REAL64, STRING, user defined]

UNS32

The type indicates the data type of the variable. Besides elementary data types (SGN08, ..., REAL64), and data type STRING here also an user defined variable type (see chapter 2.4.1 ) can be defined.

scope

[GLOBAL; CHANNEL]

CHANNEL

In the case of the scope of validity, a distinction is made between a channel-specific scope and a cross-channel, global scope.

synchronisation

[TRUE, FALSE]

TRUE

Write/read access is normally performed synchronously with processing. In individual cases, this implicit synchronisation may be suppressed (see Chapter 3.1.1).

If the variable is a variable structure, the synchronisation type is inherited to all subordinated structure elements. Additional with the type definition (see chapter 2.4.1 ) the synchronisation type can be set individually for each structure element.

access_rights

[READ_WRITE, READ_ONLY, WRITE_ONLY]

READ_WRITE

Write/read access to the variables is possible by default, and this access can be restricted by access protection.

If the variable is a variable structure, the access right is inherited to all subordinated structure elements. Additional with the type definition (see chapter 2.4.1 ) the access right can be set individually for each structure element.

array_elements

[0; MAX_UNS16]

0

If the variable is not structured as an array, the array size must be specified as 0. Otherwise, the total size of the array is defined at this point.

size

[0; MAX_UNS32]

Derived from data type (see Table 2-1)

The indication of the variable size is optional. If it is not indicated, the size is derived from the variable type. The indication of the variable size only is necessary, if additional alignment bytes have to be considered. With arrays the parameter indicates the size of the single elements.

create_hmi_interface

[TRUE, FALSE]

FALSE

In case the flag is TRUE, for each variable in addition the access by a corresponding communication object via the user interface can be enabled. For variables with user defined data type this parameter has no effect.


Example of a configuration list

Examples for comments:

# ************************************************************************

# Data

# ************************************************************************

#

# Listing

dummy[1] 1 Comment

dummy[2] 1 # Comment

dummy[3] 1 ( Comment

dummy[4] 1 /* Comment

...

...

example[0].name STRING_2 (Comment, here comment brackets necessary !)

Examples for type definitions:

use_extended_string_var 1 #Strings with 128 characters

struct[0].name VECTOR_T

struct[0].element[0].name x

struct[0].element[0].type REAL64

struct[0].element[1].name y

struct[0].element[1].type REAL64

struct[0].element[2].name z

struct[0].element[2].type REAL64

#

struct[1].name TARGET_POINT_T

struct[1].element[0].name point

struct[1].element[0].type VECTOR_T

struct[1].element[1].name valid

struct[1].element[1].type BOOLEAN

struct[1].element[1].access_rights READ_ONLY

struct[1].element[1].synchronisation TRUE

#

struct[2].name TRAJEKTORIE_T

struct[2].element[0].name nbr_points

struct[2].element[0].type SGN32

struct[2].element[1].name name

struct[2].element[1].type STRING

struct[2].element[2].name points

struct[2].element[2].type TARGET_POINT_T

struct[2].element[2].array_elements 10

Examples for variable definitions:

anzahl_belegt 5

#

var[0].name var_global_1

var[0].type UNS32

var[0].scope GLOBAL

var[0].synchronisation FALSE

var[0].access_rights READ_WRITE

#

var[1].name var_chan_1

var[1].type SGN32

var[1].scope CHANNEL

var[1].synchronisation TRUE

var[1].access_rights READ_WRITE

#

var[2].name array_chan_1

var[2].type SGN16

var[2].scope CHANNEL

var[2].synchronisation TRUE

var[2].access_rights READ_WRITE

var[2].array_elements 20

#

var[3].name name

var[3].type STRING

var[3].scope CHANNEL

var[3].synchronisation TRUE

var[3].access_rights READ_WRITE

#

var[4].name trajektorie

var[4].type TRAJEKTORIE_T

var[4].scope CHANNEL

var[4].synchronisation FALSE

var[4].access_rights READ_WRITE


Integration in NC boot-up

The configuration of the external variables is declared to each NC-channel separately by means of an ASCII list. For each channel, a file name is specified in the systems central boot description, and this file name defines the configuration of the external variables of this channel.

Example: Extract from the boot description for two channels

# ----------------------------------------

#

# Configuration data lists

#

# ----------------------------------------

#

lists ASCII

default_sda_mds ..\lists\default_sda.lis

hand_mds ..\lists\hand_mds.lis

rtconf_lis ..\lists\rtconf.lis

#

sda_mds[0] ..\lists\sda_mds1.lis

werkz_data[0] ..\lists\werkz_d1.lis

nullp_data[0] ..\lists\nullp_d1.lis

pzv_data[0] ..\lists\pzv_d1.lis

ve_var[0] ..\lists\ext_var1.lis

hmi[0].objects default

channel[0].objects default

#

sda_mds[1] ..\lists\sda_mds2.lis

werkz_data[1] ..\lists\werkz_d2.lis

nullp_data[1] ..\lists\nullp_d2.lis

pzv_data[1] ..\lists\pzv_d2.lis

ve_var[1] ..\lists\ext_var2.lis

hmi[1].objects default

channel[1].objects default


NC-program

The NC-channel access the external variables on the basis of the write/read instruction to variable V.E.<name> in the NC-program. The variables available in the NC-program result automatically from the prefix V.E. and the name <name> specified in the configuration list of the variable.

Programming example
VE-variable access in the CNC

N100 $IF V.E.CHANNEL_WR >= 100 (In accordance with the value of)
(V.E.CHANNEL_WR branching to the)
(various cases occurs)

N110 G01 X100 Y100 F1000

N120 $ELSE

N130 G01 X100 Y V.E.CHANNEL_WR F1000 (Linear interpolation in)
(Y-direction with the value)
(of V.E.CHANNEL_WR)

N140 $ENDIF

N150 V.E.GLOBAL_SWR = V.A.ABS.X (The absolute X-coordinate is assigned)

(to the external variable)

N160 G01 XV.E.GLOBAL_SWR (Linear interpolation in X-direction)

(with the value of V.E.EXT2)

Programming example 2
VE variable access in CNC from version V2.10.1025.00 onwards

N010 $IF V.E.trajektorie.name != 

N020 V.E.name = V.E.trajektorie.name

N030 P1 = 0

N040 $WHILE P1 < V.E.trajektorie.nbr_points

N050 $IF V.E.trajektorie.points[P1].valid == TRUE

N060 G0 X = V.E.trajektorie.points[P1].point.x

Y = V.E.trajektorie.points[P1].point.y

Z = V.E.trajektorie.points[P1].point.z

N070 $ENDIF

N080 P1 += 1

N090 $ENDWHILE

N100 $ENDIF

N110 V.E.name = 

N120 M30

More:

button Access synchronization by NC-channel


Access synchronization by NC-channel

The user expects variable access (read and write) in the temporal sequence as specified in the NC-program. Since NC-program decoding is performed in a planning phase which comes before actual processing of the NC-commands, a variable may not be accessed simply during program decoding but must be accessed synchronously with respect to current program execution (axis movement). This is ensured as follows:

READ When reading, decoding is halted until current program execution has reached the last decoded NC-program line (implicit FLUSH & WAIT, see also [PROG]). Since a FLUSH & WAIT is not allowed during specified cross-block NC-functionalities (e.g. active spline interpolation, active tool radius compensation), synchronous READ during this functionality is not possible either.

WRITE Write access is scheduled in the same way as any other NC-command during decoding and is actually performed later during NC machining.

Since this synchronization, in particular halting of decoding in the case of Read access, has undesirable runtime influences, this implicit synchronization can be deactivated when defining the variables. Of course, this is possible only if the instant of read access does not need to be synchronous with processing or if this is ensured anyway by an explicit synchronization point in the NC-program (e.g. explicit FLUSH & WAIT).

Fig. 3-1: Asynchronous/synchronous access of decoding (DEC) and processing (BAHN) via PLC driver (HLD)

The output of synchronized VE variables and the output of technology functions (M-/H-/T- functions) with synchronization type MOS take place via the same interface. The user has to ensure, that all data in the queue of the interface are consumed by the PLC, otherwise the synchronity to the NC channel is not guaranteed.


Graphical user interface

The graphical user interface has access to NC-interfaces and NC-data via so-called HMI-objects. The access protocol is encapsulated via a DLL which offers a Windows application write/read access to HMI-objects. Interface objects are created automatically in accordance with the configuration list for the graphical user interface, if the parameter create_hmi_interface is set.

In this case two objects are created for each specified variable, one for write access and one for read access. This occurs independently of the access rights of the NC-channel, i.e. even if the NC-channel has only read access to the variable (e.g. access_rights = READ_ONLY), the graphical user interface can also write to the variable. A GUI object is created for each array element in the case of an array.

If required, the format of the names of the GUI objects can be matched as required by specifying corresponding templates in the list (as of Version V254). In this case, %s must be specified as a wildcard for the name and, in the case of an array, also %d after it for the index.

Designator | Significance | Default value
name_rd_global_array | Read in the case of global array | cnc_ve_ %s_rd[%d]
name_wr_global_array | Write in the case of global array | cnc_ve_ %s_wr[%d]
name_rd_channel_array | Read in the case of channel-specific array | mc_ve_ %s_rd[%d]
name_wr_channel_array | Write in the case of channel-specific array | mc_ve_ %s_wr[%d]
name_rd_global | Read in the case of global variables | cnc_ve_ %s_rd
name_rd_global | Write in the case of global variables | cnc_ve_ %s_wr
name_rd_channel | Read in the case of channel-specific variables | mc_ve_ %s_rd
name_wr_channel | Write in the case of channel-specific variables | mc_ve_ %s_wr

Example: Assignment of the name for GUI interface

# ***************************************

#

# External variables V253

#

# ****************************************

#

name_rd_global_array cnc_test1_%s_rd[%d]

name_wr_global_array cnc_test1_%s_wr[%d]

name_rd_channel mc_test2_%s_rd

name_wr_channel mc_test2_%s_wr

var[0].name G_ARRAY5

var[0].index 0

var[0].type SGN32

var[0].scope GLOBAL

var[0].synchronisation FALSE

var[0].access_rights READ_WRITE

var[0].array_size 5

var[0].size 4 # 4 bytes per element

var[0].create_hmi_interface TRUE # HMI-Object will be created

#

var[1].name L_BOOLEAN

var[1].index 1

var[1].type BOOLEAN

var[1].scope CHANNEL

var[1].synchronisation FALSE

var[1].access_rights READ_WRITE

var[1].array_size 1

var[1].size 1 # 4 bytes per element

var[1].create_hmi_interface TRUE # HMI-Object will be created

The following HMI objects are created implicitly on the basis of the above extract from the configuration list:

cnc_test1_G_ARRAY5_rd[0]

cnc_test1_G_ARRAY5_wr[0]

cnc_test1_G_ARRAY5_rd[1]

cnc_test1_G_ARRAY5_wr[1]

cnc_test1_G_ARRAY5_rd[2]

cnc_test1_G_ARRAY5_wr[2]

cnc_test1_G_ARRAY5_rd[3]

cnc_test1_G_ARRAY5_wr[3]

cnc_test1_G_ARRAY5_rd[4]

cnc_test1_G_ARRAY5_wr[4]

mc_test2_L_BOOLEAN_wr

mc_test2_L_BOOLEAN_rd


PLC

The PLC receives access to the variable memory areas from the PLC-Run-Time-System after starting the control. The memory is differed in channel and global area.

pVE[iChannelNr]^.addr

pVEGlob^.addr

To simplify the access to the variable area an additional library TcCncUtilities.lib exists. With functions out of this library, which takes over the management of the variables you can access the V.E.Variables by name (max 20 characters).

If external variables are configured with user defined variable types, the PLC library TcCncUtilities.lib can not be used. In this case the variable structures should be recreated in the PLC to enable the direct access on the assigned V.E. variable memory by the pointers pVE[iChannelNr]^.addr respectively pVEGlob^.addr (see programming example 2).

Before using the different functions of the library a basic initialization must be accomplished. During this initialization the format description defined in the CNC configuration is automatically transferred to the PLC.

For this propose the SPS and the CNC exchandes the V.E.Varibles descriptions. During the initialization the will be cleared.

Additional the memory ranges, indexes and data types of the different variables will be checked during the initialization. If an error occurs an error message in the Logger is generated. To prevent the access to non-defined storage area in arrays an examination of the memory addresses is carried out. Thats why the size of the data type is passed to the respective function of the library.

For the reading and writing access to the external variables or arrays of external variables pointers to the expected data type will be generated. This pointers in each case will be initialized with the associated address of the variable in HLI memory range. After that you can access the variable with the dereferenced pointer from the PLC.

F.e.:

POINTER_TO_BOOL = VeBool(1, Peter, 0);

POINTER_TO_BOOL^=23;

Function | INPUT | RETURN | Description
VeInitialisation() |  | BOOL Status | Initializes the library for the use of V.E variables in the PLC.
 |  | Status [true/false] | Initialization of the library for access to external variables finished. While this value is not true you can not access the VE variables.
Ve<DatenTyp>() | UINT iChannel STRING strVeName UINT ISizeArrayByte | POINTER TO <DatenTyp> pDatatype | These functions deliver the memory address of variables with the data type <data type> identified by the name of variable. Data types = [Bool, Uns08, Sgn08, Uns16, Sgn16, Uns32, Sgn32, Real32, Real64, String]
 | IChannel [1 .. nChannel] |  | Number of the channel [1; nChannel] in which the variable with the name strVeName is defined.
 | StrVeName [String] |  | Name of the variables should be accessed. Name consisting out of maximum 20 characters.
 | IsizeArrayByte [sizeof(Ziel_Pointer^)] |  | Size of the expecting arrays to the examination of the correct memory access. If no array expected, this value is to be initialized with 0.
 |  | PDatatype [pIntArray ] | Address to the access for accessing V.E. variables by the name strVeName.

The following example refers on the V.E. configuration from this documentation (see text above chapter 2.3). Before accessing the V.E. variables in a program the HLI interface should be initialized (see [HLI]), TcCncUtilities.lib library in the desired project should be included and the following steps should be done:

Programming example for accessing
V.E. variables in the PLC (VeExample1.pro)

VAR

VEInitialisationDone : BOOL;

I : INT;

pCHANNEL_WR : POINTER TO ARRAY [0..9] OF INT := 0;

pGLOBAL_SWR : POINTER TO DINT := 0;

END_VAR

(* Accessing VE variables in the SPS *)

IF VEInitialisationDone = FALSE THEN

VEInitialisationDone := VeInitialisation();

IF VEInitialisationDone = TRUE THEN

pCHANNEL_WR := VeSgn32(1,'CHANNEL_WR, SIZEOF(pCHANNEL_WR^));

pGLOBAL_SWR := VeSgn16(1,'GLOBAL_SWR', 0);

ELSE

RETURN;

END_IF

END_IF

(* Now there can be a direct access to the Ve variables. For testing:

- check the content of pChannel -> 801..802....

- to test the communication to system manager execute V.E.GLOBAL_SWR=20 to write the variable on CNC.

- afterwards that the pChannel variable should have the content 0. *)

IF pCHANNEL_WR <> 0 AND pGLOBAL_SWR <> 0 THEN (* reading access*)

IF pGLOBAL_SWR^ = 20 THEN (* reading access*)

FOR I:=0 TO 9 BY 1 DO

pCHANNEL_WR^[I] := 0; (* writing access*)

END_FOR

ELSE

FOR I:=0 TO 9 BY 1 DO

pCHANNEL_WR^[I] := 800+I; (* writing access*)

END_FOR

END_IF

pGLOBAL_SWR1^:=0; (* writing access*)

This PLC example shows, how the V.E variables could be used in the PLC by replicating the variable structures. Before accessing the pointers pVE[iChannelNr]^.addr or pVEGlob^.addr the HLI interface must be initialized (s. [HLI - 15.1 Access to HLI elements]).

Programming example 2
VE variable access in PLC without TcCncUtilities.lib library
(from version V2.10.1025.00 onwards)

Definition of variable structures for the V.E. variables:

TYPE VECTOR_T :

STRUCT

x : LREAL;

y : LREAL;

z : LREAL;

END_STRUCT

END_TYPE

TYPE TARGET_POINT_T :

STRUCT

point : VECTOR_T;

valid : BOOL;

END_STRUCT

END_TYPE

TYPE TRAJEKTORIE_T :

STRUCT

nbr_points : DINT;

name : STRING(127);

points : ARRAY [0..9] OF TARGET_POINT_T;

END_STRUCT

END_TYPE

Definition of struktures for the complete, entered V.E. memory block:

TYPE VE_GLOBAL:

STRUCT

var_global_1 : DINT;

END_STRUCT

END_TYPE

TYPE VE_CHAN_1:

STRUCT

var_chan_1 : DINT;

array_chan_1 : ARRAY [0..19] OF INT;

name : STRING(127);

Trajektorie : TRAJEKTORIE_T;

END_STRUCT

END_TYPE

PLC program for the access on the V.E. variables:

PROGAM V_E

VAR

p_ve_chan_1 : POINTER TO VE_CHAN_1;

END_VAR

p_ve_chan_1 := ADR (pVe[1]^.addr^.AHLI_UNS32_Data);

IF (p_ve_chan_1^.name = )

THEN

p_ve_chan_1^.trajektorie.name := My Path!

p_ve_chan_1^.trajektorie.nbr_points := 2;

p_ve_chan_1^.trajektorie.points[0].valid := TRUE;

p_ve_chan_1^.trajektorie.points[0].point.x := 100.0;

p_ve_chan_1^.trajektorie.points[0].point.y := 200.0;

p_ve_chan_1^.trajektorie.points[0].point.z := 300.0;

p_ve_chan_1^.trajektorie.points[1].valid := TRUE;

p_ve_chan_1^.trajektorie.points[1].point.x := 200.0;

p_ve_chan_1^.trajektorie.points[1].point.y := 400.0;

p_ve_chan_1^.trajektorie.points[1].point.z := 600.0;

END_IF;


Configuration syntax up to and including V253

The configurations of the variables of a channel are specified in a textual list.

Example:

# ***************************************

#

# External variables V253

#

# ****************************************

#

anzahl_belegt 2

#

var[0].name GLOBAL_SWR

var[0].index 0 # Start position

var[0].var_typ 16 # SGN16_Array

var[0].mode 0x1 # 1 : VE_SYNCH, 2 : VE_ASYNCH

var[0].access 0x0202 # 0x100 : local, 0x200 global

# 0x1 : read, 0x2 : write

var[0].max_element 0 # Array size

var[0].offset 2 # 2 bytes per element

var[0].kennung 0 # Not used

#

var[1].name CHANNEL_WR

var[1].index 0 # Start position

var[1].var_typ 8 # SGN32

var[1].mode 0x2 # 1 : VE_SYNCH, 2 : VE_ASYNCH

var[1].access 0x0101 # 0x100 : local, 0x200 global

# 0x1 : read, 0x2 : write

var[1].max_element 10 # Array size

var[1].offset 4 # 4 bytes per element

var[1].kennung 0 # Not used

#

Ende

The elements have the following significance

Designator

Value range

Default

Significance

anzahl_belegt

[0; MAX_UNS16]

0

If var[i].* is assigned without gap, here the index of the variable defined last +1 is entered (ilast+1).

If var[i].* is assigned with gaps, here the highest index of the defined variables +1 is entered (imax+1).

var[i].*

i:= [0; 214]

Data records for the definition of variables.

name

ASCII string

The variable is identified on the basis of the name. The name is used to compose an overall name for the NC-channel and the GUI (e.g. V.E.<name>).

Upper case letters and lower case letters are differentiated.

index

[ 0; MAX_SNG32]

-1

The index defines the position in the memory at which the variable is saved. The overall memory is structured as an array of units with a size of 24 bytes.

An index of 1 indicates that the entry is not used.

var_typ

2  BOOLEAN,
3 - UNS08,
4 - SGN08,
5 - UNS16,
6 - SGN16,
7 - UNS32,
8 - SGN32;
9 - REAL64,
10 - STRING

12 BOOLEAN Array,
13 - UNS08 Array,

UNS32

The type indicates the data type of the variable. Besides elementary data types (SGN08, ..., REAL64, ARRAY_OF_SGN08, ...), there is also the data type String which currently comprises 24 bytes, including end mark.

mode

1  synchronous,
2  asynchronous

1

For optimization purposes, variables can also be accessed during decoding non-synchronously with respect to current program execution.

access

0x100  CHANNEL,
0x200  GLOBAL,

0x1  READ
0x2  WRITE

0x103

In the case of the scope of validity, a distinction is made between a channel-specific scope and a cross-channel, global scope.

Write/read access (0x3) to the variables is possible by default, and this access can be restricted with access protection.

max_element

[ 0; MAX_UNS16]

0

If the variable is not configured as an array, the array size must be specified as 0. Otherwise, the total size of the array is defined at this point.

offset

[ 0; MAX_UNS32]

4

Indicates the size of the variable including any alignment bytes, i.e. the difference between two consecutive array elements. Depending on computer architecture and alignment strategy, this size may comprise the real wanted data and additional alignment bytes.

kennung

[0; MAX_SGN16]

0

Not used. Free available user specific parameter.