TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (387 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (119 codes)
  5. Bugz Bensce (97 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 (140131 times)
  2. FAT32 Library (72525 times)
  3. Network Ethernet Library (57599 times)
  4. USB Device Library (47918 times)
  5. Network WiFi Library (43480 times)
  6. FT800 Library (42895 times)
  7. GSM click (30115 times)
  8. mikroSDK (28618 times)
  9. PID Library (27042 times)
  10. microSD click (26526 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 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.9

mikroSDK Library: 2.0.0.0

Category: Port expander

Downloaded: 115 times

Not followed.

License: MIT license  

DIGI IN Click is a compact add-board that converts industrial inputs into serialized SPI-compatible output. This board features the MAX22199, an octal industrial digital input from Analog Devices. It stands out for its compliance with the IEC 61131-2 standard, ensuring reliability and efficiency.

No Abuse Reported

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

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

Do you want to report abuse regarding "DIGI IN Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


DIGI IN Click

DIGI IN Click is a compact add-board that converts industrial inputs into serialized SPI-compatible output. This board features the MAX22199, an octal industrial digital input from Analog Devices. It stands out for its compliance with the IEC 61131-2 standard, ensuring reliability and efficiency.

digiin_click.png

Click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jan 2024.
  • Type : SPI type

Software Support

We provide a library for the DIGI IN 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 Click driver.

Standard key functions :

  • digiin_cfg_setup Config Object Initialization function.

    void digiin_cfg_setup ( digiin_cfg_t *cfg );
  • digiin_init Initialization function.

    err_t digiin_init ( digiin_t *ctx, digiin_cfg_t *cfg );
  • digiin_default_cfg Click Default Configuration function.

    err_t digiin_default_cfg ( digiin_t *ctx );

Example key functions :

  • digiin_write_reg This function is used to write data into the selected register by using SPI serial interface.

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

    err_t digiin_read_reg ( digiin_t *ctx, uint8_t reg, uint8_t *data_out );
  • digiin_pulse_latch This function is used to generate LATCH pulse for capturing channel data.

    void digiin_pulse_latch ( digiin_t *ctx );

Example Description

This example demonstrates the use of DIGI IN 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. */
    digiin_cfg_t digiin_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.
    digiin_cfg_setup( &digiin_cfg );
    DIGIIN_MAP_MIKROBUS( digiin_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == digiin_init( &digiin, &digiin_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    while ( DIGIIN_PIN_STATE_HIGH == digiin_get_rdy_pin( &digiin ) )
    {
        log_printf( &logger, "Please check if 24V is connected \r\n" );
        Delay_ms ( 1000 );
    }

    if ( DIGIIN_ERROR == digiin_default_cfg ( &digiin ) )
    {
        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;

    digiin_pulse_latch( &digiin );

    if ( DIGIIN_OK == digiin_read_reg( &digiin, DIGIIN_REG_DISTATE, &channel_data ) )
    {
        if ( channel_data & DIGIIN_CHANNEL_1_MASK )
        {
            log_printf( &logger, "Channel 1 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 1 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_2_MASK )
        {
            log_printf( &logger, "Channel 2 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 2 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_3_MASK )
        {
            log_printf( &logger, "Channel 3 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 3 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_4_MASK )
        {
            log_printf( &logger, "Channel 4 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 4 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_5_MASK )
        {
            log_printf( &logger, "Channel 5 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 5 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_6_MASK )
        {
            log_printf( &logger, "Channel 6 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 6 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_7_MASK )
        {
            log_printf( &logger, "Channel 7 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 7 State: LOW \r\n" );
        }
        if ( channel_data & DIGIIN_CHANNEL_8_MASK )
        {
            log_printf( &logger, "Channel 8 State: HIGH \r\n" );
        }
        else
        { 
            log_printf( &logger, "Channel 8 State: LOW \r\n" );
        }
        log_printf( &logger, "- - - - - - - - - - - - - -\r\n" );
    }
    else
    {
        log_error( &logger, " Read error." );
    }

    if ( DIGIIN_PIN_STATE_HIGH == digiin_get_flt_pin( &digiin ) )
    {
        uint8_t flt_data = 0;
        digiin_read_reg( &digiin, DIGIIN_REG_FAULT1, &flt_data );
        log_printf( &logger, "Fault1 data: 0x%.2X \r\n", ( uint16_t ) flt_data );
        digiin_read_reg( &digiin, DIGIIN_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.DIGIIN

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

6DOF IMU Click

0

6DOF IMU Click carries ST’s LSM6DS33TR 6-axis inertial measurement unit comprising a 3-axis gyroscope and a 3-axis accelerometer. The chip is a highly accurate 6 DOF inertial measurement unit with long-term stable operation over a wide range of temperatures.

[Learn More]

Magneto 5 Click

0

Magneto 5 Click is a very accurate and reliable magnetic sensor device, which features the MEMSIC MMC34160PJ, a 3-axis magnetic sensor IC

[Learn More]

Battery Source Click

0

Battery Source Click is a compact add-on board designed to boost power from a battery for portable applications. This board features the TPS81256, a high-efficiency step-up converter from Texas Instruments. The board boosts input voltage (2.5V to 5.5V) to 5V/1A on a USB Type-C connector. It operates at a 4MHz switching frequency, enters Power-Save mode at light loads, and reduces supply current to 43μA during light load operation. The board supports over 3W output power and has an input current of less than 1µA in shutdown mode, maximizing battery life.

[Learn More]