• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Creating a timed fan Marco and Meta

Scheduled Pinned Locked Moved
Gcode meta commands
3
13
626
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    kmoore
    last edited by kmoore 4 Apr 2022, 21:16 4 Apr 2022, 21:15

    Hello,
    For my giant cartesian printer I need to create a macro and Meta to open a compressed air valve every 1000mm of extrusion to feed the pellets to the extruder.

    Running a Duet 3 6HC. I have the compressor triggering off of a SSR which I have wired to out 7. I have that output configured to Fan 0.

    I was hoping:

    M106 P0 S255 B3;
    M106 P0 S0

    would turn it on for three seconds and turn it off.

    Is there a delay gcode that I could add in-between the two 106 commands that would add a specific delay?

    Then I need to start my research on creating a Meta code that will fire this macro every 1000mm of extrusion.

    Thank you for your help.
    -Kyle

    undefined 1 Reply Last reply 4 Apr 2022, 22:48 Reply Quote 0
    • undefined
      infiniteloop @kmoore
      last edited by infiniteloop 4 Apr 2022, 22:58 4 Apr 2022, 22:48

      @kmoore If your firmware is at least RRF 3.3, you can put your code into the system macro daemon.g which is called every ten seconds.

      As a prerequisite, you might want to initialise a global variable in your start.g macro with the state of job.file.filament[0] which tells the filament consumption of extruder drive 0 in mm. For an overview how to access the printer's object model, read this.

      Within daemon.g (insufficient details can be found here), you monitor the state of job.file.filament[0], until the value is 1000 larger than stored in your global var. That’s the time to trigger the compressor.

      After that, update your global var with the current state of job.file.filament[0] to prepare the next iteration.

      With G4 S3, you then wait 3 seconds until it’s time to switch the compressor off.

      Please note that this is just an outline of the steps to take - many details remain to be solved. One problem may be the timing: is it sufficient to look at filament progress every 10 seconds? What other edge conditions must be considered? Pellets under- or overflow, perhaps?

      I will be able to supply you with some gCodes, but before that, you should get an idea of the process, because: if something goes wrong, it's your printer who suffers. By the way: what the hell of a beast is that? Sounds interesting …

      undefined 1 Reply Last reply 5 Apr 2022, 04:07 Reply Quote 2
      • undefined
        kmoore @infiniteloop
        last edited by 5 Apr 2022, 04:07

        @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

        undefined 2 Replies Last reply 5 Apr 2022, 11:33 Reply Quote 0
        • undefined
          infiniteloop @kmoore
          last edited by 5 Apr 2022, 11:33

          @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).

          1 Reply Last reply Reply Quote 1
          • undefined
            infiniteloop @kmoore
            last edited by 5 Apr 2022, 13:05

            @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.

            undefined 1 Reply Last reply 6 Apr 2022, 00:29 Reply Quote 0
            • undefined
              kmoore @infiniteloop
              last edited by 6 Apr 2022, 00:29

              @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 bounds

              I 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.

              undefined undefined 2 Replies Last reply 6 Apr 2022, 07:20 Reply Quote 0
              • undefined
                OwenD @kmoore
                last edited by OwenD 4 Jun 2022, 07:22 6 Apr 2022, 07:20

                @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 like

                if #job.file.filament > 0
                M98 P"path-to-macro"

                Note. Untested

                1 Reply Last reply Reply Quote 0
                • undefined
                  infiniteloop @kmoore
                  last edited by 6 Apr 2022, 08:36

                  @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 bounds

                  As @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.

                  undefined 1 Reply Last reply 6 Apr 2022, 08:41 Reply Quote 0
                  • undefined
                    OwenD @infiniteloop
                    last edited by 6 Apr 2022, 08:41

                    @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 case

                    You may need to use
                    move.extruders[0].position instead

                    undefined 1 Reply Last reply 6 Apr 2022, 08:55 Reply Quote 1
                    • undefined
                      infiniteloop @OwenD
                      last edited by 6 Apr 2022, 08:55

                      @owend said in Creating a timed fan Marco and Meta:

                      You may need to use
                      move.extruders[0].position instead

                      You're right. Thank you for keeping an eye on this 😊

                      undefined 1 Reply Last reply 6 Apr 2022, 17:28 Reply Quote 0
                      • undefined
                        kmoore @infiniteloop
                        last edited by kmoore 4 Jun 2022, 17:29 6 Apr 2022, 17:28

                        @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].position

                        I 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.

                        undefined 1 Reply Last reply 6 Apr 2022, 18:22 Reply Quote 0
                        • undefined
                          infiniteloop @kmoore
                          last edited by 6 Apr 2022, 18:22

                          @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.

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            OwenD
                            last edited by 6 Apr 2022, 19:46

                            All looks good provided that your actual files are indented correctly
                            Otherwise each command will just execute sequentially

                            if 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
                            1 Reply Last reply Reply Quote 0
                            • madeinta1wanundefined madeinta1wan referenced this topic 23 Jan 2024, 18:36
                            1 out of 13
                            • First post
                              1/13
                              Last post
                            Unless otherwise noted, all forum content is licensed under CC-BY-SA