T0-T7 - Tool Change
Description
T0 through T7 are tool change commands that select a specific tool in an 8-tool changer system. Each command executes a corresponding DMC subroutine (#T0 through #T7) on the Galil controller, allowing you to define custom tool-changing logic in your DMC program.
When a T-code is processed, the library sends an XQ #T<n> command to the DMC controller and waits for the subroutine to finish before continuing to the next G-code command.
DMC Subroutines Required: You must define the corresponding #T<n> subroutine in your DMC program for each tool number you plan to use. The subroutine contains your machine-specific tool change sequence.
Syntax
Parameters
T-codes take no parameters. The tool number (0-7) is part of the command itself.
DMC Subroutine
Each T-code executes the DMC subroutine labeled #T<n>, where <n> is the tool number. You must define these subroutines in your DMC program with your machine-specific tool change logic. The subroutine must end with EN.
Example DMC Subroutine for T1
#T1
REM *** Tool Change - Select Tool 1 ***
REM Move Z axis to safe clearance height
REM Rotate tool carousel to position 1
REM Engage tool clamp
REM Verify tool is seated
REM Return Z axis to working height
ENImportant: The library waits for the subroutine to complete before processing the next command. Ensure your subroutine terminates with EN so execution can resume.
Examples
G-Code Usage
Streaming API (C)
#include "gcode_api.h"
int main() {
const char* key = getenv("GCODE_LICENSE_KEY");
GCodeHandle h = gcode_create(key);
gcode_connect(h, "192.168.1.100");
gcode_configure_linear_axis(h, 'X', 'A', 1000.0, 100.0);
gcode_configure_linear_axis(h, 'Y', 'B', 1000.0, 100.0);
gcode_configure_linear_axis(h, 'Z', 'C', 1000.0, 50.0);
gcode_add_command(h, "T1"); // Select tool 1
gcode_add_command(h, "G1 X10 Y20 F500");
gcode_add_command(h, "T3"); // Switch to tool 3
gcode_add_command(h, "G1 X50 Y30 F400");
gcode_start(h);
gcode_wait_for_queue_empty(h, 30000);
gcode_disconnect(h);
gcode_destroy(h);
return 0;
}Notes
- Tool numbers are limited to 0-7. Commands outside this range will return an error.
- The corresponding
#T<n>subroutine must be defined in your DMC program before sending a T-code. If the subroutine does not exist, the DMC controller will report an error.