Tools

Siemens AGSiemens AG

Site ExplorerSite Explorer
Close site explorer

WRITE high-level language element

Application

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. In order to prevent the loss of machining parameters during the production process, the "WRITE" high-level language element can be used to archive the machining parameters, for example, to safeguard the production. The archiving is performed through the automatic creation of a log file in the NC of the machine.

Function

The task of the "WRITE" high-level language element is to write blocks or data from NC programs to a log file. This is used, for example, to safeguard the production or for logging the measurement data. During the currently running NC program, the "WRITE" high-level language element reads out the specified data and writes it automatically to the log file of the machine NC. If a log file does not exist, it is generated in MPF format. An existing log file is automatically appended during the program execution. The created files are freely accessible and can be read, changed and deleted by all users of the machine.

Code syntax

The WRITE command is structured in accordance with the following template:

    DEF INT <error>
    WRITE(<error>,“<file name>“,“<block/data>“)

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

Command

Description

<error>

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.

<block/data>

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


Typical use of the Write command

Setpoint and actual value of a single-point measurement (CYCLE978) in the current example are read from the existing NC-program and a "PROTOKOLL.MPF" log file is written.

   DEF INT _ERROR
   G17 G54 G90
   T="3D_TASTER"
   M6
   G0 X23 Y0
   G0 Z5
   CYCLE978(100,10008,,1,0,20,5,3,2,1,"",,0,1.01,1.01,-1.01,0.34,1,0,,1,1)
   WRITE(_ERROR,"_N_LOG","SETPOINT Z="<<_OVR[3])
   WRITE(_ERROR,"_N_LOG","ACTUAL VALUE Z="<<_OVR[7])
   WRITE(_ERROR,"_N_LOG","DIFFERENCE="<<_OVR[19])
   M30

Explanation of the programming example

Programming command

Description

DEF INT_ERROR

Definition of error variables

G17 G54 G90

Starting point

T="3D_PROBE"

Selecting the probe

M6

Loading the 3D probe

G0 X23 Y0
G0 Z5

Starting point of the measurement

CYCLE978(100,10008,,1,0,20,5,3,2,1,"",,0,1.01,1.01,-
1.01,0.34,1,0,,1,1)

Measuring process

WRITE(_ERROR,"_N_LOG","SETPOINT Z="<<_OVR[3])

Writing of the setpoint in the log file

WRITE(_ERROR,"_N_LOG","ACTUAL VALUE Z="<<_OVR[7])

Writing of the actual value in the log file

WRITE(_ERROR,"_N_LOG","DIFFERENCE="<<_OVR[19])

Writing of the difference between the actual value and setpoint in the log file

OVR[3])

Offset vector I1$TC_CARR3[n], Z component

OVR[7])

Rotary axis vector V1$TC_CARR7[n], X component

OVR[19])

Offset vector I14$TC_CARR19[n], Y component

M30

End of program

After "Selection" and processing of the sequential program by pressing the "CYCLE START" button, the log file (PROTOKOLL.MPF) was created automatically in the same folder. The log file has the following content:

   SETPOINT Z=0
   ACTUAL VALUE Z=0.01300811768
   DIFFERENCE=0.01300811768

Further information

The programms and the documentation are available at the Siemens Support-Portal: