3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode
-
First of all, I am unsure if this is a bug or if I overlook something, but in any case any hint is appreciated...
Now that RC4 is available and my printer runs fine in normal mode, I wanted to get Copy and Mirror mode running - ideally without having to care for that mode when slicing, apart from using just tool 0 and taking care that the part only uses the correct part of the bed surface.
In order to do this, I created a switching macro that redefines tool 0 and tool 1 as needed:
; choose print mode - Normal, Copy or Mirror if job.file.fileName = null ; only if there is no print in progress M291 S4 K{"Normal","Copy","Mirror","Abort"} P"Normal = Standard mode (hotends independent), Copy = Hotend 2 copies the print of Hotend 1, Mirror = Hotend 2 mirrors the print of Hotend 1" R"Choose printing mode" if input = 0 M563 P0 D-1 H-1 ; delete tool 0 M563 P1 D-1 H-1 ; delete tool 1 M550 P{global.Druckername} ; update machine name, variable is defined in config.g M563 S"Hotend 1" P0 D0 H1 F0 ; tool 0 = extruder 0 + heater 1 G10 P0 X0 Y0 Z0 ; axis offsets for tool 0 M568 P0 R0 S0 ; default temperatures tool 0 0°C M563 S"Hotend 2" P1 D1 H2 F1 X3 ; tool 1 = extruder 1 + heater 2, X mapped to U G10 P1 X0 Y0 Z0 ; axis offsets for tool 1 M568 P1 R0 S0 ; default temperatures tool 1 0°C T0 ; Tool 0 active M579 U1 ; U normal set global.U_invertiert = false ; set variable to detect inverted U in homing file if input = 1 M550 P{global.Druckername}^" (Copy mode)" ; update machine name M563 P0 D-1 H-1 ; delete tool 0 M563 P1 D-1 H-1 ; delete tool 1 M563 S"Duplizieren" P0 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P0 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P0 R0 S0 ; default temperatures tool 0 0°C M567 P0 E1:1 ; extrusion ratio T0 ; Tool 0 active M579 U1 ; U normal set global.U_invertiert = false ; set variable to detect inverted U in homing file if input = 2 M563 P0 D-1 H-1 ; delete tool 0 M563 P1 D-1 H-1 ; delete tool 1 M550 P{global.Druckername}^" (Mirror mode)"; update machine name M563 S"Spiegeln" P0 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P0 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P0 R0 S0 ; default temperatures tool 0 0°C M567 P0 E1:1 ; extrusion ratio T0 ; Tool 0 active M579 U-1 ; U inverted set global.U_invertiert = true ; set variable to detect inverted U in homing file if input = 3 else M291 S0 T5 P"Mode cannot be changed during a print" R"Error"
If I home the printer in normal mode, it works perfectly fine: X ends up t -175.5mm, U ends up at 175.5mm (coordinate 0,0 is in the centre of the print bed, limit definition in config.pro is: M208 X-175.5 Y-101 Z0 U-151 S1 and M208 X151 Y101 Z209 U175.5 S0).
But if I home it in one of the other modes, X and U values get weird...
If copy mode is active, the following happens:-
as soon as the macro above has executed (printer was homed before that and presents the above values), the X value switches to 0, while the U value switches to 100.5.
Now I home X and after homing the X value stays at 0. Then I home U and the U value stays the same as well.
But if I home all axes, U switches to 0 as well.
Then I home X again, and now X is suddenly -50.25 while U stays at 0.
Then I home U again, and suddenly U becomes 100.5 again - and X switches to 0 at the same moment.
As soon as I switch back to normal mode, the values switch back to what they should be... -
The same applies in Mirror mode, only the values change:
macro excecuted: X switches to 0, U to 100.5.
X homed: both X and U switch to -100.5.
U homed: no value change.
Home all axes: both X and U change to 0.
Home X again: X = -50.25, U = 0.
Home U again: X = -100.5, U = -100.5
Moving the hotends by presssing the X motion buttons on PanelDue in Copy or Mirror mode also leads to a somewhat erratic behaviour: in general motion is as it it supposed to be, but at some place one of the two hotends decides to move some distance into the wrong direction. And I try to do a G1 X0 Y0 with the homed printer, one of the hotends tries to move over the endstop...
My homing files:
; homeall.g ; Home all axes ; caution: axes are mapped in the order XYZUVWABC, where X=0, Y=1, Z=2, U=3 etc, not by driver number ; Variables var aktivesTool = -1 ; temporarily turn off inverted U if global.U_invertiert = true M579 U1 ; remember active tool and deselect everything if state.currentTool = 0 set var.aktivesTool = 0 elif state.currentTool = 1 set var.aktivesTool = 1 T-1 P0 ; Home G91 ; Relative Positioning G1 Z250 F6000 H1 ; move z to the endstop G1 Z-2 F6000 H2 ; 2mm back G1 Z10 F160 H1 ; and once more, but slowly ; StealthChop-Init M17 X Y U ; Motors on G4 P100 ; wait G1 H2 X0.015 Y0.015 U-0.015 F1000 ; move one micro step G4 P150 ; wait at least 130ms warten G1 H2 X5 Y5 U-5 F2000 ; move 400 full steps G1 X-350 Y-250 U350 F3200 H1 ; home X, U und Y fast G1 H2 X5 Y5 U-5 F3200 ; 5mm back G1 H1 X-10 Y-10 U10 F360 ; ... and once more, but slowly G90 ; Absolute Positioning G92 Z{move.axes[2].max} ; set Z on saved max Max value ; if U is inverted, recativate it if global.U_invertiert = true M579 U-1 ; reactivate tool if var.aktivesTool = 0 T0 P0 elif var.aktivesTool = 1 T1 P0
; homex.g ; Home X-axis ; Endstop at lower end of axis ; Variables var aktivesTool = -1 var z_abgesenkt = false ; remember active tool and deselect everything if state.currentTool = 0 set var.aktivesTool = 0 elif state.currentTool = 1 set var.aktivesTool = 1 T-1 P0 ; Homing if !move.axes[2].homed M291 P"Bitte prüfen, ob das Druckbett nicht im Weg ist!" R"Z-Achse nicht genullt" S3 ; move second head out of place if needed if !move.axes[3].homed G1 U6 F360 H4 G91 ; Relative Positioning if move.axes[2].homed && move.axes[2].machinePosition < {move.axes[2].max-3} set var.z_abgesenkt = true G1 Z2 F900 H2 ; Z 2mm down M17 X ; Motor on G4 P100 ; wait G1 H2 X0.015 F1000 ; StealthChop-Tuning: move one micro step (AT#1) G4 P150 ; StealthChop-Tuning: wait at least 130ms G1 H2 X5 F2000 ; StealthChop-Tuning: move min 400 full steps (AT#2) G1 X-350 F3200 H1 ; move x to endstop G1 X5 F600 H2 ; 5mm back G1 X-10 F360 H1 ; ... once more but slower if var.z_abgesenkt = true G1 Z-2 F450 H2 ; lift z if is was lowered G90 ; Absolute Positioniing ; reactivate tool if var.aktivesTool = 0 T0 P0 elif var.aktivesTool = 1 T1 P0
; homeu.g ; Home U axis ; Endstop for U at UPPER end of axis ; Variables var aktivesTool = -1 var z_abgesenkt = false ; remember active tool and deselect everything if state.currentTool = 0 set var.aktivesTool = 0 elif state.currentTool = 1 set var.aktivesTool = 1 T-1 P0 ; temporarily turn off inverted U if global.U_invertiert = true M579 U1 ; Homing if !move.axes[2].homed M291 P"Bitte prüfen, ob das Druckbett nicht im Weg ist!" R"Z-Achse nicht genullt" S3 ; move second head out of place if needed if !move.axes[0].homed G1 X-6 F800 H4 G91 ; Relative Positioning if move.axes[2].homed && move.axes[2].machinePosition < {move.axes[2].max-3} set var.z_abgesenkt = true G1 Z2 F900 H2 ; Z 2mm down M17 U ; Motor on G4 P100 ; wait G1 H2 U-0.015 F1000 ; StealthChop-Tuning: move one micro step (AT#1) G4 P150 ; StealthChop-Tuning: wait at least 130ms G1 H2 U-5 F2000 ; StealthChop-Tuning: move min 400 full steps (AT#2) G1 U350 F3200 H1 ; move U to endstop G1 U-5 F600 H2 ; 5mm back G1 U10 F360 H1 ; ... once more, but slower if var.z_abgesenkt = true G1 Z-2 F450 H2 ; lift z if is was lowered G90 ; Absolute positioning ; if U is inverted, recativate it if global.U_invertiert = true M579 U-1 ; reactivate tool if var.aktivesTool = 0 T0 P0 elif var.aktivesTool = 1 T1 P0
My best guess would be that I have overlooked something in my code... but what?
(in case it is needed: my config.g can be found here - just the new global variables used in the above macros are missing in there: https://forum.duet3d.com/post/333082 . If required, I can post the current one as well tomorrow or Saturday. )
-
-
@NeoDue this is a pretty complex way to go about doing it. It should be workable but to make it easier to help. can you do the "standard" way of using tool 0, tool 1 tool 2 and tool 3 for X, U, copy, mirror respectively. then once its working in that manner, the deleting, adding tools so tool 0 and tool 1 are the only tools you need can then be implemented and tested.
-
@T3P3Tony okay, I did two tests now:
1st attempt: rewrote the macro to simply add the tools T2 and T3 instead of deleting T0 and T1:
; add print mode test M291 S4 K{"Copy","Mirror","Abort"} P"Add print tool 2 (Copy) or 3 (mirror)" R"Add printing mode" if input = 0 M563 S"Copy" P2 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P2 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P2 R0 S0 ; default temperatures tool 0 0°C M567 P2 E1:1 ; extrusion ratio T2 ; Tool 0 active M579 U1 ; U normal set global.U_invertiert = false ; set variable to detect inverted U in homing file if input = 1 M563 S"Mirror" P3 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P3 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P3 R0 S0 ; default temperatures tool 0 0°C M567 P3 E1:1 ; extrusion ratio T3 ; Tool 0 active M579 U-1 ; U inverted set global.U_invertiert = true ; set variable to detect inverted U in homing file
Then I executed the macro to add T2 and did the above test for "Copy". Result: exactly the same as in post 1.
Then I executed the macro again to add T3 and did the above test for "Mirror". Result: exactly the same as in post 1.2nd attempt: I added the tool definition lines to my config.g, which made my tools section look as below:
; Werkzeuge (Tools) ; M563 S"Hotend 1" P0 D0 H1 F0 ; Tool 0 = hotend 0 + heater 1 G10 P0 X0 Y0 Z0 ; axis offsets for tool 0 M568 P0 R0 S0 ; Default temperatures tool 0 0°C (=off) M563 S"Hotend 2" P1 D1 H2 F1 X3 ; tool 1 = hotend 1 + heater 2, X mapped to U G10 P1 X0 Y0 Z0 ; axis offsets for tool 1 M568 P1 R0 S0 ; Default temperatures tool 1 0°C (=off) ; test M563 S"Copy" P2 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P2 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P2 R0 S0 ; default temperatures tool 0 0°C M567 P2 E1:1 ; extrusion ratio M563 S"Mirror" P3 D0:1 H1:2 X0:3 F0:1 ; tool 0 = both hotends G10 P3 X75 U-75 Y0 Z0 ; axis offsets for tool M568 P3 R0 S0 ; default temperatures tool 0 0°C M567 P3 E1:1 ; extrusion ratio
Then I homed the printer, used the console to switch tools (and set M579 U-1 for mirror and set the variable accordingly as well) and tried the homing procedure above.
Result: again exactly the same as in post 1.
Therefore, I guess I can prove at least it is not the way of creating the tools via the macro or deleting the existing tools which causes this issue
-
Okay, it took me that long to realise I have at least one error in my homings files - this code definitely does not fit to any of the new tools:
if state.currentTool = 0 set var.aktivesTool = 0 elif state.currentTool = 1 set var.aktivesTool = 1 T-1 P0
Let me try to correct that first before anyone puts any thoughts into this topic.
-
maybe it helps looking at a working config for an IDEX, check out mine. I try to keep my configs stupid so they are easier for me to debug. I had some similar issues as you (pre 3.5) with sussing out the tool offset configurations, so take specific note of those
-
@oliof thanks a lot! That is something I should have seen earlier - I only had a config that was posted here in the forum quite a while ago as a basis - and that one turned out not to really fit to my printer.
Apart from that: a lot of the specialties in my printer result from getting the most out of the limited space and functionality of the PanelDue (this is also the reason for deleting the tools in the macro in the 1st post) - simply defining all four tools clutters up the PanelDue with six instead of two hotends and AFAIR there is nothing I can do about that) and from handling the somewhat nonstandard setup of the J1 - assisted calibration and such, if you remember.But one thing puzzles me when I look at your config and the homing files: homing seems to work on your printer regardless which tool is selected. That did not work for me from the beginning which is why I had added the code mentioned above.
Can you confirm homing works for you as i suspect, or you handle tool selection prior to homing somewhere else?
-
@NeoDue homing works for me as I expect, and I home before choosing any tools.
Remember that you home axes not tools, so if you home before dallying with tools you can experiment with
G28 X
andG28 U
before selecting tools.Also, please note that in my setup, X homes towards minimum of axis andl U homes towards maximum of axis.
-
@oliof same here - I wonder if there are any IDEX printer that home the second hotend on the lower end of the axis The only thing that differs significantly in that part of our setups (apart from the obvious axis limit values...) is that z homes at z_max in my printer as well.
@oliof said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
@NeoDue homing works for me as I expect, and I home before choosing any tools.
Remember that you home axes not tools, so if you home before dallying with tools you can experiment with G28 X and G28 U before selecting tools.Ah, okay. I need to make sure I can home at any time. For example, I have to home (or rather the filament load script does it) if I want to load filament since I need to move the print heads to a specified position before doing that.
-
@NeoDue I could have homed the second tool to the first, but that's not a fixed target in space and I would always need to home or at least position the first tool, seems like an unneccessary complication.
I can home at any time since the tools move in opposite directions for homing. I just rarely need to do it while the machine is in use. If your printhead can move within the homed axis area, I dont see why you would need to rehome unless you manually move it in X for the filament change.
-
@oliof the filament change is not the only case. I rehome as well for any of the calibration routines I have, for cleaning the nozzles etc. All that is started via a button on the PanelDue. Whenever some move is done, I want to be sure that the print heads neither collide with the bed nor with themselves, and I automatically turn off the steppers after a while. Therefore: homing is good, and the printer shall be able to do that in any case. (That is the big advantage of having the z endstop sensor at z_max.)
Anyway: now that the homing macros are corrected, homing spits out the same values each time. Now I need to find out why the x and u carriage switches to the wrong values for copy and mirror. Let's see if your config helps me with that
-
@oliof @T3P3Tony I went through this now step by step, starting with the standard tools (with and without offset) to verify my view on "tool offset" vs. "axis position" is correct, which I found it is.
Then I went on with a standard Copy tool as T2, and here I found some things that I do guess to be (albeit not function-critical, apart from the last one) bugs, and these were the ones that had driven me off the right track initially:
- if you home the printer correctly (i.e. without tools selected, not the stupid thing I did above...🫣) and then just switch to the Copy tool, the Duet gives out strange positions of X and U until you actually move the new tool for the first time. That initial calculation seems take the position of X and the position of U relative to X0Y0, adds a possible tool offset to both values, creates the sum of both, divides the result by 2 and calls that the position of X, while the U value correctly stays as it is. If it had not changed at all, I would have concluded that you must move the axis to get a change, but since it changed to unlogical values I guessed wrong.
Now if you do that for a symmetric position and symmetric tool offsets (simple example: position of X hotend at X-150 and U hotend at U150, tool offset 0 for both) you get "0" for X in any case which does not fit at all. - as soon as you actually move the tool, it will move to where it belongs but will not reliably update the displayed U position any more. Sometimes it updates U, sometimes the U value just stays the same (if I can find some logic behind the behaviour, I will add this).
- axis limits are not obeyed consistently. Sometimes I do get a message "Error: G90: intermediate position outside machine limits", but if this occurs, it is once at max. As soon as I have confirmed the message, I am free to crash the hotend anywhere I like, until the next homing procedure is started. It seems to make a bit of a difference there if if I use many small motion steps (repeatedly tapping 1mm or 0.1mm on the PanelDue) instead of a large one. Remark, in case it matters: Tested with the U hotend, i.e. on the upper end of the x axis.
- if you home the printer correctly (i.e. without tools selected, not the stupid thing I did above...🫣) and then just switch to the Copy tool, the Duet gives out strange positions of X and U until you actually move the new tool for the first time. That initial calculation seems take the position of X and the position of U relative to X0Y0, adds a possible tool offset to both values, creates the sum of both, divides the result by 2 and calls that the position of X, while the U value correctly stays as it is. If it had not changed at all, I would have concluded that you must move the axis to get a change, but since it changed to unlogical values I guessed wrong.
-
@NeoDue said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
f you home the printer correctly (i.e. without tools selected, not the stupid thing I did above...🫣) and then just switch to the Copy tool, the Duet gives out strange positions of X and U until you actually move the new tool for the first time. That initial calculation seems take the position of X and the position of U relative to X0Y0, adds a possible tool offset to both values, creates the sum of both, divides the result by 2 and calls that the position of X, while the U value correctly stays as it is.
That is correct. When using the copy tool, user X is mapped to both machine X and U. When the positions of machine X and U are inconsistent with the mapping, RRF takes an average to calculate user X, and that is what will be displayed when DWC is displaying user coordinates. The U axis is not mapped so its displayed position is independent of where the machine X axis is. You may wish to include a command such as G0 X0 F6000 in the tpost file for the copy tool.
@NeoDue said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
As soon as you actually move the tool, it will move to where it belongs but will not reliably update the displayed U position any more. Sometimes it updates U, sometimes the U value just stays the same (if I can find some logic behind the behaviour, I will add this).
Interesting. If the U head actually moves then I would expect the displayed U position to be updated too.
@NeoDue said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
axis limits are not obeyed consistently. Sometimes I do get a message "Error: G90: intermediate position outside machine limits", but if this occurs, it is once at max. As soon as I have confirmed the message, I am free to crash the hotend anywhere I like, until the next homing procedure is started. It seems to make a bit of a difference there if if I use many small motion steps (repeatedly tapping 1mm or 0.1mm on the PanelDue) instead of a large one. Remark, in case it matters: Tested with the U hotend, i.e. on the upper end of the x axis.
I think there may be two issues here:
- To prevent the X and U heads crashing into each other, you will need to reduce the X axis upper limit and increase the U axis lower limit using M208. You can do this in the tpre or tpost file for the tool. Restore them to normal in the tfree file for the tool.
- Even without using M208, RRF should prevent you sending X below the low endstop or U beyond the high endstop. If that's not working, it sounds like a bug in RRF.
-
@dc42 thanks a lot for the hints!
One suggestion, if I may: it might be worthwhile including those notes in https://docs.duet3d.com/User_manual/Machine_configuration/Configuration_IDEX for other users.
@dc42 said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
- Even without using M208, RRF should prevent you sending X below the low endstop or U beyond the high endstop. If that's not working, it sounds like a bug in RRF.
Yes, that does indeed feel like one since the message does pop up but it is unreliable. I guess other tasks are more important right now when to comes to filling your schedule with tasks, but if I can help with that one, please do not hesitate to ask
Edit: by the way, the heads crashing into each other seems to be counteracted by the toolhead distance defined with G10. The Duet tries to keep that one - at least until one hotend is stopped by the end of the rail after it ignored the endstop switch.
-
@NeoDue I've taken a look at the code and I think the current behaviour regarding axis limits should be as follows when you use the copy tool, assuming that you don't change the M208 limits:
- If you try to move to an X coordinate that would be below the X axis minimum, that should be detected and the move should be limited to the reachable X axis minimum (which is normally where the homing switch triggers).
- However, if you try to move to an X coordinate that would move the U head to a point beyond the high stop, that will not be detected and limited; but after the move starts you might get a "intermediate position unreachable" error.
Is that the behaviour that you see?
-
@dc42 said in 3.5.0 rc4: weird homing behaviour in IDEX copy or mirror mode:
@NeoDue I've taken a look at the code and I think the current behaviour regarding axis limits should be as follows when you use the copy tool, assuming that you don't change the M208 limits:
- If you try to move to an X coordinate that would be below the X axis minimum, that should be detected and the move should be limited to the reachable X axis minimum (which is normally where the homing switch triggers).
Yes, the X carriage obeys the x axis limit. If I let the tool run into this limit using the PanelDue, the U carriage does behave a little strange: instead of strictly keeping its defined distance (in my case 150mm) from the X carriage as I would suspect, you can move it closer to the X carriage for an additional four moves after the X carriage has stopped moving - and how close you get, depends on the travel you want to make with these moves:
- if I move in 10mm steps by pressing "-10" on the PanelDue, I end up with about 130mm distance between the nozzles after four motions
- if I move in 1mm steps, I end up with about 148mm distance between the nozzles after four motions
- if I move in 100mm steps, I end up with just about 55mm distance between the nozzles after one motion (and I did not dare trying what happens if I press the button again, most probably the carriages crash into another)
- if I start a lower motion step after a higher one (e.g. pressing "-100" once and then "-10", the U carriage moves into the opposite direction of what you would expect it to on the second button press,
The value of the U axis is not updated on moves where the X carriage is moved as well, but it is updated on those weird additional moves by the way. The value of U is somewhat random though, and even of you move back to where the X carriage moves as well, the U value keeps showing values that are off by up to several mm. I can use that as a random number generator
- However, if you try to move to an X coordinate that would move the U head to a point beyond the high stop, that will not be detected and limited; but after the move starts you might get a "intermediate position unreachable" error.
Is that the behaviour you see?
Not fully - I just played a bit more with it to be sure:
- if I start a move that would move the U head to a point beyond the high stop, the Duet shows me an "intermediate position outside machine limits" error before the move starts - but it does so only if I press the 10mm button (again, I do not dare pressing the 100mm button since that will probably end up with the U stepper stalling which then will cause the Duet to burn its coil. Those Mocotech steppers are weird).
- If I use 1mm steps however, the machine ignores the upper limit right away in most cases, but sometimes the message does pop up there as well.
Edit: if it helps, I can share a video showing this.
-
@NeoDue thanks. I was able to include one quick fix in the 3.5.1 release: the U axis upper limit should now be honoured.
-
@dc42 3.5 has gone stable AND you already managed to fix that??
Thanks a lot - and congratulations! That was some really hard work for you and the whole Duet team! If I remember correctly, 3.5. had the longest beta / RC phase of all the RRF versions I saw and used in the last seven or so years.
(edit - after upgrading the printer yesterday, I just took the chance to test the updated function: crash detection works, and now U behaves exactly as X did - i.e. U does not crash into the endstop any more, but the X carriage ends up at places where it should not go. But that bug is just an inconvenience, not critical for the printer)