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

    How can I create a toggle macro?

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    7
    16
    1.4k
    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.
    • PaulHewundefined
      PaulHew @OwenD
      last edited by

      @owend said in How can I create a toggle macro?:

      if fans[10].actualValue = 1

      Thank You for your reply.
      I did not know there was a Meta Commands section in the forum.

      I have learnt and understand a little more now, thank you.

      Regards,

      Paul.

      RailCore II - Duet Mini + 1LC, Voron V0.1 - Duet Mini
      Voron 2.4 disassembled..... Waiting for the RailCore Mini....

      1 Reply Last reply Reply Quote 0
      • Yaoundefined
        Yao @dc42
        last edited by Yao

        @dc42 is something like this (led toggle on/off with if-else macro) also possible for OUT1 on duet3 board ?
        I can't seem to get it to work...
        Thanks.

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

          @yao
          Yes it is.
          Please post what you have so far.
          Both config.g and macro so we know how you're configuring the pin and how you're controlling it.

          Yaoundefined 1 Reply Last reply Reply Quote 0
          • Yaoundefined
            Yao @OwenD
            last edited by Yao

            @owend Hi, thanks for your response,

            in the config:

            ; white led chamber light ALL
            M950 P25 C"out1" ;use main out1 for full Chamber light
            M42 P25 S0.5 ;on 50%

            this can be adjusted with:
            ; chamber lights hi
            M42 P25 S1
            ; chamber lights low
            M42 P25 S0.02

            I was trying:
            if out1[25].actualValue >= 0.8
            M42 P25 S0.02
            else
            M42 P25 S1

            whatever I try i get unknow value 'out1'

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

              @yao
              What board are you using?
              On my Duet 2 running RRF3.4 , the output port limit seems to be 20.
              Do you really need it to be 25?
              Try using a lower number

              And your code should look like
              if state.gpOut[nn].pwm >= 0.8

              Yaoundefined 1 Reply Last reply Reply Quote 1
              • Yaoundefined
                Yao @OwenD
                last edited by

                @owend !!! that works!
                I am running a duet3. my lights start at P20.
                originally from the 3HC (hence the P20 range) but I ran out of connections so moved back to the main. for clarity for myself I kept the lights within the P20 range.

                using the following now:

                if state.gpOut[25].pwm >= 0.8
                M42 P25 S0.02
                else
                M42 P25 S{state.gpOut[25].pwm + 0.2}

                I now have 5 steps to full brightness and then it toggles to almost off.

                Thanks for this. I have to investigate more into correct names and designations for usage of pins. I am not C minded, more of a mechanical guy. It amazes me every time how garbled the expression stackups need to be..

                what does the 'pwm' mean? and why does it need to be there?

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

                  @yao
                  Is not really that complicated
                  It's a hierarchical structure no different to your street address. Country/state/city/street/number/unit
                  These are not official designations but...
                  State - refers to functions on the board you might normally monitor
                  GPout[] - refers to the GP output pins as a whole (analogous with your street). It's an array, so you need a port number to identify an individual pin (house number)
                  pwm - refers to the PWM (pulse width modulation) value of that pin. You need that because the pin may have many different properties that are applied. e.g (name, inversion etc). Just as a street number may have one or 100 dwellings. If you don't address the right one, your letter may not get there.

                  If you use the object model browser it becomes easy and you can copy the correct syntax with the button provided.

                  Yaoundefined 1 Reply Last reply Reply Quote 2
                  • Yaoundefined
                    Yao @OwenD
                    last edited by

                    @owend @owend Never had such a clear explanation is this!
                    But, is there a clear 'roadmap' where i can find all these specific DUET adresses, numbers, extensions and designations?
                    Where can I find the 'object model browser' :
                    this ?: https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation#overview
                    I can't find the specific addresses you mention in that list.
                    M409 gives me an empty list of strings...

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

                      @yao
                      This post shows you how to look at the object model browser
                      https://forum.duet3d.com/post/277538

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

                        some where I found this some time ago

                        Macro "leds on/off"

                        if state.gpOut[1].pwm == 1
                           M42 P1 S0
                        else
                           M42 P1 S1
                        

                        in config files

                        ; LEDS
                        M950 P1 C"e1heat" Q500							;use heater 1 outupt for LED
                        M42 P1 S1										; turn off LEDS
                        
                        
                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post
                        Unless otherwise noted, all forum content is licensed under CC-BY-SA