External tool management (C10)

1.1 IntroductionPAGEREF _Toc307405791 \h2

1.2 Tool data 3

1.2.1 Access to tool data in the NC program (V.G.WZ..) 3

1.3 Saving tool life quantities 3

1.4 Saving tool data 3

1.5 Parameters 3

1.5.1 Overview 3

1.5.2 Description of channel parameters 3

1.6 ADS communication with external tool management (PLC) 3

1.6.1 Tool data (D or #TOOL DATA) 3

1.6.2 Tool change (T or #TOOL PREP) 3

1.6.2.1 Initialisation 3

1.6.2.2 Information to PLC 3

1.6.3 Tool life quantities 3

More:

button Introduction

button Tool data

button Saving tool life quantities

button Saving tool data

button Parameters

button ADS communication with external tool management (PLC)


Introduction

Task

Diverse tools are used when a workpiece is machined. The tool data (geometry, dynamics, tool life, etc.) is kept in a database and is requested whenever required, e.g. before use in the NC program.

As the PLC mostly also coordinates and realises the tool change, the data of the tools required by the CNC can also be managed via the PLC. Here, the CNC uses the external tool management.

The existence of external tool management must be communicated to the CNC via the channel parameter P-CHAN-00016.

An exchange of data takes place between the CNC and the PLC if tool data is needed in the CNC or if tool life data or changes to tool parameters are to be made available.

This exchange of data between the CNC and PLC is realised via ADS (see Chapter 1.6).

Communication | Communication between the CNC and the PLC takes place in the CNC's asynchronous task.
PLC -> CNC | In particular, the complete tool data including additional tool parameters are transferred to the CNC.
CNC -> PLC | Conversely, every time new tool data is requested (D command), the additional tool parameters and other information about the tool last active are returned to the PLC. Therefore, by means of these additional tool parameters, data can be transferred from the NC program to the external tool management and stored there.


Tool data

Standard programming | By default, tools are identified in the NC program by means of one-part numbers. In conformity with DIN 66025, this numeric ID is programmed with the D command for calculation of new data (calculatory tool change). In conjunction with the T command, the ID defines the next tool that is to be physically changed in.
External tool management | For the calculation of new tool data, these must be requested with the D command through an additional interface from an (external) tool management application provided by the user, possibly integrated decentrally, e.g. in the PLC. The tool management has special, manufacturer-specific algorithm in order to define the tool to be changed in on the basis of the tool ID.
Tool change | The T number primarily serves as technological information, i.e. it reaches the interface to the PLC through the NC channel. The T command itself does not initiate a tool change. In conformity with DIN 66025, physical insertion of the new tool in the work spindle is triggered with the machine function M06. Separate specification of the two commands "T with tool number" and M06 can be used to take preparatory measures after the T command, e.g. in the tool magazine (P-CHAN-00087), before the tool is actually physically inserted in the work spindle with M06.
T with D | If the corresponding channel-specific parameter is defined (P-CHAN-00014), execution of the D command is also implicitly triggered with the T command.
Influence on the NC program run | Due to waiting times during execution of the T command, delayed processing of prior motion blocks may occur during communication with the tool management. This can be avoided by setting the channel parameter P-CHAN-00106.
Tool identification (TOOL ID) | In the NC program, every tool is identified by means of a unique number. In the tool management, tool data is identified by means of a three-part number, which is referred to below as the tool ID. This is specified in the PLC by means of the following structure CNC_TOOL_ID.
Structur CNC_TOOL_ID in the PLC | basic : DINT; sister : DINT; variant : DINT; sister_valid : BOOL; variant_valid : BOOL; The basic tool number (basic) describes the tool type and the sister tool number (sister) defines an example of this tool type. The variant number (variant) is purely for data processing purposes. Therefore, diverse records can be used for a tool. Tool ID = basic tool No. + sister tool No. + variant number
T command D command | The mathematical expressions when specifying the T and D commands must always be interpreted as the basic tool number (basic). Therefore, the tool management still has the same degree of freedom as previously when it comes to selection of the tool record. T <basic> or D<basic>

#TOOL PREP
#TOOL DATA

Take into account the fact that only the tool type is defined with the communicated tool ID and that several tools of the same type (sister tools) may be ready for use in the tool magazine. Therefore, it may be that the tool cannot be uniquely identified in the NC program by way of the T or D command.

This is why, as an alternative, the tool ID can be programmed by means of plain-language commands. The preparatory technological command for the physical tool change with #TOOL PREP corresponds to the T command and requesting of new tool data with #TOOL DATA corresponds to D command.

Announcing a tool change (T)

#TOOL PREP [ <basic> [,<sister> [,<variant> ] ] ]

Requesting new tool data (D)

#TOOL DATA [ <basic> [,<sister> [,<variant> ] ] ]

It is imperative to specify the basic tool number (basic). Moreover, sister can be optionally programmed for the sister tool number and variant for the variant. Zero is inserted if sister or variant is not programmed (comma follows comma or close parentheses follows comma).

Tool description

Excerpt from structur CNC_TOOL_DESC
in the PLC

For the CNC, a tool is described by means of the data structure CNC_TOOL_DESC:

tool_id : CNC_TOOL_ID;

laenge : DINT;

radius : DINT;

ax_versatz : ARRAY [1..32] OF DINT;

kopf_versatz : ARRAY [1..28] OF DINT;

mass_einheit : UINT;

typ : UINT;

srk_lage : UINT;

kin_id : UINT;

log_ax_nr_spdl : UINT;

tool_fixed : BOOL;

valid : BOOL;

res : ARRAY [1..4] OF BYTE;

param : ARRAY [1..60] OF LREAL;

vb_min : LREAL;

vb_max : LREAL;

a_max : LREAL;

The complete meanings of the individual data items are described in [TOOL].

A tool can be described by way of further data which, however, is not needed when requesting the tool geometry from the CNC and is additionally held only in the PLC.

More:

button Access to tool data in the NC program (V.G.WZ..)


Access to tool data in the NC program (V.G.WZ..)

V.G.WZ[j]...

The "V.G.WZ[j]" variables enable R ead access to the data of any tool in the external tool management (transparent access; j corresponds to the tool number).

V.G.WZ[j].R | Radius of the tool | R
V.G.WZ[j].L | Length of the tool | R
V.G.WZ[j].P[i] | Parameter of the tool | R
V.G.WZ[j].V[i] | Axis offsets of the tool | R
V.G.WZ[j].ME | Dimension unit of the tool data | R
V.G.WZ[j].OK | Valid flag of the tool | R
V.G.WZ[j].SPDL_AX_NR | Logical axis number of the assigned spindle | R
V.G.WZ[j].KIN_PARAM[i] | Kinematics parameters of the tool | R
V.G.WZ[j].KIN_ID | Kinematics ID of the tool | R
V.G.WZ[j].TYPE | Tool type | R
V.G.WZ[j].SRK_ID | Cutting position in the case of a turning tool | R
V.G.WZ[j].S_MIN_SPEED | Minimum speed (Tool dynamic data) | R
V.G.WZ[j].S_MAX_SPEED | Maximum speed (Tool dynamic data) | R
V.G.WZ[j].S_MAX_ACC | Maximum acceleration (Tool dynamic data) | R
V.G.WZ[j].SISTER_VALID | Valid flag of the sister tool (TOOL-ID) | R
V.G.WZ[j].SISTER | Number of the valid sister tool | R
V.G.WZ[j].VARIANT_VALID | Valid flag of the variant tool (TOOL-ID) | R
V.G.WZ[j].VARIANT | Number of the valid variant tool | R

V.G.WZ_AKT...

The "WZ_AKT" variables as well as "T_AKT" and "D_AKT" enable access to data of the currently selected tool.

V.G.T_AKT | Number of the selected tool | R
V.G.D_AKT | Number of the selected tool record | R

W rite access results in temporary modification of the tool's data, as long as it is selected. The modified data is lost when a new tool is selected (Dxx) or when the tool is cancelled (D0).

Exception

When external tool management is used, the so-called additional tool parameters (V.G.WZ_AKT.P[i]) are accepted and saved when a new tool is selected or when a tool is cancelled.

V.G.WZ_AKT.R | Radius of the selected tool | R/W
V.G.WZ_AKT.L | Length of the selected tool | R/W
V.G.WZ_AKT.P[i] | Parameters of the selected tool | R/W
V.G.WZ_AKT.V[i] | Axis offset of the selected tool | R/W
V.G.WZ_AKT.ME | Unit of measure of the selected tool | R
V.G.WZ_AKT.OK | Valid flag of the selected tool | R
V.G.WZ_AKT.SPDL_AX_NR | Logical axis number of the assigned spindle | R
V.G.WZ_AKT.KIN_PARAM[i] | Kinematics parameters of the selected tool; note on write access: the value must be programmed in internal units! | R/W
V.G.WZ_AKT.KIN_ID | Kinematics ID of the selected tool | R
V.G.WZ_AKT.TYPE | Tool type of the selected tool | R
V.G.WZ_AKT.SRK_ID | Cutting position of the selected turning tool | R
V.G.WZ_AKT.S_MIN_SPEED | Minimum speed (Tool dynamic data) | R
V.G.WZ_AKT.S_MAX_SPEED | Maximum speed (Tool dynamic data) | R
V.G.WZ_AKT.S_MAX_ACC | Maximum acceleration ( Tool dynamic data ) | R
V.G.WZ_AKT.SISTER_VALID | Valid flag of the sister tool (TOOL-ID) | R
V.G.WZ_AKT.SISTER | Number of the valid sister tool | R
V.G.WZ_AKT.VARIANT_VALID | Valid flag of the variant tool (TOOL-ID) | R
V.G.WZ_AKT.VARIANT | Number of the valid variant tool | R
V.G.WZ_AKT.WEAR_RADIUS | Radius wear at radius compensation (OTC) | R
V.G.WZ_AKT.WEAR[i] | Wear in axis <i> at length compensation (OTC) | R
V.G.WZ_AKT.WEAR_CONST | Wear constant (OTC) | R/W

As an alternative to V.G.WZ_AKT.P[i], the following variable can also be used to access the additional tool parameters. It is available only when using external tool management:

V.G.WZ_INFO[i]

Parameters of the selected tool

R

 | Programming example
NC program with tool requesting | In the following example, various tools are inserted by the CNC and the data is requested from the external tool management. The request always contains the tool parameters of the tool that was last active for return transfer of updated values to the PLC. %ext_wzv.nc N10 X0 Y0 G91 G01 F1000 N20 T0 D0 (report back last parameters of T<?>&D<?>) (with request D0) N30 T1 D1 (report back last parameters of T0&D0) (with request D1) N32 V.G.WZ_AKT.P[0] = 123 N40 T2 N50 T3 N60 T4 N70 D2 (report back last parameters of T1&D1) (with request D2) N080 V.G.WZ_AKT.P[0] = 1 N090 V.G.WZ_AKT.P[1] = 2 N100 V.G.WZ_AKT.P[2] = 3 M30


Saving tool life quantities

Tool life
Tool life distance

When tool life quantities are recorded, a tool's intervention time (tool life) and the distance covered during intervention (tool life distance) are calculated.

Only travel by motion blocks is considered. Positioning by rapid traversing has no impact on the tool life quantities.

The tool ID, intervention time and intervention distance data is indicated by the interpolator after removal of the tool.

The tool life is recorded in [ms], and the tool life distance in [mm].

Time of
storage

Weighting

Weighting factors

With every tool change announced with the T command and when P-CHAN-00076 is set, the complete tool ID, the tool life and the tool life distance are sent automatically by the interpolator to the tool management and are stored there. All quantities are then set to zero and life quantity recording for the newly inserted tool is started again.

The weighting of the tool quantities can be modified via the NC program. The modifiable factor serves to adjust tool life recording to the use of the tool.

The following two decoder variables serve to program the weighting factors of the tool life and the tool life distance (access not in synchronism with real time):

Tool life weighting

V.TLM.TIME_FACT

Tool life distance weighting

V.TLM.DIST_FACT

The variables can be read and written. Both factors are 100% when the program is started. Both variables may be written in an NC block.

Example

A tool should be weighted with the factor 100% if it is always in contact. If material removal only takes place over half of the travel distance, however, you can calculate with a weighting factor of 0.5.

The default tool life and tool life distance weighting factors amount to 1.0.

Conditions for recording :

q Rapid traversing blocks are ignored in tool life recording.

q If the feed rate is zero, tool life recording is also idle.

q All motion types with the exception of rapid traversing interpolation are used for tool life recording, e.g. G01, G02, G03, spline interpolation and G63 are included.

q The weighting factors are included in calculation.

q In the case of axes involved in motion, no distinction is made between main and slave axes. The contouring feed rate is always taken for distance addition. In the case of slave axes programmed on their own in the block, the distance covered by the slave axis is added to the tool life distance. If this is not wished, the programmer can intervened correctively by specifying the weighting factors V.TLM.TIME_FACT/ DIST_FACT = 0.

q Active master and slave arrangements are not considered.

q In the event of a reset or program aborting, the values that were last current are also included in the tool management database.

q No data is sent if a tool is only inserted, i.e. no tool was previously in the spindle and the current T number is equal to zero.


Saving tool data

Tool parameters

T/D number

In the NC program it is possible to permanently modify certain information for the current tool, i.e. to save it beyond tool cancellation.

This is done with the aid of the so-called additional tool parameters (V.G.WZ_AKT.P[i]). Here, wear data, for example, of the currently active tool can be stored during the program run time. This data is then written back to the external tool management on selection of a new tool record (Dxx) or on tool cancellation (D0), where it is then processed further or stored.

If an active tool is not cancelled by the end of the program, and in the event of corresponding channel-specific parameter definition (P-CHAN-00103), when the program is started the next time it is possible to implicitly write the data of this tool used last back to the external tool management.

When a tool record is selected, the T and D numbers of the tool used last are transferred back to the external tool management.

 | Programming example
NC program with tool requesting | In the following example, diverse items of tool data (life quantities and tool parameters) are written by the CNC and returned to the external tool management. %ext_wzv.nc N10 X0 Y0 G91 G01 F1000 (Enter wear for T1/D1) V.G.WZ_AKT.P[0] = 123 V.G.WZ_AKT.P[1] = 234 N40 T22 D22 N31 T2 (-> T2-Info) N32 D2 (-> then D2 request) N33 D3 T3 (-> first D3 request and the T3 info) N35 X11 N40 #TOOL DATA [4, 1] (D geometry in extended syntax) (request) N50 #TOOL PREP [4] (request T in extended syntax) N55 X22 (Use application-specific tool parameters) G90 XV.G.WZ[3].P[0] G91 N130 X100 N140 X200 N150 T22 N160 D33 N170 X-100 N180 D0 (Cancellation of the tool geometry) M30


Parameters

Parameter definition

The user can configure communication between the CNC and the external tool management by means of settings in the channel parameter list [CHAN].

The parameters are set in relation to the specific channel. The settings can be made in the default list if they are to concern all channels.

More:

button Overview

button Description of channel parameters


Overview

ID | Parameter | Description
P-CHAN-00014 | einrechnen_mit_t | Implicit execution of the D word in the event of T programming
P-CHAN-00016 | ext_wzv_vorhanden | External tool management available in the system
P-CHAN-00076 | tool_life_to_wzv | Send tool life quantities of a tool to the tool management
P-CHAN-00087 | t_info_to_wzv | Prepare a tool change in the magazine
P-CHAN-00103 | d_clear_to_wzv | Save tool data on program start
P-CHAN-00106 | t_with_implicit_flush | Release of motion blocks on T selection .


Description of channel parameters

P-CHAN-00014 | Implicit execution of the D command in the event of T programming
Parameter | einrechnen_mit_t
Description | For the tool number "T", the D command with the same number is implicitly executed when the T command is programmed.
Data type | BOOLEAN
Data range | [0; 1]
Default | 0
Remarks | If P-CHAN-00014 is set to TRUE, programming of "T80" corresponds to the programming command "T80 D80", for example.

P-CHAN-00016 | External tool management available in the system
Parameter | ext_wzv_vorhanden
Description | This flag must be set to 1 if there is an external tool management application in the system.
Data type | BOOLEAN
Data range | [0; 1]
Default | 0
Remarks | -

P-CHAN-00076 | Send tool life quantities of a tool to the tool management
Parameter | tool_life_to_wzv
Description | In the case of TwinCAT controllers, by default only the tool data is requested from the external tool management when external tool management is activated. To send the tool life quantities of a tool determined in the NC kernel to the tool management, the P-CHAN-00076 parameter must also be assigned the value TRUE.
Data type | BOOLEAN
Data range | [0; 1]
Default | 0
Remarks | This parameter is used in TwinCAT systems only. The flag is evaluated only if there is an external tool management application (P-CHAN-00016).

P-CHAN-00087 | Prepare a tool change in the magazine
Parameter | t_info_to_wzv
Description | Programming of the T command generates a message to the external tool management to prepare a tool change in the magazine (e.g. clean tool and move to change position).
Data type | BOOLEAN
Data range | [0; 1]
Default | 0
Remarks | The flag is evaluated only if there is an external tool management application (P-CHAN-00016).

P-CHAN-00103

Save tool data on program start

Parameter

d_clear_to_wzv

Description

In the NC program, data of the current tool (e.g. wear parameters) can be modified by variable access (V.G.WZ_AKT.[i]...).

For saving, this data is written back to the external tool management each time a new tool is selected. If a tool has been programmed in the previous NC program, D0 (tool cancellation) is implicitly requested on program restart. When this request is made, the data of the tool used last is simultaneously returned to the tool management. This makes sure that any possibly modified tool data is not lost.

This implicit requesting of D0 can be switched by means of the P-CHAN-00103 parameter.

Data type

BOOLEAN

Data range

[0; 1]

Default

0

Remarks

No implicit D0 is requested on reset, i.e. the data of the tool used last is only saved the next time the program is started.

The flag is evaluated only if there is an external tool management application (P-CHAN-00016).

P-CHAN-00106 | Release of motion blocks on T selection
Parameter | t_with_implicit_flush
Description | For synchronisation reasons, waiting times during execution can occur during communication with an external tool management application when use is made of the T word. Due to the buffering effect of the NC channel, this leads to a situation in which a specific number of NC blocks relevant to motion that are programmed before the T word is held back. By setting the P-CHAN-00106 flag, you force execution of all motion blocks up to the T word. This consists of a "#FLUSH CONTINUE" (cf. [PROG]) implicitly triggered by the T word.
Data type | BOOLEAN
Data range | [0; 1]
Default | 0
Remarks | The flag is evaluated only if there is an external tool management application (P-CHAN-00016).


ADS communication with external tool management (PLC)

CNC channel identification

Each query contains a unique job number (invoke id, ADSRDWRTIND.INVOKEID, 32 bits). In the case of a multiple-channel CNC, the channel number [1; max] indicating from which CNC channel the query was initiated is coded in the first 24 bits. When replying, the job number must be returned.

More:

button Tool data (D or #TOOL DATA)

button Tool change (T or #TOOL PREP)

button Tool life quantities


Tool data (D or #TOOL DATA)

Tool geometry

With every D<i> or #TOOL DATA, the CNC requests the data of the tool during NC program decoding.

When the new tool is requested, the D number, the T number and the freely usable P parameter of the currently inserted tool are also included. As a result, the PLC can recognise which tool is to be replaced. Via the P parameter, the wear can be entered in the NC program, for example, and can be returned to the PLC in the tool change.

The following data (CNC_TOOL_REQUEST_IN) is transferred in the query from the CNC to the PLC:

id : CNC_TOOL_ID; (tool id of requested tool)

act_t_nr : DINT; (actual t number in nc kernel)

act_d_nr : CNC_TOOL_ID; (actual tool id in nc kernel)

param : ARRAY[1..60] OF LREAL;

The PLC returns the complete tool record (CNC_TOOL_DESC).

Figure1-1: Requesting tool data from the PLC

 | Programming example
Tool manager in PLC-program Tool data | RInd : ADSRDWRTIND; RRes : ADSRDWRTRES; Rind; IF RInd.VALID THEN (* initialize response *) RRes.NETID := ''; RRes.PORT := RInd.PORT; RRes.INVOKEID := RInd.INVOKEID; (* sender channel nr is coded in the invoke id *) cnc_channel_nr := RInd.INVOKEID; cnc_channel_nr := cnc_channel_nr AND 16#00FFFFFF; (* CNC requests tool geometry data caused by D<i> *) IF RInd.IDXGRP = ADS_IGRP_TOOL_DESC_READ THEN (* Tool data request from CNC *) pToolReq := RInd.DATAADDR; BasicToolId := pToolReq^.id.basic; SpiindleID := pToolReq^.log_ax_nr_tool_length; IF BasicToolId <= MAX_TOOLS THEN (* transmit tool data in the response *) RRes.LEN := SIZEOF(tool[1].cnc.tool_desc); RRes.DATAADDR := ADR(tool[BasicToolId].cnc.tool_desc); RRes.RESULT := ADS_RDWRT_IND_NO_ERROR; ELSE (* Tool not present *) RRes.LEN := 0; RRes.DATAADDR := 0; RRes.RESULT := WZV_TOOL_ID_BASIC_INVALID; END_IF

Programming example

%main

N10 X1200

N11 S2[D1] (Request tool D1 for spindle S2)

N20 S2[D2 REV=1 M4] (Request tool D2 for spindle S2)

N30 D3 S100 M3 (Request tool D3 for spindle S)

N40 X0

N480 M30


Tool change (T or #TOOL PREP)

More:

button Initialisation

button Information to PLC


Initialisation

Data format

Often, there is a real tool in the spindle when the controller is restarted. The PLC has a possibility of directly communicating this tool to the CNC.

actual_tool : DINT;

PLC example

bWrite: BOOL := FALSE;

ToolWrite : ADSWRITE;

ToolNr : DINT := 4711;

IF bWrite = TRUE THEN

bWrite := FALSE;

ToolWrite(Write := FALSE);

ToolWrite.NETID := '';

ToolWrite.PORT := ADS_PORT_TASK_SDA;

ToolWrite.IDXGRP := ADS_IGRP_DECODER_OF_CHANNEL + 1;

ToolWrite.IDXOFFS := ADS_IOFFS_ACTUAL_T_NUMBER;

ToolWrite.SrcAddr := ADR(ToolNr);

ToolWrite.LEN := SIZEOF(ToolNr);

ToolWrite(Write := TRUE);

END_IF

ToolWrite();


Information to PLC

Tool change

With every programmed T<i> or #TOOL PREP, during NC program decoding the CNC communicates the tool number to the PLC, provided this is activated in the channel parameter list (P-CHAN-00087).

This advance information can be used by the external tool management to prepare a tool change (cleaning the tool, turning the disk changer, etc.) to save time.

The following data (CNC_TOOL_ID) is transferred in the query from the CNC to the PLC; the T number is entered in the basic element:

basic : DINT;

sister : DINT;

variant : DINT;

sister_valid : BOOL;

variant_valid : BOOL;

The PLC acknowledges receipt by returning the identical message.

Figure1-2: Advance information about tool change to the PLC

 | Programming example
Tool manager in PLC-program Tool information | ... (* CNC teil den Werkzeugwechsel T<i> (während Programm- dekodierung) mit *) ELSIF RInd.IDXGRP = ADS_IGRP_TOOL_INFO_WRITE THEN (* CNC writes tool life data *) pTid := RInd.DATAADDR; BasicToolId := pTid^.basic; IF BasicToolId <= MAX_TOOLS THEN (* save actual requested tool T<nr> *) (* Tool id in valid range *) RRes.LEN := SIZEOF(pTid^); RRes.DATAADDR := pTid; RRes.RESULT := ADS_RDWRT_IND_NO_ERROR; ELSE (* no data transmitted in the reposnse *) RRes.LEN := 0; RRes.DATAADDR := 0; RRes.RESULT := WZV_TOOL_ID_BASIC_INVALID; END_IF ELSE


Tool life quantities

Tool life,
Tool life distance

With every programmed T<i> or #TOOL PREP and when P-CHAN-00076 is set, the complete tool ID, the tool life and the tool life distance are sent automatically from the CNC to the PLC and are stored there.

The following data is transferred from the CNC to the PLC:

CNC_TOOL_DATA_IN (Tool life data sent from CNC)

tool_id : CNC_TOOL_ID; (Tool id from CNC)

time_used : LREAL; (Usage time of tool in seconds)

dist_used : LREAL; (Usage distance in mm)

Figure1-3: Transferring tool life quantities to the PLC

Programming example

Tool manager in PLC-program

Tool information

...

(* CNC updates tool life data after deselection of another

tool T<i> *)

ELSIF RInd.IDXGRP = ADS_IGRP_TOOL_LIFE_DATA_WRITE THEN

(* CNC writes tool life data *)

pToolLife := RInd.DATAADDR;

BasicToolId := pToolLife^.tool_id.basic;

(* no data transmitted in the reposnse *)

RRes.LEN := 0;

RRes.DATAADDR := 0;

IF BasicToolId <= MAX_TOOLS THEN

(* actualize tooll life data *)

tool[BasicToolId].cnc.tool_life.dist_used := tool[BasicToolId].cnc.tool_life.dist_used

+ pToolLife^.dist_used;

tool[BasicToolId].cnc.tool_life.time_used := tool[BasicToolId].cnc.tool_life.time_used

+ pToolLife^.time_used;

(* Tool id in valid range *)

RRes.RESULT := ADS_RDWRT_IND_NO_ERROR;

ELSE

RRes.RESULT := WZV_TOOL_ID_BASIC_INVALID;

END_IF