bambu icon indicating copy to clipboard operation
bambu copied to clipboard

X Home required at end

Open canton7 opened this issue 1 year ago • 20 comments

Hi,

Firstly, thanks for putting this together! It's awesome.

I found I needed a G28 X at the end: without it, the layers after a color change could be offset in the X direction. Presumably we're stalling out the X at some point.

Thanks!

canton7 avatar Dec 12 '24 14:12 canton7

Hi canton7,

Thank you for reporting. That would trigger homing for the X-axis.. I haven't noticed any issues with the few prints I've done with this code. But, since I also own an X1C with AMS, it's my first choice for multi-color usually.

Since you mention 'could be offset', have you found any possible causes for it? e.g. did it take longer for you to follow-up on the filament swap? And do you have picture of a print where the offset happened (are we talking a few steps or a huger offset), just to get an idea?

I guess it's safe to add G28 X in, but it would be great to understand the need for it. Also, it requires some testing (which is a bit hard for me on short term).

Are there more people with this issue? Please report.

I haven't checked if there's a newer code in latest Bambu Studio for the A1 Mini, I will take a look at that as well and see if I can update it accordingly.

Dennis-Q avatar Dec 12 '24 14:12 Dennis-Q

Sure! I did a dead simple test print: two 10x10x0.2mm layers on top of each other.

IMG_20241212_150117 IMG_20241212_150208

(The bending is from where I pulled it off the bed, and the mottling in the white is the bed texture).

Annoyingly I didn't check to see whether it had lost steps in the +ve or -ve X direction (but it was definitely X), which might help narrow down where it's stalling.

Since you mention 'could be offset', have you found any possible causes for it?

To be precise, I did one test and saw the offset above. (I then added the home at the very end of the script, re-tested, and it was perfect).

As you say, a home should be harmless even if it isn't actually needed.

canton7 avatar Dec 12 '24 15:12 canton7

Thank you for sharing, that definitely didn't happen to my tests. Have you got this repeatedly? I will try to do some tests myself this weekend too.

Maybe it's caused by an update of Bambu Studio, the printer profile and/or printer firmware (although I don't think there was any update on the printer itself lately?).

Dennis-Q avatar Dec 12 '24 15:12 Dennis-Q

There was a firmware update the other day, it's possible that's related I guess.

I'll try again when the printer's not busy doing something else!

canton7 avatar Dec 12 '24 16:12 canton7

So I just checked the latest Bambu Studio but the 'Change filament G-code' has not changed (or at least the date is still 20240830), so that's not it.

But I did notice there is a firmware update now, I feel the issue is related to that. Maybe I should test before and after firmware update to see if the issue is there. Hopefully I can find some time this weekend.

UPDATE: so version I tested this code on was '01.03.01.02', the new firmware available is: '01.04.00.00'.

Dennis-Q avatar Dec 12 '24 16:12 Dennis-Q

So release notes mention something about a change when the printer is paused (which happens with this gcode):

  • "Gradually increase the heatbed moving speed when restarting a paused print for increased safety"

I feel it might be related by this.

@canton7 , if you have time, can you also test if the shift happens if you manually put in a pause (with the untouched filament chang code)? A manual pause during print could also trigger it already maybe.

Dennis-Q avatar Dec 12 '24 16:12 Dennis-Q

Hey! So i'm a A1 Mini owner and i kinda created my own manual AMS recently. Planning to use this g-code. Do i need to add G28 X at the end of it or it should be okay as is? ( Sorry for useless questions like that - i'm new to 3D printing )

Nik0-0 avatar Jan 08 '25 12:01 Nik0-0

Sorry for the delay.. I tested with the old firmware first and then with the new firmware and had no issues with the code on this github. I have no layer shifts, it just works as expected.

Some questions with your testing @canton7, also to understand differences with my setup:

  • Did you use a prime tower?
  • Have you disabled the single wall on top layer?
  • Have you used multiple layers per color (e.g. minimum of 2)? Due to prime time of the nozzle (especially when no prime tower is used) it might look like a layer shift in some cases. Therefore, I advice 2 layers minimum after a color change.
  • What procedure did you use to swap the filaments? Can you explain step-by-step what you do to unload and load the new filament?

If you have used the Filament menu with load/unload option, that might be the issue. It is important not to use that but instead use Control and set the temp to the new filament temperature, then remove it (usually it's cut already so you can remove it right away without pushing the extruder buttons). Then insert the new filament and press the extruder button down to insert it.. When you feel it feeds, you can press the play button. Then it will start flushing the filaments (as per values in the slices).

The above instructions are also in the file mentioned as 'Instructions (by Hillbilly-Phil)' in the gcode file.

Dennis-Q avatar Jan 13 '25 09:01 Dennis-Q

Hey! So i'm a A1 Mini owner and i kinda created my own manual AMS recently. Planning to use this g-code. Do i need to add G28 X at the end of it or it should be okay as is? ( Sorry for useless questions like that - i'm new to 3D printing )

It is okay as it is. The G28 X is not needed according to my testings. So I would advice not to add it at all.

What I do think is important that you generally understand what this code does and you test if it works for you by manually changing the filament. If it works for you and you don't see any layer shifts, then the G28 X code is not needed.

If you manually have to do steps to unload/load filament when swapping filament swaps, I think you can use the code as-is with your manual AMS system. Just make sure not to use the unload/load buttons but the right procedure as can be found in the gcode.

Dennis-Q avatar Jan 13 '25 09:01 Dennis-Q

Sorry! I've been meaning to get back to this and do some more testing, but it keeps slipping.

While I haven't done dedicated tests without the home, I have done some more multi-color prints, and I think I saw the X-axis stall out as it was pressing into the cutter. The movent looks more abrupt than when the Mini is cutting the filament during an Unload, and I heard the characteristic sound of a stepper stalling. However since I was using gcode which added an X home (which would have corrected any offset due to a stall), I can't confirm whether this apparent stall would actually have lead to an X offset.

Did you use a prime tower?

No

Have you disabled the single wall on top layer?

No

Have you used multiple layers per color (e.g. minimum of 2)? Due to prime time of the nozzle (especially when no prime tower is used) it might look like a layer shift in some cases. Therefore, I advice 2 layers minimum after a color change.

The test I did was just 2 layers, one of one color and then one of another. You can see quite clearly that it is not just the time taken for the new color to come through (and the dynamic flow calibration in your gcode extrudes a significant amount of filament anyway): there is clearly an offset, which is visible from both the top and bottom of the print, see my photos above.

Also, if this was the issue, how did homing the X-axis fix it?

What procedure did you use to swap the filaments? Can you explain step-by-step what you do to unload and load the new filament?

Wait until pause; remove old filament; push new filament down PTFE tube; press "Resume"; continue feeding new filament down PTFE tube until the extruder catches it.

Since adding a home adds an imperceptible delay, will never be the cause of a problem, and will correct for any failures due to stalls (caused by the filament cut, or the user being fat-fingered when loading in a new filament), I'd recommend adding one anyway: there are no downsides.

canton7 avatar Jan 13 '25 11:01 canton7

No problem @canton7 thanks for the quick response this time.

So I agree your pictures clearly show a layer shift and not an priming issue, but I thought it would be good to mentioned it anyway to be aware when (others are) doing some tests. This is also why I think 4 layers is a better test and removing the top layer single wall options as well.

I have never heard mine grinding/stalling when cutting the filament. For this reason, I think pakonambawan has reduced the length and also reduced the acceleration. Since we don't know the exact gcode used with load/unload, I am sure it looks different.

While I agree G28 X will not harm, I prefer to understand the need for it if it's really stalling/grinding for some. I prefer to improve the code to stop that from happening for everyone. As far as I can tell, we might want to adapt this line: G1 X197 F500.

Maybe we should start with another test first: put G28 X just before G1 X180 F18000 (this is the line before G1 X197 F500 to see if you still get the stalling. I will try to see if I can reduce the X197 value to e.g. X193 and see if it still cuts the filament..

If you want to help and do some testing too that would be great. Also, if more people face the same issue, please do reply to this issue and report, so we know 'how big' this issue actually is.

Dennis-Q avatar Jan 13 '25 14:01 Dennis-Q

Since adding a home adds an imperceptible delay, will never be the cause of a problem, and will correct for any failures due to stalls (caused by the filament cut, or the user being fat-fingered when loading in a new filament), I'd recommend adding one anyway: there are no downsides.

Shouldn't you add home for every axis? But Z would probably lead to problems.

ms-wer avatar Jan 13 '25 19:01 ms-wer

While I haven't done dedicated tests without the home, I have done some more multi-color prints, and I think I saw the X-axis stall out as it was pressing into the cutter. The movent looks more abrupt than when the Mini is cutting the filament during an Unload, and I heard the characteristic sound of a stepper stalling. However since I was using gcode which added an X home (which would have corrected any offset due to a stall), I can't confirm whether this apparent stall would actually have lead to an X offset.

I did some testing as well, so far only with the G28 X at the end, and I've ran into the same issue where the head stalls out while trying to cut the filament. It tries to cut but it's not strong enough to push the cutter in. This leads to some rattling noise, maybe some gears slipping? When it's going to the flushing position at the other end of the x-axis there's a bang as if the head runs into the end without stopping.

Could this be related to the wrong x position?

My guess is, that the filament is too cold to cut which leads to the failed cutting.

ms-wer avatar Jan 15 '25 08:01 ms-wer

Aha! Glad it's not just me. Interestingly the filament seemed to be cut fine in my testing, despite the stall. Stepper torque depends on speed, so it might just be that it's trying to move into the cutter too quickly (I haven't done a side-by-side comparison with the the built-in Unload function though).

canton7 avatar Jan 15 '25 08:01 canton7

While I haven't done dedicated tests without the home, I have done some more multi-color prints, and I think I saw the X-axis stall out as it was pressing into the cutter. The movent looks more abrupt than when the Mini is cutting the filament during an Unload, and I heard the characteristic sound of a stepper stalling. However since I was using gcode which added an X home (which would have corrected any offset due to a stall), I can't confirm whether this apparent stall would actually have lead to an X offset.

I did some testing as well, so far only with the G28 X at the end, and I've ran into the same issue where the head stalls out while trying to cut the filament. It tries to cut but it's not strong enough to push the cutter in. This leads to some rattling noise, maybe some gears slipping? When it's going to the flushing position at the other end of the x-axis there's a bang as if the head runs into the end without stopping.

Could this be related to the wrong x position?

My guess is, that the filament is too cold to cut which leads to the failed cutting.

Yes, we already expected it was related to the cutting of the filament and I did some suggestions in the thread earlier. The thing is, the filament cutting works fine for me (and some others that used the code which I based mine on).

To confirm it is related to the filament cutting, I think you should remove or comment out 2 lines, currently line 44 and 45:

G1 X197 F500 ; ADDED: finetuning by pakonambawan
G1 X180 F500 ; ADDED: finetuning by pakonambawan

Adding a semicolon to these lines, will not move the head to the end and will then not do the filament cut at all. Then, the print should be resumed with the same filament, to be sure it is really related to this part of the code causing your issues. If you don't get the layer shift (assuming you always got it before), it is related to these commands, which we can then finetune (see my comment of 3 days ago).

Can one of you please test and report back?

Dennis-Q avatar Jan 16 '25 05:01 Dennis-Q

I have never heard mine grinding/stalling when cutting the filament.

I can second the occurrence of this. I haven't done any testing, nor have I seen any layer shifts, I have 100% seen and heard the skipping during the cut (note: for me it fails to actually cut) and I have to do an unload/load.

My procedure is to wait for pause, and assuming it properly cut and unloaded automatically, run a "load" from the menu, then baby sit the flush since I'm printing HueForges, and cannot afford to have any mixing.

After that's one I'll hit the resume button. I've been meaning to test it out without bothering with the load to ensure it purges enough to not affect the color, but just haven't had the change.

I'm also having some odd bed adhesion issues recently that I'm fairly sure are unrelated to the filament swap code, so I'm not sure when I can assist with testing.

WhoDunDidIt avatar Jan 22 '25 07:01 WhoDunDidIt

I had a bit of a play this morning, and so far I haven't been able to reproduce it. I've tried 3 times with 3 different filaments, including the ones I used when I last saw this.

canton7 avatar Jan 22 '25 10:01 canton7

Hello, I had read this thread since I had the same issues, so I decided to do an investigation. I thought that this must have to do with stepper current. In the default start gcode, M17 is used:

...
M17 Z0.3 ; lower the z-motor current

G90
M17 X0.7 Y0.9 Z0.5 ; reset motor current to default
...

And in the default end gcode:

...
M400 ; wait all motion done
M17 S
M17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom
{if (max_layer_z + 100.0) < 180}
    G1 Z{max_layer_z + 100.0} F600
    G1 Z{max_layer_z +98.0}
{else}
    G1 Z180 F600
    G1 Z180
{endif}
M400 P100
M17 R ; restore z current
...

I assumed, that: M17 X Y Z sets stepper current M17 S saves currently used values of current M17 R restores saved values of current

I confirmed my assumptions by writing this simple testing g-code file:

M109 S200 ; heat nozzle to simulate print
G28 T300 ; home, ignoring heated nozzle
M83 ; extruder relative
M17 X0.7 Y0.9 Z0.5 ; sets default stepper current, this can be found in default start gcode
G1 Z15 F1000 ; lifts
G1 X185 F18000 ; moves next to cutting position
M17 S ; saves the default stepper current values
M400 ; waits for commands to complete
M17 X1 ; sets x stepper current higher
G1 X197 F400 ; cuts filament a little slower
G1 X185 F500 ; returns back to position before cutting, high current still applied, because force from arm is still being applied
M400 ; waits for commands to complete
M17 R ; restores saved stepper current values
G1 X180 F18000 ; moves little to the left, so that cutter doesnt apply pressure to filament when extruding
G1 E10 F180 ; extrudes a little to get new, uncut filament to cut
G1 X185 F18000 ; moves next to cutting position
G1 X197 F400 ; cuts filament a little slower
G1 X185 F500 ; returns back to position before cutting, high current still applied, because force from arm is still being applied

...and running it, as viewed in the attached video (playing with sound recommended):

https://github.com/user-attachments/assets/1aeb4e65-b0c6-49a1-90fc-1dfb833f701a

The first cut is executed at higher stepper current value, the second one uses default values. I then applied these findings to your g-code, adjusting here:

...
G1 X185 F18000 ; moves next to cutting position
M17 S ; saves the default stepper current values
M400 ; waits for commands to complete
M17 X1 ; sets x stepper current higher
G1 X197 F400 ; cuts filament a little slower, ADDED: finetuning by pakonambawan
G1 X185 F500 ; returns back to position before cutting, ADDED: finetuning by pakonambawan
M400 ; waits for commands to complete
M17 R ; restores saved stepper current values
...

...and tried to print in two colors. As you can see in the following video, the fix worked for me.

https://github.com/user-attachments/assets/c8961161-3cdb-482e-bb52-6b8c427fc7a4

As of now, the used value of current for cutting is X1 ( one Ampere?). Will post a PR soon - if this value is too low for you, you can suggest there.

kraftaksvk avatar Jan 27 '25 16:01 kraftaksvk

Closed by accident but the commit of @kraftaksvk has fixed it. Please test @canton7 and @WhoDunDidIt and re-open the issue if not resolved.

Dennis-Q avatar Feb 05 '25 10:02 Dennis-Q

Testet with a 0,2mm Nozzle. The slipping is gone and it cuts as intended.

ms-wer avatar Feb 08 '25 20:02 ms-wer