初学者
10 分钟

使用ISOM8710和STM32F302VC实现高压安全隔离

高压,无忧

Opto 7 Click with CLICKER 4 for STM32F302VCT6

已发布 7月 22, 2025

点击板

Opto 7 Click

开发板

CLICKER 4 for STM32F302VCT6

编译器

NECTO Studio

微控制器单元

STM32F302VC

一种安全屏蔽装置,可以添加到电子系统中,特别适用于电源、电表、马达驱动和自动化系统等应用。

A

A

硬件概览

它是如何工作的?

Opto 7 Click 基于两个 ISOM8710,它们是德州仪器的高速单通道光耦仿真器。它可以传输高达 25Mbps 的数据速率,并输出 CMOS 兼容的 3.3V 和 5V 信号。与光耦相比,ISOM7810 具有较高的共模瞬态抗扰度、低传播延迟、小脉冲失真、低功耗等优点。Opto 7 Click 配备了两个这些光耦仿真

器用于接收和传输数据。外部电源可以连接到 VCC2 端子,必须是 3.3V 或 5V。三针端子连接输入和输出数据线以及公共接地。Opto 7 Click 可以使用通用 IO 通过 GP1 和 GP2 引脚与主机 MCU 通信。它还可以用于标准 UART 通信隔离,常用的 UART RX 和 TX 引脚。选择可以通过 OUT SEL 和 IN 

SEL 跳线进行。为了通信正常工作,两者都应处于正确位置。此 Click board™ 可以通过 VCC SEL 跳线选择 3.3V 或 5V 逻辑电压级别进行操作。这样,具有 3.3V 和 5V 功能的 MCU 都可以正确使用通信线。另外,此 Click board™ 配有包含易于使用功能和示例代码的库,可作为进一步开发的参考。

Opto 7 Click hardware overview image

功能概述

开发板

Clicker 4 for STM32F3 是一款紧凑型开发板,作为完整的解决方案而设计,可帮助用户快速构建具备独特功能的定制设备。该板搭载 STMicroelectronics 的 STM32F302VCT6 微控制器,配备四个 mikroBUS™ 插槽用于连接 Click boards™、完善的电源管理功能以及其他实用资源,是快速开发各类应用的理想平台。其核心 MCU STM32F302VCT6 基于高性能 

Arm® Cortex®-M4 32 位处理器,运行频率高达 168MHz,处理能力强大,能够满足各种高复杂度任务的需求,使 Clicker 4 能灵活适应多种应用场景。除了两个 1x20 引脚排针外,板载最显著的连接特性是四个增强型 mikroBUS™ 插槽,支持接入数量庞大的 Click boards™ 生态系统,该生态每日持续扩展。Clicker 4 各功能区域标识清晰,界面直观简洁,极大

提升使用便捷性和开发效率。Clicker 4 的价值不仅在于加速原型开发与应用构建阶段,更在于其作为独立完整方案可直接集成至实际项目中,无需额外硬件修改。四角各设有直径 4.2mm(0.165")的安装孔,便于通过螺丝轻松固定。对于多数应用,只需配套一个外壳,即可将 Clicker 4 开发板转化为完整、实用且外观精美的定制系统。

CLICKER 4 for STM32F302VCT6 double image

微控制器概述 

MCU卡片 / MCU

STM32F302VC Image

建筑

ARM Cortex-M4

MCU 内存 (KB)

256

硅供应商

STMicroelectronics

引脚数

100

RAM (字节)

40960

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
ID COMM
PA4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
PE9
PWM
General-Purpose I/O
PD0
INT
UART TX
PA2
TX
UART RX
PA3
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Opto 7 Click Schematic schematic

一步一步来

项目组装

PIC32MZ MXS Data Capture Board front image hardware assembly

从选择您的开发板和Click板™开始。以CLICKER 4 for STM32F302VCT6作为您的开发板开始。

PIC32MZ MXS Data Capture Board front image hardware assembly
Thermo 21 Click front image hardware assembly
Thermo 21 Click complete accessories setup image hardware assembly
Board mapper by product6 hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
PIC32MZ MXS Data Capture Board NECTO MCU Selection Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto image step 11 hardware assembly

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

该库包含 Opto 7 Click 驱动程序的 API。

关键功能:

  • opto7_generic_write - Opto 7 数据写入功能。

  • opto7_set_gp1_pin - Opto 7 设置 GP1 引脚功能。

  • opto7_get_gp2_pin - Opto 7 获取 GP2 引脚功能。

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief Opto 7 Click 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.
 *
 * ## 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.
 * 
 * ## Additional Function
 * - static void opto7_clear_app_buf ( void )
 * - static void opto7_log_app_buf ( void )
 * - static err_t opto7_process ( opto7_t *ctx )
 * 
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "opto7.h"

// Example selection macros
#define EXAMPLE_GPIO                1               // Example of using GPIO
#define EXAMPLE_UART                2               // Example of using UART
#define DEMO_EXAMPLE                EXAMPLE_GPIO    // Example selection macro

// Macros for UART example
#define TRANSMITTER                 // Comment out this line to place device into receiver mode
#define TX_MESSAGE                  "Opto 7 Click Example \r\n"

// Application buffer size
#define APP_BUFFER_SIZE             500
#define PROCESS_BUFFER_SIZE         200

static opto7_t opto7;
static log_t logger;


static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

/**
 * @brief Test clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void opto7_clear_app_buf ( void );

/**
 * @brief Test log application buffer.
 * @details This function logs data from application buffer to USB UART.
 * @note None.
 */
static void opto7_log_app_buf ( void );

/**
 * @brief Test data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #opto7_t object definition for detailed explanation.
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t opto7_process ( opto7_t *ctx );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    opto7_cfg_t opto7_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.
    opto7_cfg_setup( &opto7_cfg );
    OPTO7_MAP_MIKROBUS( opto7_cfg, MIKROBUS_1 );
    
#if ( DEMO_EXAMPLE == EXAMPLE_GPIO )
    opto7_drv_interface_selection( &opto7_cfg, OPTO7_DRV_SEL_GPIO );
#else
    opto7_drv_interface_selection( &opto7_cfg, OPTO7_DRV_SEL_UART );
#endif
    
    if ( UART_ERROR == opto7_init( &opto7, &opto7_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
#if ( DEMO_EXAMPLE == EXAMPLE_GPIO )
    log_printf( &logger, " GP1 pin state HIGH \r\n" );
    opto7_set_gp1_pin( &opto7, OPTO7_PIN_STATE_HIGH );
     if ( OPTO7_PIN_STATE_HIGH == opto7_get_gp2_pin( &opto7 ) )
    {
        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" );
    opto7_set_gp1_pin( &opto7, OPTO7_PIN_STATE_LOW );
    if ( OPTO7_PIN_STATE_HIGH == opto7_get_gp2_pin( &opto7 ) )
    {
        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
}

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;
}

static void opto7_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static void opto7_log_app_buf ( void )
{
    for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
    {
        log_printf( &logger, "%c", app_buf[ buf_cnt ] );
    }
}

static err_t opto7_process ( opto7_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = opto7_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) ) 
    {
        if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE ) 
        {
            overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
            app_buf_len = APP_BUFFER_SIZE - rx_size;
            memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
            memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
        }
        for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
            }
        }
        return OPTO7_OK;
    }
    return OPTO7_ERROR;
}

// ------------------------------------------------------------------------ END

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。