top of page

1. How does it work?

1.1 Summary

1.How Does it Work?
- 1.1 Summary

The MODSPI Quad Relay board features 4x 5A relays each controlled over SPI using an IO Expander, all inside the compact footprint of 33 x 53mm. This makes it the most compact quad relay board on the market and provides the functionality of being controlled via SPI, using less GPIO pins than a conventional relay board.

1.2 IO Expander & Optocoupler

- 1.2 IO Expander & Optocoupler

The SPI interface operates on both 3.3V and 5V logic power allowing it to be controlled by any arduino microcontroller. The IO Expander used is an MCP23S17, the same used on the MODSPI Digital Outputs to simplify your programming experience.

Each output of the IO Expander is then stepped up to 24V using LTV817 optocouplers to provide suitable power to active the coils of the relays.

IO Expander Schematic.png

1.3 24V Relays

- 1.3 24V Relays

The relays used are HF49FD 24V. They are not only much higher quality than other relay boards but also high compact, allowing 4 of them to fit in a small footprint. Each relay channel has an indicator LED, with an additional fly-back diode for added protection. Both contacts of each relay are connected to the output connector labeled A and B. 

schematic_relay.png

1.4 Component packaging

To fit all of this amazing functionality within the small footprint of a MODSPI board size, some of the thinner components were placed on the underside of the board. 

- 1.4 Component Packaging
frontback.png

2. Specification 

2.1. Form

Form.png
  • 3.5mm plugable terminal connector (plug included).

  • Standard MODSPI interface with 8 way, 2.54mm pitch header pins for Power + Comms.

  • 2x M2 mounting holes.

  • Approx 16mm tall, with IO Expander mounted underneath. 

- 2.1 Form
2. Specification

2.2. Pinout

Form.png
- 2.2 Pinout

2.3. Electrical Characteristics 

QuadRelay Electrical Characteristics .png
- 2.3 Electrical Characteistics
- 2.4 Schematic

2.5. BOM

BOM.png
- 2.5 BOM

3. Code

3. Code

Overview

This example demonstrates how to use the MODSPI_QuadRelays class to control a set of 4 relays. The code initializes a MODSPI_QuadRelays instance, sets all relays off initially, and then sequentially toggles each output relay in the main loop.

Prerequisites

Ensure you have the MODSPI library installed in your Arduino IDE. If not, you can download and install it from the Library Manager or GITHUB.

Available Functions

Void begin (int chipSelect)

Starts the Initializes the quad relay module with the specified chip select pin. If you're using a MODSPI controller you can also put in "BAY1" and select your desired bay.

Void write (int channel, bool state)

Sets the specified relay channel (from 1-4) to the given state (HIGH or LOW). 

Example Code Breakdown

Include the MODSPI Library

First, we need to include the MODSPI library to access the necessary functions and classes.

#include <MODSPI.h>      

Create an Instance of MODSPI_QuadRelays

Next you create an instance of the MODSPI_QuadRelaysclass and name it whatever you want, for example relays1. If you have multiple digital output modules, you will need to create additional instances.

MODSPI_QuadRelays relays1;       

Setup Function

The setup function is called once when the Arduino starts. Here, we initialize the instance and perform some initial actions.

void setup() {

    // Initialize the relays1 instance with D5 as the chip select pin.

    relays1.begin(D5); // D5 is the chip select pin.

​

    // Turn off all of the relays

    for (int a = 1; a <= 4; a++) {

       relays1.write(a,LOW); // Turn off the relay

    }

}

Main Loop

In the main loop function we cycle through the 4 relays, turning each on and off in sequence.

void loop() {

    // Loop through the 4 relays, turning each on and off in sequence.

    for (int a = 1; a <= 4; a++) {

        relays1.write(a,HIGH); // Turn on the relay

        delay(100); // Wait for 500 milliseconds.

        relays1.write(a,LOW); // Turn off the relay

    }  

}

Want this product?

Check out our shop!

bottom of page