初学者
10 分钟

使用ACS37600K和PIC18F96J94获取电路中电流流量的精确数据

用于基于磁芯电流检测的可编程线性霍尔效应传感器

Current 11 Click with EasyPIC PRO v8

已发布 8月 22, 2024

点击板

Current 11 Click

开发板

EasyPIC PRO v8

编译器

NECTO Studio

微控制器单元

PIC18F96J94

测量输出电流以进行负载监控和电源调节

A

A

硬件概览

它是如何工作的?

Current 11 Click 基于 Allegro Microsystems 的 ACS37600K (ACS37600KOKATN-006B5-C),这是一款高精度、可编程的线性霍尔效应传感器IC。ACS37600K 包含一个高精度、低偏移的斩波稳定霍尔效应前端,能够检测垂直于 IC 封装表面的磁通量,并将其转换为与之成比例的电压。此 Click board™ 设计为与铁磁核心配对,形成一个极其精确的电流传感器,非常适合各种工业、商业和通信应用。它在电流传感模块、电机控制系统、不间断电源(UPS)、过流检测、电源等应用中表现出色。ACS37600K 允

许在制造后进行灵敏度和偏移的客户特定编程,以及温度依赖的灵敏度调整,以抵消铁磁核心的漂移。其灵敏度为 6mV/G,双向工作范围为 ±333G,确保了电流传感应用中的行业领先精度。此外,它提供了一个用户可编程的双向参考电压引脚,通过一个未填充的 VREF 接头,范围为 0.6V 至 2.65V,能够持续监控零电流电压,增强了传感器的可靠性和精度。ACS37600K 的输出信号可以通过 MCP3221 转换为数字值,MCP3221 是来自 Microchip 的具有 12 位分辨率的逐次逼近 A/D 转换器,使用 2 线 I2C 兼容接

口,或者可以直接发送到 mikroBUS™ 插座上标记为 AN 的模拟引脚。选择可以通过板载 SMD 跳线标记为 ADC SEL 来执行,将其置于标记为 AN 和 ADC 的适当位置。此 Click board™ 可以通过 VCC SEL 跳线选择使用 3.3V 或 5V 逻辑电压水平。因此,3.3V 和 5V 兼容的 MCU 都可以正确使用通信线路。此外,这款 Click board™ 配备了包含易用功能的库和示例代码,可作为进一步开发的参考。

Current 11 Click hardware overview image

功能概述

开发板

EasyPIC PRO v8 是一款专为快速开发嵌入式应用而设计的开发板。它支持多种高引脚计数的 8 位 PIC 微控制器,来自 Microchip,不论其引脚数量如何,并具备一系列独特功能,例如首次通过 WiFi 的嵌入式调试器/程序员。开发板布局合理,设计周到,确保最终用户在一个地方可以找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,EasyPIC PRO v8 提供了流畅而沉浸式的工作体验,

允许在任何情况下、任何地方都能访问。EasyPIC  PRO v8 开发板的每个部分都包含了使同一板块运行最高效的必要组件。除了先进的集成 CODEGRIP 程序/调试模块,该模块提供许多有价值的编程/调试选项并与 Mikroe 软件环境无缝集成外,该板还包括一个为开发板提供的干净且调节过的电源供应模块。它可以使用广泛的外部电源,包括电池、外部 12V 电源供应,以及通过 USB Type-C(USB-C)连接器的电

源。通信选项包括 USB-UART、USB DEVICE 和  Ethernet,还包括广受好评的 mikroBUS™ 标准、为 MCU 卡提供的标准化插座(SiBRAIN 标准),以及两种显示选项(图形和基于字符的 LCD)。EasyPIC PRO v8 是 Mikroe 快速开发生态系统的一个重要组成部分,由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。

EasyPIC PRO v8 horizontal image

微控制器概述 

MCU卡片 / MCU

default

类型

8th Generation

建筑

PIC

MCU 内存 (KB)

64

硅供应商

Microchip

引脚数

100

RAM (字节)

3862

使用的MCU引脚

mikroBUS™映射器

Analog Output
PA3
AN
NC
NC
RST
ID COMM
PL1
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
PC3
SCL
I2C Data
PC4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Current 11 Click Schematic schematic

一步一步来

项目组装

Fusion for PIC v8 front image hardware assembly

从选择您的开发板和Click板™开始。以EasyPIC PRO v8作为您的开发板开始

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image 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”替换为要显示的参数。

软件支持

库描述

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

关键功能:

  • current11_set_vref - 此函数为 Current 11 Click 驱动器设置电压参考。

  • current11_calibrate_offset - 此函数校准零电流偏移值。

  • current11_read_current - 此函数基于 CURRENT11_NUM_CONVERSIONS 的电压测量结果读取输入电流值 [A]。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Current 11 Click Example.
 *
 * # Description
 * This example demonstrates the use of Current 11 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 zero current offset.
 *
 * ## Application Task
 * Reads the input current measurements and displays the results on the USB UART
 * approximately once per second.
 *
 * @note
 * For better accuracy, set the voltage reference by using the @b current11_set_vref function,
 * increase the number of conversions by modifying the @b CURRENT11_NUM_CONVERSIONS macro, 
 * and adjust the @b CURRENT11_COUPLING_FACTOR_G_A value.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "current11.h"

static current11_t current11;   /**< Current 11 Click driver object. */
static log_t logger;    /**< Logger object. */

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    current11_cfg_t current11_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.
    current11_cfg_setup( &current11_cfg );
    CURRENT11_MAP_MIKROBUS( current11_cfg, MIKROBUS_1 );
    err_t init_flag = current11_init( &current11, &current11_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    log_printf( &logger, " Calibrating zero current offset in 5 seconds...\r\n" );
    log_printf( &logger, " Make sure no current flows through the sensor during the calibration process.\r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    if ( CURRENT11_ERROR == current11_calibrate_offset ( &current11 ) )
    {
        log_error( &logger, " Calibrate offset." );
        for ( ; ; );
    }
    log_printf( &logger, " Calibration DONE.\r\n" );

    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    float current = 0;
    if ( CURRENT11_OK == current11_read_current ( &current11, &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

额外支持

资源

喜欢这个项目吗?

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