Beginner
10 min

Achieve flexible industrial digital input and output control for various industrial applications with MAX14906 and ATmega328P

IEC 61131-2 compliant quad-channel industrial digital output/input solution

DIGI I/O Click with Arduino UNO Rev3

Published Nov 11, 2024

Click board™

DIGI I/O Click

Dev. board

Arduino UNO Rev3

Compiler

NECTO Studio

MCU

ATmega328P

Gain flexible control over industrial digital inputs and outputs with configurable channels and built-in diagnostics ideal for automation, motor control, and PLC systems

A

A

Hardware Overview

How does it work?

DIGI I/O Click is based on the MAX14906, a quad-channel industrial digital input/output IC from Analog Devices, designed to meet the IEC 61131-2 standards. This IC allows each of its four channels to be configured independently, making it an ideal solution for applications that require high-speed digital I/O flexibility. Each channel can function as a high-side switch, push-pull driver, or digital input that complies with Type 1, 2, or 3 standards. This Click board™ excels in environments where adaptable digital I/O functionality is critical, offering robust and reliable performance for complex industrial automation and control systems. In output mode, the MAX14906 offers exceptional control, with high-side switch current limiting that can be adjusted between 130mA and 1.2A and an inrush current capability of up to twice the load current, ensuring reliable performance in demanding environments. The device also features an on-resistance of just 120mΩ at 25°C, allowing for efficient operation with minimal power loss. Additionally, the push-pull driver configuration enables high-speed signal transmission over cables, ensuring fast discharge of load capacitance for enhanced responsiveness. As a digital input

device, the MAX14906 supports precise current sinking for various configurations, with 2.3mA for Type 1 and 3 inputs and 7mA for Type 2. This versatility makes DIGI I/O Click suitable for industrial digital input and output modules, motor control systems, Programmable Logic Controllers (PLC), and Distributed Control Systems (DCS). Each of the four DO/I channels (1-4 terminals at the top of the board) can be individually configured for digital output operation by setting the corresponding SetDi_ bit within the SetOUT register to 0. By default, all four channels initialize as outputs. Driving the EN pin HIGH activates the outputs for channels 1-4 while setting it LOW disables or three-states all outputs. Two DoMode bits in the ConfigDO register control the output mode for each channel, allowing selection between high-side or push-pull configurations. The Typ2Di bit in the ConfigDI register manages the input configuration mode, switching between Type 1 and 3 or Type 2 inputs. To control or read the I/O levels, users can either use the SPI interface or directly manage the four bidirectional logic pins (D1 to D4). This Click board™ is designed for 24V operation, supplied through a terminal labeled V24. By

default, all channels (1-4) are powered with 24V; however, each channel can be individually powered with different voltage values by connecting alternative voltages to the V1-V4 terminals. To enable this functionality, users must first cut the traces on the back of the board to disable the default power configuration. Additionally, the board includes a VOK green LED that indicates the presence of a valid external power supply. The board communicates with the host MCU via an SPI interface with a maximum frequency of 10MHz. The SPI interface includes a built-in chip addressing decoder, enabling communication with multiple MAX14906-based boards using a shared SPI bus with a common chip select (CS) line. To support this, the board features a configurable SPI address that can be set using the ADDR SEL jumpers, allowing access to multiple MAX14906-based boards when used together. The SPI interface offers flexibility for global and per-channel configuration and diagnostics, including supply overvoltage and undervoltage detection, wire-break or open-wire detection, thermal overload protection, and current limit reporting.

DIGI I/O Click hardware overview image

Features overview

Development board

Arduino UNO is a versatile microcontroller board built around the ATmega328P chip. It offers extensive connectivity options for various projects, featuring 14 digital input/output pins, six of which are PWM-capable, along with six analog inputs. Its core components include a 16MHz ceramic resonator, a USB connection, a power jack, an

ICSP header, and a reset button, providing everything necessary to power and program the board. The Uno is ready to go, whether connected to a computer via USB or powered by an AC-to-DC adapter or battery. As the first USB Arduino board, it serves as the benchmark for the Arduino platform, with "Uno" symbolizing its status as the

first in a series. This name choice, meaning "one" in Italian, commemorates the launch of Arduino Software (IDE) 1.0. Initially introduced alongside version 1.0 of the Arduino Software (IDE), the Uno has since become the foundational model for subsequent Arduino releases, embodying the platform's evolution.

Arduino UNO Rev3 double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

2048

You complete me!

Accessories

Click Shield for Arduino UNO has two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the Arduino UNO board without effort. The Arduino Uno, a microcontroller board based on the ATmega328P, provides an affordable and flexible way for users to try out new concepts and build prototypes with the ATmega328P microcontroller from various combinations of performance, power consumption, and features. The Arduino Uno has 14 digital input/output pins (of which six can be used as PWM outputs), six analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header, and reset button. Most of the ATmega328P microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the Arduino UNO board with our Click Shield for Arduino UNO, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Arduino UNO accessories 1 image

Wire Jumpers Male to Male (15 cm length, 10pcs) is a set of high-quality jumper wires designed for easy prototyping and testing. Each wire in the set is 15cm long, with male connectors on both ends, allowing an easy connection between components on breadboards or other electronic projects. The set includes ten wires in different colors, providing clear identification and organization in your circuit. These wire jumpers are ideal for DIY projects, setups, and other electronic applications where quick, reliable connections are required.

DIGI I/O Click accessories 2 image

Wire Jumpers Male to Female (15 cm length, 10pcs) is a set of high-quality jumper wires designed for easy prototyping and testing. Each wire in the set is 15cm long, with male connectors on one end and female on other, allowing an easy connection between components on breadboards or other electronic projects. The set includes ten wires in different colors, providing clear identification and organization in your circuit. These wire jumpers are ideal for DIY projects, setups, and other electronic applications where quick, reliable connections are required.

DIGI I/O Click accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Data Ready Indicator
PC0
AN
Output Enable / ID SEL
PD2
RST
SPI Select / ID COMM
PB2
CS
SPI Clock
PB5
SCK
SPI Data OUT
PB4
MISO
SPI Data IN
PB3
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Synchronization Control
PD6
PWM
Fault Indicator
PC3
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

DIGI I/O Click Schematic schematic

Step by step

Project assembly

Click Shield for Arduino UNO front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Arduino UNO Rev3 as your development board.

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Arduino UNO Rev3 Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Arduino UNO MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for DIGI I/O Click driver.

Key functions:

  • digiio_write_reg - This function writes data to the selected register by using SPI serial interface.

  • digiio_read_reg - This function reads data from the selected register by using SPI serial interface.

  • digiio_sync_io - This function synchronizes registers by toggling the SYNC pin logic state.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief DIGI IO Click example
 *
 * # Description
 * This example demonstrates the use of DIGI IO click board by setting and reading 
 * the DOI channels state.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration which sets 
 * the DOI1 and DOI2 as output and the DOI3 and DOI4 as inputs.
 *
 * ## Application Task
 * Toggles the DOI1 and DOI2 pins state and then reads the status of all four DOI pins
 * and displays the results on the USB UART approximately once per second.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "digiio.h"

static digiio_t digiio;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    digiio_cfg_t digiio_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    digiio_cfg_setup( &digiio_cfg );
    DIGIIO_MAP_MIKROBUS( digiio_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == digiio_init( &digiio, &digiio_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( DIGIIO_ERROR == digiio_default_cfg ( &digiio ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    uint8_t set_out = 0;
    uint8_t doi_level = 0;
    digiio_sync_io ( &digiio );
    if ( DIGIIO_OK == digiio_read_reg ( &digiio, DIGIIO_REG_SET_OUT, &set_out ) )
    {
        set_out ^= ( DIGIIO_SET_OUT_HIGH_O1_MASK | DIGIIO_SET_OUT_HIGH_O2_MASK );
        if ( DIGIIO_OK == digiio_write_reg ( &digiio, DIGIIO_REG_SET_OUT, set_out ) )
        {
            digiio_sync_io ( &digiio );
        }
    }
    if ( DIGIIO_OK == digiio_read_reg ( &digiio, DIGIIO_REG_DOI_LEVEL, &doi_level ) )
    {
        if ( doi_level & DIGIIO_DOI_LEVEL_DOI1 )
        {
            log_printf ( &logger, " DOI1: HIGH\r\n" );
        }
        else
        {
            log_printf ( &logger, " DOI1: LOW\r\n" );
        }
        if ( doi_level & DIGIIO_DOI_LEVEL_DOI2 )
        {
            log_printf ( &logger, " DOI2: HIGH\r\n" );
        }
        else
        {
            log_printf ( &logger, " DOI2: LOW\r\n" );
        }
        if ( doi_level & DIGIIO_DOI_LEVEL_DOI3 )
        {
            log_printf ( &logger, " DOI3: HIGH\r\n" );
        }
        else
        {
            log_printf ( &logger, " DOI3: LOW\r\n" );
        }
        if ( doi_level & DIGIIO_DOI_LEVEL_DOI4 )
        {
            log_printf ( &logger, " DOI4: HIGH\r\n" );
        }
        else
        {
            log_printf ( &logger, " DOI4: LOW\r\n" );
        }
        log_printf ( &logger, "\r\n" );
    }
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.