A firmware mystery: What is the "autoload filament sensor?"
I'm preparing to submit a git commit to the Buddy firmware with a request to fix a bug, but I encountered something that I don't understand and I want to check with the community first.
The specific question I have is: Does the MK4/4S have an "autoload" filament sensor that is separate from the normal extruder filament sensor?
The problem that I'm trying to address is described in this GitHub bug report:
https://github.com/prusa3d/Prusa-Firmware-Buddy/issues/4474
...namely: when the printer runs out of filament mid-print, the UI can get stuck on a particular screen with no user input and no way to progress, forcing the user to power-cycle the printer and wreck the print. More specifically: When the printer detects filament runout, it automatically ejects the filament and displays the dialog: "Was the filament ejected?" If the user answers Yes, the printer sometimes switches to a screen reading: "Please remove filament from filament sensor" with no user interface options, and no response to fiddling with the filament or extruder - literally the only option is to reset the printer.
Initially, I chalked this up to my filament sensor going bad. The weird part is that after resetting the printer, when I instruct the printer to load filament, the filament sensor is perfectly fine: the printer asks me to insert filament, and when I do, it detects the filament and loads it. So it can't be a case where the filament sensor is flaking out during filament runout / reload and then works perfectly fine a moment later after resetting. I figured it must be a logic bug.
Since Prusa's team hasn't addressed this issue (and it kept wrecking my prints), I decided to roll up my sleeves and dig into the firmware. I tracked down the logic to a function in pause.cpp (excerpted here):
void Pause::filament_not_in_fs_process([[maybe_unused]] Response response) { ... if (!FSensors_instance().has_filament_surely(LogicalFilamentSensor::autoload)) { ...
In essence, this function goes like this: If the user responded "Yes" to "has the filament been ejected," check with the filament sensor to make sure that it isn't detecting filament. Wait for the filament sensor to respond "no filament" for a full second before continuing with the process.
So what's the problem? It's this part:
has_filament_surely(LogicalFilamentSensor::autoload)
Looking through the entire firmware codebase, every other time that the printer needs to check the filament sensor, it does this:
has_filament_surely(LogicalFilamentSensor::extruder)
The only place in the entire Buddy firmware that checks the "autoload" LogicalFilamentSensor instead of the "extruder" LogicalFilamentSensor is the filament_not_in_fs_process function. That's why it behaves so oddly.
So what is "LogicalFilamentSensor:autoload?" This is where things get weird. Looking in the file filament_sensor_types.hpp, I find this:
enum class LogicalFilamentSensor : uint8_t { /// Filament sensor on the current extruder extruder, /// Side sensor for the current extruder /// MK4+MMU: MMU sensor | XL: current side sensor | OTHER: none side, /// The first runout filament sensor - the one further from the extruder /// XL: side sensor | MK4+MMU: MMU sensor | OTHER: extruder sensor primary_runout, /// The second runout filament sensor - the one closer to the extruder /// XL,MK4+MMU: extruder sensor | OTHER: none secondary_runout, /// Filament sensor that is used to detect autoload autoload, }; static constexpr size_t logical_filament_sensor_count = 5;
Okay, there's an "extruder" sensor, a few other sensors for the XL and MMU, and then... this "autoload" sensor, with no meaningful description. The rest of the firmware treats this sensor just like the extruder sensor, by polling it to detect its state and raise events and such.
The crux of the issue, I think, is that I don't believe that the MK4/4s *has* an "autoload" sensor separate from the main extruder filament sensor. If this sensor doesn't exist, then obviously its state never changes, it never gets any events, and the filament_not_in_fs_process function that is awaiting a "no filament detected" event on this sensor will wait forever - exactly what I'm encountering.
The solution here is very simple: just change has_filament_surely(LogicalFilamentSensor::autoload) in that function to has_filament_surely(LogicalFilamentSensor::extruder) to be consistent with the rest of the code. But before I submit that change to the GitHub repository, I want to see what people know about an "autoload" filament sensor in the context of the MK4/4S.
RE:
MK4/MK4S itself has no other sensor in the filament path than the one on the extruder. The only possibility of cooperation between two sensors is if an MMU3 is mounted and the second one is FINDA on the MMU3 exactly as described in the file filament_sensor_types.hpp
RE: A firmware mystery: What is the "autoload filament sensor?"
I also wondered if the "autoload" sensor has something to do with the fact that it is possible to modify the entire Nextruder in the sensor area for MMU and therefore has a changed behavior even if MMU is deactivated in the printer menu. In this case, the gear wheel of the original Nextruder starts to rotate only after the filament is detected in the sensor. In the modified Nextruder for MMU, it starts to rotate immediately after the filament loading command is requested and the sensor is activated only after the filament is captured by the gear wheel and pulled under the pressure wheels. But even so, the FW would have to respond to the selection of the Nextruder type in the printer menu.
RE: A firmware mystery: What is the "autoload filament sensor?"
And it could also be a preparation for the Core One, because it actually has two sensors in the filament path. One is right at the filament's entrance into the PTFE tube, and the other is the familiar sensor at the top of the Nextruder.
RE: A firmware mystery: What is the "autoload filament sensor?"
On the issue with second "remove filament" window: I had that recently. So I took the scrap piece of filament which I have just removed, put it in the sensor and removed again. The window was happy and proceeded with filament insertion.
RE:
@david-s174-2
There is no extra sensor for the autoload function.
After the extruder rejects the filament, the filament stays in extruder pushing on the FS ball. The FW monitors the FS status. The request "Please remove filament from filament sensor" expects you to pull out the rest of the filament. This action trigers the FS and the printer recognises it is free of the filament and asks you to put in the new one. The entered filament pushes on the FS ball attached to the magnet. The magnet movement triggers the hall senzor and the FW starts rotating the extruder motor. That´s it.
The autoload function works at the moment you have the FS activated. You enter the filament to the extruder, the FS triggers and the FW starts to spin the extruder motor. When you do not have the FS activated, you can start to load the filament manually from the menu only.