load unload macro with endless loop and cancel condition
-
@OwenD said in load unload macro with endless loop and cancel condition:
@Krohm-Koala said in load unload macro with endless loop and cancel condition:
@LB Do you ever have the message done loading/unloading ? I tried your solution but as soon as i cancel the purge, it kills the macro and won't finish it.
likewise in the above case, abort would kill the macro (and print)At present if you hit cancel in an M291 S3 dialog it will cancel the macro, so no, you would never get the finished message in that instance.
There was discussion about adding a third option to M291, but it doesn't seem to be on the current list for implementation.
Perhaps some some time after 3.2 is finalized.@OwenD
Thanks for pointing this out! That is what I assumed! Conditional G-code is pretty new, so not everything can be there from the start. But over time I guess there will be an option so I just let the code there to change it whenever the solution arrives...
@Krohm-Koala
To be honest I feel settled with the no "final" message since anyway in DWC it shows you that it has loaded everything -> since I currently only work with printers with only 1 extruder (and no colourchanger or stuff like that) the filamentchange-code posted is good enough for me now... hope you understand -
@LB Totally understand it's just me who want too much
-
I just did this and I deeply loath writing a macro for every filament. I'll have to go back and try G701 inside load/unload to save some extra lines that are not totally DRY. Here is what I did:
each filament has a config that defines some variables
; set filament name, temperature and speed "variables" M563 P5 S"PLA" G10 P5 X215 Y300 ; set retraction parameters M207 S0.4 F2100
When I make a new filament, this is a bsically all I have to do now.
Then load.g and unload.g just load up those variables and call a macro (this is where I need to try M703):
M98 P"/filaments/PLA/config.g" ; the filament config isn't loaded until AFTER this macro runs, but we need the variables set now. M98 P"/macros/Filament/loadFilament.g"
Then my load macro looks like this:
; loadFilament.g ; ask the user if they really want to light up the heater and load some filament M291 S3 P{"Click OK to heat to " ^ tools[5].offsets[0] ^ "C and load " ^ tools[5].name} R{"Load " ^ tools[5].name ^ "?"} ; Set current the configured temperature and wait for the extruder to reach temp M109 S{tools[5].offsets[0]} ; Pause and ask the user to position the filament for feeding M291 S2 P{"Load filament in the extruder and click OK to start loading " ^ tools[5].name} R{"Ready to Load " ^ tools[5].name} M83 ; Extruder to relative mode ; rapidly feed filament from the gears to the bottom of the heat break G1 E58 F900 ; Feed 58mm of filament at 15mm/s G1 E30 F300 ; Feed 30mm of filament slowly ; purge and ask for more loop while true G1 E30 F300 ; Feed 30mm of filament slowly M400; Wait for moves to complete ; ask the user if they want to do that again? M291 S3 P{"Click OK to purge some more"} R{"Continue purging?"}
So it asks put the temps and the filament name in all the messages. Plus it has a loop to purge more plastic and you can keep doing that as long as you want. (See the whole commit on github)
When variables are implemented this will become so much less ugly.
My next challenge is finding a way to check, at print start, if the filament/tool pairings in the print match the filaments configured on the tools in in the printer and abort if they don't
-
Hi, really impressive - hat´s off!
It is promising to us all to simplify things by getting rid of redundant code via "links" & "variables"!What I do not understand by looking at the code:
-> How does this work with the code you just posted, because is RRF not looking for the "un-"/"load.g" within the filament-folder of the selected filament? Since yours seems to be within the macros/filaments/ how does it find it automatically without throwing an error?
-> Does this work really automatic with pressing within e.g. DWC here:
What I really like:
It does make sense to have a general/1-for-all un-/load.g one layer "before" in the folder-structure within Files/Filaments so to say, and to only be able to "overwrite" it with a more specific un-/load.g within that filament-folder, IF a special filament really needs it I guess That way we could get rid of some redundant code?
-> Wouldn´t some sort of it be cool as the general layout? Or did I oversee something here
-
@LB Personnally, i've updated my filament change macro to have specific heat file by filament, it's not the most intuitive at first, but now that i have all my files, it's insanely good to use, i also add an axe movement to choose the filament i'm loading wich is also useful, loading a config file at the end could be easy to add but don't need it now, thanks to meta code
I hope the endless loop for purging could be done at one time but it's already good nowM291 P"Mettre les chauffes et changer le filament ?" R"Changement du Filament" S3 M80 T0 P0 ;Select tool M106 S0 M98 P{"0:/filaments/" ^ {move.extruders[state.currentTool].filament} ^ "/e-heat.g"} M291 P"Mise aux origines..." R"Changement du Filament" S0 T30 G28 ; homing M291 P"Mise à la position de purge..." R"Changement du Filament" S0 T30 G1 X253 Y-5.9 F12000 ; aller à la position de purge while heat.heaters[1].current <= heat.heaters[1].active M291 P"Chauffes en cours... Veuillez Patienter..." R"Changement du Filament" S0 if sensors.filamentMonitors[0].status == "ok" M291 P"Déchargement en cours, veuillez patienter..." R"Changement du Filament" S0 T30 G1 E5 F150 ;Extrude 10mm filament at low speed ;G1 E-15 F500 ;Retract 15mm filament at low speed G1 E-100 F3600 ;Retract 100mm filament at high speed M400 while sensors.filamentMonitors[0].status == "ok" M291 P"Merci de retirer le filament." R"Changement du Filament" S0 T30 G4 S0.1 ;attendre 0.1s pour éviter de surcharger le processeur while true if sensors.filamentMonitors[0].status == "noFilament" M291 P"Filament déchargé, merci d''insérer le nouveau filament." R"Changement du Filament" S0 T30 G4 S0.1 ;attendre 0.1s pour éviter de surcharger le processeur else break else while true if sensors.filamentMonitors[0].status == "noFilament" M291 P"Aucun filament, merci d''insérer un filament." R"Changement du Filament" S0 T30 G4 S0.1 ;attendre 0.1s pour éviter de surcharger le processeur else break G4 S0.7 ;attendre 1s pour laisser le temps d'insérer le filament M291 P"Chargement en cours...." R"Changement du Filament" S0 M106 S255 ;mise en route du ventilateur pour refroidir la purge G1 E65 F3600 ; extrude 65mm at high speed M83 ; mode d'extrusion relative G1 E20 F200 ; extrude 10mm at low speed M400 M98 P"/macros/Filament/Purge.g" G1 Z0.1 F200 ;Essuyer la purge G1 X0 F12000 G1 Z20 F3000 M106 S0 M291 P"Filament chargé. Merci de définir le nouveau filament." R"Changement du Filament" S2 M291 P"Déplacez l''axe X pour choisir le filament voulu. 0 = Aucun Changement / 1 = PLA / 2 = PETG / 3 = TPU" R"Changement du Filament" S2 X1 if move.axes[0].machinePosition < 1 elif move.axes[0].machinePosition < 2 M702 M701 S"PLA" elif move.axes[0].machinePosition < 3 M702 M701 S"PETG" elif move.axes[0].machinePosition < 4 M702 M701 S"TPU" M291 P{"""" ^ move.extruders[0].filament ^ """ a bien été défini comme filament chargé."} R"Changement du Filament" S2 M98 P{"0:/filaments/" ^ {move.extruders[state.currentTool].filament} ^ "/heat.g"}
-
@LB
For whatever reason my version of RRF seems happy finding these paths (3.1.1, Duet 3 with a Pi attached). I've actually tried to use relative paths, but found that they are all relative to
/sys/
. If you are having trouble there is an absolute path option forM98
that starts from0:/some/path/macros/filaments/loadFilament.g
.Yes this it totally automatic from the GUI!
I had another idea last night that im going to try: maybe the filament name is somewhere in the Object Model after
M703
gets run and I don't have to use that extra tool to store the filament name string. I'll work on it some more today. -
The filament name is available in the OM as move.extruders[n].filament.
-
Thanks everyone for the props and the new information. I was able to get rid of that "virtual tool" and use the object model for the filament name. I tried
M703
but it doesn't work in the filament load script, so I have to execute the config file with a macro call instead.So now that I lost my virtual tool I needed somewhere to store the temprature and feed rate. I looked into this idea of "virtual axes" so I could store the filament settings per-tool rather than globally. This took some trial and error and I still have some warnings in the console but it work. And once I had gone that far I didn't see any reason not to do the same thing to tool changing, no reason that cant be just 3 macros either!
I'm using the A axis to store the filament temp, B for the slow feed rate, U and V to hold the machine absolute coordinates of each tool and S to hold the nozzle diameter. then I use expressions like
{tools[state.currentTool].offsets[7]}
andY{tools[state.nextTool].offsets[8]}
to get the setting from the appropriate tool in the macros.Firmware 3.2 fixes the bug with
G1
commands not accepting expressions so now the feed rate setting works as well and my flexibles wont shoot out the side of the extruderI'm not going to attempt to post all of the code here, that's what github is for: https://github.com/garethky/E3D-ToolChanger-Configuration/compare/8ee9b057f122e24b47c47b57480a3bb26d76375d..206529f2f50617df253abac9db369fd81ff42fc8
Cheers!
-
I got 2 questions for giving the approach to only have 1 load.g/unload.g with in the general filaments folder a try (also that needs a workaround with a macro in each filament to point to the general file):
1st
for the individual load.g that is more or less only a macro-call-file for the general parametric ones you had post the exampleM98 P"/filaments/PLA/config.g" ; the filament config isn't loaded until AFTER this macro runs, but we need the variables set now
With the new move.extruders[n].filament that could be something like
M98 P"/filaments/move.extruders[0].filament/config.g"
Or wouldn´t just M703 be sufficient
?2nd
How can I fetch the nozzle-temperature from the material (beside calling M703 of course), now I have:G10 S235 ; Set current tool temperature direct S___
-> Would that become something like:
G10 S{heat.heaters[1].active} ;fetch from what is in filament-config.g of selected filament
?
3rd
And for the temperature-reach-wait nowM116 P0
-> would that be something like:
M116 P{tools[0]} ; wait for temps to be reached - for tool selected
?
Looking at the object model that comes with RRF3.2, but I will only learn how to use it - every help appreciated
-
#1 That's a good optimization! I upgraded to 3.2 firmware and now it seems that the Filament name is not set in the object model when load gets called. I haven't had a chance to investigate further. M703 didn't work there on 3.1.1. I have to go back and experiment again in 3.2
#2 I have 2 ideas:
First idea: If you don't have a tool selected (maybe its the beginning of the print) then this should work:T-1 T2 P0 ; set the active tool but do not run the tool change macors M703 ; do whatever needs doing with the filament settings T-1 P0
This should also be a durable solution long term.
Second idea: storing per-tool filament settings in the work offset system. I got started with some of the ideas over in this thread: https://forum.duet3d.com/topic/20681/virtual-axis-break-stall-detection/6?_=1610137141350
My end goal with this is to have enough information to write a Live-Z calibration print that uses the math expressions for the extrusion lengths so they adapt to the filament diameter and nozzle diameter to print an accurate test pattern regardless of machine configuration. This doesn't require that I have access to multiple tool temperatures at the same time, so M703 will work for me.
#3 In my
tpost.g
macro I have this to handle getting the tool up to temp:; wait for hot end temp M116 P{state.currentTool}
-
@LB
1st
it'll be that to load the config.g of the current loaded filamentM98 P{"0:/filaments/" ^ {move.extruders[state.currentTool].filament} ^ "/config.g"}
2nd
You can do as i've done, create a heat.g file in each filament, in wich you put your G10 (and maybe the bed temp also, i've separate the two and made a file that call the two macros) so you'll just have to callM98 P{"0:/filaments/" ^ {move.extruders[state.currentTool].filament} ^ "/heat.g"}
3rd
@garethky line is the way to go -
Thanks!
1.
yeah now in my filament specific load/unload there is just a macro that points to the one and only load/unload for all the filaments since I get the temperatures from the filament-config.g
2.
have to think about it or even better: try it out
3.
THANKS! Now it works! -
Thanks!
1.
Thanks now it works but I had to take out the last "/" before config.g
2.
Yep
We are some sort of "brothers in lazyness" I guess
3.
What? I do not get it... -
@LB the 3 was just saying that the @garethky gcode was right (sorry if it have a meaning or something that i don't understand, i haven't the greatest english x) )
It's weird that you had to take the last "/" before config.g, it's working for me ^^ -
@Krohm-Koala said in load unload macro with endless loop and cancel condition:
@LB the 3 was just saying that the @garethky gcode was right (sorry if it have a meaning or something that i don't understand, i haven't the greatest english x) )
It's weird that you had to take the last "/" before config.g, it's working for me ^^YOU are correct here -> That was an error of me, because when no filament is yet selected ("empty tool") that just threw an error SORRY -> YOU are correct here!
-
@LB Nice that it works now
-
@Krohm-Koala said in load unload macro with endless loop and cancel condition:
@LB Nice that it works now
It is not "really" working clean and cool, rather a big "workaround" to get it done somehow, but let´s see how this all evolves the next month.
-
@LB How does it look now ? and what's left to do ? It's really cool to see how everyone do it their ways
-
I have upgraded to 3.2 final and I no longer get the filament name in
move.extruders[n].filament
insideload.g
. This now mirrors the behavior of tool changes where there is no tool selected whentpreN.g
is called. I'm not against the logical consistency of this. But for tool changes we havestate.nextTool
which contains the tool being loaded, we don't have a similar concept for filaments. I think we should ask for amove.extruders[n].nextFilament
variable in the Object Model.Using this to find the filament macros directory is a neat idea. Although what we have essentially done is eliminate the need for M703 almost entirely.
-
Still works for me
1/10/2021, 10:53:33 AM echo move.extruders[0].filament ABS
Board: Duet 2 WiFi (2WiFi)
Firmware: RepRapFirmware for Duet 2 WiFi/Ethernet 3.2 (2021-01-05)
Duet WiFi Server Version: 1.25Are you sure that there is a filament recorded in filaments.csv?
If there is a filament loaded in all tools the next tool is accessable using
echo move.extruders[state.nextTool].filament