Safeguard delicate signals from potential harm, such as electrical noise or voltage fluctuations, ensuring they reach their destination intact and unaltered.
A
A
Hardware Overview
How does it work?
Opto 2 Click is based on four TLP2770, 20Mbps low-power optocouplers from Toshiba Semiconductor. These are fast optocouplers, with their output stages shielded against EMI, allowing them to work on higher speeds, providing common-mode transient immunity of ±20 kV/μs. The internal LED elements are driven with 4mA for 5V operation or 2.6mA for 3.3V operation. The input stages are also equipped with (Schottky) diodes, which prevents inverse polarization of the LED elements and thus, a permanent damage that might occur in that case. The working principle of the optocouplers is quite simple: A photo-emitting element - usually a LED, is encapsulated inside the die along with the photo-sensitive element, which can be a photo-sensitive transistor or a photo-diode. LEDs and photo-sensing elements are galvanically isolated, making the input and output electrical networks completely independent of each other. When the LED is biased, it emits light which in return causes the current to flow through
the photo-sensitive element. In these particular optocouplers, the output stage is additionally conditioned by a Schmitt trigger and it drives the output transistors which form a totem pole output stage. Having a totem pole output configuration allows the output stage to both sink and source current. The optocoupler inputs - the anodes (labeled as A) and cathodes (labeled as C) of the internal optocoupler LEDs, are routed to the screw terminals, which allow connection the external electrical circuit, used to trigger an event on the isolated MCU. The electrical potential between the anode and the cathode input of each optocoupler element should stay within the range between 3.3V and 5V. The optocoupler outputs are routed to the mikroBUS™ The mikroBUS™ pins INT, CS, RST, and AN, are routed to the optocoupler outputs 1, 2, 3, and 4, respectively, and are labeled as IN1, IN2, IN3, and IN4. As already mentioned, the output stages are conditioned with the Schmitt trigger circuit, reducing the input noise sensitivity
and false triggering. The Faraday shield protects the output stages against EMI and provides common-mode transient immunity of ±20 kV/μs. Although these mikroBUS™ pins are labeled as IN1 to IN4, they are actually outputs from the optocouplers, and it is highly recommended to use them as the INPUT pins on the host MCU. The Click board™ is equipped with an SMD jumper labeled as LOGIC, which allows selection of the voltage, applied to the optocoupler output stage. This voltage effectively determines the logic voltage level for the MCU pins. It can be selected between 3.3V and 5V, allowing this Click board™ to be interfaced with both 3.3V and 5V MCUs. The provided library offers functions that simplify and speed up the application development. The included example application demonstrates their use. This application can be used as a reference for custom projects.
Features overview
Development board
PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive
mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI
GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.
Microcontroller Overview
MCU Card / MCU
![default](https://dbp-cdn.mikroe.com/catalog/mcus/resources/PIC18F57Q43.jpeg)
Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
48
RAM (Bytes)
8196
You complete me!
Accessories
Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
![Opto 2 Click Schematic schematic](https://dbp-cdn.mikroe.com/catalog/click-boards/resources/1ee790b8-1f4e-6fa2-a2f1-0242ac120009/schematic.webp)
Step by step
Project assembly
Track your results in real time
Application Output
After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.
![Application Output Step 1](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed554e-d80f-6694-8cb9-02420a000272/AP-Step1.jpg)
After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.
![Application Output Step 3](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed5550-3c0f-6800-a19f-02420a000272/AP-Step3.jpg)
Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.
![Application Output Step 4](https://dbp-cdn.mikroe.com/cms/shared-resources/1eed5550-d4d0-6b20-a348-02420a000272/AP-Step4.jpg)
Software Support
Library Description
This library contains API for Opto 2 Click driver.
Key functions:
opto2_check_out1
- OUT1 Check functionopto2_check_out2
- OUT2 Check functionopto2_check_out3
- OUT3 Check function
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief Opto 2 Click example
*
* # Description
* This application used to provide an optical isolation of sensitive microcontroller.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes device selects the outputs (OUT1 - OUT4) which state be checked.
*
* ## Application Task
* Performs the check procedure for selected outputs and logs the states from that
outputs on USB UART. Repeat the check procedure every 2 seconds.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "opto2.h"
// ------------------------------------------------------------------ VARIABLES
static opto2_t opto2;
static log_t logger;
static uint8_t sel_output;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void opto2_set_logger ( uint8_t sel_out1, uint8_t sel_out2, uint8_t sel_out3, uint8_t sel_out4 )
{
if ( sel_out1 > 1 )
{
sel_out1 = 1;
}
if ( sel_out2 > 1 )
{
sel_out2 = 1;
}
if ( sel_out3 > 1 )
{
sel_out3 = 1;
}
if ( sel_out4 > 1 )
{
sel_out4 = 1;
}
sel_output = 0;
sel_output |= sel_out1;
sel_output |= sel_out2 << 1;
sel_output |= sel_out3 << 2;
sel_output |= sel_out4 << 3;
}
void application_init ( void )
{
log_cfg_t log_cfg;
opto2_cfg_t cfg;
/**
* 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 );
opto2_cfg_setup( &cfg );
OPTO2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
opto2_init( &opto2, &cfg );
log_info( &logger, "---- Application Init ----" );
opto2_set_logger( 1, 1, 0, 0 );
log_printf( &logger, "OPTO 2 is initialized \r\n" );
log_printf( &logger, "" );
Delay_ms( 200 );
}
void application_task ( void )
{
uint8_t check_output;
uint8_t cnt;
uint8_t tmp;
tmp = 1;
for ( cnt = 0; cnt < 4; cnt++ )
{
switch ( sel_output & tmp )
{
case 0x01 :
{
check_output = opto2_check_out1( &opto2 );
if ( check_output == 0 )
{
log_printf( &logger, "OUT1 is low\r\n" );
}
else
{
log_printf( &logger, "OUT1 is high\r\n" );
}
break;
}
case 0x02 :
{
check_output = opto2_check_out2( &opto2 );
if ( check_output == 0 )
{
log_printf( &logger, "OUT2 is low\r\n" );
}
else
{
log_printf( &logger, "OUT2 is high\r\n" );
}
break;
}
case 0x04 :
{
check_output = opto2_check_out3( &opto2 );
if ( check_output == 0 )
{
log_printf( &logger, "OUT3 is low\r\n" );
}
else
{
log_printf( &logger, "OUT3 is high\r\n" );
}
break;
}
case 0x08 :
{
check_output = opto2_check_out4( &opto2 );
if ( check_output == 0 )
{
log_printf( &logger, "OUT4 is low\r\n" );
}
else
{
log_printf( &logger, "OUT4 is high\r\n" );
}
break;
}
default :
{
break;
}
}
tmp <<= 1;
}
Delay_ms( 2000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END