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

    2 different brushes for 4 printheads

    Scheduled Pinned Locked Moved Solved
    Tuning and tweaking
    6
    19
    578
    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.
    • jay_s_ukundefined
      jay_s_uk @Mike 1
      last edited by

      @MIke-1 why not call the macro as part of tpost?

      Otherwise query the current tool in the object model and then run the appropriate commands

      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

      Mike 1undefined 1 Reply Last reply Reply Quote 0
      • Mike 1undefined
        Mike 1 @jay_s_uk
        last edited by

        @jay_s_uk

        Oh, I am not sure if I understand the sentence correctly. Do you mean that I shall call the makro in one of the tool changes skripts? That's what I am doing now. But I would like to wipe on layer change controlled by superslicer.

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

          @MIke-1 then call the macro at later change and have an if statement to check the current too in the object model and if tool 0 and 1 do this else if 2 or 3 do that

          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

          Mike 1undefined 1 Reply Last reply Reply Quote 0
          • Mike 1undefined
            Mike 1 @jay_s_uk
            last edited by

            @jay_s_uk said in 2 different brushes for 4 printheads:

            rrent too in the object model and if tool 0 and 1 do this else if 2 or 3 do that

            That's what I need, but how does it work?

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

              @MIke-1 see https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands and https://docs.duet3d.com/en/User_manual/RepRapFirmware/Object_Model

              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

              Mike 1undefined 1 Reply Last reply Reply Quote 1
              • Mike 1undefined
                Mike 1 @jay_s_uk
                last edited by

                @jay_s_uk

                OK, did my best and got this error message:

                T0
                Error: in file macro line 2 column 21: meta command: unknown value 'active'

                if tools[0].state = active
                M98 P"brush_right.g"
                elif tools[1].state = active
                M98 P"brush_left.g"
                elif tools[2].state = active
                M98 P"brush_right.g"
                elif tools[3].state = active
                M98 P"brush_left.g"
                else
                continue

                OwenDundefined dc42undefined 2 Replies Last reply Reply Quote 0
                • Phaedruxundefined
                  Phaedrux Moderator
                  last edited by

                  are you using indentation with your statements?

                  Perhaps you could use

                  state.currentTool
                  Number of the currently selected tool or -1 if none is selected
                  

                  and then check for the tool number and act accordingly.

                  Z-Bot CoreXY Build | Thingiverse Profile

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

                    @MIke-1
                    Try something like this
                    The indentation is important

                    if state.currentTool != -1 ; check if a tool selected 
                      if state.currentTool < 2 ; must be 0 or 1
                        M98 P"leftbrush.g"
                      else
                        M98 P"rightbrush.g ; must be 2 or higher
                    
                    Mike 1undefined 1 Reply Last reply Reply Quote 0
                    • dc42undefined
                      dc42 administrators @Mike 1
                      last edited by dc42

                      @MIke-1 the reason that doesn't work is that you need to put "active" in double quotes. But an easier way is to use state.currentTool as @OwenD suggests.

                      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

                      Mike 1undefined 1 Reply Last reply Reply Quote 0
                      • Mike 1undefined
                        Mike 1 @OwenD
                        last edited by

                        @OwenD
                        Oh, I can't use this version because my tools are alternating.

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

                          @dc42
                          Oh thanks! Now it is working fine!

                          You are all awsome!

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

                            @MIke-1 said in 2 different brushes for 4 printheads:

                            @OwenD
                            Oh, I can't use this version because my tools are alternating.

                            Apologies
                            I missed that

                            Mike 1undefined 1 Reply Last reply Reply Quote 0
                            • Mike 1undefined
                              Mike 1 @OwenD
                              last edited by

                              @OwenD
                              Thanks anyway!

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

                                @MIke-1
                                My clumsy effort was mainly to prompt you to try to condense your code if possible.
                                Whilst manually creating an if / elif for every tool works, it's often more efficient in code and easier to read if you look for a pattern that will work regardless of the number of tools (or heaters or whatever).
                                In your case, one pattern is whether the tool selected is an odd or even number.
                                We can check that using mod()
                                What I should have posted was something like this.

                                if state.currentTool != -1 ; check if a tool selected 
                                  if mod(state.currentTool,2) = 0 ; tool must be even number or zero
                                    M98 P"brush_right.g"
                                  else
                                    M98 P"brush_left.g" ; must be odd numbered tool
                                else
                                  echo "no tool selected"
                                

                                You do however have to ensure that there is indeed a tool selected, otherwise state.currentTool is -1 and it would resolve to false and run the brush left macro
                                mod(-1,2)=0 is false
                                Whereas in your code, you don't have a condition for -1, so that wouldn't occur.

                                If the code works, it's not wrong and it terms of lines of code there's not much difference in this case, so there's no reason for you to change what you have now.

                                Mike 1undefined 2 Replies Last reply Reply Quote 1
                                • Mike 1undefined
                                  Mike 1 @OwenD
                                  last edited by

                                  @OwenD

                                  Sorry for the late reply, I did not expect an answer.

                                  But your code hepled me to better understand how the coding here works 🙂

                                  I used the first line to make homing more save, as I can only do homing without a tool attached to the printheard.

                                  I will keep my code because it ist more simpple to read and allows me to select a 3rd or 4th macro with different bush settings. It might get interesting, if I will use a vulacono hotened in the future.

                                  Thanx!

                                  1 Reply Last reply Reply Quote 0
                                  • Mike 1undefined
                                    Mike 1 @OwenD
                                    last edited by

                                    @OwenD said in 2 different brushes for 4 printheads:

                                    if state.currentTool != -1 ; check if a tool selected
                                    if mod(state.currentTool,2) = 0 ; tool must be even number or zero
                                    M98 P"brush_right.g"
                                    else
                                    M98 P"brush_left.g" ; must be odd numbered tool
                                    else
                                    echo "no tool selected"

                                    Can I use 2 commands after an if? How do I know when the if ends? I am missing () or endif to understand when something ends 🙂

                                    gloomyandyundefined 1 Reply Last reply Reply Quote 0
                                    • gloomyandyundefined
                                      gloomyandy @Mike 1
                                      last edited by

                                      @MIke-1 The meta commands in RRF use indentation to indicate which statements are part of the body for conditional statements so for instance

                                      if state.currentTool != -1
                                          G28 X
                                          G28 Y
                                      

                                      Makes both home commands conditional but in

                                      if state.currentTool != -1
                                          G28 X
                                      G28 Y
                                      

                                      only the G28 X is conditional

                                      See: https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#conditional-construct

                                      Mike 1undefined 1 Reply Last reply Reply Quote 0
                                      • Mike 1undefined
                                        Mike 1 @gloomyandy
                                        last edited by

                                        @gloomyandy
                                        Thanx!

                                        Topic can be closed 🙂

                                        1 Reply Last reply Reply Quote 0
                                        • Phaedruxundefined Phaedrux marked this topic as a question
                                        • Phaedruxundefined Phaedrux has marked this topic as solved
                                        • First post
                                          Last post
                                        Unless otherwise noted, all forum content is licensed under CC-BY-SA