初学者
10 分钟

通过使用TSC1641和STM32L496AG提供电流、电压、功率和温度的测量

用于警报不良工作状态的数字功率监视器

Current 12 Click with Discovery kit with STM32L496AG MCU

已发布 7月 22, 2025

点击板

Current 12 Click

开发板

Discovery kit with STM32L496AG MCU

编译器

NECTO Studio

微控制器单元

STM32L496AG

实现精确的电压、电流和功率的调节和监控,确保稳定可靠的电力传输。

A

A

硬件概览

它是如何工作的?

Current 12 Click基于STMicroelectronics的TSC1641,这是一款具有I2C接口的60V 16位高精度功率监控器。TSC1641是一款高精度模拟前端(AFE),用于监控电流、电压、功率和温度。它通过分流电阻测量电流,并以同步方式测量从0V到60V的负载电压。电流测量可以是高端、低端和双向的。该设备集成了一个高精度16

位分辨率的双通道Σ-Δ ADC,具有可编程转换时间,范围从128µs到32.7ms。该板非常适用于工业电池组、功率逆变器、直流电源、数据中心、电信设备、电动工具等应用。Current 12 Click使用标准的2线I2C通信协议,使主机MCU能够控制TSC1641。I2C接口支持高达1MHz的时钟频率,I2C地址可通过ADDR SEL跳线选择。报

警中断ALR引脚允许针对电压、电流、功率和温度的多种报警的声明,可以在特定寄存器中为每个参数设置阈值。此Click板只能使用3.3V逻辑电压电平运行。在使用具有不同逻辑电平的MCU之前,板必须执行适当的逻辑电压电平转换。此外,此Click板配备了一个包含易于使用的功能和示例代码的库,可用作进一步开发的参考。

Current 12 Click hardware overview image

功能概述

开发板

32L496GDISCOVERY Discovery 套件是一款功能全面的演示和开发平台,专为搭载 Arm® Cortex®-M4 内核的 STM32L496AG 微控制器设计。该套件适用于需要在高性能、先进图形处理和超低功耗之间取得平衡的应用,支持无缝原型开发,适用于各种嵌入式解决方案。STM32L496AG 采用创新的节能架构,集成

了扩展 RAM 和 Chrom-ART 图形加速器,在提升图形性能的同时保持低功耗,使其特别适用于音频处理、图形用户界面和实时数据采集等对能效要求较高的应用。为了简化开发流程,该开发板配备了板载 ST-LINK/V2-1 调试器/编程器,提供即插即用的调试和编程体验,使用户无需额外硬件即可轻松加载、调

试和测试应用程序。凭借低功耗特性、增强的内存能力以及内置调试工具,32L496GDISCOVERY 套件是开发先进嵌入式系统、实现高效能解决方案的理想选择。

Discovery kit with STM32L496AG MCU double side image

微控制器概述 

MCU卡片 / MCU

STM32L496AG Image

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

STMicroelectronics

引脚数

169

RAM (字节)

327680

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
ID COMM
PG11
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Alert Interrupt
PH2
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB8
SCL
I2C Data
PB7
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Current 12 Click Schematic schematic

一步一步来

项目组装

Discovery kit with STM32H750XB MCU front image hardware assembly

从选择您的开发板和Click板™开始。以Discovery kit with STM32L496AG MCU作为您的开发板开始。

Discovery kit with STM32H750XB MCU front image hardware assembly
Thermo 21 Click front image hardware assembly
Prog-cut hardware assembly
Thermo 21 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
Discovery kit with STM32H750XB MCU 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

软件支持

库描述

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

关键功能:

  • current12_get_load_voltage - 此函数读取负载电压测量值 [V]。

  • current12_get_dc_power - 此函数读取直流功率测量值 [W]。

  • current12_get_current - 此函数读取电流测量值 [mA]。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Current 12 Click example
 *
 * # Description
 * This example demonstrates the use of the Current 12 Click board 
 * by reading and displaying the input current measurements.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of the I2C module and log UART.
 * After driver initialization, the app sets the default configuration.
 *
 * ## Application Task
 * The demo application reads and displays the results 
 * of the input current, voltage, and power measurements.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "current12.h"

static current12_t current12;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    current12_cfg_t current12_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.
    current12_cfg_setup( &current12_cfg );
    CURRENT12_MAP_MIKROBUS( current12_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == current12_init( &current12, &current12_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( CURRENT12_ERROR == current12_default_cfg ( &current12 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
    log_printf( &logger, "_____________________\r\n " );
    Delay_ms ( 100 );
}

void application_task ( void ) 
{
    float meas_data = 0;
    if ( CURRENT12_OK == current12_get_shunt_voltage( &current12, &meas_data ) )
    {
        log_printf( &logger, " Shunt Voltage: %.2f [mV]\r\n ", meas_data );
        Delay_ms ( 100 );
    }

    if ( CURRENT12_OK == current12_get_load_voltage( &current12, &meas_data ) )
    {
        log_printf( &logger, " Load Voltage: %.2f [V]\r\n ", meas_data );
        Delay_ms ( 100 );
    }

    if ( CURRENT12_OK == current12_get_dc_power( &current12, &meas_data ) )
    {
        log_printf( &logger, " DC Power: %.2f [W]\r\n ", meas_data );
        Delay_ms ( 100 );
    }

    if ( CURRENT12_OK == current12_get_current( &current12, &meas_data ) )
    {
        log_printf( &logger, " Current: %.2f [mA]\r\n", meas_data );
        Delay_ms ( 100 );
    }
    log_printf( &logger, "_____________________\r\n " );
    Delay_ms ( 1000 );
    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

额外支持

资源

喜欢这个项目吗?

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