Tool data (D or #TOOL DATA)

Tool geometry

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

When the new tool is requested, the D number, T number and the freely usable P parameter of the currently replaced tool are also included. This permits the PLC to detect which tool is to be replaced. Wear can be entered in the NC program by the P parameter, for example, and can be returned to the PLC in the tool change.

The following data (CNC_TOOL_REQUEST_IN) is transferred in the request 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;

log_ax_nr_tool_length: UINT; (spindle axis for tool length compensation)

The PLC returns the complete tool record (CNC_TOOL_DESC).

Tool data (D or #TOOL DATA) 1:
Requesting tool data from the PLC

Programming Example

Tool manager in the PLC program

RInd: ADSRDWRTIND;
RRes : ADSRDWRTRES;
Rind;
IF RInd.VALID THEN
(* initialise response *)
RRes.NETID := '';
RRes.PORT := RInd.PORT;
RRes.INVOKEID := RInd.INVOKEID;
(* sender channel no. 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 due to D<i> *)
IF RInd.IDXGRP = ADS_IGRP_TOOL_DESC_READ THEN
(* Tool data request from CNC *)
pToolReq := RInd.DATAADDR;
BasicToolId := pToolReq^.id.basic;
SpindleID:= 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

Tool request

%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
N50 M30