初学者
10 分钟

使用ACS37030和STM32F302VC在高速和严苛环境中监测电流流动

DC至5MHz带宽,具有电气隔离的电流感应解决方案

Hall Current 21 Click with CLICKER 4 for STM32F302VCT6

已发布 7月 22, 2025

点击板

Hall Current 21 Click

开发板

CLICKER 4 for STM32F302VCT6

编译器

NECTO Studio

微控制器单元

STM32F302VC

高隔离和宽带宽电流测量适用于电源、数据中心和太阳能转换器的快速、可靠监控

A

A

硬件概览

它是如何工作的?

Hall Current 21 Click 基于 Allegro Microsystems 的 ACS37030,这是一款直流至 5MHz 带宽的电流传感器,具有电气隔离功能,专为提供广泛频率范围内的精确电流测量而设计,非常适合需要快速且精确电流监控的应用。ACS37030 提供双向电流检测,测量范围为 ±65A,灵敏度为 20.3mV/A,能够精确监控正负电流。其通过了 AEC-Q100 等级 0 认证,确保其在恶劣环境下的高可靠性和耐用性。此外,其宽工作带宽和低噪声特性使其适用于快速控制回路和高频开关电流的监控。这款 Click 板非常适合多种应用,包括服务器和数据中心电源、太阳能 DC-DC 转换器以及其他高性能电源管理系统,需求快速、精确且隔离的电

流感应。ACS37030 使用两种独立的信号路径进行电流检测:霍尔效应元件捕获直流和低频电流,感应线圈测量高频电流。通过结合两条路径的输出,传感器实现了广泛的频率覆盖,并最大限度地减少噪声,确保在各种工作条件下的可靠性能。随着频率的增加,线圈的特性提高了信噪比(SNR),进一步减少了输出噪声,确保了清晰准确的测量。传感器的创新设计提供了高水平的隔离。电流在导体中的流动与传感器元件之间的磁耦合,确保了无需直接物理接触即可感应电流,从而在主信号和次信号引线之间实现 3500 VRMS 的隔离额定值。该隔离额定值提供了高达 840 VRMS 的工作电压,非常适合工业和汽车环境中需要

高隔离的应用。ACS37030 输出与双向交流或直流初级电流成线性变化的模拟信号。然后,该信号通过 Texas Instruments 的两通道 12 位 A/D 转换器 ADC122S101 发送给主 MCU。该 ADC 基于逐次逼近寄存器架构,带有内部保持电路,并在 500ksps 到 1Msps 的采样率范围内完全规格化。此 Click 板可以通过 VCC SEL 跳线选择 3.3V 或 5V 逻辑电压水平。这使得 3.3V 和 5V 的 MCU 都能正确使用通信线。此外,该 Click 板配备了包含易于使用的函数和示例代码的库,可作为进一步开发的参考。

Hall Current 21 Click Current Warning image
Hall Current 21 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
ID SEL
PC15
RST
SPI Select / ID COMM
PA4
CS
SPI Clock
PA5
SCK
SPI Data OUT
PA6
MISO
SPI Data IN
PA7
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Hall Current 21 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”替换为要显示的参数。

软件支持

库描述

该库包含 Hall Current 21 Click 驱动程序的 API。

关键功能:

  • hallcurrent21_read_voltage_avg - 此函数读取所需数量的ADC采样,并计算所选输入通道的平均电压水平。

  • hallcurrent21_calib_resolution - 此函数读取传感器电压参考,并在已知负载电流下校准数据分辨率

  • hallcurrent21_read_current - 此函数读取输入电流值(安培)。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Hall Current 21 Click example
 *
 * # Description
 * This example demonstrates the use of Hall Current 21 Click board by reading and
 * displaying the input current measurements.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and calibrates the data resolution at 3A load current.
 *
 * ## Application Task
 * Reads the input current measurements and displays the results on the USB UART
 * approximately once per second.
 *
 * @note
 * The measurement range is approximately: +/- 65A.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "hallcurrent21.h"

// Load current [A] used for the data resolution calibration process.
#define HALLCURRENT21_CALIBRATING_CURRENT   3.0f

static hallcurrent21_t hallcurrent21;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    hallcurrent21_cfg_t hallcurrent21_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.
    hallcurrent21_cfg_setup( &hallcurrent21_cfg );
    HALLCURRENT21_MAP_MIKROBUS( hallcurrent21_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == hallcurrent21_init( &hallcurrent21, &hallcurrent21_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    log_printf( &logger, " Calibrating data resolution in 5 seconds...\r\n" );
    log_printf( &logger, " Keep the load current set at %.1fA during the calibration process.\r\n", 
                HALLCURRENT21_CALIBRATING_CURRENT );
    for ( uint8_t cnt = 5; cnt > 0; cnt-- )
    {
        log_printf( &logger, " %u\r\n", ( uint16_t ) cnt );
        Delay_ms ( 1000 );
    }
    if ( HALLCURRENT21_ERROR == hallcurrent21_calib_resolution ( &hallcurrent21, 
                                                                 HALLCURRENT21_CALIBRATING_CURRENT ) )
    {
        log_error( &logger, " Calibrate resolution." );
        for ( ; ; );
    }
    log_printf( &logger, " Data resolution calibration DONE.\r\n" );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    float current = 0;
    if ( HALLCURRENT21_OK == hallcurrent21_read_current ( &hallcurrent21, &current ) ) 
    {
        log_printf( &logger, " Current : %.1f A\r\n\n", current );
        Delay_ms ( 1000 );
    }
}

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

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

额外支持

资源

喜欢这个项目吗?

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