Creating a timed fan Marco and Meta
-
@infiniteloop
Thanks for your help. I am going to attempt to write up some code tonight and implement in the morning.
I think checking every 10 seconds will be fine. The way I have the feed tube set up right now there will be a certain amount that goes from the large hopper to the tube. This is determined by gravity and a bend in the tubing. The compressed air just pushes it from holding to a small hopper at the extruder. (I don't want to have too much weight with the extruder). I plan to do some experimenting tomorrow to figure out exactly the weight of the pellets/blast and then calculate the weight of plastic extruded out of my 2.75mm nozzle and use that for the mm of extrusion.Thanks for the help. My build is a 3000x1500 build. I think by the end my build volume will be 1000x2400x1000. I am using a re3d pellet extruder and so far am printing around .75kg/hr.
Here is a link if you want to see my latest video talking about some of the components.
https://youtu.be/e6AMm3SlXuw -
@kmoore Hello Kyle, that’s a really impressive machine. It reminded me of Apple’s "Think different" campaign with it’s dedication to people like you: "This is for the crazy ones …"
After watching the video, I’m sure you know what you do. So here are some code snippets you can start with (at your own risk).
The global variable holding the filament progress should be initialised at the end of config.g:
global filamentProgress = 0.0
In start.g, insert the line:
set global.filamentProgress = job.file.filament[0]
This can be tricky, as your slicer might want to prime the hotend with a lot of filament - maybe you need to blow some pellets into the pipe at this stage to account for the priming.
Another thing which can happen is that your slicer resets the mm count to 0 after start.g has already be run. But I think the following code will be able to cure any initialisation problems.
The code for the daemon should be put into its own macro (which is then called from daemon.g), let’s call it "filamentMonitor.g". I would place this macro into the sys directory.
; filamentMonitor.g ; ; Check filament progress, feed pellets if needed if {{global.filamentProgress + 1000.0} <= job.file.filament[0]} ; 1000 mm are done? Then … set global.filamentProgress = {job.file.filament[0] + 1000.0} ; … prepare for the next meter M106 P0 S255 ; … start the compressor (fan 0) G4 S3 ; … wait 3 seconds M106 P0 S0 ; … stop the compressor
Note that all lines following the "if" statement must be inserted.
Finally, put this into daemon.g (create that file if missing):
M98 P"filamentMonitor.g"
I’m sorry that, for the next couple of hours, I cannot test the code for syntactical errors - my duet is busy until tomorrow (which happens to arrive earlier here than in the states).
-
@kmoore As you plan to apply different nozzle sizes, measuring the length of the extruded filament will not always match the needed amount of pellets. In the long run, you could install some kind of "weight watcher" near the hotend: a small pellets reservoir which closes a switch if it runs low. That signal, in turn, can trigger the compressor - just modify the "if" statement in filamentMonitor.g to look for the switch state.
-
@infiniteloop
I created a test macro that just opens the air valve for 3 seconds and closes it. It worked great.When I implemented the suggested changes to the config.g file start.g file daemon.g file and created the filamentmonitor.g file I am getting an error notice.
#1 - M98P”0:/macros/filamentmonitor.g”
Error: in file macro line 9 column 43: meta command: array index out of boundsI am not sure if I am getting this error because it is conditional on the start of a print and the print hasn't started yet.
Thanks for you help.FYI - after some testing the compressed air system pushes 75g of pellets every operation cycle, which equates to 9500mm of extrusion.
-
@kmoore
When you first boot up, daemon.g will begin to run immediately, but the job.file.filament array is empty.
Therefore you can't yet address job.file.filament[0]
You'll need to add some code to not call your macro in this case
Something likeif #job.file.filament > 0 M98 P"path-to-macro"
Note. Untested
-
@kmoore said in Creating a timed fan Marco and Meta:
#1 - M98P”0:/macros/filamentmonitor.g”
Error: in file macro line 9 column 43: meta command: array index out of boundsAs @OwenD points out, the
job.file.filament
array is empty when daemon.g starts running. I suggest to add these two lines in front of all other gCodes in filamentMonitor.g:if job.file.fileName == null ; no job file around? M99 ; exit
This ensures that the filament check is only performed if there is a print file around. This time, I could even test it: works.
One other note: I notice that you have put filamentMonitor.g into the macros/ directory. I'm fine with that, but in this place, it adds up to the potentially long list of user-accessible commands. To keep that clean, I prefer to place macros who are only called by the system exactly there: in sys/. Admittedly, this directory can become quite crowded, too.
-
@infiniteloop
I just started a print and note that job.file.filament[0] seems to be the total filament used for the job. It's 30192.7 in this caseYou may need to use
move.extruders[0].position instead -
@owend said in Creating a timed fan Marco and Meta:
You may need to use
move.extruders[0].position insteadYou're right. Thank you for keeping an eye on this
-
@infiniteloop @OwenD
Thank you both for all of your help. I've implemented changes and I am not getting errors any more. I wont be able to print until tomorrow due to severe weather in my area.But I wanted to post the scripts below to make sure I am not missing anything.
At the end of config.g
global move.extruders[0].position=0.0
; daemon.g
; Constantly runs in background to check outputs etc
;
M98 P"filamentmonitor.g"
; filamentmonitor.g
; Check filament progress, feed pellets if needed
if job.file.fileName == null ; no job file around?
M99 ; exit
if {{global.filamentProgress + 11500.0} <= move.extruders[0].position} ; 11500 mm are done? Then …
set global.filamentProgress = {move.extruders[0].position + 11500.0} ; … prepare for the next meter
M106 P0 S255 ; … start the compressor (fan 0)
G4 S3 ; … wait 3 seconds
M106 P0 S0 ; … stop the compressor
; start.g
; runs immediately before any slicer created gcode
set global.filamentProgress = move.extruders[0].positionI am not sure how you are posting gcode script so mine is just copied and pasted. There are proper indents after the if statements in my files.
-
@kmoore Please keep the original line in config.g:
global filamentProgress = 0.0
Every other bit of the code you just posted is fine. Hm, except of the comment "… prepare for the next meter" which you've measured to be 11500 mm long
I am not sure how you are posting gcode script
We use the icon </> from the header of the comments editor which inserts a couple of apostrophes to tag codelines. If you remove all line breaks from the tagged string,
you get this here
which we usually apply to single gCodes. -
All looks good provided that your actual files are indented correctly
Otherwise each command will just execute sequentiallyif job.file.fileName == null M99 if {{global.filamentProgress + 11500.0} <= move.extruders[0].position} ; set global.filamentProgress = {move.extruders[0].position + 11500.0} M106 P0 S255 G4 S3 M106 P0 S0
-