Getting Started Guide

This page will guide you on how to set up the FibStack PiSwitcher Plus board. The page includes hardware and software installation, recommendations, limitations, and code examples. As we and the Open Source community improve the design, the content of this guide and the reference material may change as well.

Hardware Installation

WARNING. Hazard of severe electrical shock or burn when using High Voltage/Current applications. Obey High Voltage/Current safety procedures. FibStack is not responsible for any damage or injury that occurs from improper use of the PiSwitcher Plus board.

IMPORTANT

  • Disconnect all power sources before installing or servicing the board
  • Verify all the connections before turning any power source on
  • Provide the power through the Raspberry Pi board. The GND and +5V pins on the PiSwitcher Plus board are reference voltage for the ADC channels.
  • DO NOT USE voltage and current values outside the specified range specified.
  • Use the High Voltage/Current applications at your own risk.

Installation Steps

  1. Disconnect the Raspberry Pi board from the power supply
  2. We recommend attaching M2.5 16mm standoffs to prevent PiSwitcher Plus board contacts from touching Raspberry Pi board components.
  3. Attach the PiSwitcher Plus board to the Raspberry Pi board
  4. Connect the wires to the relay switches and ADC channels according to your project schematics. To avoid any damage or injury, make sure there is no current running through the wires while connecting
  5. Connect the power source to the Raspberry Pi board. The red LED on the PiSwitcher board should light up.

The default FibStack PiSwitcher Plus board I2C address is 0X50. If you want to add another board that uses the same default address, make sure you change the I2C address of the current board. You can easily change the I2C address using the Dashboard or the FibStack CLI utility.

Relay Switches

The FibStack PiSwitcher Plus board has four relay switches. The screw terminal block has three contacts for each relay. COM - Common, NC - Normal Close, and NO - Normal Open. When energizing a relay’s coil, the COM contact will disconnect from NC and connect to NO, and the corresponding LED indicator will light up. We recommend using the J0971C relay model. The maximum switching alternative current/voltage for this relay is 10A/250VAC, and maximum switching continuous current/voltage is 5A/30VDC.

Relay Switch

When all relay switches and LED indicators are on, the PiSwitcher Plus board will consume about 0.5A (2.5W) more on top of what the Raspberry Pi board consumes. You may get a low voltage warning or unpredictable behavior if the power supply doesn’t provide enough current. When you stack multiple boards together, make sure your power source provides enough current.

ADC Channels

Warning The +5V and GND pins on the PiSwitcher Plus board are a reference voltage for the ADC channels. The devices connected to the ADC channel should not consume power from the +5V pin.

The FibStack PiSwitcher Plus board also has four 12-bit ADC channels. The reference voltage is the board power source voltage coming from the Raspberry Pi board, so the signal connected to the ADC channel should be between 0 - 5V range. Between 0 and 4097 is the converted value. Warning: the power source voltage coming from the Raspberry Pi board may fluctuate and affect the ADC conversion results. If you leave the ADC channel pin unconnected or ungrounded, the ADC converter will convert the noise to that pin.

ADC Channels

The ATTiny824 microcontroller converts the signal on each channel sequentially. And the I2C interface speed may also limit the rate you receive the conversion results. So the board is not appropriate for high-frequency applications such as converting an audio signal.

Software installation

IMPORTANT: Currently, the FibStack Software package supports only Raspberry Pi OS.

To control the PiSwitcher board, you need to download and install the FibStack software package. The software package is available as a self-extractable script and as a *.tar.gz archive.

File Size Release
fibstack_package-1.0.3.run 103KB March-15, 2023
fibstack_package-1.0.3.tar.gz 84KB March-15, 2023

Download one of the installation packages and follow the instructions below to install.

Self-extractable file installation

Step 1: Make sure that the *.run script has executable permission. Run ls -l in the folder where the file is.

$ ls -l
total 104
-rw-r--r-- 1 pi pi 105522 Nov 11 06:53 fibstack_package.run

Step 2: Use the chmod command to set the executable permission on the file if not set.

$ chmod +x fibstack_package.run
$ ls -l
total 104
-rwxr-xr-x 1 pi pi 105522 Nov 11 06:53 fibstack_package.run

Step 3: Run the installation file as a sudoer user. Otherwise, the software package will not install.

sudo ./fibstack_package.run

*.tar.gz file installation

Step 1: Unarchive the content of the *.tar archive.

tar -xf fibstack_package.tar.gz

Step 2: Run the install.sh file as a sudoer.

sudo ./install.sh

The installation process will install the FibStack Dashboard, FibStack CLI tool, programming libraries and enable the I2C interface if not enabled. If the installation was successful, you should be able to access the FibStack Dashboard at http://localhost:4545. The default I2C address is 0X50. You can change it using the FibStack Dashboard or FibStack CLI tool.

Code Examples

Before we dive into code examples, I want to take a few minutes and explain how the board works.

The FibStack Switcher Plus board contains eight devices: four relay switches and four 12-bit ADC channels. Each device on the board has an ID assigned to it.

The Relay Switch device is a Read/Write device, and it can have two potential values: 0 and 1 (or FALSE and TRUE, or OFF or ON).
0 - means default state, when no voltage applies to the relay coil, and the COM contact connects to NC contact.
1 - means connected state, the chip on the board energizes the relay’s coil, the COM contact connects to NO, and the LED indicator is lit up. The ADC device is Read-Only, and its value represents the result of the ADC conversion. The ADC device converts the signal applied to the corresponding ADC channel pin.

The FibStack Programming API allows to:

  • query all FibStack boards attached to the Raspberry Pi
  • get the values of each device on the board
  • set the value for the Read/Write devices

The code examples below assume you have the PiSwitcher Plus board attached to the Raspberry Pi and install the software package.

Below are C and Python program examples that turn on the relay switch 1 when the signal on the ADC device (channel 1) is above the half voltage reference. When the signal drops below the half voltage reference, the program turns off the Relay Switch 1.

Here is a sample schematic for the code sample below. It uses a potentiometer to change the signal value on the ADC1 pin. Based on the signal value, the example below will turn the light bulb on and off.

Example Schematic