opto7 2.1.0.0
Main Page

Opto 7 click

‍Opto 7 Click is a compact add-on board that provides uncomplicated safety isolation from high voltage. This board features two ISOM8710, high-speed single-channel opto-emulators from Texas Instruments. The ISOM8710 opto-emulator has a diode-emulator input and digital output

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Sep 2023.
  • Type : UART/GPIO type

Software Support

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

Standard key functions :

  • opto7_cfg_setup Config Object Initialization function.
    void opto7_cfg_setup(opto7_cfg_t *cfg)
    Opto 7 configuration object setup function.
    Opto 7 Click configuration object.
    Definition opto7.h:148
  • opto7_init Initialization function.
    err_t opto7_init ( opto7_t *ctx, opto7_cfg_t *cfg );
    err_t opto7_init(opto7_t *ctx, opto7_cfg_t *cfg)
    Opto 7 initialization function.
    Opto 7 Click context object.
    Definition opto7.h:125

Example key functions :

Example Description

‍This example demonstrates the use of Opto 7 click board by processing the incoming data and displaying them on the USB UART.

The demo application is composed of two sections :

Application Init

‍Initialization of UART LOG and GPIO pin, and UART drivers.

void application_init ( void )
{
log_cfg_t log_cfg;
opto7_cfg_t opto7_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
opto7_cfg_setup( &opto7_cfg );
OPTO7_MAP_MIKROBUS( opto7_cfg, MIKROBUS_1 );
#if ( DEMO_EXAMPLE == EXAMPLE_GPIO )
#else
#endif
if ( UART_ERROR == opto7_init( &opto7, &opto7_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define OPTO7_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition opto7.h:100
void opto7_drv_interface_selection(opto7_cfg_t *cfg, opto7_drv_t drv_sel)
Opto 7 driver interface setup function.
void application_init(void)
Definition main.c:78
@ OPTO7_DRV_SEL_GPIO
Definition opto7.h:115
@ OPTO7_DRV_SEL_UART
Definition opto7.h:116

Application Task

‍This example is made of two parts: GPIO Example - The output pin is toggled every 5 seconds and input pin state is being tracked. UART Example - Device assigned as transmitter is sending message and receiver is reading it and displaying it on USB UART.

void application_task ( void )
{
#if ( DEMO_EXAMPLE == EXAMPLE_GPIO )
log_printf( &logger, " GP1 pin state HIGH \r\n" );
{
log_printf( &logger, " GP2 pin state HIGH \r\n" );
}
else
{
log_printf( &logger, " GP2 pin state LOW \r\n" );
}
log_printf( &logger, "- - - - - - - - - - - -\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " GP1 pin state LOW \r\n" );
{
log_printf( &logger, " GP2 pin state HIGH \r\n" );
}
else
{
log_printf( &logger, " GP2 pin state LOW \r\n" );
}
log_printf( &logger, "- - - - - - - - - - - -\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#else
#if defined TRANSMITTER
log_printf( &logger, " Message sent! \r\n" );
opto7_generic_write( &opto7, TX_MESSAGE, strlen( TX_MESSAGE ) );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#else
if ( OPTO7_OK == opto7_process( &opto7 ) )
{
opto7_log_app_buf( );
opto7_clear_app_buf( );
}
#endif
#endif
}
#define OPTO7_PIN_STATE_LOW
Definition opto7.h:74
#define OPTO7_PIN_STATE_HIGH
Opto 7 control commands.
Definition opto7.h:73
#define TX_MESSAGE
Definition main.c:39
void application_task(void)
Definition main.c:115
@ OPTO7_OK
Definition opto7.h:173

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.Opto7

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.