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

    How to make a loop of a Output_Pin ON and OFF?

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    5
    11
    485
    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.
    • FBGundefined
      FBG
      last edited by FBG

      Hello everybody,

      I need to make a thing that I think that is easy but for a newbie as me not...

      While I am printing I need that a output pin turn ON during 2 seconds and off 10 seconds, continuously while I am printing
      ON 2 seconds
      OFF 10 seconds
      ON 2 seconds
      OFF 10 seconds
      ...loop... until finish the printing

      //
      I know how create a PIN output and turn on manually with the code, but not know how to make this "program" and start in loop while the printer is printing...

      How I can make this?

      Best Regards

      jay_s_ukundefined 1 Reply Last reply Reply Quote 0
      • jay_s_ukundefined
        jay_s_uk @FBG
        last edited by jay_s_uk

        @FBG you'll want to use a while loop in daemon.g
        https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands#loop
        something like

        while state.status != "idle"
          M42 P0 S1
          G4 S2
          M42 P0 S0
          G4 S10
        

        edited to swap <> for !=

        Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

        FBGundefined 1 Reply Last reply Reply Quote 1
        • FBGundefined
          FBG @jay_s_uk
          last edited by

          @jay_s_uk I try but....
          Error: Failed to read code from macro daemon.g: Failed to evaluate "state.status <> idle": expected an expression

          This is my daemon file:

          while state.status <> idle
          M42 P5 S1
          G4 S2
          M42 P5 S0
          G4 S10
          
          jay_s_ukundefined OwenDundefined dc42undefined 3 Replies Last reply Reply Quote 0
          • jay_s_ukundefined
            jay_s_uk @FBG
            last edited by

            @FBG you missed the " around idle

            Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

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

              @FBG
              Compare what you posted with @jay_s_uk 's sample.
              You missed the quoted string and have not indented the following code

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

                @FBG also replace <> by !=

                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

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

                  @dc42 said in How to make a loop of a Output_Pin ON and OFF?:

                  @FBG also replace <> by !=

                  Haha. Missed that! 🧑‍🦯 🤪

                  1 Reply Last reply Reply Quote 0
                  • FBGundefined
                    FBG
                    last edited by

                    Thanks a lot!

                    Now is working properly!!

                    1 Reply Last reply Reply Quote 0
                    • T3P3Tonyundefined T3P3Tony marked this topic as a question
                    • T3P3Tonyundefined T3P3Tony has marked this topic as solved
                    • FBGundefined
                      FBG
                      last edited by

                      Sorry dears, not solved.
                      I was thinking that is working because don't show error but now say:

                      Error: Failed to read code from macro daemon.g: empty while loop detected in line 2

                      My code is:

                      while state.status  != "idle"
                      M42 P5 S1
                      G4 S2
                      M42 P5 S0
                      G4 S10
                      
                      jay_s_ukundefined apakundefined 2 Replies Last reply Reply Quote 0
                      • jay_s_ukundefined
                        jay_s_uk @FBG
                        last edited by

                        @FBG You haven't indented the code

                        Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

                        1 Reply Last reply Reply Quote 0
                        • apakundefined
                          apak @FBG
                          last edited by

                          @FBG said Need to indent the code

                          My code is:

                          while state.status  != "idle"
                              M42 P5 S1
                              G4 S2
                              M42 P5 S0
                              G4 S10
                          
                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Unless otherwise noted, all forum content is licensed under CC-BY-SA