中级
30 分钟

使用MLX91210和PIC32MZ2048EFM100将电流测量转化为可行的智能数据

在电流测量中体验极致精度!

Hall Current 3 click with Curiosity PIC32 MZ EF

已发布 7月 22, 2025

点击板

Hall Current 3 click

开发板

Curiosity PIC32 MZ EF

编译器

NECTO Studio

微控制器单元

PIC32MZ2048EFM100

通过利用我们解决方案的精确电流测量,检测异常和潜在风险,提高安全协议和系统完整性。

A

A

硬件概览

它是如何工作的?

Hall Current 3 Click 基于 Melexis 的 MLX91210 线性霍尔电流传感器。该传感器利用霍尔效应测量通过 IC 输入引脚的电流。这使得串联电阻保持在 μΩ 的量级,减少了主电流流中的损耗和散热。通过 IC 输入轨的主电流流产生磁场,从而在两个集成的霍尔板上引起霍尔效应。这两个板差分连接,防止外部磁干扰影响测量。前端部分对信号进行调节和放大,消除干扰。调节后的信号可在 MLX91210 的 VOUT 引脚上获得,并与输入电流线性相关。该信号进一步传输到 A/D 转换器。VOUT 电压稳定,并且温度敏感性漂移低(在标称电流下为 ±1.5%)。在 0A 电流时,MLX91210 的 VOUT 引脚保持在 VDD(5V)的一半。这使您能够测量两极

性:正电流极性将使 VOUT 高于 VDD 的一半,而负电流极性将使 VOUT 低于 VDD 电压。MLX91210 还具有故障报告功能,如果发生过压、欠压或校准数据 CRC 错误,将把 VOUT 引脚设置为高阻抗模式(Hi-Z)。数据手册提供了有关每种错误类型 Hi-Z 定时的说明。MLX91210 IC 的分辨率可以从完整的 IC 标签中确定:MLX91210KDF-CAS-101-SP,其中 CAS-101 表示其模拟电压分辨率为 80mV/A 或全量程(FS)测量为 ±25A。输出电压还传输到 Microchip 的 12 位 SAR 型 ADC MCP3221,该 ADC 具有 I2C 接口。该 ADC 在多个不同的 Click board™ 设计中使用,因为它提供了准确的转换,所需的外部组件较少,并且具有相当好的信噪比

(SNR)。它可以达到高达 22.3ksps 的速度,允许大多数用途的良好测量分辨率。在 VOUT 测量电压转换为数字值后,可以通过 MCP3221 ADC 的 I2C 总线读取。由于 ADC IC 仅使用 3.3V 通信电压水平,Click board™ 配备了 PCA9306,一个双向 I2C 电平转换器。该 IC 接受两种电压水平:一种用于输入信号,另一种用于输出信号。VCC SEL 跳线可以选择输出参考信号,允许与 3.3V 和 5V MCU 通信。I2C 总线已包含上拉电阻,因此无需进一步配置;可以立即使用。输入端子截面积为 2.5mm,因此可以接受超过 10A 的高输入电流。它有两个输入极:IP+ 和 IP-。需要测量电流的导体可以连接到此端子。

Hall Current 3 click hardware overview image
Hall Current 3 Click  Current Warning image

功能概述

开发板

Curiosity PIC32 MZ EF 开发板是一个完全集成的 32 位开发平台,特点是高性能的 PIC32MZ EF 系列(PIC32MZ2048EFM),该系列具有 2MB Flash、512KB RAM、集成的浮点单元(FPU)、加密加速器和出色的连接选项。它包括一个集成的程序员和调试器,无需额外硬件。用户可以通过 MIKROE 

mikroBUS™ Click™ 适配器板扩展功能,通过 Microchip PHY 女儿板添加以太网连接功能,使用 Microchip 扩展板添加 WiFi 连接能力,并通过 Microchip 音频女儿板添加音频输入和输出功能。这些板完全集成到 PIC32 强大的软件框架 MPLAB Harmony 中,该框架提供了一个灵活且模块化的接口

来应用开发、一套丰富的互操作软件堆栈(TCP-IP、USB)和易于使用的功能。Curiosity PIC32 MZ EF 开发板提供了扩展能力,使其成为连接性、物联网和通用应用中快速原型设计的绝佳选择。

Curiosity PIC32MZ EF double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC32

MCU 内存 (KB)

2048

硅供应商

Microchip

引脚数

100

RAM (字节)

524288

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Hall Current 3 click Schematic schematic

一步一步来

项目组装

Curiosity PIC32MZ EF front image hardware assembly

从选择您的开发板和Click板™开始。以Curiosity PIC32 MZ EF作为您的开发板开始。

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 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
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

软件支持

库描述

此库包含 Hall Current 3 Click 驱动程序的 API。

关键功能:

  • hallcurrent3_getCurrent - 计算电流值

  • hallcurrent3_read_data - 从指定寄存器读取两个字节的数据

开源

代码示例

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

/*!
 * \file 
 * \brief HallCurrent3 Click example
 * 
 * # Description
 * The example starts off with the logger and Click modules and then starts measuring and
 * displaying current values.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes and configures the logger and Click modules.
 * 
 * ## Application Task  
 * Reads and displays current values every second.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "hallcurrent3.h"

// ------------------------------------------------------------------ VARIABLES

static hallcurrent3_t hallcurrent3;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( )
{
    log_cfg_t log_cfg;
    hallcurrent3_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 );
    log_info( &logger, "---- Application Init ----" );

    //  Click initialization.

    hallcurrent3_cfg_setup( &cfg );
    HALLCURRENT3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    hallcurrent3_init( &hallcurrent3, &cfg );
}

void application_task ( )
{
    float current_data;

    current_data = hallcurrent3_get_current( &hallcurrent3 );
    log_printf( &logger, "Current : %f mA\r\n", current_data );

    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

额外支持

资源

喜欢这个项目吗?

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