Beginner
10 min

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

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

DIGI I/O Click with EasyAVR v7

Published Nov 11, 2024

Click board™

DIGI I/O Click

Dev. board

EasyAVR v7

Compiler

NECTO Studio

MCU

ATmega32

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

EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more

efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)

connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyAVR v7 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

2048

You complete me!

Accessories

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
PA7
AN
Output Enable / ID SEL
PA6
RST
SPI Select / ID COMM
PA5
CS
SPI Clock
PB7
SCK
SPI Data OUT
PB6
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Synchronization Control
PD4
PWM
Fault Indicator
PD2
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

EasyAVR v7 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR v7 as your development board.

EasyAVR v7 front image hardware assembly
GNSS2 Click front image hardware assembly
MCU DIP 40 hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
EasyAVR v7 Access DIP 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
EasyPIC PRO v7a Display Selection Necto Step hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image 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.