top of page

1. How does it work?

1.1 Summary

1.How Does it Work?
- 1.1 Summary

Most industrial components operate at 12V or 24V, which presents a challenge when integrating them with microcontrollers like Arduino, which typically operate at 3.3V or 5V. Directly connecting these higher voltage inputs risks damaging the microcontroller, as they are not isolated and are vulnerable to voltage spikes. Addressing this, the MODSPI Digital Inputs Module offers a streamlined solution.

The module provides 8 opto-isolated inputs, capable of safely handling voltages between 12V and 30V. Each input is processed through an SPI IO Expander, significantly reducing the number of GPIO pins required on the microcontroller. Optocouplers ensure robust electrical isolation, safeguarding your microcontroller from harmful spikes or surges. For added convenience, each input features an indicator LED, offering clear visual feedback on the system’s status. This design simplifies integration with industrial components while conserving critical GPIO resources, making it an ideal choice for more efficient and reliable project development.

1.2 IO Expander

- 1.2 IO Expander

This module is built around the MCP23S17 IO Expander, which features 16 channels distributed over two buses, effectively expanding the digital IO capacity available to a microcontroller. For this specific setup, bus A is dedicated to digital inputs, allowing each input to be monitored either individually or collectively.

Input signals, which can range from 12-30V, are appropriately stepped down to the microcontroller's VCC level, either 3.3V or 5V, thanks to the integration of an optocoupler circuit. This allows the IO Expander to operate within a safe range and maximizes the input range this module can support. 

IO Expander.png

1.3 Opto Coupler Relay

- 1.3 Isolated Channels

Each digital input channel on this module is optically isolated, employing an LTV-847 Optocoupler for this purpose. The setup works by taking the high-voltage digital input to simultaneously power the indicator LED and activate the optocoupler's internal LED. This arrangement ensures that a clean, noise-free output voltage, matching the microcontroller's VCC (either 3.3V or 5V), is produced for the IO Expander to read. Additionally, a 10K pull-down resistor is integrated into each channel to facilitate fast switching, further optimizing the module's performance for precise and reliable digital input processing.

RelaySchematic.png

2. Specification 

2.1. Form

DigitalInputs_form.png
  • 9 way 3.5mm plugable terminal connectors (plug included).

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

- 2.1 Form
2. Specification

2.2. Pinout

DigitalInput Pinout.png
- 2.2 Pinout

2.3. Electrical Characteristics 

Coming Soon...

- 2.3 Electrical Characteistics

2.4. Schematic 

Schematic PNG.jpg
- 2.4 Schematic

3. Code

3. Code

Overview

This example demonstrates how to use the MODSPI_DigitalInputs class to read a set of digital input channels. The code initializes a MODSPI_DigitalInputs instance and then reads through each input channel 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 digital Input 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.

Bool read (int channel)

Reads the specified Input channel (from 0-7).

Int8_t state readAll ()

Reads all the input channels at once. 

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_DigitalInputs

Next you create an instance of the MODSPI_DigitalInputs class and name it whatever you want, for example inputs1. If you have multiple digital inputs modules, you will need to create additional instances.

MODSPI_DigitalInputs inputs1;       

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 inputs1 instance with D5 as the chip select pin.

    Serial.begin(9600); // Start the Serial

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

}

Main Loop

In the main loop function we cycle through digital inputs 0 to 7 and prints the read state.

void loop() {

    // Loop through digital inputs 0 to 7 and print them to Serial.

    for (int a = 0; a <= 7; a++) {

        bool readInput = inputs1.read(a);

        Serial.print("Input ");

        Serial.print(a);

        Serial.print(" : ");

        Serial.println( readInput );

    }

}

Want this product?

Check out our shop!

bottom of page