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

    Get Output Pin States for Conditional GCode

    Scheduled Pinned Locked Moved
    Gcode meta commands
    4
    8
    791
    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.
    • webdes03undefined
      webdes03
      last edited by

      I have relays connected to "out8" and "out9" on my Duet 3, for the purpose of powering a mister and vacuum.

      ;Set up vacuum and misting outputs
      M950 P2 C"out8" ; define P2 as vacuum
      M950 P3 C"out9" ; define P3 as mister
      

      Everything works correctly, and I added M7/9/10/11.gfiles to enable those functions):

      # M7.g
      M42 P3 S1	; enable mister
      G4 P2000	; wait for 2 seconds
      
      # M9.g
      M42 P3 S0	; disable mister
      G4 P2000	; wait for 2 seconds
      

      Now, I'm trying to create macros to toggle the mister and vacuum on and off, but I can't figure out how to read the outputs to determine if they're on or not so I can do the appropriate action of the toggle (turn it on of it's off, or off if it's on).

      Presumably I can do something like the following, I just can't seem to master the right solution to make it work:

      # ToggleMister.g
      if P3 EQ 0
        M7
      else
        M9
      
      1 Reply Last reply Reply Quote 1
      • SpoonUnitundefined
        SpoonUnit
        last edited by SpoonUnit

        The current value of the pin will be in the object model under sensors probably. Explore the object model using the console in DWC using

        M409 F"v" K"sensors"
        

        I think you'll find your pin values under

        M409 F"v" K"sensors.inputs"
        

        e.g.

        M409 F"v" K"sensors.inputs[1].value"

        Once you've nailed it. You can then use echo to test the value and trigger the tool to test changes

        echo sensors.inputs[1].value
        

        Now you're in position to use the conditional GCODE. Following what you have above, this might look like this

        if sensors.inputs[1].value
            M7
        else
            M9
        
        1 Reply Last reply Reply Quote 0
        • webdes03undefined
          webdes03
          last edited by

          Hmmm... let me poke around. I only see inputs, not outputs... but maybe it's staring me in the face and it's just not "clicking".

          1 Reply Last reply Reply Quote 0
          • webdes03undefined
            webdes03
            last edited by

            And by "I only see inputs", I mean endstops...

            {
                "key": "sensors",
                "flags": "v",
                "result": {
                    "analog": [],
                    "endstops": [
                        {
                            "triggered": false,
                            "type": "inputPin"
                        },
                        {
                            "triggered": false,
                            "type": "inputPin"
                        },
                        {
                            "triggered": false,
                            "type": "inputPin"
                        },
                        {
                            "triggered": false,
                            "type": "inputPin"
                        }
                    ],
                    "filamentMonitors": [],
                    "inputs": [],
                    "probes": [
                        {
                            "calibrationTemperature": 25.0,
                            "deployedByUser": false,
                            "disablesHeaters": false,
                            "diveHeight": 5.0,
                            "maxProbeCount": 1,
                            "offsets": [
                                0,
                                0
                            ],
                            "recoveryTime": 0,
                            "speed": 2.0,
                            "temperatureCoefficient": 0,
                            "threshold": 500,
                            "tolerance": 0.030,
                            "travelSpeed": 100.0,
                            "triggerHeight": 0.700,
                            "type": 0,
                            "value": [
                                1000
                            ]
                        }
                    ]
                }
            }
            
            1 Reply Last reply Reply Quote 0
            • webdes03undefined
              webdes03
              last edited by

              Just in case the full dump helps diagnose anything:

              I am running RC7 if that makes a difference.

              M409.json

              1 Reply Last reply Reply Quote 0
              • T3P3Tonyundefined
                T3P3Tony administrators
                last edited by

                Just confirmed with @dc42 that output pin States are not yet in the Object Model however there are plans to add them.

                www.duet3d.com

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

                  I've just added output pin states to the OM, so it will be in the next release.

                  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 1
                  • webdes03undefined
                    webdes03
                    last edited by

                    Ahh awesome, thanks guys!

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