Tool Change scripts not being called
-
I'm trying to set up single hotend/heater, dual extruder. I think I've got all the config, tfree# and tpre# scripts set up right, but when I run
T0
orT1
they're not being executed. Not sure where to look/start figuring out why though.config.g
; General preferences G90 ; Send absolute coordinates... M83 ; ...but relative extruder moves M667 S1 ; Select CoreXY mode ; Network M550 PThreedee ; Set machine name M552 S1 ; Enable network M587 S"********" P"********" ; Configure access point. You can delete this line once connected M586 P0 S1 ; Enable HTTP M586 P1 S0 ; Disable FTP M586 P2 S0 ; Disable Telnet ; Drives M569 P0 S1 ; Drive 0 goes forwards M569 P1 S1 ; Drive 1 goes forwards M569 P2 S1 ; Drive 2 goes forwards M569 P3 S0 ; Drive 3 goes forwards M569 P4 S1 ; Drive 4 goes backwards M92 X80 Y80 Z1600.00 E414.8:402.4 ; Set steps per mm M350 X16 Y16 Z16 I1;E16:16 I1 ; Configure microstepping with interpolation M350 E64:64 ; https://wilriker.github.io/microstep-calculator/ M566 X600 Y600 Z50 ; Set maximum instantaneous speed changes (mm/min) M203 X18000 Y18000 Z480 E3600:3600 ; Set maximum speeds (mm/min) M201 X1000 Y1000 Z240 ; Set accelerations (mm/s^2) M906 X1600 Y1600 Z1800 E1100:1100 I30 ; Set motor currents (mA) and motor idle factor in per cent M84 S30 ; Set idle timeout ; Retraction Settings ;M207 S4.5 F6500 T3500 R0.025 Z0.4 ; Distance 4.5mm, Speed 6500, de-retract 3500, extra distance 0.025, zhop 0.4 ;M204 T7500 ; Set Travel Accel ;M566 E4000:4000 ; Set Extruder Jerk ;M201 E6600:6600 ; Set Extruder Accel ; Axis Limits M208 X0 Y-25 Z0 S1 ; Set axis minima M208 X300 Y285 Z290 S0 ; Set axis maxima ; Stall Detection M915 X Y S4 F0 H200 R1 ; Endstops M574 Z1 S2 ; Set Z-Probe at low end M574 X1 Y1 S3 ; Set active high endstops ; Z-Probe M558 P8 F360 T1800 I1 R0.5 A5 S0.03 ;M558 P8 F350 T750 I1 R0.4 A5 Z1 A0.05 H7.5 ; Piezo Z probe G31 P100 X0 Y0 Z-0.1 ; Set Z probe trigger value, offset and trigger height M557 X30:270 Y30:270 S48 ; Define mesh grid ; Bed Heater ;M305 P0 T100000 B4138 C0 R4700 ; Set thermistor + ADC parameters for heater 0 M305 P0 T100000 B4725 C7.060000e-8 R4700 M143 H0 S120 ; Extruder Heaters M305 P1 T100000 B4725 C7.060000e-8 R4700 ; Set thermistor + ADC parameters for heater 1 M143 H1 S285 ; Set temperature limit for heater 1 to 280C ; Tools M563 P0 D1 H1 S"Extruder1" ; Define tool 0 G10 P0 X0 Y0 Z0 ; Set tool 0 axis offsets G10 P0 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C M563 P1 D0 H1 S"Extruder2" ; Define tool 1 G10 P1 X0 Y0 Z0 ; Set tool 1 axis offsets G10 P1 R0 S0 ; Set initial tool 1 active and standby temperatures to 0C ; Fans M106 P0 S0 I0 F75 H-1 C"PartFan" ; Set fan 2 value, PWM signal inversion and frequency. Thermostatic control is turned off M106 P1 S1 I0 F75 H1:2 T45 C"ExtruderFan" ; Set fan 1 value, PWM signal inversion and frequency. Thermostatic control is turned on M106 P2 S1 I0 F75 H100 T45 C"DuetCooling" ; Set fan 0 value, PWM signal inversion and frequency. Thermostatic control is turned off ; Automatic power saving M911 S22 R23 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; Set voltage thresholds and actions to run on power loss ; Pressure Advance M572 D0 S0.02 ; Heater 3 LEDs M307 H3 A-1 C-1 D-1 M42 P3 S0 ; Heater 4 Servo M307 H4 A-1 C-1 D-1 M42 P4 S0 ; Filament out ;M591 D0 P1 C3 S1 M591 D1 P5 C4 R70:110 E3.0 S1 T0 ; Load override M501
tfree0.g
M117 "Freeing Extruder0" M83 ; Make sure extruder is in relative mode (prob not needed anymore) G1 E-5.0 F3600 ; Retract filament as soon as possible... G91 ; Relative G1 Z2 F600 ; ...Then lower the bed... G90 ; Absolute G1 X10 Y150 F18000 ; ...Then get the hell away from the print G4 S2 ; Pause two seconds to cool the retracted filament G1 E4.9 F3600 ; Pack the filament to eliminate the tail G1 E-155 F8000 ; Yank the filament past the Y adapter and into its Bowden tube
tpre0.g
M117 "Selecting Extruder0"
tpost0.g
M116 P0 ; wait for tool 0 only to reach operating temperature G1 E150 F6000 ; Extrude 145mm @ 100mm/s G1 E5 F1500 ; Extrude 5mm @ 25mm/s G91 ; Relative G1 Z-2 F6000 ; Raise bed G90 ; Absolute
-
The reason is quite simple, the tool change macros are not invoked if the axes are not homed when a T-code is called. If you run G28 or G92 XYZ before your T0 code in config.g, I bet it will work.
-
That'll be it. Now that you say that, I seem to remember reading it a while ago, evidently that snippet of information failed to stay in my brain
Would it be a good idea to make T commands output a message to the console along the lines of "free/pre/post scripts not executed as axes are not homed"?
-
I think it's as simple as this, unfortunately can't get the firmware to compile (even unchanged) to test.
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index f3ca91a..43a2233 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -580,59 +580,65 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) toolChangeRestorePoint.feedRate = gb.MachineState().feedRate; gb.AdvanceState(); if ((gb.MachineState().toolChangeParam & TFreeBit) != 0) { const Tool * const oldTool = reprap.GetCurrentTool(); if (oldTool != nullptr && AllAxesAreHomed()) { String<ShortScratchStringLength> scratchString; scratchString.printf("tfree%d.g", oldTool->Number()); DoFileMacro(gb, scratchString.c_str(), false); + }else { + reply.printf("No previous tool or axes not homed, skipping tfree%d.g", oldTool->Number()); } } break; case GCodeState::toolChange1: // Release the old tool (if any), then run tpre for the new tool case GCodeState::m109ToolChange1: // Release the old tool (if any), then run tpre for the new tool if (LockMovementAndWaitForStandstill(gb)) // wait for tfree.g to finish executing { const Tool * const oldTool = reprap.GetCurrentTool(); if (oldTool != nullptr) { reprap.StandbyTool(oldTool->Number(), simulationMode != 0); } gb.AdvanceState(); if (reprap.GetTool(gb.MachineState().newToolNumber) != nullptr && AllAxesAreHomed() && (gb.MachineState().toolChangeParam & TPreBit) != 0) { String<ShortScratchStringLength> scratchString; scratchString.printf("tpre%d.g", gb.MachineState().newToolNumber); DoFileMacro(gb, scratchString.c_str(), false); + }else { + reply.printf("No previous tool or axes not homed, skipping tpre%d.g", gb.MachineState().newToolNumber); } } break; case GCodeState::toolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools) and run tpost case GCodeState::m109ToolChange2: // Select the new tool (even if it doesn't exist - that just deselects all tools) and run tpost if (LockMovementAndWaitForStandstill(gb)) // wait for tpre.g to finish executing { reprap.SelectTool(gb.MachineState().newToolNumber, simulationMode != 0); UpdateCurrentUserPosition(); // get the actual position of the new tool gb.AdvanceState(); if (AllAxesAreHomed()) { if (reprap.GetTool(gb.MachineState().newToolNumber) != nullptr && (gb.MachineState().toolChangeParam & TPostBit) != 0) { String<ShortScratchStringLength> scratchString; scratchString.printf("tpost%d.g", gb.MachineState().newToolNumber); DoFileMacro(gb, scratchString.c_str(), false); } + }else { + reply.printf("Axes not homed, skipping tpost%d.g", gb.MachineState().newToolNumber); } } break; case GCodeState::toolChangeComplete: case GCodeState::m109ToolChangeComplete: if (LockMovementAndWaitForStandstill(gb)) // wait for tpost.g to finish executing { // Restore the original Z axis user position, so that different tool Z offsets work even if the first move after the tool change doesn't have a Z coordinate currentUserPosition[Z_AXIS] = toolChangeRestorePoint.moveCoords[Z_AXIS];