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).

Tool data (D or #TOOL DATA) 1:
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