Purge line placed at random instead of fix location - custom gcode
 
Notifications
Clear all

Purge line placed at random instead of fix location - custom gcode  

  RSS
chmax
(@chmax)
Eminent Member
Purge line placed at random instead of fix location - custom gcode

I had, in my 4.5 years of owning an mk3, a significant trench dig in the pei sheet by having the purge line always in the same place.

Now that I have an mk4 I've decided to randomize the start of the purge line to avoid repeating history 😀

If you have any interest in this just replace into "Printer Settings" - "Start GCode" the original lines beginning at the "Extrude purge line" comment with the new ones (see below).

Enjoy!

;
; Extrude purge line
;
G92 E0 ; reset extruder position
G1 E{(filament_type[0] == "FLEX" ? 4 : 2)} F2400 ; deretraction after the initial one before nozzle cleaning

; Original Prusa code commented out
;G0 E7 X15 Z0.2 F500 ; purge
;G0 X25 E4 F500 ; purge
;G0 X35 E4 F650 ; purge
;G0 X45 E4 F800 ; purge
;G0 X{45 + 3} Z{0.05} F{8000} ; wipe, move close to the bed
;G0 X{45 + 3 * 2} Z0.2 F{8000} ; wipe, move quickly away from the bed

; Random start of purge line inside the first half of the plate
{
local rndpos = int(random(0, print_bed_max[0] / 2));
"M117 Purge begins at " + rndpos + "; share the new start
";
rndpos = rndpos + 15;
"G0 E7 X" + rndpos + " Z0.2 F500 ; purge
";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F500 ; purge
";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F650 ; purge
";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F800 ; purge
";
"G0 X" + (rndpos+3) + " Z{0.05} F{8000} ; wipe, move close to the bed
";
rndpos = rndpos + 3 * 2;
"G0 X" + rndpos + " Z0.2 F{8000} ; wipe, move quickly away from the bed
";
}

 

Napsal : 16/08/2023 8:28 am
FoxRun3D
(@foxrun3d)
Famed Member
RE: Purge line placed at random instead of fix location - custom gcode

In the initial firmware for the XL and Mk4 they moved the prime line next to the object, which I thought was a cool idea. But after a few prints I realized that that means over the long run you're going to get the damage you mentioned all over the sheet. Sure enough, they moved it back, outside the print area, in subsequent releases, where it won't hurt.

Formerly known on this forum as @fuchsr -- until all hell broke loose with the forum software...

Napsal : 16/08/2023 11:11 am
chmax
(@chmax)
Eminent Member
Topic starter answered:
RE: Purge line placed at random instead of fix location - custom gcode

right! I remember that. I still think that randomizing the position of the line, near the object or outside of the printing space, will avoid stressing the same spot over and over...

 

Napsal : 16/08/2023 1:29 pm
the-powl
(@the-powl)
Eminent Member
RE: Purge line placed at random instead of fix location - custom gcode

Just a question about your code: how did you learn that you can define variables and that there's even e random function? I can't find any documentation for this.

 

Napsal : 01/09/2023 10:15 pm
chmax
(@chmax)
Eminent Member
Topic starter answered:
RE:

Good question 🙂 I went through a series of searches. I’ve stumbled upon an old request in the github repo asking for random(), then on the documentation for macros, then it was just my decades long programming experience (aka ‘I must have this working so I try until it does’) that gave me the final syntax. The “\n” for example was something I tried as I couldn’t believe it was not implemented, it worked but ZERO documentation (known to me) on that.

The various G and M codes are also rather poorly kept up to date and it is rather difficult for me to reconcile the what I see done by the MK4 printer and the code behind it. Eg the nozzle purging (that I’d like to place at random as well)… I seem not to be able to understand what is triggering that.

There is always the ‘read the firmware code’ way but -although fully in my skillset as I used to write OSs and program HW like this- it would take too much time for something as simple as what I am trying to do…

sorry for the long answer

This post was modified před 1 year by chmax
Napsal : 01/09/2023 10:43 pm
the-powl se líbí
chmax
(@chmax)
Eminent Member
Topic starter answered:
RE: Purge line placed at random instead of fix location - custom gcode

btw here un updated and optimized version of the code using “\n” that I am using in my MK4…

; Random start of purge line inside the first half of the plate
{
local rndpos = int(random(15, print_bed_max[0] / 2));
"M117 Purge begins at " + rndpos + "; share the new start\n";
"G0 E7 X" + rndpos + " Z0.2 F500 ; purge\n";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F500 ; purge\n";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F650 ; purge\n";
rndpos = rndpos + 10;
"G0 X" + rndpos + " E4 F800 ; purge\n";
"G0 X" + (rndpos+3) + " Z0.05 F8000 ; wipe, move close to the bed\n";
"G0 X" + (rndpos+6) + " Z0.2 F8000 ; wipe, move quickly away from the bed\n";
}

 

Napsal : 01/09/2023 10:55 pm
vhubbard
(@vhubbard)
Estimable Member
RE:

Please submit to the slicer team as an enhancement.  I tried submitting a "multiple" start location enhancement 2-3 months ago.  The refusal answer I was given showed me developers are not always in touch with the user community.   These functions are needed by everyone and we need to support the growing number of " non techie" users in the field. The MK4 is tripling the users in my family.   I know G code well, but that doesn't mean I want to write my own fixes all the time.   

Thanks for the outline. 

Napsal : 21/09/2023 4:25 am
chmax
(@chmax)
Eminent Member
Topic starter answered:
RE: Purge line placed at random instead of fix location - custom gcode

I did it on Aug 15th already. ( https://github.com/prusa3d/PrusaSlicer/issues/11132)

I wonder if I need to do something more to get it "into the code"... from my point of view, it would be a good thing and rather easy to add to the production version.

Napsal : 29/09/2023 8:03 am
Ckobar
(@ckobar)
Trusted Member
RE: Purge line placed at random instead of fix location - custom gcode

hi, my simple solution ist to put a piece of Captontape in the spot of the purgeline. 🙂  i have to change it of course regularly

Napsal : 29/09/2023 9:03 am
chmax
(@chmax)
Eminent Member
Topic starter answered:
RE: Purge line placed at random instead of fix location - custom gcode

good as well, on his a passive solution, mine is active. They are not mutually exclusive and can be combined 😀 

Napsal : 29/09/2023 9:08 am
Share: