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

    Inputs for a Simple Switch Filament Sensor

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    filament sensor
    4
    20
    7.2k
    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.
    • SnowCrashundefined
      SnowCrash
      last edited by

      Hi,

      I'm trying to figure out the best place to connect a simple switch filament sensor to the DuetWifi in a Delta printer.

      Currently, the DuetWifi's X, Y and Z endstop inputs are connected to the printer's towers endstops, whereas the E0 endstop is connected to the printer's bed-leveling sensor (aka z-sensor).

      According to the documentation:

      Cnn Which input the filament sensor is connected to. On Duet electronics: 0=X endstop input, 1=Y endstop input, 2=Z endstop input, 3=E0 endstop input etc.

      This seems to imply the E1 can also be used (with configuration C4), and so my first question is if this is correct?

      Also, are there any other configurable inputs on the DuetWifi where the said filament sensor could be hooked-up? And, if so, where can I find the full list of acceptable values for selecting them?

      Many thanks in advance,
      SnowCrash

      Phaedruxundefined 1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator @SnowCrash
        last edited by

        @snowcrash I'm looking to connect either a microswitch or optical endstop as a filament monitor myself.

        I hadn't seen that documentation though. I was just going to connect it to the E0 endstop. The documentation you linked seems pretty specific to the magnetic monitor. I'm not sure if all that's required when just using a simple switch.

        Z-Bot CoreXY Build | Thingiverse Profile

        1 Reply Last reply Reply Quote 0
        • resamundefined
          resam
          last edited by

          I'm using a microswitch connected to the E1 endstop connector.
          This is my config.g for it: M581 E1 T1 S0 C1 ; Filament run-out sensor triggers a pause
          And then I'm using this in my start-gcode: M582 T1 ; check if filament is present.

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

            Yes you can use the E1 endstop input. See the M591 command in the gcode wili page.

            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
            • SnowCrashundefined
              SnowCrash @resam
              last edited by

              @phaedrux said in Inputs for a Simple Switch Filament Sensor:

              @snowcrash I'm looking to connect either a microswitch or optical endstop as a filament monitor myself.

              I hadn't seen that documentation though. I was just going to connect it to the E0 endstop. The documentation you linked seems pretty specific to the magnetic monitor. I'm not sure if all that's required when just using a simple switch.

              Thanks Phaedrux!

              I just included the above link for reference. From what I could tell, other references contained the same info more or less.

              @resam said in Inputs for a Simple Switch Filament Sensor:

              I'm using a microswitch connected to the E1 endstop connector.
              This is my config.g for it: M581 E1 T1 S0 C1 ; Filament run-out sensor triggers a pause
              And then I'm using this in my start-gcode: M582 T1 ; check if filament is present.

              Thanks resam!

              Are you sure it's M582 in both cases, though? Not M591?

              @dc42 said in Inputs for a Simple Switch Filament Sensor:

              Yes you can use the E1 endstop input. See the M591 command in the gcode wili page.

              Thanks dc42!

              Is there any additional location apart from the X, ... E1 mentioned above?

              dc42undefined 1 Reply Last reply Reply Quote 0
              • resamundefined
                resam
                last edited by resam

                @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                Are you sure it's M582 in both cases, though? Not M591?

                M581 in combination with M582 works just fine for me - I pauses a print if not filament is detected (microswitch not pressed).

                My config is from 1.18-times - before we got M591 - and it still works.
                Maybe I should update my config!

                SnowCrashundefined 1 Reply Last reply Reply Quote 0
                • resamundefined
                  resam
                  last edited by

                  @dc42 I think the wiki page could use an update to mention the newer filament sensor types:
                  https://duet3d.dozuki.com/Wiki/Connecting_and_configuring_filament-out_sensors

                  1 Reply Last reply Reply Quote 0
                  • SnowCrashundefined
                    SnowCrash @resam
                    last edited by SnowCrash

                    @resam said in Inputs for a Simple Switch Filament Sensor:

                    @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                    Are you sure it's M582 in both cases, though? Not M591?

                    M581 in combination with M582 works just fine for me - I pauses a print if not filament is detected (microswitch not pressed).

                    My config is from 1.18-times - before we got M591 - and it still works.
                    Maybe I should update my config!

                    Got it. Thanks for the clarification, resam!

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

                      @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                      Thanks dc42!

                      Is there any additional location apart from the X, ... E1 mentioned above?

                      Yes, for a simple switch you can use any of the 12 endstop inputs that are not being used for homing axes. For the more complex sensors you can't use inputs 5 to 9 on a DueX expansion board, because they can't generate low latency interrupts.

                      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

                      SnowCrashundefined 1 Reply Last reply Reply Quote 0
                      • SnowCrashundefined
                        SnowCrash @dc42
                        last edited by

                        @dc42 said in Inputs for a Simple Switch Filament Sensor:

                        @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                        Is there any additional location apart from the X, ... E1 mentioned above?

                        Yes, for a simple switch you can use any of the 12 endstop inputs that are not being used for homing axes. For the more complex sensors you can't use inputs 5 to 9 on a DueX expansion board, because they can't generate low latency interrupts.

                        Thanks dc42!

                        I ended up hooking up the filament sensor to E0 (while moving the z-sensor to the dedicated Z-Probe connector), but run into strange behavior when I attempted to set it up in software and would appreciate advice on how to fix it.

                        I studied the relevant documentation for M591, then connected the sensor according to the pinout diagram, and finally, inserted the following line at the end of config.g:

                        M591 D0 P1 C3 ; filament sensor for Extruder 0, Active-High, connected to E0 endstop

                        The sensor seemed to be working fine and this was reflected in the web interface showing it changing state from 'hit' to 'no-hit' based on the presence of filament.

                        However, the reported signal was inverse, that is, in the 'Machine Properties' section of the web interface, it showed the 'E0 endstop' as being 'hit' when there was filament, and 'not-hit' when there wasn't any filament in the sensor.

                        I therefore changed the config line to:

                        M591 D0 P2 C3 ; filament sensor for Extruder 0, Active-Low, connected to E0 endstop

                        However - and this is the strange part - I got exactly the same behavior, instead of the expected (i.e. inverse) one.

                        Any idea why the sensor would not report the opposite behavior when the P parameter is changed from P1 to P2 and vice versa?

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

                          When an endstop is not configured for use as a homing switch, DWC just reports the state of the input. The inversion (or not, depending on P1 vs P2) is done in the filament sensor code.

                          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

                          SnowCrashundefined 1 Reply Last reply Reply Quote 0
                          • SnowCrashundefined
                            SnowCrash @dc42
                            last edited by SnowCrash

                            @dc42 said in Inputs for a Simple Switch Filament Sensor:

                            When an endstop is not configured for use as a homing switch, DWC just reports the state of the input. The inversion (or not, depending on P1 vs P2) is done in the filament sensor code.

                            Thanks dc42!

                            Sorry, was with you at the beginning of the answer, but totally lost you here:

                            The inversion (or not, depending on P1 vs P2) is done in the filament sensor code.

                            Isn't the 'filament sensor code' the lines of code I mentioned above (that is, M591 D0 P2 C3 or M591 D0 P2 C3)?

                            If it is, then that's precisely my problem - the switch from P1 to P2 doesn't seem to inverse the input reading in DWC.

                            And if it isn't, what does the term 'filament sensor code' refer to exactly? Where do I find it? Instructions on how to use it?

                            (Btw, I did search the documentation for an solution to this problem prior to posting this thread, but couldn't find any).

                            1 Reply Last reply Reply Quote 0
                            • resamundefined
                              resam
                              last edited by

                              @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                              And if it isn't, what does the term 'filament sensor code' refer to exactly? Where do I find it? Instructions on how to use it?

                              He is referring to the actual firmware implementation, which is C++ code. You can find it here: https://github.com/dc42/RepRapFirmware/blob/dev/src/FilamentMonitors/SimpleFilamentMonitor.cpp#L49

                              DWC won't show it correctly, because the C++ code is only invoked during printing (in a completely different section of the firmware).

                              SnowCrashundefined 1 Reply Last reply Reply Quote 0
                              • SnowCrashundefined
                                SnowCrash @resam
                                last edited by SnowCrash

                                @resam said in Inputs for a Simple Switch Filament Sensor:

                                @snowcrash said in Inputs for a Simple Switch Filament Sensor:

                                And if it isn't, what does the term 'filament sensor code' refer to exactly? Where do I find it? Instructions on how to use it?

                                He is referring to the actual firmware implementation, which is C++ code. You can find it here: https://github.com/dc42/RepRapFirmware/blob/dev/src/FilamentMonitors/SimpleFilamentMonitor.cpp#L49

                                DWC won't show it correctly, because the C++ code is only invoked during printing (in a completely different section of the firmware).

                                Thanks for the clarification & pointer, resam!

                                And now I'm utterly confused! 🙂

                                Let me go back to the beginning in the hope of at least making the problem clearer:

                                I have a simple switch-based filament sensor - it's either active-high or active-low, I'm not sure (didn't think it mattered as it was supposed to be configurable via DWC, but I can find out if needed).

                                I connected this sensor to E0 and it looks to be functioning properly, that is, it changes state when filament is inserted or taken out.

                                I thought the next step is to add either 'M591 D0 P1 C3 ' or 'M591 D0 P2 C3' to the config.g file and that would be it.

                                However, this doesn't seem to be the case because although the signal from the sensor works as intended (switching between Low and High based on the presence/absence of filament), DWC doesn't show this change.

                                Moreover, I don't know if anything else needs to be configured or added to the code for the sensor to do its job properly.

                                So my question is where do I go from here?

                                I assume other people have successful connected a simple switch-based filament sensor to the DuetWifi like I'm trying to do, and got it configured correctly, but I couldn't find any clear step-by-step instructions for noobs such as myself on how this ought to be done (and I have spent time researching this, believe me).

                                Help please?

                                1 Reply Last reply Reply Quote 0
                                • resamundefined
                                  resam
                                  last edited by

                                  M591 with the correct parameters should be everything you need.
                                  I'm using M581 - as explained above - and it works. However, I don't see the information in DWC.

                                  Did you start a print? Just try it and see what happens. Once it is heated up and it would start the first extrusion (skirt or first layer) it should pause if the filament is missing.

                                  SnowCrashundefined 1 Reply Last reply Reply Quote 0
                                  • SnowCrashundefined
                                    SnowCrash @resam
                                    last edited by

                                    @resam said in Inputs for a Simple Switch Filament Sensor:

                                    M591 with the correct parameters should be everything you need.
                                    I'm using M581 - as explained above - and it works. However, I don't see the information in DWC.

                                    Did you start a print? Just try it and see what happens. Once it is heated up and it would start the first extrusion (skirt or first layer) it should pause if the filament is missing.

                                    Thanks again, resam! I appreciate you taking the time to help with this!

                                    I haven't started a print yet as I'm still in the process of configuring all the different settings for the printer (it's a new custom-build).

                                    I take your point that the M591 command ought to be enough, but this leaves two substantial questions begging, namely:

                                    (1) There must be an accurate representation of the filament sensor's state in DWC just like it is for any other sensor/parameter, no?

                                    It makes no sense to me that the only way to find out if things are hooked-up and configured correctly is to run an actual print (be it a filament sensor or anything else for that matter).

                                    (2) Assuming my above formulation of the M591 commands is correct, how come switching between them in the config.g file makes no difference at all when it comes to the actual reading shown in DWC?

                                    (Btw, I'm a noob when it comes to the Duet Wifi, but I'm also a trained programer and for the life of me I can't see how 2 different lines of code could produce the exact same outcome unless something is wrong somewhere or the commands don't do what they're thought to be doing).

                                    1 Reply Last reply Reply Quote 0
                                    • resamundefined
                                      resam
                                      last edited by resam

                                      Filament Sensors are still a fairly new thing and have evolved with every recent firmware release.
                                      AFAIK DWC simply has not caught up with all the features in RepRapFirmware.
                                      I'm not aware of an accurate representation of filament sensor data in DWC. Only via the Console section, where you can enter G-Code yourself.

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

                                        DWC does not report filament sensor state. Many filament sensors (e.g. laser, rotating wheel) do not produce a static present/not present signal, so there would be nothing to show.

                                        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
                                        • SnowCrashundefined
                                          SnowCrash
                                          last edited by SnowCrash

                                          I found what looks like the solution to my original problem - that is, correct (or, at least, logical) representation of a simple switch filament sensor's state that's shown in DWC in real-time.

                                          The solution was provided in another thread by no other than dc42, and I thought I'd share it here in the hope it might help others who try to tackle the same issue.

                                          The relevant comment by dc42 can be found here, where he says:

                                          Use a multimeter to identify which 2 of the 3 wires from the sensor are the contacts that are closed when filament is present and open when filament is not present. Connect those 2 wires to the outer 2 pins of the endstop connector, leaving the 3rd wire not connected. Use P2 in your M591 commands.

                                          I've done exactly that, and as per dc42's instructions, added this command inside config.g:

                                          M591 D0 P2 C3 ; Filament Sensor (Extruder0)

                                          Now DWC shows 'no' for the sensor (or, more accurately, E0 endstop) when there's filament present, and 'yes' when filament is absent.

                                          I'm aware the above might sound inverted, but to me it makes sense as I'm thinking of the sensor's state as a 'pause' instruction - that is, if filament is present don't pause, and if it's absent then pause.

                                          I'm not sure if this is all that's required or whether I need to add further instructions at the beginning of each print-job's g-file so that the sensor's on-going reading will be implemented (i.e. pause the print if filament isn't present at the beginning or runs out midway). So if anyone has advice on this, it would be very much appreciated!

                                          All the best,
                                          SnowCrash

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

                                            That's all you should need to do. Future firmware versions may also require S1 to enable pause on filament error.

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