Archiving the machining parameters

Output on an external device

Archiving the machining parameters

Production with CNC machine tools requires a large quantity of measurement data and parameters to guarantee the quality and verify the production in accordance with the legal requirements. This applies particularly to the medical technology and aircraft construction sectors. Both sectors are confronted with very high demands on quality and the accountability for the manufactured parts over decades.


In order to prevent the loss of machining parameters during the production process, the EXTOPEN, WRITE and EXTCLOSE high-level language elements can be used to archive the machining parameters, for example, to safeguard the production. Archiving using a log file is possible in all machining channels of the NCK for all of the available output devices at the machine.


The example below should provide users with an application to output data at an external device using the EXTOPEN, WRITE and EXTCLOSE high-level language elements.



Writing data from the part program to a predefined device outside the NCK using language commands is possible using the high-level language elements WRITE. For example, in order that production of measurement data can be backed up or measurement data logged, the WRITE high-level language element must be used in conjunction with the EXTOPEN command.


In this combination, EXTOPEN initiates that the external, predefined device is opened before the data or data sets are read out using WRITE and written to the target folder. After the data have been successfully output on the external device, the operation is terminated using EXTCLOSE, when the end of the program is reached M30 or for a "Channel reset". For instance, files on a local CompactFlash card are considered as external devices or files.

Structure of programming command

Output to an external device/file is realized in 3 steps.


Open the external device/file

An external device/file is opened for the channel for writing using the EXTOPEN command.


Data are written

The WRITE command is used for writing


Closing the external device/file

The device/file is released again using the EXTCLOSE command or when the end the program (M30) is reached.


The EXTOPEN, WRITE and EXTCLOSE commands are structured as following:


DEF INT <error>

DEF STRING[<n>] <output>

EXTOPEN (<error>,“<ExtG>“,<processing mode>,<use mode>,<write mode>)

<output>="output data"






Character string of a defined length


Command to open an external device/file


Variable for returning the error value


Symbolic identifier for the external device to be opened

<processing mode>

Processing mode for the write commands to this device

<use mode>

Use mode for this device (shared/exclusive)

<write mode>

"O" = Overwrite, "A" = Append


Command for attaching a block or data to the end of a specified file.


Variable for returning the error value.

<file name>

The name of the file in the passive file system in which the specified block or specified data is to be added.


A symbolic identifier must be specified for the external device to be opened.


The block or data that is to be added to the specified file.


Command to close an external device/file that has been opened


Variable for returning the error value


Symbolic identifier for the external device/file to be closed

Would you like to contact the CNC4you team?

Questions or suggestions? Write us!

Do you have a suggestion for a video tutorial, a workpiece or an online article? We are curious about it!