How to build the SFB controller board

This tutorial will guide you...

through the process of building your SFB controller board.

Please Notice: You need this controller board only if you want to build a "Smart" Filament Buffer, which is able to track up to 5 filaments for run-out. If you don't need a filament run-out sensor here or you already have a different solution elsewhere, you don't need this controller at all.

Also, this Filament Buffer is made for 5 materials / filaments. If you need to buffer more materials, you'll need two or more of these (for up to 20 filaments) and Daisy-Chain them.

The schematic...

for this board is shown on the left and can be downloaded here as well.







To build this board, you'll need a couple of items:

  • 1 x SFB PCB from either PCBWay or from AISLER (as seen on the left)

  • 1 x Arduino Nano V3

  • 1 x I2C / TWI OLED, 0.96" (typically SSD1306)

  • 3 x micro switch (6 x 6 x 10 mm)

  • 1 x JST B5B-XH ST90 header

  • 1 x pin header with 4 pins (for the OLED)

  • 5 x linear Hall effect sensor (AA1326 LUA-T or SS495A)

  • 5 pieces of ferromagnetic tape or 5x1 mm Neodymium magnets

  • 4 self tapping screws 2.9x6 mm (or similar)

  • the SFB firmware

Assembly of the SFB-PCB

The assembly of the SFB-PCB can be accomplished in five simple steps. If you don't have the PCB, you can wire it up manually on a 60x40 mm prototype board according to the schematic. It'll take a bit longer but you can follow the same steps shown here.

Many thanks to maker Defenc for providing the assembly steps pictures.

Step 1

Solder the Arduino Nano directly to the SFB PCB. Make sure the USB port of the Nano points towards the "USB" printout on the silk screen.

Don't use a socket for the Arduino because the PCB won't fit into the housing anymore.

Keep in mind: You don't need to solder all pins, it's absolutely sufficient to solder only the 16 pins that have traces to the Arduino socket.

Step 2

Solder the 5 pin JST header onto the PCB.

Step 3

Place and solder the three push buttons to the PCB. Make sure they sit flush on the PCB.

Step 4

Bend the Hall sensor legs by 90 degree, so that the smaller surface of the IC is pointing upwards and you can still read the print.
Next, screw on the Sensor-Solder-Helper you have printed from the top and place all sensors into the grooves from the bottom side of the PCB. Solder the sensors from the top side.

After this, unscrew and remove the Sensor-Solder-Helper.

Step 5

Before you solder the display, please make sure your OLED has the same pin-out (same order) as written on the SFB-PCB. Some of these displays come with a swapped VCC/GND arrangement. In such case it's safer to replace the OLED with one with the correct arrangement.

Now solder the OLED also directly to the PCB. Put the Solder-Helper-OLED below the display to get the desired distance between SFB PCB and OLED PCB. Solder the display from the bottom side and remove the Solder-Helper-OLED.

Flashing the firmware

In order to flash the Arduino Nano with the SFB firmware, you first have to download (or clone) the SFB repository from Github. Unzip the contents into a folder and open that folder with VS-Code. Click on the PlatformIO icon (Ant/Alien - whatever it is), open the Nano folder and click on Build. If the build was successful, connect the Nano to your PC and make sure the COM port assigned to the Nano matches the upload_port in platformio.ini. If it doesn't, simply change the setting to the new COM port, then click on Upload in the Project Tasks.

If VS-Code appears to have problems programming your device, resulting in a couple of messages stating:

avrdude: stk500_recv(): programmer is not responding

it may indicate that your Arduino Nano has a newer bootloader (which is mostly the case on genuine Arduino boards; not as much on clones).

In this case, open platformio.ini of the SFB project and append new to the board in the [env:Nano] section (i.e. board = nanoatmega328new), and try flashing it once again. If that doesn't solve the problem, you might have a faulty device. Simply try another Nano.

Wiring the SFB to your controller

In order to wire the SFB up (in normal or standalone mode), you only need just a few things:

  • a 3 wire cable (colored red, black, green for example)

  • a 5 pin JST B3B-XH female connector

  • a connector for your 3D printer controller board, which most likely will be a 3 pin JST B3B-XH or 3 pin Dupont female connector, depending on your controller.

Arrange the wires on the 5 pin JST as follows: GND (black) goes to pin 1, +5V (red) goes to pin 2 and SIG (green) goes to pin 3. If you don't know which pin is which, take a look at the SFB-PCB top layer silk screen.

Since we're dealing with the filament run-out sensor here, your best option is using the extruder endstop a.k.a E0-STOP as the input on your controller board. Always refer to the pin-out diagram of your controller board (usually supplied by the manufacturer, mostly on Github) to locate the connector and its pin assignment (see picture to the right for example).

Hence, the pin assignment on the controllers side is pretty straight forward: Assign the +5V (red) coming from the SFB to the +5V pin, the GND (black) to the GND pin and the SIG (green) to the signal input pin (i.e. PC15 as shown in the picture).

That's it. This is all we need to make the SFB work.

Please notice: 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 also 5V! 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 the SIG pin and the GPIO pin!
Though, most of the MCUs used in 3D printers nowadays are capable of handling higher voltage levels on
GPIOs by design. However, it is better checking it twice than to regret.

Daisy-Chaining SFBs

Daisy-Chaining SFB devices is being used if you need to handle more than 5 filaments. This (common) technique allows passing (run-out) signals between different devices, so that it appears as one "big" device to the outside. Hence, even with more than one SFB, the 3D printer controller needs to handle only one signal as a run-out occurs.
Thus, the wiring on the 3D printer controllers side stays the same as described above for standalone mode.

In order to use the Daisy-Chain feature on the SFB, you need to chain up the SIG output from one device to the other (previous) device, i.e.:

Simply add a wire from the SIG output (pin 3) of the next device to pin TX (pin 5) of the current device on the JST B5B-XH connector, as shown above. The wiring of the very first SFB in the chain stays the same as in standalone mode, except the additional wire on pin TX. Of course, every SFB in the chain also needs the power wires, +5V and GND. That's all you need to do on the electrical side.

Setting up the Daisy-Chain

Simply add a wire from the SIG output (pin 3) of the next device to pin TX (pin 5) of the current device on the JST B5B-XH connector, as shown above. The wiring of the very first SFB in the chain stays the same as in standalone mode, except the additional wire on pin TX. Of course, every SFB in the chain also needs the power wires, +5V and GND. That's all you need to do on the electrical side.

Beyond the wiring, all the SFBs need to know that they're operating in Daisy-Chain mode. To set them up accordingly, you need to enter the Mode menu of each device and set it to either Chained or Last and assign the proper ID in settings menu Device (as shown in the picture above).
Chained means there is yet another device in the chain sending a run-out signal, Last means this is the very last device in the chain. The Last device will handle the run-out timer (countdown), whereas all other devices will pass on the SIG state to the previous device instantly. The assigned ID (1st, 2nd, 3rd,...) will cause the SFB to show the correct tool numbers on the display of the main screen, i.e. T0 - T4 on the first device, T5 - T9 on the second and so on.

Please keep the following in mind:

  • In Daisy-Chain mode the TX pin of the SFB will be detached internally and thus, it won't be able to send any data back to the controller. Though, it'll be still able to receive Tn commands from the controller.

  • For flashing the firmware you must detach the connector from J1.

  • All devices need to be powered with +5V/GND from the same source.

  • In order to use the Advanced Mode (for monitoring only one sensor), all devices must be able to receive the tool commands via the RX pin. This may require adding an external driver IC (such as the SN74LS126A or similar) between the TX wire of the senders serial interface and the RX input of each SFB, in case you encounter the SFBs aren't reacting to the Tn commands.

Advanced Mode

As mentioned above, the SFB is able to handle a more sophisticated mode. In normal mode, the SFB will trigger a run-out as soon as no filament is reported being "loaded" and the run-out timer has elapsed. If at least one tool reports being "loaded", even if that tool isn't currently in use, the filament run-out will not trigger at all. Even though this is very unlikely to happen in common 3D printing scenarios, it still can happen. To prevent this, there's the Advanced Mode.

In Advanced Mode the SFB will listen to the serial interface and look out for Tn commands (n = tool number), just as the SMuFF does in order to determine if a tool change has been requested. As long as "no tool" is set (T -1), the SFB will behave the same as in normal mode and monitor all sensors.
As soon as a tool command has been received (i.e. T3), the SFB will monitor the sensor for this particular tool only and set the run-out signal accordingly, regardless of the current state of other tools. This mode can be visually distinguished, as only the tool in charge will have its sensor trigger state drawn on the main screen.

In order to use this mode, you'd need to wire up the RX pin of each SFB to a serial interface TX pin on the 3D printer controller or the SMuFF and set the baudrate for this serial port accordingly (115200 baud).

Please notice: The Advanced Mode is for future use only!
Unfortunately, no existing 3D printer firmware is able to support such a feature yet, and the amount of viable serial ports on a 3D printer controller board (or even the SMuFF) is limited.
I plan to add this feature in future versions of the SMuFF firmware, because it doesn't really matter which instance is sending the tool commands to the SFB, as long as they match the current print and the SMuFF is supposed to know best when this happens.

Calibration

Before the SFB is ready to use, you'll need to calibrate it after you've assembled it. To do so, press the MENU button to open the Options menu and select the item Sensors. The SFB will show the Sensors screen and continuously print the readout of the Hall sensor values onto the display.

Please be aware that, as long as no filaments are "loaded", all sensor readouts are supposed to be in the same value range (+/-20 Gs). If one or more of the sensors show a negative value, while all others show positive values, you have to flip the magnets - of those showing negatives - upside-down.

If you push against the steel ball of one of the sensors, the sensor readout will raise towards the max. value of 640 Gs. This way you can easily check whether all sensors are working correctly.

Once all sensors are in the same (lower) range, press the PREV button to start the calibration sampling. After the sampling is done, the SFB will show the min./max. Gauss values at the very bottom of the display.
Now press the
NEXT button in order to store these values in EEPROM and the calibration is done.

SFB Trickery

It's hard not to notice that the SFB design is based on the principles of gravity. During printing, the 3D printers extruder pulls on the filament, causing the steel ball to rise and triggering the Hall sensor. When the filament is unloaded, the tension is released and gravity forces the steel ball to drop. This causes a change in the magnetic field, which is detected by the Hall sensor and triggers the run-out condition if needed.
This statement is valid as long as the SFB is being operated in the orientation for which it was designed: upright.

Being asked, I've always stated that it's not possible running the SFB in a different orientation but thanks to maker Defenc over on Discord, who wanted this feature so badly that he started experimenting on his own, we now have a feasible solution to this problem. All you need to do is:

  • get a soft but somewhat sturdy kitchen sponge (or any other sponge in this behalf)

  • cut out five cubes of roughly 7mm

  • put those cubes into the steel ball chambers between magnet and Hall sensor (see picture)

Done.

When the filament is unloaded, the sponge cube will expand and therefore push the steel ball into its resting position. This neat little trick works so well, even if the SFB is being placed upside-down it'll reliably disengage the Hall sensor.

To prevent the Hall sensors from being bent over, I designed a small bracket that you simply slide under the Hall sensors and lock it in place with a drop of superglue.

You'll find this little gadget on Printables.com.