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

    Using conditional gcode to evaluate a value

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    2
    6
    237
    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
      last edited by

      I've just added switches to detect when a tool is installed to my printer.
      I can then identify which one is fitted and dock it accordingly if needed.
      IO inputs are available in the OM but how do I evaluate them using conditional gcode?
      i've tried

      if sensors.gpIn[0] = 1
      

      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
      • dc42undefined
        dc42 administrators
        last edited by dc42

        That should work, You can use:

        echo sensors.gpIn[0]

        to check the state from the DWC console.

        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

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

          I get this if I try echo in the console

          echo sensors.gpIn[0]
          Error: Failed to evaluate "sensors.gpIn[0]": unsupported type code 11
          

          The error from code I tried in post 1 is

          Failed to evaluate "sensors.gpIn[0] = 1": cannot convert operands to same type
          

          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
          • dc42undefined
            dc42 administrators
            last edited by

            Which firmware version are you using?

            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

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

              PS - using recent firmware (preferably 3.01-RC12) you would need to use:

              if sensors.gpIn[0].value = 1
              

              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

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

                That worked. Thank you!

                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
                • First post
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA