How to configure the SFB

This "How to" is dedicated to the configuration of the Smart Filament Buffer (SFB) on your Printer

Prerequisites

Before you configure the SFB on your printer, make sure you have read the Build the SFB controller board chapter.

From the 3D printers perspective, the SFB is just an ordinary filament run-out sensor, capable of signalling two states: ALL OK or RUNOUT.

This is accomplished by either a HIGH or LOW signal on the according GPIO input pin. Which state has which meaning is determined by the firmware itself and is usually configurable. For SFB, the LOW state (0V) indicates ALL OK and the HIGH state (+5V) indicates a RUNOUT.

Speaking of voltages, please keep in mind that the Arduino Nano, which generates the run-out signal runs on 5V and hence, at HIGH state the voltage on the GPIO of the controller will be 5V also. This is important to note, since it means that you must not attach this signal to a MCU that's not 5V tolerant on the GPIO pin used. If that's the case with your MCU, you need to add a voltage level converter in between!
Though, most of the MCUs used in 3D printers nowadays are capable of handling higher voltage levels on input pins by design. However, it is better checking it twice than to regret.

...in Marlin

you need to configure the run-out sensor in your Configuration.h file. Therefore open the Marlin firmware source files and search for the FILAMENT_RUNOUT_SENSOR phrase. Enable it by removing the comment (//) in front of the #define and set the the following:

#define FILAMENT_RUNOUT_SENSOR

#if ENABLED(FILAMENT_RUNOUT_SENSOR)

  #define FIL_RUNOUT_ENABLED_DEFAULT true    // Enable the sensor on startup. Override with M412 followed by M500.

  #define NUM_RUNOUT_SENSORS   1             // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.

  

  #define FIL_RUNOUT1_PIN      PC15          // Depends on your controller board!

  #define FIL_RUNOUT1_STATE    HIGH          // Pin state indicating that filament is NOT present.

  #define FIL_RUNOUT1_PULLDOWN               // Use internal pulldown for filament runout pins.

  ...

#endif

Here is assumed that the E0-STOP input pin is used and therefore with an SKR E3 V3.0, this signal is mapped to the PC15 pin of the MCU.
You need to map this pin definition to the pin your dedicated control board uses for it. Usually the pin mapping is well documented on the vendor's website/Github repository.

After you've applied these changes, compile the firmware and flash it onto you controller board. 

...in Klipper

you need to configure the pin of the [filament_switch_sensor runout_sensor] within your printer.cfg file. For example, pin GPIO16, active high: 

[filament_switch_sensor runout_sensor]
switch_pin: gpio16
pause_on_runout: True

Again, it's assumed that the E0-STOP input pin is used and therefore with an SKR PICO, this signal is mapped to the GPIO16 pin of the MCU.

...on the Duet3D / RRF

you need to add these two lines to use the e0stop pin, active high (for RRF Firmware >3.1): 

M591 D0 P1 C"e0stop" S0 ; T0 active high (disabled)
M581 P0 T1 R1 ; Run-out for T0 triggers a pause

Once again, the E0-STOP input pin is used. The pin name "e0stop" should be valid throughout all Duet3D boards.