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

    Conditional Code For daemon.g

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    10
    683
    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.
    • Topherundefined
      Topher
      last edited by

      I have a few tasks for daemon.g if I can get some help working out the bugs, that would be awesome! First up, I run a lot of different printers here so to streamline my slicer would save me some time as fans have different names in my case. Im trying to run a part fan based on height however I'm getting an error:

      if job.layer >= 2	; Set part fan to 100% when print gets to layer 2
      	M106 P1 S255
      

      Error: in file macro line 1 column 19: meta command: cannot convert operands to same type

      I believe this error is in reference to the "2" in my argument. What am I doing wrong?

      OwenDundefined 1 Reply Last reply Reply Quote 0
      • OwenDundefined
        OwenD @Topher
        last edited by

        @leckietech

        job.layer will be null at the start of the print.

        You need to allow for that

        something like this should work

        if job.layer = null
              M106 P1 S0
        elif job.layer > 2
             M106 P1 S255
        

        On another note, daemon.g by default only runs once every 10 seconds,
        If you need to sample faster than that then you need to set up a loop within daemon.g

        Topherundefined 1 Reply Last reply Reply Quote 2
        • Topherundefined
          Topher @OwenD
          last edited by

          @owend said in Conditional Code For daemon.g:

          @leckietech

          job.layer will be null at the start of the print.

          You need to allow for that

          Ah! Makes so much sense, I knew it was going to be simple!

          On another note, daemon.g by default only runs once every 10 seconds,
          If you need to sample faster than that then you need to set up a loop within daemon.g

          Thank you for the tip!
          Next up, Ive looked throughout the Object Model and cant seem to find a node that keeps track of files being uploaded. We have so many printers here and so may operators, often we have someone run a print from an sd card while someone else is uploading. So logical solution: Change the LCD color and put a message on the screen "uploading file". I will also need a way to display on the screen if the file failed to upload - as this is something that happens here all the time.
          Any suggestions on how to achieve this?

          OwenDundefined 1 Reply Last reply Reply Quote 0
          • OwenDundefined
            OwenD @Topher
            last edited by

            @leckietech
            I can't see anything in the object model that would indicate when an upload is in place.
            If it were anywhere I would have thought it would have been in state.status, but it doesn't appear so.

            About the only way I can think of achieving what you want might be to use M559 or M560 to upload the file.
            I think you'd have to have a script/program that first sent M560 to start the upload, then maybe send M291 to display a message, then send each line of your G Code file, finally follweed by <!-- EoF --> or M29 as required and M292 to close the message.

            Topherundefined 1 Reply Last reply Reply Quote 0
            • Topherundefined
              Topher @OwenD
              last edited by Topher

              @owend said in Conditional Code For daemon.g:

              About the only way I can think of achieving what you want might be to use M559 or M560 to upload the file.

              Thanks for the response. I did look into this, we load our files from the desktop, our phones, ipads, all kinds of stuff and we have thousands of files so loading the file by Gcode command or scrips might not be the way. I did however come up with another way to solve half the problem, at least.

              I've made a system file: printBEGIN.g
              We use Simplify3d - in the post-processing window Im using the following script

              {REPLACE "G90" "G90 ; This is a trigger in post for M98 printBEGIN\nM98 P"printBEGIN.g" "}

              G90 is the first command of the start of the print and there is only one for the entire slice file. This will point to M98 P"printBEGIN" which the very first line of that file starts with

              M291 S3 R"Ready to run file?" P{job.file.fileName}

              This will at least halt the printer and display the file via the 12864 screen on the printer itself as well as any DWC device running. The only issue is: S3D doesn't like the command with quotations in it.

              The post command:
              {REPLACE "G90" "G90 ; This is a trigger in post for M98 printBEGIN\nM98 P"printBEGIN.g" "}

              Gcode output:

              G90 ; This is a trigger in post for M98 printBEGIN
              M98 P
              

              The post-processor skips over the "printBEGIN" portion in quotes.
              Any ideas?

              dc42undefined 1 Reply Last reply Reply Quote 0
              • dc42undefined
                dc42 administrators @Topher
                last edited by dc42

                @leckietech you might need to replace each double quote in the replacement string by something that the post processor will recognise as being part of the replacement string. That might be \" or "".

                Duet WiFi hardware designer and firmware engineer
                Please do not ask me for Duet support via PM or email, use the forum
                http://www.escher3d.com, https://miscsolutions.wordpress.com

                Topherundefined 1 Reply Last reply Reply Quote 0
                • Topherundefined
                  Topher @dc42
                  last edited by

                  @dc42 I tried every combination of this, still no go. Jumped over to the simplified forums, seems it cant be done.

                  dc42undefined 1 Reply Last reply Reply Quote 0
                  • dc42undefined
                    dc42 administrators @Topher
                    last edited by dc42

                    @leckietech are you running with attached SBC? If you are not, then you can omit the quotes around the filename assuming that it doesn't contain any spaces, semicolons etc.

                    Alternatively, create a global variable in config.g:

                    global printBeginMacro = "printBEGIN.g"
                    

                    then in your script you can use:

                    {REPLACE "G90" "G90 ; This is a trigger in post for M98 printBEGIN\nM98 P{printBeginMacro}}
                    

                    if S3D doesn't mind the embedded { }.

                    Yet another way: pick an unused M-command number such as M990, rename printBegin.g to M990.g, make sure it is in /sys, and use M990 instead of M98 P"printBEGIN.g".

                    Duet WiFi hardware designer and firmware engineer
                    Please do not ask me for Duet support via PM or email, use the forum
                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                    Topherundefined 1 Reply Last reply Reply Quote 0
                    • Topherundefined
                      Topher @dc42
                      last edited by Topher

                      @dc42

                      Yet another way: pick an unused M-command number such as M990, rename printBegin.g to M990.g, make sure it is in /sys, and use M990 instead of M98 P"printBEGIN.g".

                      I had no idea this could be done! Thanks so much! These tips will get put to use in other ways, too, now that I know about them! Is it possible to use G commands as well? ie, G110

                      Topherundefined 1 Reply Last reply Reply Quote 0
                      • Topherundefined
                        Topher @Topher
                        last edited by

                        Is it possible to use G commands as well? ie, G110

                        Answered my own question - G and M commands can be used. They also can not be in their own folder ie a folder calledCustom Gcodes

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Unless otherwise noted, all forum content is licensed under CC-BY-SA