Good afternoon friends. Today I would like to tell you about the PAT9125 filament sensor, as well as about my experience with it.
PAT9125 is an optical sensor used in Prusa 3D printers. This sensor can track not only the end of the filament but also the moment it gets stuck. For example, if you have a heat plug.
The main problem of the sensor is that it cannot be connected directly to the board with Marlin. Since Marlin only supports encoder connection, this encoder must be connected via I2C interface. To solve this problem I used attiny85 digispark. The sensor is connected to Attiny and already Attiny, in turn, emulates the operation of the encoder.
Setting up Marlin
In the Configuration.h file, you need to uncomment the #define FILAMENT_RUNOUT_SENSOR parameter. But the #define FIL_RUNOUT_PULLUP parameter is better to comment out, since we have a fake encoder, then pulling the attiny to the power line will only interfere with the work.
#define FILAMENT_RUNOUT_DISTANCE_MM Marlin , . 25. , - . 5 .
Configuration_adv.h #define ADVANCED_PAUSE_FEATURE
Pinout #define FIL_RUNOUT_PIN.
. , .
Attiny. P3 Attiny . , Attiny . P5, Attiny , Attiny. P1, .
I also want to note that the sensor tracks separately the movement along the X axis and along the Y axis. In my case, the X axis is used, but if you want to position the sensor differently. For example, if you position it perpendicular to the movement of the filament, then you need to replace the X axis with Y in the Attiny firmware.
This is what my printer looks like with a sensor.