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.
-
@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).
-
@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).
-
@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?
-
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.
-
@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).
-
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. -
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.
-
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 -
That's all you should need to do. Future firmware versions may also require S1 to enable pause on filament error.