TOP Contributors

  1. MIKROE (2672 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (137407 times)
  2. FAT32 Library (70434 times)
  3. Network Ethernet Library (56227 times)
  4. USB Device Library (46648 times)
  5. Network WiFi Library (42297 times)
  6. FT800 Library (41535 times)
  7. GSM click (29218 times)
  8. mikroSDK (26748 times)
  9. PID Library (26562 times)
  10. microSD click (25591 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

DIGI IN 2 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-29

Package Version: 2.1.0.1

mikroSDK Library: 2.0.0.0

Category: Port expander

Downloaded: 11 times

Not followed.

License: MIT license  

DIGI IN 2 Click is a compact add-on board designed for converting high-voltage industrial signals into logic-level outputs, ideal for enhancing industrial control systems. This board features the MAX22196, a high-performance octal industrial sink/source digital input IC from Analog Devices. This Click board™ stands out for its ability to interface eight industrial inputs (8V-24V) via SPI, configurable as either sinking or sourcing with built-in current limiters, ensuring adherence to IEC 61131-2 standards.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "DIGI IN 2 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "DIGI IN 2 click" changes.

Do you want to report abuse regarding "DIGI IN 2 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


DIGI IN 2 click

DIGI IN 2 Click is a compact add-on board designed for converting high-voltage industrial signals into logic-level outputs, ideal for enhancing industrial control systems. This board features the MAX22196, a high-performance octal industrial sink/source digital input IC from Analog Devices. This Click board™ stands out for its ability to interface eight industrial inputs (8V-24V) via SPI, configurable as either sinking or sourcing with built-in current limiters, ensuring adherence to IEC 61131-2 standards.

digiin2_click.png

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Dec 2023.
  • Type : SPI type

Software Support

We provide a library for the DIGI IN 2 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for DIGI IN 2 Click driver.

Standard key functions :

  • digiin2_cfg_setup Config Object Initialization function.

    void digiin2_cfg_setup ( digiin2_cfg_t *cfg );
  • digiin2_init Initialization function.

    err_t digiin2_init ( digiin2_t *ctx, digiin2_cfg_t *cfg );
  • digiin2_default_cfg Click Default Configuration function.

    err_t digiin2_default_cfg ( digiin2_t *ctx );

Example key functions :

  • digiin2_get_flt_pin This function is used to get state of the FLT pin.

    uint8_t digiin2_get_flt_pin ( digiin2_t *ctx );
  • digiin2_write_reg This function is used to write data into the selected register by using SPI serial interface.

    err_t digiin2_write_reg ( digiin2_t *ctx, uint8_t reg, uint8_t data_in );
  • digiin2_read_reg This function reads a data byte from the selected register by using SPI serial interface.

    err_t digiin2_read_reg ( digiin2_t *ctx, uint8_t reg, uint8_t *data_out );

Example Description

This example demonstrates the use of DIGI IN 2 Click board by reading and displaying the state of the channels.

The demo application is composed of two sections :

Application Init

Initializes the driver, performs the click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    digiin2_cfg_t digiin2_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.
    digiin2_cfg_setup( &digiin2_cfg );
    DIGIIN2_MAP_MIKROBUS( digiin2_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == digiin2_init( &digiin2, &digiin2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( DIGIIN2_ERROR == digiin2_default_cfg ( &digiin2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Reads and displays on the USB UART the channel state every second.

void application_task ( void )
{    
    uint8_t channel_data = 0;

    digiin2_pulse_latch( &digiin2 );

    if ( DIGIIN2_OK == digiin2_read_reg( &digiin2, DIGIIN2_REG_DISTATE, &channel_data ) )
    {
        if ( channel_data & DIGIIN2_CHANNEL_1_MASK )
        {
            log_printf( &logger, "Channel 1 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 1 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_2_MASK )
        {
            log_printf( &logger, "Channel 2 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 2 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_3_MASK )
        {
            log_printf( &logger, "Channel 3 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 3 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_4_MASK )
        {
            log_printf( &logger, "Channel 4 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 4 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_5_MASK )
        {
            log_printf( &logger, "Channel 5 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 5 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_6_MASK )
        {
            log_printf( &logger, "Channel 6 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 6 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_7_MASK )
        {
            log_printf( &logger, "Channel 7 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 7 counter: LOW \r\n" );
        }
        if ( channel_data & DIGIIN2_CHANNEL_8_MASK )
        {
            log_printf( &logger, "Channel 8 counter: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 8 counter: LOW \r\n" );
        }
        log_printf( &logger, "- - - - - - - - - - - - - -\r\n" );
    }
    else
    {
        log_error( &logger, " Read error." );
    }

    if ( DIGIIN2_PIN_STATE_HIGH == digiin2_get_flt_pin( &digiin2 ) )
    {
        uint8_t flt_data = 0;
        digiin2_read_reg( &digiin2, DIGIIN2_REG_FAULT, &flt_data );
        log_printf( &logger, "Fault1 data: 0x%.2X \r\n", ( uint16_t ) flt_data );
        digiin2_read_reg( &digiin2, DIGIIN2_REG_FAULT2, &flt_data );
        log_printf( &logger, "Fault2 data: 0x%.2X \r\n", ( uint16_t ) flt_data );
        log_printf( &logger, "- - - - - - - - - - - - - -\r\n" );
    }

    Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.DIGIIN2

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

Thumbwheel click

15

Thumbwheel click is a mikroBUS add-on board with a 10-position rotary sprocket connected to a 1-Wire 8-Channel Addressable Switch.

[Learn More]

EEG click

5

EEG Click is a Click board that allows monitoring of brain activity. Although not suitable for clinical examination, it is quite sufficient to allow some insight into brain activity.

[Learn More]

Accel 16 click

0

Accel 16 Click is a compact add-on board that contains an acceleration sensor. This board features the ADXL363, a micropower three-sensor combination including acceleration and temperature from Analog Devices. This device combines a 3-axis MEMS accelerometer, a temperature sensor, and an analog-to-digital converter (ADC) input for synchronized conversions of external signals.

[Learn More]