Function and characteristics
External variables describe a data memory which is used to exchange any values between the CNC (NC channel), the graphic user interface (GUI) and the PLC. Data can be used within the CNC either channel-specific (only accessible by one channel) or cross-channel (“global”). The meaning of the individual memory locations (here an external variable) is defined by the application (NC program, GUI and PLC).
The CNC itself only has the task of defining the memory layout and allowing the user access to the variables in the NC program. During the configuration phase, a name, a type and an access right (write and/or read) are assigned to each external variable. Optionally, memory addresses and variable size can be assigned by the user.
It is recommended to use the automated address assignment by the CNC to avoid problems caused by alignment or memory overlaps. A combination of the two address assignments is possible but this is also not recommended.
Defining the memory layout
The external variables are configured on the basis of an ASCII list only once during start-up.
User-defined structures can be defined besides “simple” variables. In addition, unidimensional arrays of simple variables or structures are possible. Access can be indexed to them.
A memory description is required to permit the GUI or a PLC to access the memory layout correctly - ultimately, this is defined by the CNC. This is made possible by the command #EXPORT VE. It is recommended to execute this command before the first start of the PLC. The command generates declaration files which can be directly integrated in the PLC programming environment. This obviates the need for an extremely (!) error-prone manual simulation of the memory layout by the GUI or PLC.
Attention
If addresses and types are not identical between the CNC and the PLC or GUI variables, the CNC has no possibility of checking this or preventing an error response.
The only way to protect the CNC from an invalid REAL64 parameter - which will cause a controller crash - is to check for "1.#INF", "-1.#INF" and "1.#SNAN” patterns. This check takes place when an external variable is read and, in case of error, it results in the output of messages with the ID 21820 or ID 21821.
The values of local variables apply throughout the lifetime of an NC program, i.e. they are not cleared, for instance when a new NC program is started.
Writing/reading instants
There are two options to determine the instant of writing/reading a variable from the NC program:
- Access to a variable is performed synchronously in the interpolator to execute the NC program, i.e. this ensures the temporal sequence of NC commands and variable access operations.
- Writing/reading a variable is executed at the instant of decoding (asynchronous with the execution of the NC program in the interpolator, i.e. “in advance”).
The user must evaluate the advantages and disadvantages of the two variants.
Synchronous read accesses cause the decoder to stop until the synchronous read value is available to the decoder. In addition, it is not permitted to read synchronous variables, e.g. with functions such as an enabled Tool radius compensation; the message is output with the ID 20651.
Access to the data by the GUI or PLC
- is not synchronised with NC program processing. This means that it cannot be ensured when data is read or written, i.e. when data is valid for the viewpoint of an application.
- In the same way, it cannot be guaranteed that data is consistently transferred in structures or arrays.
The only thing that can be guaranteed (by the processor) is correct access to the basic types of byte, word, doubleword and REAL64. From a programming viewpoint, the user must guarantee access protection with regard to instant and completeness.