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

    Quick confirmation of M950, please....

    Scheduled Pinned Locked Moved Solved
    Duet Hardware and wiring
    3
    10
    395
    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.
    • Nightowlundefined
      Nightowl
      last edited by Nightowl

      I've got a normally open switch configured in config.g like this:

      ; Pause button
      M950 J9 C"io0.in"				; create input 9 on io0.in
      M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
      

      On the advice of others, I'm changing the NO to NC, so is it simply a case of changing tit to this, please?

      ; Pause button
      M950 J9 C"!io0.in"				; create input 9 on io0.in
      M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
      

      Thanks

      Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
      I'm still on my learning curve, so take everything I say with caution!

      RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

      fcwiltundefined dc42undefined 2 Replies Last reply Reply Quote 0
      • fcwiltundefined
        fcwilt @Nightowl
        last edited by

        @nightowl999 said in Quick confirmation of M950, please...:

        I've got a normally open switch configured in config.g like this:

        ; Pause button
        M950 J9 C"io0.in"				; create input 9 on io0.in
        M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
        

        On the advice of others, I'm changing the NO to NC, so is it simply a case of changing tit to this, please?

        ; Pause button
        M950 J9 C"!io0.in"				; create input 9 on io0.in
        M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
        

        Thanks

        That is part of the process but you also have to change the wiring to the switch to use the NC connection - if it has one, not all do.

        Here is a microswitch with the contacts marked as C for common, NO for normally open and NC for normally closed.

        Microswitch Contacts.png

        Frederick

        Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

        Nightowlundefined 2 Replies Last reply Reply Quote 1
        • Nightowlundefined
          Nightowl @fcwilt
          last edited by Nightowl

          Thanks, @fcwilt

          Yeah, the switch I'm using has both, so I'll change the connection, too.

          Thanks again 👍

          Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
          I'm still on my learning curve, so take everything I say with caution!

          RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

          1 Reply Last reply Reply Quote 1
          • Nightowlundefined
            Nightowl @fcwilt
            last edited by Nightowl

            @fcwilt

            Hmm, that doesn't seem to work. Should I also change the M581 line from this:

            M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
            

            ...to this...

            M581 P9 T2 S0					; invoke trigger 2 active-to-inactive edge is detected on input 9
            

            Thanks

            Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
            I'm still on my learning curve, so take everything I say with caution!

            RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

            fcwiltundefined 1 Reply Last reply Reply Quote 0
            • fcwiltundefined
              fcwilt @Nightowl
              last edited by

              @nightowl999 said in Quick confirmation of M950, please...:

              @fcwilt

              Hmm, that doesn't seem to work. Should I also change the M581 line from this:

              M581 P9 T2 S1					; invoke trigger 2 inactive-to-active edge is detected on input 9
              

              ...to this...

              M581 P9 T2 S0					; invoke trigger 2 active-to-inactive edge is detected on input 9
              

              Thanks

              That would control if the trigger was activate when the switch was pushed or released. If it doesn't work as desired change the setting to the other edge.

              A NC switch would have a rising signal, on the input to the Duet, when pressed and a falling signal when released.

              Perhaps the ! character doesn't apply in this case since you can control the edge responded to.

              Frederick

              Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

              Nightowlundefined 1 Reply Last reply Reply Quote 0
              • Nightowlundefined
                Nightowl @fcwilt
                last edited by

                @fcwilt
                I think I'm being a bit slow with this - or it's well past my bed time...

                The NC switch is connected across the io0.in and GND, so I'd assumed I would only need to make the first change above, i.e. inverting the input by using the C"!io0.in" parameter.

                Doing that didn't work, which led me to think I should change the S1 parameter in the M581 line to S0, which invokes trigger 2 on the inactive-to-active edge.

                Are you saying I might only need to do the last part and leave the C parameter not inverted, i.e. C"io0.in".

                Thanks

                Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                I'm still on my learning curve, so take everything I say with caution!

                RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

                fcwiltundefined 1 Reply Last reply Reply Quote 0
                • fcwiltundefined
                  fcwilt @Nightowl
                  last edited by

                  @nightowl999 said in Quick confirmation of M950, please...:

                  @fcwilt
                  I think I'm being a bit slow with this - or it's well past my bed time...

                  The NC switch is connected across the io0.in and GND, so I'd assumed I would only need to make the first change above, i.e. inverting the input by using the C"!io0.in" parameter.

                  Doing that didn't work, which led me to think I should change the S1 parameter in the M581 line to S0, which invokes trigger 2 on the inactive-to-active edge.

                  Are you saying I might only need to do the last part and leave the C parameter not inverted, i.e. C"io0.in".

                  Thanks

                  It is a bit confusing. Normally to change the state of something like a switch you add or remove the ! character so the inactive state of the switch is seen by the firmware as inactive.

                  With triggers having the option to select rising/falling edge that does somewhat the same thing.

                  I'm away from home at the moment so I cannot verify what I have done.

                  But I would think you would not want the ! character but would want the rising edge option.

                  Frederick

                  Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

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

                    @nightowl999 your original configuration looks correct for a NC switch to me. Are you sure you didn't already have it wired as NC ?

                    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

                    Nightowlundefined 1 Reply Last reply Reply Quote 0
                    • Nightowlundefined
                      Nightowl @dc42
                      last edited by Nightowl

                      @dc42
                      No, the original config.g file settings were for a no switch, and it worked.

                      I think @fcwilt is suggesting I should leave the M950 as it was originally and change only the M581 line, so it would look like this:

                      ; Pause button
                      M950 J9 C"io0.in"	; create input 9 on io0.in
                      M581 P9 T2 S0		; invoke trigger 2 active-to-inactive edge is detected on input 9
                      

                      This seems to work, except the Resume is triggered immediately after the Pause code has completed, so it looks like I'll need to check the trigger2.g file, as using the Pause/Resume buttons in DWC work as they should. Hmmm...

                      Here's the trigger2.g code:

                      echo "Called at " ^ state.time
                      G4 S1				; delay 10ms to debounce
                      if sensors.gpIn[9].value=1
                      	echo "Debounce"
                      	M99 			; break out if sensor value is zero again (bouncing)
                      if job.file.fileName !=null	; if there's a job filename then it's reasonably safe to say we are printing
                      if global.PausePress == false	; the button hasn't been pressed so we'll pause
                      	echo "Pause"
                      	M25			; pause the current toolpath
                      else
                      	echo "Resume"		; resume the current toolpath
                      	M24
                      

                      Perhaps I've missed an indent somewhere...

                      Thank you.

                      Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                      I'm still on my learning curve, so take everything I say with caution!

                      RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

                      Nightowlundefined 1 Reply Last reply Reply Quote 0
                      • Nightowlundefined
                        Nightowl @Nightowl
                        last edited by Nightowl

                        @nightowl999

                        Yep, sorted.

                        The M950 line doesn't need the io0.in pin inverted
                        The M581 line S parameter needs to be changed to S0

                        ...and I had the indents in the trigger2.g file wrong. Here's what it should look like:

                        ; trigger2.g
                        echo "Called at " ^ state.time
                        G4 S1					; delay 10ms to debounce
                        if sensors.gpIn[9].value=1
                        	echo "Debounce"
                        	M99 				; break out if sensor value is zero again (bouncing)
                        if job.file.fileName !=null		; if there's a job filename then it's reasonably safe to say we are printing
                        	if global.PausePress == false	; the button hasn't been pressed so we'll pause
                        		echo "Pause"
                        		M25			; pause the current toolpath
                        	else
                        		echo "Resume"		; resume the current toolpath
                        		M24
                        

                        Thanks, guys!

                        Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                        I'm still on my learning curve, so take everything I say with caution!

                        RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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