中级
30 分钟

使用 CT415 和 PIC18F57Q43 测量宽范围的电流值

目前是最好的!

Current 9 Click with Curiosity Nano with PIC18F57Q43

已发布 6月 24, 2024

点击板

Current 9 Click

开发板

Curiosity Nano with PIC18F57Q43

编译器

NECTO Studio

微控制器单元

PIC18F57Q43

精准和准确的电流感知解决方案

A

A

硬件概览

它是如何工作的?

Current 9 Click基于CT415-HSN830DR,这是来自Crocus Technology的XtremeSense® TMR电流传感器,提供高精度的电流测量。CT415-HSN830DR具有集成的电流载体导体(CCC),可处理从0A到30A的电流。它具有高灵敏度和宽动态范围,具有出色的准确性(低总输出误差),适用于许多消费者、企业和工业应用。当电流流经CCC时,芯片内部的XtremeSense® TMR传感器感应到场,产生差分电压信号,通过模拟前端输出电流测量,总输出误差不超过±1%满量程。CT415-

HSN830DR旨在实现快速响应时间的电流测量。此外,用户可以通过板载SMD跳线器选择传感器的输出电压电平,将其放置到标记为3V3或5V的适当位置。即使具有1MHz的高带宽,CT415-HSN830DR的功耗也很小。CT415-HSN830DR的输出信号可以使用MCP3221转换为数字值,MCP3221是一款来自Microchip的具有12位分辨率的逐次逼近A/D转换器,使用2线I2C兼容接口,也可以直接发送到标记为AN的mikroBUS™插座的模拟引脚。选择可以通过标记为ADC SEL的板载

SMD跳线器进行,将其放置在标记为EXT和INT的适当位置。此外,此Click板应与负载串联连接。两个板载端子连接器测量电流,一个端子块用于正电流输入,另一个用于负电流输入。此Click板可以使用通过VCC SEL跳线选择的3.3V或5V逻辑电压电平之一运行。这样,既可以使用3.3V又可以使用5V的MCU正确使用通信线。然而,此Click板配备了一个包含易于使用函数和示例代码的库,可用作进一步开发的参考。

Current 9 Click hardware overview image
Current 9 Click Current Warning image

功能概述

开发板

PIC18F57Q43 Curiosity Nano 评估套件是一款尖端的硬件平台,旨在评估 PIC18-Q43 系列内的微控制器。其设计的核心是包含了功能强大的 PIC18F57Q43 微控制器(MCU),提供先进的功能和稳健的性能。这个评估套件的关键特点包括一个黄 色用户 LED 和一个响应灵敏的机械用户开关,提供无

缝的交互和测试。为一个 32.768kHz 水晶振荡器足迹提供支持,确保精准的定时能力。套件内置的调试器拥有一个绿色电源和状态 LED,使编程和调试变得直观高效。此外,增强其实用性的还有虚拟串行端口 (CDC)和一个调试 GPIO 通道(DGI GPIO),提供广泛的连接选项。该套件通过 USB 供电,拥有由

 MIC5353 LDO 调节器提供支持的可调目标电压功能,确保在 1.8V 至 5.1V 的输出电压范围内稳定运行,最大输出电流为 500mA,受环境温度和电压限制。

PIC18F57Q43 Curiosity Nano double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC

MCU 内存 (KB)

128

硅供应商

Microchip

引脚数

48

RAM (字节)

8196

你完善了我!

配件

Curiosity Nano Base for Click boards 是一款多功能硬件扩展平台,专为简化 Curiosity Nano 套件与扩展板之间的集成而设计,特别针对符合 mikroBUS™ 标准的 Click 板和 Xplained Pro 扩展板。这款创新的基板(屏蔽板)提供了无缝的连接和扩展可能性,简化了实验和开发过程。主要特点包括从 Curiosity Nano 套件提供 USB 电源兼容性,以及为增强灵活性而提供的另一种外部电源输入选项。板载锂离子/锂聚合物充电器和管理电路确保电池供电应用的平稳运行,简化了使用和管理。此外,基板内置了一个固定的 3.3V 电源供应单元,专用于目标和 mikroBUS™ 电源轨,以及一个固定的 5.0V 升压转换器,专供 mikroBUS™ 插座的 5V 电源轨,为各种连接设备提供稳定的电力供应。

Curiosity Nano Base for Click boards accessories 1 image

使用的MCU引脚

mikroBUS™映射器

Analog Signal
PA0
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
PB2
SCL
I2C Data
PB1
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Current 9 Click Schematic schematic

一步一步来

项目组装

Curiosity Nano Base for Click boards front image hardware assembly

从选择您的开发板和Click板™开始。以Curiosity Nano with PIC18F57Q43作为您的开发板开始。

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Board mapper by product8 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
PIC18F57Q43 Curiosity 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

软件支持

库描述

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

关键功能:

  • current9_read_voltage - 该函数读取原始ADC值并将其转换为相应的电压水平。

  • current9_read_current - 该函数基于@b CURRENT9_NUM_CONVERSIONS的电压测量值,读取输入电流水平[A]。

  • current9_set_vref - 该函数设置Current 9 Click驱动程序的电压参考。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Current 9 Click Example.
 *
 * # Description
 * This example demonstrates the use of Current 9 Click board by reading and
 * displaying the input current measurements.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger.
 *
 * ## 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 current9_set_vref function,
 * increase the number of conversions by modifying the @b CURRENT9_NUM_CONVERSIONS macro, 
 * and adjust the @b CURRENT9_ZERO_CURRENT_OFFSET voltage value.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "current9.h"

static current9_t current9;   /**< Current 9 Click driver object. */
static log_t logger;    /**< Logger object. */

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    current9_cfg_t current9_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.
    current9_cfg_setup( &current9_cfg );
    CURRENT9_MAP_MIKROBUS( current9_cfg, MIKROBUS_1 );
    err_t init_flag = current9_init( &current9, &current9_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    float current = 0;
    if ( CURRENT9_OK == current9_read_current ( &current9, &current ) ) 
    {
        log_printf( &logger, " Current : %.3f[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

额外支持

资源

喜欢这个项目吗?

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