Welcome! Log In Create A New Profile

Advanced

Custom g-code commands on tool change

Posted by viesturs.lacis 
Custom g-code commands on tool change
September 30, 2014 03:24AM
Hello!

I am trying to prepare a code for multi-extruder machine. It is one of those setups, where one stepper motor is feeding filament, the other stepper motor is selecting, which filament is used.
I am using Machinekit to drive my printer, so I have selected "LinuxCNC" in g-code flavor in general printer settings.
What I tried:
In printer settings, custom g-code tab, tool change g-code window I have this text:
M06 T[next_extruder]

The result is that in the g-code file there actually are M06 T0 and M06 T1 commands, which is nice.

There are 2 problems at the current moment:

1) there also are just T0 and T1 commands on separate lines as well.
For example, the beginning of file:

G21 ; set units to millimeters
G64 P0.05
G21 G17
G90 ; use absolute coordinates
T0
G1 F1200.000 A-2.00000
G0 Z0.350 F7800.000
G0 X13.400 Y13.400 F7800.000
G1 A0.00000 F1200.000
G1 X-13.400 Y13.400 A2.43695 F1260.000
G1 X-13.400 Y-13.400 A4.87391
G1 X13.400 Y-13.400 A7.31086

Then in the middle of the file, when extruders are changed:
G1 X-14.650 Y-14.650 A25.26912
G1 X14.650 Y-14.650 A27.93335
G1 X14.650 Y14.598 A30.59282
G0 X14.347 Y14.475 F7800.000
G1 F1200.000 A20.59282
M06 T1
T1
G0 X12.332 Y-7.065 F7800.000
G1 X12.935 Y-7.668 A0.08416 F1260.000
G1 X12.935 Y-11.506 A0.46314
G1 X12.582 Y-11.153 A0.51242

My ideal solution - all the bare "T0" and "T1" commands have "M06" placed in front of them, so that all they become "M06 T0" and "M06 T1" even at the beginning of file - that would ensure that correct filament is selected from very beginning of file (in case previous file ended with other filament). Is there any easy way I can fix that? (there is always "find and replace" command in text editor, but I would like something more convenient).

2) second problem is something that I do not even know, how to fix even in a dirty way:
the position of the extruder (A axis); it is counting position for each extruder separately, but using the same A word for both of them, which does not make any sense to me.
In the case of the "one stepper motor is feeding filament, the other stepper motor is selecting filament" type setup, the position of extruder filament-driving motor has to be sum of positions of all filaments.
I see 3 possible theoretical solutions:
a) I would prefer that it is done by software and there are correct A positions already in g-code
b) A position starts at 0 on each tool change so that I can use "custom tool change g-code" option to include command that would set A to 0 on each extruder change
c) each extruder has its own axis word (letters A, B, C, U, V, W are still available) in g-code so that in Machinekit I can sum positions of particular axes in HAL and feed that to stepgen.

Any ideas will be appreciated!
Thanks in advance!

Viesturs
Sorry, only registered users may post in this forum.

Click here to login